I purchased Role-Playing Game Programming with DirectX and I thought this would be a good time for me to start using Visual C++ since almost all of what I have read says it is the best when having to deal with DirectX.
I am 70% sure I installed the SDK right, but I am getting errors that make it look like it is not installed properly. I can build a basic program with just a WinMain and return 0; but when I started to do more I started to get a lot of errors:
PHP Code:
------ Build started: Project: WinTest, Configuration: Debug Win32 ------
Linking...
main.obj : error LNK2019: unresolved external symbol __imp__PostQuitMessage@4 referenced in function "long __stdcall WindowProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WindowProc@@YGJPAUHWND__@@IIJ@Z)
main.obj : error LNK2019: unresolved external symbol __imp__DefWindowProcA@16 referenced in function "long __stdcall WindowProc(struct HWND__ *,unsigned int,unsigned int,long)" (?WindowProc@@YGJPAUHWND__@@IIJ@Z)
main.obj : error LNK2019: unresolved external symbol __imp__UnregisterClassA@8 referenced in function _WinMain@16
main.obj : error LNK2019: unresolved external symbol __imp__DispatchMessageA@4 referenced in function _WinMain@16
main.obj : error LNK2019: unresolved external symbol __imp__TranslateMessage@4 referenced in function _WinMain@16
main.obj : error LNK2019: unresolved external symbol __imp__PeekMessageA@20 referenced in function _WinMain@16
main.obj : error LNK2019: unresolved external symbol __imp__UpdateWindow@4 referenced in function _WinMain@16
main.obj : error LNK2019: unresolved external symbol __imp__ShowWindow@8 referenced in function _WinMain@16
main.obj : error LNK2019: unresolved external symbol __imp__CreateWindowExA@48 referenced in function _WinMain@16
main.obj : error LNK2019: unresolved external symbol __imp__RegisterClassExA@4 referenced in function _WinMain@16
My code is:
Code:
#include <windows.h>
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd);
LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam);
int WINAPI WinMain(
HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPSTR lpCmdLine,
int nShowCmd)
{
WNDCLASSEX wcex = {sizeof(WNDCLASSEX), CS_CLASSDC,
WindowProc, 0L, 0L, hInstance, NULL,
NULL, NULL, NULL, "GameClass", NULL};
if(!RegisterClassEx(&wcex))
return false;
HWND hWnd;
hWnd = CreateWindow("GameClass", "Knights of the Wraith",
WS_OVERLAPPEDWINDOW, 0, 0, 400, 400, NULL, NULL,
hInstance, NULL);
if(hWnd == NULL)
return false;
ShowWindow(hWnd, SW_SHOWNORMAL);
UpdateWindow(hWnd);
MSG Msg;
ZeroMemory(&Msg, sizeof(MSG));
while(Msg.message != WM_QUIT) {
if(PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE)) {
TranslateMessage(&Msg);
DispatchMessage(&Msg);
} else {
}
}
UnregisterClass("GameClass", hInstance);
return 0;
}
LRESULT CALLBACK WindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
switch(uMsg){
case WM_DESTROY:
PostQuitMessage(0);
break;
default: return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
return 0;
}
I have looked up the SDK and checked everything and it all looks like the code is valid and the SDK is set up right.
~Wraith