Mercurial > repos > rhope
comparison window_test.c @ 0:76568becd6d6
Rhope Alpha 2a source import
author | Mike Pavone <pavone@retrodev.com> |
---|---|
date | Tue, 28 Apr 2009 23:06:07 +0000 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:76568becd6d6 |
---|---|
1 #include <windows.h> | |
2 | |
3 LRESULT CALLBACK WindowProc (HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) | |
4 { | |
5 switch (message) | |
6 { | |
7 /* case WM_CREATE: | |
8 CreateChildControls(hwnd); | |
9 break; | |
10 | |
11 case WM_COMMAND: | |
12 if( HIWORD( wParam ) == BN_CLICKED ) | |
13 { | |
14 ProcessButtonClick( (char)LOWORD( wParam ) ); | |
15 } | |
16 break;*/ | |
17 | |
18 case WM_DESTROY: | |
19 PostQuitMessage (0); | |
20 break; | |
21 } | |
22 return DefWindowProc (hwnd, message, wParam, lParam); | |
23 } | |
24 char g_szClassName[ ] = "WindowsApp"; | |
25 HINSTANCE glob_instance; | |
26 int glob_cmdshow; | |
27 BOOL wind_created=FALSE; | |
28 | |
29 DWORD WINAPI message_thread(void * param) | |
30 { | |
31 WSADATA wsa_data; | |
32 /* Define the Window Class and try to register it */ | |
33 WNDCLASSEX wc; | |
34 HWND hwnd; | |
35 MSG messages; | |
36 wc.cbSize = sizeof (WNDCLASSEX); | |
37 wc.style = 0; | |
38 wc.lpfnWndProc = WindowProc; | |
39 wc.cbClsExtra = 0; | |
40 wc.cbWndExtra = 0; | |
41 wc.hInstance = glob_instance; | |
42 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); | |
43 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | |
44 wc.hbrBackground = (HBRUSH) COLOR_BACKGROUND; | |
45 wc.lpszMenuName = NULL; | |
46 wc.lpszClassName = g_szClassName; | |
47 wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); | |
48 if (!RegisterClassEx (&wc)) return 0; | |
49 | |
50 /* Create and Show the Window */ | |
51 hwnd = CreateWindowEx ( | |
52 0, g_szClassName, "The OMGWTF Calculator", | |
53 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, | |
54 220, 270, | |
55 HWND_DESKTOP, NULL, glob_instance, NULL); | |
56 | |
57 CreateWindow("STATIC", "test", SS_BLACKFRAME | SS_WHITERECT | SS_LEFT, | |
58 10, 10, 100, 20, hwnd, NULL, GetModuleHandle(NULL), NULL); | |
59 | |
60 ShowWindow (hwnd, glob_cmdshow); | |
61 | |
62 while (GetMessage (&messages, NULL, 0, 0)) | |
63 { | |
64 TranslateMessage(&messages); | |
65 DispatchMessage(&messages); | |
66 } | |
67 MessageBox(NULL, "No More messages!", "Blah", MB_OK); | |
68 wind_created = TRUE; | |
69 return 0; | |
70 } | |
71 | |
72 int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) | |
73 { | |
74 WSADATA wsa_data; | |
75 /* Define the Window Class and try to register it */ | |
76 WNDCLASSEX wc; | |
77 HWND hwnd; | |
78 MSG messages; | |
79 /*wc.cbSize = sizeof (WNDCLASSEX); | |
80 wc.style = 0; | |
81 wc.lpfnWndProc = WindowProc; | |
82 wc.cbClsExtra = 0; | |
83 wc.cbWndExtra = 0; | |
84 wc.hInstance = hInstance; | |
85 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); | |
86 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | |
87 wc.hbrBackground = (HBRUSH) COLOR_BACKGROUND; | |
88 wc.lpszMenuName = NULL; | |
89 wc.lpszClassName = g_szClassName; | |
90 wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION); | |
91 if (!RegisterClassEx (&wc)) return 0; | |
92 | |
93 | |
94 hwnd = CreateWindowEx ( | |
95 0, g_szClassName, "The OMGWTF Calculator", | |
96 WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, | |
97 220, 270, | |
98 HWND_DESKTOP, NULL, hInstance, NULL); | |
99 ShowWindow (hwnd, nCmdShow);*/ | |
100 glob_instance = hInstance; | |
101 glob_cmdshow = nCmdShow; | |
102 CreateThread(NULL, 0, message_thread, NULL, 0, NULL); | |
103 /* Process the Message Loop */ | |
104 while(!wind_created) | |
105 Sleep(0); | |
106 /*while (GetMessage (&messages, NULL, 0, 0)) | |
107 { | |
108 TranslateMessage(&messages); | |
109 DispatchMessage(&messages); | |
110 }*/ | |
111 | |
112 return (int)messages.wParam; | |
113 } |