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