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
|
#include <Windows.h>
LRESULT CALLBACK WindowProcedure (HWND, unsigned int, WPARAM, LPARAM);
int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpsCmdLine, int iCmdShow) {
WNDCLASSEX WindowClass;
WindowClass.cbClsExtra = 0;
WindowClass.cbWndExtra = 0;
WindowClass.cbSize = sizeof (WNDCLASSEX);
WindowClass.style = 0;
WindowClass.lpszClassName = "1"; // Or what ever you want, I always use numbers
WindowClass.lpszMenuName = NULL;
WindowClass.lpfnWndProc = WindowProcedure; // Or what ever you named your wndproc function
WindowClass.hInstance = hInstance;
WindowClass.hCursor = LoadCursor (NULL, IDC_ARROW);
WindowClass.hIcon = LoadIcon (NULL, IDI_APPLICATION);
WindowClass.hIconSm = LoadIcon (NULL, IDI_APPLICATION);
WindowClass.hbrBackground = CreateSolidBrush (RGB (255, 255, 255)); // The three numbers are the red, green, and blue values for your background window, 255 x3 = white
if (!RegisterClassEx (&WindowClass)) {
MessageBox (NULL, "Window class registration failed", NULL, MB_ICONWARNING);
return 0;
}
HWND hWnd = CreateWindow ("1", // Or what you named your class
"Title here",
WS_OVERLAPPEDWINDOW,
315, 115, // Start points of your window
700, 480, // Width and height of your window
NULL, NULL,
hInstance, NULL);
if (hWnd == NULL) {
MessageBox (hWnd, "Window creation failed", NULL, MB_ICONWARNING);
return 0;
}
ShowWindow (hWnd, SW_SHOW);
MSG uMsg;
while (GetMessage (&uMsg, NULL, 0, 0) > 0) {
TranslateMessage (&uMsg);
DispatchMessage (&uMsg);
}
return 0;
}
LRESULT CALLBACK WindowProcedure (HWND hWnd, unsigned int uiMsg, WPARAM wParam, LPARAM lParam) {
switch (uiMsg) {
case WM_CLOSE:
DestroyWindow (hWnd);
break;
case WM_DESTROY:
PostQuitMessage (0);
break;
}
return DefWindowProc (hWnd, uiMsg, wParam, lParam);
}
|