1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 10:48:51 -05:00

Replace Win32 window long with window property

Related to #25.
This commit is contained in:
Camilla Berglund 2016-03-27 21:20:31 +02:00
parent 3503cba5d9
commit c1e4c45c7a

View File

@ -369,20 +369,13 @@ static void releaseMonitor(_GLFWwindow* window)
static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg, static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
WPARAM wParam, LPARAM lParam) WPARAM wParam, LPARAM lParam)
{ {
_GLFWwindow* window = (_GLFWwindow*) GetWindowLongPtrW(hWnd, 0); _GLFWwindow* window = (_GLFWwindow*) GetPropW(hWnd, L"GLFW");
if (!window) if (!window)
{ {
// This is the message handling for the hidden helper window // This is the message handling for the hidden helper window
switch (uMsg) switch (uMsg)
{ {
case WM_NCCREATE:
{
CREATESTRUCTW* cs = (CREATESTRUCTW*) lParam;
SetWindowLongPtrW(hWnd, 0, (LONG_PTR) cs->lpCreateParams);
break;
}
case WM_DISPLAYCHANGE: case WM_DISPLAYCHANGE:
{ {
_glfwInputMonitorChange(); _glfwInputMonitorChange();
@ -815,7 +808,7 @@ static int createWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig)
NULL, // No parent window NULL, // No parent window
NULL, // No window menu NULL, // No window menu
GetModuleHandleW(NULL), GetModuleHandleW(NULL),
window); // Pass object to WM_CREATE NULL);
free(wideTitle); free(wideTitle);
@ -825,6 +818,8 @@ static int createWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig)
return GLFW_FALSE; return GLFW_FALSE;
} }
SetPropW(window->win32.handle, L"GLFW", window);
if (_glfw_ChangeWindowMessageFilterEx) if (_glfw_ChangeWindowMessageFilterEx)
{ {
_glfw_ChangeWindowMessageFilterEx(window->win32.handle, _glfw_ChangeWindowMessageFilterEx(window->win32.handle,
@ -846,6 +841,7 @@ static void destroyWindow(_GLFWwindow* window)
{ {
if (window->win32.handle) if (window->win32.handle)
{ {
RemovePropW(window->win32.handle, L"GLFW");
DestroyWindow(window->win32.handle); DestroyWindow(window->win32.handle);
window->win32.handle = NULL; window->win32.handle = NULL;
} }
@ -866,7 +862,6 @@ GLFWbool _glfwRegisterWindowClassWin32(void)
wc.cbSize = sizeof(wc); wc.cbSize = sizeof(wc);
wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC; wc.style = CS_HREDRAW | CS_VREDRAW | CS_OWNDC;
wc.lpfnWndProc = (WNDPROC) windowProc; wc.lpfnWndProc = (WNDPROC) windowProc;
wc.cbWndExtra = sizeof(void*) + sizeof(int); // Make room for one pointer
wc.hInstance = GetModuleHandleW(NULL); wc.hInstance = GetModuleHandleW(NULL);
wc.hCursor = LoadCursorW(NULL, IDC_ARROW); wc.hCursor = LoadCursorW(NULL, IDC_ARROW);
wc.lpszClassName = _GLFW_WNDCLASSNAME; wc.lpszClassName = _GLFW_WNDCLASSNAME;