Mercurial > sdl-ios-xcode
comparison src/video/win32/SDL_win32events.c @ 1719:5b9f50c957ed SDL-1.3
You can now create multiple windows on Win32
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Wed, 28 Jun 2006 08:12:07 +0000 |
parents | ed4d4f1ea201 |
children | 5daa04d862f1 |
comparison
equal
deleted
inserted
replaced
1718:ed4d4f1ea201 | 1719:5b9f50c957ed |
---|---|
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 | 26 |
27 static LRESULT CALLBACK | 27 LRESULT CALLBACK |
28 WinMessage(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) | 28 WIN_WindowProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam) |
29 { | 29 { |
30 return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam); | 30 SDL_WindowData *data; |
31 SDL_Window *window; | |
32 | |
33 /* Get the window data for the window */ | |
34 data = (SDL_WindowData *) GetProp(hwnd, TEXT("SDL_WindowData")); | |
35 if (!data) { | |
36 return CallWindowProc(DefWindowProc, hwnd, msg, wParam, lParam); | |
37 } | |
38 window = data->window; | |
39 | |
40 return CallWindowProc(data->wndproc, hwnd, msg, wParam, lParam); | |
31 } | 41 } |
32 | 42 |
33 void | 43 void |
34 WIN_PumpEvents(_THIS) | 44 WIN_PumpEvents(_THIS) |
35 { | 45 { |
61 SDL_Appstyle = (CS_BYTEALIGNCLIENT | CS_OWNDC); | 71 SDL_Appstyle = (CS_BYTEALIGNCLIENT | CS_OWNDC); |
62 SDL_Instance = hInst ? hInst : GetModuleHandle(NULL); | 72 SDL_Instance = hInst ? hInst : GetModuleHandle(NULL); |
63 } | 73 } |
64 | 74 |
65 if (name) { | 75 if (name) { |
66 SDL_Appname = SDL_iconv_utf8_ucs2(name); | 76 SDL_Appname = WIN_UTF8ToString(name); |
67 SDL_Appstyle = style; | 77 SDL_Appstyle = style; |
68 SDL_Instance = hInst ? hInst : GetModuleHandle(NULL); | 78 SDL_Instance = hInst ? hInst : GetModuleHandle(NULL); |
69 } | 79 } |
70 | 80 |
71 /* Register the application class */ | 81 /* Register the application class */ |
75 class.lpszMenuName = NULL; | 85 class.lpszMenuName = NULL; |
76 class.lpszClassName = SDL_Appname; | 86 class.lpszClassName = SDL_Appname; |
77 class.hbrBackground = NULL; | 87 class.hbrBackground = NULL; |
78 class.hInstance = SDL_Instance; | 88 class.hInstance = SDL_Instance; |
79 class.style = SDL_Appstyle; | 89 class.style = SDL_Appstyle; |
80 class.lpfnWndProc = WinMessage; | 90 class.lpfnWndProc = DefWindowProc; |
81 class.cbWndExtra = 0; | 91 class.cbWndExtra = 0; |
82 class.cbClsExtra = 0; | 92 class.cbClsExtra = 0; |
83 if (!RegisterClass(&class)) { | 93 if (!RegisterClass(&class)) { |
84 SDL_SetError("Couldn't register application class"); | 94 SDL_SetError("Couldn't register application class"); |
85 return (-1); | 95 return (-1); |
108 SDL_free(SDL_Appname); | 118 SDL_free(SDL_Appname); |
109 SDL_Appname = NULL; | 119 SDL_Appname = NULL; |
110 } | 120 } |
111 } | 121 } |
112 | 122 |
123 /* Sets an error message based on GetLastError() */ | |
124 void | |
125 WIN_SetError(const char *prefix) | |
126 { | |
127 TCHAR buffer[1024]; | |
128 char *message; | |
129 | |
130 FormatMessage(FORMAT_MESSAGE_FROM_SYSTEM, | |
131 NULL, | |
132 GetLastError(), 0, buffer, SDL_arraysize(buffer), NULL); | |
133 | |
134 message = WIN_StringToUTF8(buffer); | |
135 SDL_SetError("%s%s%s", prefix ? prefix : "", prefix ? ":" : "", message); | |
136 SDL_free(message); | |
137 } | |
138 | |
113 /* vi: set ts=4 sw=4 expandtab: */ | 139 /* vi: set ts=4 sw=4 expandtab: */ |