Mercurial > sdl-ios-xcode
comparison test/testnativew32.c @ 3071:6f3308d4b6cd
indent
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 17 Feb 2009 05:57:54 +0000 |
parents | 4cf533f434d8 |
children | e8916fe9cfc8 |
comparison
equal
deleted
inserted
replaced
3070:3e3724fb829e | 3071:6f3308d4b6cd |
---|---|
10 "win32", | 10 "win32", |
11 CreateWindowWin32, | 11 CreateWindowWin32, |
12 DestroyWindowWin32 | 12 DestroyWindowWin32 |
13 }; | 13 }; |
14 | 14 |
15 LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | 15 LRESULT CALLBACK |
16 WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | |
16 { | 17 { |
17 switch(msg) | 18 switch (msg) { |
18 { | 19 case WM_CLOSE: |
19 case WM_CLOSE: | 20 DestroyWindow(hwnd); |
20 DestroyWindow(hwnd); | |
21 break; | 21 break; |
22 case WM_DESTROY: | 22 case WM_DESTROY: |
23 PostQuitMessage(0); | 23 PostQuitMessage(0); |
24 break; | 24 break; |
25 default: | 25 default: |
26 return DefWindowProc(hwnd, msg, wParam, lParam); | 26 return DefWindowProc(hwnd, msg, wParam, lParam); |
27 } | 27 } |
28 return 0; | 28 return 0; |
29 } | 29 } |
30 | 30 |
31 static void * | 31 static void * |
32 CreateWindowWin32(int w, int h) | 32 CreateWindowWin32(int w, int h) |
33 { | 33 { |
34 HWND hwnd; | 34 HWND hwnd; |
35 WNDCLASS wc; | 35 WNDCLASS wc; |
36 | 36 |
37 wc.style = 0; | 37 wc.style = 0; |
38 wc.lpfnWndProc = WndProc; | 38 wc.lpfnWndProc = WndProc; |
39 wc.cbClsExtra = 0; | 39 wc.cbClsExtra = 0; |
40 wc.cbWndExtra = 0; | 40 wc.cbWndExtra = 0; |
41 wc.hInstance = GetModuleHandle(NULL); | 41 wc.hInstance = GetModuleHandle(NULL); |
42 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); | 42 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); |
43 wc.hCursor = LoadCursor(NULL, IDC_ARROW); | 43 wc.hCursor = LoadCursor(NULL, IDC_ARROW); |
44 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); | 44 wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1); |
45 wc.lpszMenuName = NULL; | 45 wc.lpszMenuName = NULL; |
46 wc.lpszClassName = "SDL Test"; | 46 wc.lpszClassName = "SDL Test"; |
47 | 47 |
48 if(!RegisterClass(&wc)) | 48 if (!RegisterClass(&wc)) { |
49 { | |
50 MessageBox(NULL, "Window Registration Failed!", "Error!", | 49 MessageBox(NULL, "Window Registration Failed!", "Error!", |
51 MB_ICONEXCLAMATION | MB_OK); | 50 MB_ICONEXCLAMATION | MB_OK); |
52 return 0; | 51 return 0; |
53 } | 52 } |
54 | 53 |
55 hwnd = CreateWindow("SDL Test", "", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, w, h, NULL, NULL, GetModuleHandle(NULL), NULL); | 54 hwnd = |
56 if(hwnd == NULL) | 55 CreateWindow("SDL Test", "", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, |
57 { | 56 CW_USEDEFAULT, w, h, NULL, NULL, GetModuleHandle(NULL), |
57 NULL); | |
58 if (hwnd == NULL) { | |
58 MessageBox(NULL, "Window Creation Failed!", "Error!", | 59 MessageBox(NULL, "Window Creation Failed!", "Error!", |
59 MB_ICONEXCLAMATION | MB_OK); | 60 MB_ICONEXCLAMATION | MB_OK); |
60 return 0; | 61 return 0; |
61 } | 62 } |
62 | 63 |
63 ShowWindow(hwnd, SW_SHOW); | 64 ShowWindow(hwnd, SW_SHOW); |
64 | 65 |
66 } | 67 } |
67 | 68 |
68 static void | 69 static void |
69 DestroyWindowWin32(void *window) | 70 DestroyWindowWin32(void *window) |
70 { | 71 { |
71 DestroyWindow((HWND)window); | 72 DestroyWindow((HWND) window); |
72 } | 73 } |
73 | 74 |
74 #endif | 75 #endif |