Mercurial > sdl-ios-xcode
comparison src/video/win32/SDL_win32events.c @ 1718:ed4d4f1ea201 SDL-1.3
Further progress on the new Windows video driver:
* SDL_SetModuleHandle() is obsolete, I hope.
* SDL 1.3 uses the UNICODE API
* I'm ignoring Windows CE for the moment, we'll reevaluate what needs to be different for Windows CE later.
* Pulled the stdio redirection from WinMain()
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 27 Jun 2006 07:46:36 +0000 |
parents | 931d111e737a |
children | 5b9f50c957ed |
comparison
equal
deleted
inserted
replaced
1717:e3637569ab86 | 1718:ed4d4f1ea201 |
---|---|
21 */ | 21 */ |
22 #include "SDL_config.h" | 22 #include "SDL_config.h" |
23 | 23 |
24 #include "SDL_win32video.h" | 24 #include "SDL_win32video.h" |
25 | 25 |
26 | |
27 static LRESULT CALLBACK | |
28 WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | |
29 { | |
30 return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam); | |
31 } | |
32 | |
26 void | 33 void |
27 WIN32_PumpEvents(_THIS) | 34 WIN_PumpEvents(_THIS) |
28 { | 35 { |
36 MSG msg; | |
37 while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE)) { | |
38 TranslateMessage(&msg); | |
39 DispatchMessage(&msg); | |
40 } | |
41 } | |
42 | |
43 static int app_registered = 0; | |
44 LPTSTR SDL_Appname = NULL; | |
45 Uint32 SDL_Appstyle = 0; | |
46 HINSTANCE SDL_Instance = NULL; | |
47 | |
48 /* Register the class for this application */ | |
49 int | |
50 SDL_RegisterApp(char *name, Uint32 style, void *hInst) | |
51 { | |
52 WNDCLASS class; | |
53 | |
54 /* Only do this once... */ | |
55 if (app_registered) { | |
56 ++app_registered; | |
57 return (0); | |
58 } | |
59 if (!name && !SDL_Appname) { | |
60 name = "SDL_app"; | |
61 SDL_Appstyle = (CS_BYTEALIGNCLIENT | CS_OWNDC); | |
62 SDL_Instance = hInst ? hInst : GetModuleHandle(NULL); | |
63 } | |
64 | |
65 if (name) { | |
66 SDL_Appname = SDL_iconv_utf8_ucs2(name); | |
67 SDL_Appstyle = style; | |
68 SDL_Instance = hInst ? hInst : GetModuleHandle(NULL); | |
69 } | |
70 | |
71 /* Register the application class */ | |
72 class.hCursor = NULL; | |
73 class.hIcon = LoadImage(SDL_Instance, SDL_Appname, | |
74 IMAGE_ICON, 0, 0, LR_DEFAULTCOLOR); | |
75 class.lpszMenuName = NULL; | |
76 class.lpszClassName = SDL_Appname; | |
77 class.hbrBackground = NULL; | |
78 class.hInstance = SDL_Instance; | |
79 class.style = SDL_Appstyle; | |
80 class.lpfnWndProc = WinMessage; | |
81 class.cbWndExtra = 0; | |
82 class.cbClsExtra = 0; | |
83 if (!RegisterClass(&class)) { | |
84 SDL_SetError("Couldn't register application class"); | |
85 return (-1); | |
86 } | |
87 | |
88 app_registered = 1; | |
89 return (0); | |
90 } | |
91 | |
92 /* Unregisters the windowclass registered in SDL_RegisterApp above. */ | |
93 void | |
94 SDL_UnregisterApp() | |
95 { | |
96 WNDCLASS class; | |
97 | |
98 /* SDL_RegisterApp might not have been called before */ | |
99 if (!app_registered) { | |
100 return; | |
101 } | |
102 --app_registered; | |
103 if (app_registered == 0) { | |
104 /* Check for any registered window classes. */ | |
105 if (GetClassInfo(SDL_Instance, SDL_Appname, &class)) { | |
106 UnregisterClass(SDL_Appname, SDL_Instance); | |
107 } | |
108 SDL_free(SDL_Appname); | |
109 SDL_Appname = NULL; | |
110 } | |
29 } | 111 } |
30 | 112 |
31 /* vi: set ts=4 sw=4 expandtab: */ | 113 /* vi: set ts=4 sw=4 expandtab: */ |