Drezard
February 20th, 2007, 03:07 AM
Hello, I'm attempting to make a game engine. I have almost finished the Win32 Code of it. I just need some help. I need some help excuting the code to test it...
Now heres all of the code:
SystemCore.h:
// SystemCore.h
// Last updated: 20 Feb 2007, Drezard
#include <windows.h> // Standard windows include file
#include <windowsx.h> // Standard windows include file
#ifndef SYSTEMCORE_H // Checks if the header has already been called
#define SYSTEMCORE_H // If it hasnt then it will call it with this code
class DrezSystem; // Declare the class
static LRESULT CALLBACK AppWindowProc(HWND hWnd, // Declare a WNDPROC to handle Wm_Quit
UINT uMsg,
WPARAM wParam,
LPARAM lParam);
static DrezSystem* g_pApp = 0; // Pointer to the class
class DrezSystem { // Class prototype
private: // Declare all the private members
WNDCLASSEX m_Wcex; // Declare our windows struct
HINSTANCE m_hInst; // Declare a variable for our programs Instance
HWND m_hWnd; // Declare a variable for our programs Handle
public: // Declare all the public members
DrezSystem(); // Constructor
~DrezSystem(); // Destructor
bool run(); // Registers the class
virtual LRESULT CALLBACK MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
};
#endif
SystemCore.cpp:
// SystemCore.cpp
// Last updated: 20 Feb 2007, Drezard
#include "SystemCore.h"
DrezSystem::DrezSystem(){ // Constructor
g_pApp = this; // Set g_aApp pointer to the class
m_hInst = GetModuleHandle(0); // Set the programs instance
m_hWnd = NULL; // Set the programs handle
m_Wcex.cbSize = sizeof(WNDCLASSEX); // Size of the windows class
m_Wcex.style = CS_CLASSDC; // Style
m_Wcex.lpfnWndProc = AppWindowProc; // No Win Proc yet
m_Wcex.cbClsExtra = 0;
m_Wcex.cbWndExtra = 0;
m_Wcex.hInstance = m_hInst; // Hinstance
m_Wcex.hIcon = LoadIcon(0, IDI_APPLICATION); // Load the icon
m_Wcex.hCursor = LoadCursor(0, IDC_ARROW); // Load the cursor
m_Wcex.hbrBackground = 0;
m_Wcex.lpszMenuName = 0;
m_Wcex.lpszClassName = L"TEST";
m_Wcex.hIconSm = LoadIcon(0, IDI_APPLICATION);
}
DrezSystem::~DrezSystem(){ // Destructor
m_hInst = NULL; // Set the programs instance (Memory Release)
m_hWnd = NULL; // Set the programs handle (Memory Release)
}
LRESULT CALLBACK AppWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_DESTROY:
PostQuitMessage(true);
break;
default:
return g_pApp->MsgProc(hWnd, uMsg, wParam, lParam);
break;
}
return 0;
}
bool DrezSystem::run() { // Registers the class
if(!(RegisterClassEx(&m_Wcex))) { // If Registering the Class fails
return false; // Return false
}
UnregisterClass(L"TEST", m_hInst); // Unregister the class (Memory Release)
return true; // Return true
m_hWnd = CreateWindowEx(NULL, // Set the handle
L"TEST", // Our class
L"Our First Windowed Program", // Window title
WS_OVERLAPPEDWINDOW, // Window style
300, // X-position of the window
300, // Y-position of the window
500, // Width of the window
400, // Height of the window
NULL, // Parent Window
NULL, // Menus
m_hInst, // Application Handle
NULL); // Mutliple Windows
ShowWindow(m_hWnd, nCmdShow); // Show the Window
MSG msg;
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
};
WinMain.cpp:
#include "SystemCore.h"
#include <windows.h>
#include <windowsx.h>
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
DrezSystem::DrezSystem();
bool DrezSystem::run();
DrezSystem::~DrezSystem();
}
Now, Heres the errors, but I know they are cause of my problems in the WinMain.cpp. With the class declarations...
Errors:
c:\documents and settings\daniel\my documents\engine\systemcore\systemcore\systemcore\systemcore.cpp(77) : error C2065: 'nCmdShow' : undeclared identifier
WinMain.cpp
c:\documents and settings\daniel\my documents\engine\systemcore\systemcore\systemcore\winmain.cpp(13) : error C2761: 'bool DrezSystem::run(void)' : member function redeclaration not allowed
c:\documents and settings\daniel\my documents\engine\systemcore\systemcore\systemcore\winmain.cpp(15) : error C2352: 'DrezSystem::~DrezSystem' : illegal call of non-static member function
c:\documents and settings\daniel\my documents\engine\systemcore\systemcore\systemcore\systemcore.h(29) : see declaration of 'DrezSystem::~DrezSystem'
Cheers, Daniel
Now heres all of the code:
SystemCore.h:
// SystemCore.h
// Last updated: 20 Feb 2007, Drezard
#include <windows.h> // Standard windows include file
#include <windowsx.h> // Standard windows include file
#ifndef SYSTEMCORE_H // Checks if the header has already been called
#define SYSTEMCORE_H // If it hasnt then it will call it with this code
class DrezSystem; // Declare the class
static LRESULT CALLBACK AppWindowProc(HWND hWnd, // Declare a WNDPROC to handle Wm_Quit
UINT uMsg,
WPARAM wParam,
LPARAM lParam);
static DrezSystem* g_pApp = 0; // Pointer to the class
class DrezSystem { // Class prototype
private: // Declare all the private members
WNDCLASSEX m_Wcex; // Declare our windows struct
HINSTANCE m_hInst; // Declare a variable for our programs Instance
HWND m_hWnd; // Declare a variable for our programs Handle
public: // Declare all the public members
DrezSystem(); // Constructor
~DrezSystem(); // Destructor
bool run(); // Registers the class
virtual LRESULT CALLBACK MsgProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam) {
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
};
#endif
SystemCore.cpp:
// SystemCore.cpp
// Last updated: 20 Feb 2007, Drezard
#include "SystemCore.h"
DrezSystem::DrezSystem(){ // Constructor
g_pApp = this; // Set g_aApp pointer to the class
m_hInst = GetModuleHandle(0); // Set the programs instance
m_hWnd = NULL; // Set the programs handle
m_Wcex.cbSize = sizeof(WNDCLASSEX); // Size of the windows class
m_Wcex.style = CS_CLASSDC; // Style
m_Wcex.lpfnWndProc = AppWindowProc; // No Win Proc yet
m_Wcex.cbClsExtra = 0;
m_Wcex.cbWndExtra = 0;
m_Wcex.hInstance = m_hInst; // Hinstance
m_Wcex.hIcon = LoadIcon(0, IDI_APPLICATION); // Load the icon
m_Wcex.hCursor = LoadCursor(0, IDC_ARROW); // Load the cursor
m_Wcex.hbrBackground = 0;
m_Wcex.lpszMenuName = 0;
m_Wcex.lpszClassName = L"TEST";
m_Wcex.hIconSm = LoadIcon(0, IDI_APPLICATION);
}
DrezSystem::~DrezSystem(){ // Destructor
m_hInst = NULL; // Set the programs instance (Memory Release)
m_hWnd = NULL; // Set the programs handle (Memory Release)
}
LRESULT CALLBACK AppWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg)
{
case WM_DESTROY:
PostQuitMessage(true);
break;
default:
return g_pApp->MsgProc(hWnd, uMsg, wParam, lParam);
break;
}
return 0;
}
bool DrezSystem::run() { // Registers the class
if(!(RegisterClassEx(&m_Wcex))) { // If Registering the Class fails
return false; // Return false
}
UnregisterClass(L"TEST", m_hInst); // Unregister the class (Memory Release)
return true; // Return true
m_hWnd = CreateWindowEx(NULL, // Set the handle
L"TEST", // Our class
L"Our First Windowed Program", // Window title
WS_OVERLAPPEDWINDOW, // Window style
300, // X-position of the window
300, // Y-position of the window
500, // Width of the window
400, // Height of the window
NULL, // Parent Window
NULL, // Menus
m_hInst, // Application Handle
NULL); // Mutliple Windows
ShowWindow(m_hWnd, nCmdShow); // Show the Window
MSG msg;
while(GetMessage(&msg, NULL, 0, 0))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
};
WinMain.cpp:
#include "SystemCore.h"
#include <windows.h>
#include <windowsx.h>
int WINAPI WinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nCmdShow)
{
DrezSystem::DrezSystem();
bool DrezSystem::run();
DrezSystem::~DrezSystem();
}
Now, Heres the errors, but I know they are cause of my problems in the WinMain.cpp. With the class declarations...
Errors:
c:\documents and settings\daniel\my documents\engine\systemcore\systemcore\systemcore\systemcore.cpp(77) : error C2065: 'nCmdShow' : undeclared identifier
WinMain.cpp
c:\documents and settings\daniel\my documents\engine\systemcore\systemcore\systemcore\winmain.cpp(13) : error C2761: 'bool DrezSystem::run(void)' : member function redeclaration not allowed
c:\documents and settings\daniel\my documents\engine\systemcore\systemcore\systemcore\winmain.cpp(15) : error C2352: 'DrezSystem::~DrezSystem' : illegal call of non-static member function
c:\documents and settings\daniel\my documents\engine\systemcore\systemcore\systemcore\systemcore.h(29) : see declaration of 'DrezSystem::~DrezSystem'
Cheers, Daniel