3
/* Declare Windows procedure */
4
LRESULT CALLBACK WindowProcedure (HWND, UINT, WPARAM, LPARAM);
6
/* Make the class name into a global variable */
7
char szClassName[ ] = "CodeBlocksWindowsApp";
9
int WINAPI WinMain (HINSTANCE hThisInstance,
10
HINSTANCE hPrevInstance,
14
HWND hwnd; /* This is the handle for our window */
15
MSG messages; /* Here messages to the application are saved */
16
WNDCLASSEX wincl; /* Data structure for the windowclass */
18
/* The Window structure */
19
wincl.hInstance = hThisInstance;
20
wincl.lpszClassName = szClassName;
21
wincl.lpfnWndProc = WindowProcedure; /* This function is called by windows */
22
wincl.style = CS_DBLCLKS; /* Catch double-clicks */
23
wincl.cbSize = sizeof (WNDCLASSEX);
25
/* Use default icon and mouse-pointer */
26
wincl.hIcon = LoadIcon (NULL, IDI_APPLICATION);
27
wincl.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
28
wincl.hCursor = LoadCursor (NULL, IDC_ARROW);
29
wincl.lpszMenuName = NULL; /* No menu */
30
wincl.cbClsExtra = 0; /* No extra bytes after the window class */
31
wincl.cbWndExtra = 0; /* structure or the window instance */
32
/* Use Windows's default colour as the background of the window */
33
wincl.hbrBackground = (HBRUSH) COLOR_BACKGROUND;
35
/* Register the window class, and if it fails quit the program */
36
if (!RegisterClassEx (&wincl))
39
/* The class is registered, let's create the program*/
40
hwnd = CreateWindowEx (
41
0, /* Extended possibilites for variation */
42
szClassName, /* Classname */
43
"Code::Blocks Template Windows App", /* Title Text */
44
WS_OVERLAPPEDWINDOW, /* default window */
45
CW_USEDEFAULT, /* Windows decides the position */
46
CW_USEDEFAULT, /* where the window ends up on the screen */
47
544, /* The programs width */
48
375, /* and height in pixels */
49
HWND_DESKTOP, /* The window is a child-window to desktop */
51
hThisInstance, /* Program Instance handler */
52
NULL /* No Window Creation data */
55
/* Make the window visible on the screen */
56
ShowWindow (hwnd, nCmdShow);
58
/* Run the message loop. It will run until GetMessage() returns 0 */
59
while (GetMessage (&messages, NULL, 0, 0))
61
/* Translate virtual-key messages into character messages */
62
TranslateMessage(&messages);
63
/* Send message to WindowProcedure */
64
DispatchMessage(&messages);
67
/* The program return-value is 0 - The value that PostQuitMessage() gave */
68
return messages.wParam;
72
/* This function is called by the Windows function DispatchMessage() */
74
LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
76
switch (message) /* handle the messages */
79
PostQuitMessage (0); /* send a WM_QUIT to the message queue */
81
default: /* for messages that we don't deal with */
82
return DefWindowProc (hwnd, message, wParam, lParam);