Beginning Windows Programming

Hello
I'm beginning windows programming and the problem is while browsing a book, I was told to build this code as my first window creation. But the program has something wrong and I cannot find it by searching the internet. The program opens and resides in memory without closing or being visible to me. I have to close it using CTRL-ALT-DEL .. can any one help me ?

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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
 #include <windows.h>

// Message handler prototype
LRESULT CALLBACK WndProc ( HWND hWindow , UINT iMessage , WPARAM wParam , LPARAM lParam ) ;

int WINAPI WinMain ( HINSTANCE hInstance , HINSTANCE hPrevInst , PSTR lpCmdLine , int nShowCmd )
{
	// The Window Class
	WNDCLASS  kWndClass;

	// Visual Properties
	kWndClass.hCursor = LoadCursor ( NULL , IDC_ARROW ) ;
	kWndClass.hIcon = LoadIcon ( NULL , IDI_APPLICATION ) ;
	kWndClass.hbrBackground = ( HBRUSH ) GetStockObject ( WHITE_BRUSH ) ;
	
	// System Properties
	kWndClass.hInstance = hInstance	;
	kWndClass.lpfnWndProc = WndProc ;
	kWndClass.lpszClassName = "ZooM Class" ;

	// Extra Properties
	kWndClass.lpszMenuName = NULL ;
	kWndClass.cbClsExtra = NULL ;
	kWndClass.cbWndExtra = NULL ;
	kWndClass.style = NULL ;

	// Exit if didn't register class
	if ( ! RegisterClass ( &kWndClass ) ) { return -1 ; }

	// Creates the Window
	HWND hWindow = CreateWindow ( "ZooM Window" , "A Blank Window" ,
		WS_OVERLAPPEDWINDOW | WS_VISIBLE, CW_USEDEFAULT ,
		CW_USEDEFAULT , CW_USEDEFAULT , CW_USEDEFAULT , NULL , NULL , hInstance , NULL ) ;
	
	// Enter the message loop and deal with all messages sent to our window
	MSG kMessage ;
	while ( GetMessage ( & kMessage , hWindow , 0 , 0 ) )
	{
		TranslateMessage ( & kMessage ) ;
		DispatchMessage ( & kMessage ) ;
	}
	return 0 ;
}

// "The Message Handler" */
LRESULT CALLBACK WndProc ( HWND hWindow , UINT iMessage , WPARAM wParam , LPARAM lParam )
{
	switch ( iMessage )
	{
		// if messege was close :
	case WM_CLOSE :
		PostQuitMessage ( 0 ) ;
		break ;
	default :
		return DefWindowProc ( hWindow , iMessage , wParam , lParam ) ;
	}
	return 0 ;
}


thanks
Last edited on
Is line 31 correct?
Are you sure it should be "ZooM Window" or "ZooM Class"
yesssssssssss :D

cannot believe how a stupid mistake cost me hours of searching ..
thanks !
Topic archived. No new replies allowed.