I have a compiler error when creating a window

Im following a directx tutorial but i get a compiler error which i can't find a solution to

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include <windows.h>

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE prevInstance, LPWSTR cmdLine, int cmdShow){

	UNREFERENCED_PARAMETER(prevInstance);
	UNREFERENCED_PARAMETER(cmdLine);

	WNDCLASSEX wndclass = { 0 };
	wndclass.cbSize = sizeof(WNDCLASSEX);
	wndclass.style = CS_HREDRAW | CS_VREDRAW;
	wndclass.lpfnWndProc = WndProc;
	wndclass.hInstance = hInstance;
	wndclass.hCursor = LoadCursor( NULL, IDC_ARROW );
	wndclass.hbrBackground = ( HBRUSH )( COLOR_WINDOW + 1 );
	wndclass.lpszMenuName = NULL;
	wndclass.lpszClassName = "DX window";

	if(!RegisterClassEx(&wndclass)){
		return 0;
	}

	RECT rc = {0, 0, 640, 480};
	AdjustWindowRect(&rc, WS_OVERLAPPEDWINDOW, FALSE);

	HWND hwnd = CreateWindowA( "DX window", "blank win32 window",
		WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT,
		rc.right - rc.left, rc.bottom - rc.top,
		NULL, NULL, hInstance, NULL);

	if(!hwnd){
		return -1;
	}

	ShowWindow(hwnd, cmdShow);

	return 0;
}


the compiler errors i get is:

1
2
Error	1	error C2065: 'WndProc' : undeclared identifier	c:\users\sumsar\documents\visual studio 2012\projects\direct x\direct x\main.cpp	11	1	Direct x
	2	IntelliSense: identifier "WndProc" is undefined	c:\Users\Sumsar\Documents\Visual Studio 2012\Projects\Direct x\Direct x\Main.cpp	11	25	Direct x


thanks in advance
Even if it doesn't do anything you still have to define your Windows callback function anytime you have a Window class. It's this thing right here: http://msdn.microsoft.com/en-us/library/windows/desktop/ms633573(v=vs.85).aspx
Maybe DefWindowProc can be used in that case without defining any callback function.

wndclass.lpfnWndProc = DefWindowProc;
I have not tested this though.
http://msdn.microsoft.com/en-us/library/windows/desktop/ms633572(v=vs.85).aspx
yeah i found the bug i forgot to add a function

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
LRESULT CALLBACK WndProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam )
{
    PAINTSTRUCT paintStruct;
    HDC hDC;

    switch( message )
    {
        case WM_PAINT:
            hDC = BeginPaint( hwnd, &paintStruct );
            EndPaint( hwnd, &paintStruct );
            break;

        case WM_DESTROY:
            PostQuitMessage( 0 );
            break;

        default:
            return DefWindowProc( hwnd, message, wParam, lParam );
    }

    return 0;
}
Topic archived. No new replies allowed.