Help with errors! Please Help Me!

Feb 5, 2013 at 3:17am
Hi im making this blank window in microsoft visual studios 2012. (c++) Here is the code:

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
#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="DX11BookWindowClass";

	if( !RegisterClassEx( &wndClass))
		return -1;

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

	HWND hwnd=CreateWindowA ( "DX11BookWindowClass", "Blank Win32 Window", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, rc.right - rc.left, rc.bottom - rc.top, NULL, NULL, hInstance, NULL );

	if( !hwnd )
		return -1;

	ShowWindow( hwnd, cmdShow );

	return 0;
}



Here is the error code:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
1>Build started 2/4/2013 9:10:23 PM.
1>ClCompile:
1>  main1.cpp
1>c:\users\#$%@\documents\visual studio 2012\projects\blankwindow\blankwindow\main1.cpp(13): error C2065: 'WndProc' : undeclared identifier
1>c:\users\#$%@\documents\visual studio 2012\projects\blankwindow\blankwindow\main1.cpp(26): warning C4003: not enough actual parameters for macro 'CreateWindowA'
1>c:\users\#$%@\documents\visual studio 2012\projects\blankwindow\blankwindow\main1.cpp(26): error C2059: syntax error : ')'
1>  main.cpp
1>c:\users\@#$%\documents\visual studio 2012\projects\blankwindow\blankwindow\main.cpp(13): error C2065: 'WndProc' : undeclared identifier
1>c:\users\#$%@\documents\visual studio 2012\projects\blankwindow\blankwindow\main.cpp(26): warning C4003: not enough actual parameters for macro 'CreateWindowA'
1>c:\users\#$%@\documents\visual studio 2012\projects\blankwindow\blankwindow\main.cpp(26): error C2059: syntax error : ')'
1>  Generating Code...
1>
1>Build FAILED.
1>
1>Time Elapsed 00:00:07.63
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Last edited on Feb 5, 2013 at 3:20am
Feb 5, 2013 at 3:39am
'WndProc' : undeclared identifier


I don't see where WndProc is defined or declared anywhere in your code. Your compiler doesn't see it either. Maybe you should declare/define it.
Feb 5, 2013 at 4:43am
Or maybe you could get away by passing NULL as DispatchMessage is never called.
Feb 5, 2013 at 10:20am
you should create your WndProc function.

it is used to catch and dispatch messages.

search through the web.

Windows Api Programming will help you out.
Feb 5, 2013 at 3:29pm
Now How would i define it?
Feb 5, 2013 at 3:34pm
return DefWindowProc(hWnd,

?
Feb 5, 2013 at 3:45pm
As others have pointed out, you are missing a Window Procedure (a WndProc function) and a message loop.

See here: http://msdn.microsoft.com/en-us/library/vstudio/bb384843.aspx
Feb 26, 2013 at 3:17pm
I have read on and found a solution to the problem in the book... It was actually missing a few parts with the wndproc function.. thanks anyways!
Topic archived. No new replies allowed.