annotate test/testnativew32.c @ 5266:595814f561f7

There is only one width and height for the window. If those are changed during the course of a fullscreen mode change, then they'll stay that size when returning to windowed mode.
author Sam Lantinga <slouken@libsdl.org>
date Fri, 11 Feb 2011 20:49:13 -0800
parents e8916fe9cfc8
children
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
5062
e8916fe9cfc8 Fixed bug #925
Sam Lantinga <slouken@libsdl.org>
parents: 3071
diff changeset
4 #ifdef TEST_NATIVE_WINDOWS
3057
089a77aebb7d Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
5
5062
e8916fe9cfc8 Fixed bug #925
Sam Lantinga <slouken@libsdl.org>
parents: 3071
diff changeset
6 static void *CreateWindowNative(int w, int h);
e8916fe9cfc8 Fixed bug #925
Sam Lantinga <slouken@libsdl.org>
parents: 3071
diff changeset
7 static void DestroyWindowNative(void *window);
3057
089a77aebb7d Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
8
5062
e8916fe9cfc8 Fixed bug #925
Sam Lantinga <slouken@libsdl.org>
parents: 3071
diff changeset
9 NativeWindowFactory WindowsWindowFactory = {
e8916fe9cfc8 Fixed bug #925
Sam Lantinga <slouken@libsdl.org>
parents: 3071
diff changeset
10 "windows",
e8916fe9cfc8 Fixed bug #925
Sam Lantinga <slouken@libsdl.org>
parents: 3071
diff changeset
11 CreateWindowNative,
e8916fe9cfc8 Fixed bug #925
Sam Lantinga <slouken@libsdl.org>
parents: 3071
diff changeset
12 DestroyWindowNative
3057
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
3071
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
15 LRESULT CALLBACK
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
16 WndProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
3060
4cf533f434d8 Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
17 {
3071
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
18 switch (msg) {
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
19 case WM_CLOSE:
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
20 DestroyWindow(hwnd);
3060
4cf533f434d8 Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
21 break;
3071
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
22 case WM_DESTROY:
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
23 PostQuitMessage(0);
3060
4cf533f434d8 Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
24 break;
3071
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
25 default:
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
26 return DefWindowProc(hwnd, msg, wParam, lParam);
3060
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 *
5062
e8916fe9cfc8 Fixed bug #925
Sam Lantinga <slouken@libsdl.org>
parents: 3071
diff changeset
32 CreateWindowNative(int w, int h)
3057
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
3071
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
37 wc.style = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
38 wc.lpfnWndProc = WndProc;
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
39 wc.cbClsExtra = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
40 wc.cbWndExtra = 0;
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
41 wc.hInstance = GetModuleHandle(NULL);
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
42 wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
43 wc.hCursor = LoadCursor(NULL, IDC_ARROW);
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
44 wc.hbrBackground = (HBRUSH) (COLOR_WINDOW + 1);
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
45 wc.lpszMenuName = NULL;
3060
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
3071
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
48 if (!RegisterClass(&wc)) {
3060
4cf533f434d8 Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
49 MessageBox(NULL, "Window Registration Failed!", "Error!",
3071
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
50 MB_ICONEXCLAMATION | MB_OK);
3060
4cf533f434d8 Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
51 return 0;
4cf533f434d8 Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
52 }
4cf533f434d8 Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
53
3071
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
54 hwnd =
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
55 CreateWindow("SDL Test", "", WS_OVERLAPPEDWINDOW, CW_USEDEFAULT,
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
56 CW_USEDEFAULT, w, h, NULL, NULL, GetModuleHandle(NULL),
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
57 NULL);
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
58 if (hwnd == NULL) {
3060
4cf533f434d8 Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
59 MessageBox(NULL, "Window Creation Failed!", "Error!",
3071
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
60 MB_ICONEXCLAMATION | MB_OK);
3060
4cf533f434d8 Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
61 return 0;
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
4cf533f434d8 Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
64 ShowWindow(hwnd, SW_SHOW);
4cf533f434d8 Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
65
4cf533f434d8 Implemented Win32 version of the native window test
Sam Lantinga <slouken@libsdl.org>
parents: 3057
diff changeset
66 return hwnd;
3057
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
089a77aebb7d Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
69 static void
5062
e8916fe9cfc8 Fixed bug #925
Sam Lantinga <slouken@libsdl.org>
parents: 3071
diff changeset
70 DestroyWindowNative(void *window)
3057
089a77aebb7d Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
71 {
3071
Sam Lantinga <slouken@libsdl.org>
parents: 3060
diff changeset
72 DestroyWindow((HWND) window);
3057
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
089a77aebb7d Added test program for SDL_CreateWindowFrom()
Sam Lantinga <slouken@libsdl.org>
parents:
diff changeset
75 #endif