diff options
| author | Pietro Gagliardi <[email protected]> | 2014-08-14 16:12:43 -0400 |
|---|---|---|
| committer | Pietro Gagliardi <[email protected]> | 2014-08-14 16:12:43 -0400 |
| commit | 868161b7f0f5de708f242aaf82a3165edbaa22e8 (patch) | |
| tree | 6284f0ded45f49ec14f746de49c9999802b79557 /redo/common_windows.c | |
| parent | d944af860934fdf8a3a38fc48a0b158428d90a0f (diff) | |
Moved code to handle window user data in the Windows backend to a single function.
Diffstat (limited to 'redo/common_windows.c')
| -rw-r--r-- | redo/common_windows.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/redo/common_windows.c b/redo/common_windows.c index 01da0ef..53f2b3e 100644 --- a/redo/common_windows.c +++ b/redo/common_windows.c @@ -29,11 +29,23 @@ void updateWindow(HWND hwnd) xpanic("error calling UpdateWindow()", GetLastError()); } -void storelpParam(HWND hwnd, LPARAM lParam) +void *getWindowData(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam, LRESULT *lResult, void (*storeHWND)(void *, HWND)) { CREATESTRUCTW *cs = (CREATESTRUCTW *) lParam; + void *data; - SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) (cs->lpCreateParams)); + data = (void *) GetWindowLongPtrW(hwnd, GWLP_USERDATA); + if (data == NULL) { + // the lpParam is available during WM_NCCREATE and WM_CREATE + if (uMsg == WM_NCCREATE) { + SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR) (cs->lpCreateParams)); + data = (void *) GetWindowLongPtrW(hwnd, GWLP_USERDATA); + (*storeHWND)(data, hwnd); + } + // act as if we're not ready yet, even during WM_NCCREATE (nothing important to the switch statement below happens here anyway) + *lResult = DefWindowProcW(hwnd, uMsg, wParam, lParam); + } + return data; } /* |
