Mercurial > sdl-ios-xcode
annotate 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 |
rev | line source |
---|---|
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
1 |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
2 #include "testnative.h" |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
3 |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
4 #ifdef TEST_NATIVE_WIN32 |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
5 |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
6 static void *CreateWindowWin32(int w, int h); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
7 static void DestroyWindowWin32(void *window); |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
8 |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
9 NativeWindowFactory Win32WindowFactory = { |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
10 "win32", |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
11 CreateWindowWin32, |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
12 DestroyWindowWin32 |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
13 }; |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
14 |
3060
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
15 LRESULT CALLBACK WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
16 { |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
17 switch(msg) |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
18 { |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
19 case WM_CLOSE: |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
20 DestroyWindow(hwnd); |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
21 break; |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
22 case WM_DESTROY: |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
23 PostQuitMessage(0); |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
24 break; |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
25 default: |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
26 return DefWindowProc(hwnd, msg, wParam, lParam); |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
27 } |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
28 return 0; |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
29 } |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
30 |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
31 static void * |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
32 CreateWindowWin32(int w, int h) |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
33 { |
3060
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
34 HWND hwnd; |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
35 WNDCLASS wc; |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
36 |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
37 wc.style = 0; |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
38 wc.lpfnWndProc = WndProc; |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
39 wc.cbClsExtra = 0; |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
40 wc.cbWndExtra = 0; |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
41 wc.hInstance = GetModuleHandle(NULL); |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
42 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION); |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
43 wc.hCursor = LoadCursor(NULL, IDC_ARROW); |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
44 wc.hbrBackground = (HBRUSH)(COLOR_WINDOW+1); |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
45 wc.lpszMenuName = NULL; |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
46 wc.lpszClassName = "SDL Test"; |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
47 |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
48 if(!RegisterClass(&wc)) |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
49 { |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
50 MessageBox(NULL, "Window Registration Failed!", "Error!", |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
51 MB_ICONEXCLAMATION | MB_OK); |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
52 return 0; |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
53 } |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
54 |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
55 hwnd = CreateWindow("SDL Test", "", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT, CW_USEDEFAULT, w, h, NULL, NULL, GetModuleHandle(NULL), NULL); |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
56 if(hwnd == NULL) |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
57 { |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
58 MessageBox(NULL, "Window Creation Failed!", "Error!", |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
59 MB_ICONEXCLAMATION | MB_OK); |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
60 return 0; |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
61 } |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
62 |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
63 ShowWindow(hwnd, SW_SHOW); |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
64 |
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
65 return hwnd; |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
66 } |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
67 |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
68 static void |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
69 DestroyWindowWin32(void *window) |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
70 { |
3060
4cf533f434d8
Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents:
3057
diff
changeset
|
71 DestroyWindow((HWND)window); |
3057
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
72 } |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
73 |
089a77aebb7d
Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff
changeset
|
74 #endif |