From a4b5c5db1c52a29d1145a01045bcab8ca209dee5 Mon Sep 17 00:00:00 2001 From: Nikolay Sivov Date: Sun, 11 Oct 2009 16:25:17 +0400 Subject: [PATCH] comctl32: Don't use additional heap allocated pointer to old window procedure. --- dlls/comctl32/tests/datetime.c | 26 +++------- dlls/comctl32/tests/header.c | 20 +++---- dlls/comctl32/tests/listview.c | 95 +++++++++++----------------------- dlls/comctl32/tests/monthcal.c | 27 +++------- dlls/comctl32/tests/tab.c | 19 ++----- dlls/comctl32/tests/trackbar.c | 26 +++------- dlls/comctl32/tests/updown.c | 49 +++++------------- 7 files changed, 74 insertions(+), 188 deletions(-) diff --git a/dlls/comctl32/tests/datetime.c b/dlls/comctl32/tests/datetime.c index 1de433cc076..973d41128e3 100644 --- a/dlls/comctl32/tests/datetime.c +++ b/dlls/comctl32/tests/datetime.c @@ -121,14 +121,9 @@ static const struct message test_dtm_set_and_get_system_time_seq[] = { { 0 } }; -struct subclass_info -{ - WNDPROC oldproc; -}; - static LRESULT WINAPI datetime_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - struct subclass_info *info = (struct subclass_info *)GetWindowLongPtrA(hwnd, GWLP_USERDATA); + WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA); static LONG defwndproc_counter = 0; LRESULT ret; struct message msg; @@ -143,7 +138,7 @@ static LRESULT WINAPI datetime_subclass_proc(HWND hwnd, UINT message, WPARAM wPa add_message(sequences, DATETIME_SEQ_INDEX, &msg); defwndproc_counter++; - ret = CallWindowProcA(info->oldproc, hwnd, message, wParam, lParam); + ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam); defwndproc_counter--; return ret; @@ -151,13 +146,9 @@ static LRESULT WINAPI datetime_subclass_proc(HWND hwnd, UINT message, WPARAM wPa static HWND create_datetime_control(DWORD style) { - struct subclass_info *info; + WNDPROC oldproc; HWND hWndDateTime = NULL; - info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info)); - if (!info) - return NULL; - hWndDateTime = CreateWindowEx(0, DATETIMEPICK_CLASS, NULL, @@ -168,14 +159,11 @@ static HWND create_datetime_control(DWORD style) NULL, NULL); - if (!hWndDateTime) { - HeapFree(GetProcessHeap(), 0, info); - return NULL; - } + if (!hWndDateTime) return NULL; - info->oldproc = (WNDPROC)SetWindowLongPtrA(hWndDateTime, GWLP_WNDPROC, - (LONG_PTR)datetime_subclass_proc); - SetWindowLongPtrA(hWndDateTime, GWLP_USERDATA, (LONG_PTR)info); + oldproc = (WNDPROC)SetWindowLongPtrA(hWndDateTime, GWLP_WNDPROC, + (LONG_PTR)datetime_subclass_proc); + SetWindowLongPtrA(hWndDateTime, GWLP_USERDATA, (LONG_PTR)oldproc); return hWndDateTime; } diff --git a/dlls/comctl32/tests/header.c b/dlls/comctl32/tests/header.c index 3bbaaa8e30a..2fecaeefa15 100644 --- a/dlls/comctl32/tests/header.c +++ b/dlls/comctl32/tests/header.c @@ -396,14 +396,9 @@ static WCHAR pszUniTestW[] = {'T','S','T',0}; ok(res == i, "Got Item Count as %d\n", res);\ } -struct subclass_info -{ - WNDPROC oldproc; -}; - static LRESULT WINAPI header_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - struct subclass_info *info = (struct subclass_info *)GetWindowLongPtrA(hwnd, GWLP_USERDATA); + WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA); static LONG defwndproc_counter = 0; LRESULT ret; struct message msg; @@ -417,7 +412,7 @@ static LRESULT WINAPI header_subclass_proc(HWND hwnd, UINT message, WPARAM wPara add_message(sequences, HEADER_SEQ_INDEX, &msg); defwndproc_counter++; - ret = CallWindowProcA(info->oldproc, hwnd, message, wParam, lParam); + ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam); defwndproc_counter--; return ret; @@ -487,7 +482,7 @@ static HWND create_custom_parent_window(void) static HWND create_custom_header_control(HWND hParent, BOOL preloadHeaderItems) { - struct subclass_info *info; + WNDPROC oldproc; HWND childHandle; HDLAYOUT hlayout; RECT rectwin; @@ -505,9 +500,6 @@ static HWND create_custom_header_control(HWND hParent, BOOL preloadHeaderItems) flush_sequences(sequences, NUM_MSG_SEQUENCES); - info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info)); - if (!info) - return NULL; childHandle = CreateWindowEx(0, WC_HEADER, NULL, WS_CHILD|WS_BORDER|WS_VISIBLE|HDS_BUTTONS|HDS_HORZ, @@ -534,9 +526,9 @@ static HWND create_custom_header_control(HWND hParent, BOOL preloadHeaderItems) SetWindowPos(childHandle, winpos.hwndInsertAfter, winpos.x, winpos.y, winpos.cx, winpos.cy, 0); - info->oldproc = (WNDPROC)SetWindowLongPtrA(childHandle, GWLP_WNDPROC, - (LONG_PTR)header_subclass_proc); - SetWindowLongPtrA(childHandle, GWLP_USERDATA, (LONG_PTR)info); + oldproc = (WNDPROC)SetWindowLongPtrA(childHandle, GWLP_WNDPROC, + (LONG_PTR)header_subclass_proc); + SetWindowLongPtrA(childHandle, GWLP_USERDATA, (LONG_PTR)oldproc); return childHandle; } diff --git a/dlls/comctl32/tests/listview.c b/dlls/comctl32/tests/listview.c index 2e8e555a0fd..f6c5bf9cfac 100644 --- a/dlls/comctl32/tests/listview.c +++ b/dlls/comctl32/tests/listview.c @@ -271,11 +271,6 @@ static const struct message lvs_ex_transparentbkgnd_seq[] = { { 0 } }; -struct subclass_info -{ - WNDPROC oldproc; -}; - static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { static LONG defwndproc_counter = 0; @@ -421,7 +416,7 @@ static HWND create_parent_window(BOOL Unicode) static LRESULT WINAPI listview_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - struct subclass_info *info = (struct subclass_info *)GetWindowLongPtrA(hwnd, GWLP_USERDATA); + WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA); static LONG defwndproc_counter = 0; LRESULT ret; struct message msg; @@ -445,21 +440,17 @@ static LRESULT WINAPI listview_subclass_proc(HWND hwnd, UINT message, WPARAM wPa add_message(sequences, LISTVIEW_SEQ_INDEX, &msg); defwndproc_counter++; - ret = CallWindowProcA(info->oldproc, hwnd, message, wParam, lParam); + ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam); defwndproc_counter--; return ret; } static HWND create_listview_control(DWORD style) { - struct subclass_info *info; + WNDPROC oldproc; HWND hwnd; RECT rect; - info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info)); - if (!info) - return NULL; - GetClientRect(hwndparent, &rect); hwnd = CreateWindowExA(0, WC_LISTVIEW, "foo", WS_CHILD | WS_BORDER | WS_VISIBLE | LVS_REPORT | style, @@ -467,15 +458,11 @@ static HWND create_listview_control(DWORD style) hwndparent, NULL, GetModuleHandleA(NULL), NULL); ok(hwnd != NULL, "gle=%d\n", GetLastError()); - if (!hwnd) - { - HeapFree(GetProcessHeap(), 0, info); - return NULL; - } + if (!hwnd) return NULL; - info->oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, - (LONG_PTR)listview_subclass_proc); - SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)info); + oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, + (LONG_PTR)listview_subclass_proc); + SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc); return hwnd; } @@ -483,15 +470,11 @@ static HWND create_listview_control(DWORD style) /* unicode listview window with specified parent */ static HWND create_listview_controlW(DWORD style, HWND parent) { - struct subclass_info *info; + WNDPROC oldproc; HWND hwnd; RECT rect; static const WCHAR nameW[] = {'f','o','o',0}; - info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info)); - if (!info) - return NULL; - GetClientRect(parent, &rect); hwnd = CreateWindowExW(0, WC_LISTVIEWW, nameW, WS_CHILD | WS_BORDER | WS_VISIBLE | LVS_REPORT | style, @@ -499,29 +482,21 @@ static HWND create_listview_controlW(DWORD style, HWND parent) parent, NULL, GetModuleHandleW(NULL), NULL); ok(hwnd != NULL, "gle=%d\n", GetLastError()); - if (!hwnd) - { - HeapFree(GetProcessHeap(), 0, info); - return NULL; - } + if (!hwnd) return NULL; - info->oldproc = (WNDPROC)SetWindowLongPtrW(hwnd, GWLP_WNDPROC, - (LONG_PTR)listview_subclass_proc); - SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR)info); + oldproc = (WNDPROC)SetWindowLongPtrW(hwnd, GWLP_WNDPROC, + (LONG_PTR)listview_subclass_proc); + SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc); return hwnd; } static HWND create_custom_listview_control(DWORD style) { - struct subclass_info *info; + WNDPROC oldproc; HWND hwnd; RECT rect; - info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info)); - if (!info) - return NULL; - GetClientRect(hwndparent, &rect); hwnd = CreateWindowExA(0, WC_LISTVIEW, "foo", WS_CHILD | WS_BORDER | WS_VISIBLE | style, @@ -529,22 +504,18 @@ static HWND create_custom_listview_control(DWORD style) hwndparent, NULL, GetModuleHandleA(NULL), NULL); ok(hwnd != NULL, "gle=%d\n", GetLastError()); - if (!hwnd) - { - HeapFree(GetProcessHeap(), 0, info); - return NULL; - } + if (!hwnd) return NULL; - info->oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, - (LONG_PTR)listview_subclass_proc); - SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)info); + oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, + (LONG_PTR)listview_subclass_proc); + SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc); return hwnd; } static LRESULT WINAPI header_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - struct subclass_info *info = (struct subclass_info *)GetWindowLongPtrA(hwnd, GWLP_USERDATA); + WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA); static LONG defwndproc_counter = 0; LRESULT ret; struct message msg; @@ -560,31 +531,27 @@ static LRESULT WINAPI header_subclass_proc(HWND hwnd, UINT message, WPARAM wPara add_message(sequences, LISTVIEW_SEQ_INDEX, &msg); defwndproc_counter++; - ret = CallWindowProcA(info->oldproc, hwnd, message, wParam, lParam); + ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam); defwndproc_counter--; return ret; } static HWND subclass_header(HWND hwndListview) { - struct subclass_info *info; + WNDPROC oldproc; HWND hwnd; - info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info)); - if (!info) - return NULL; - hwnd = ListView_GetHeader(hwndListview); - info->oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, - (LONG_PTR)header_subclass_proc); - SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)info); + oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, + (LONG_PTR)header_subclass_proc); + SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc); return hwnd; } static LRESULT WINAPI editbox_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - struct subclass_info *info = (struct subclass_info *)GetWindowLongPtrA(hwnd, GWLP_USERDATA); + WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA); static LONG defwndproc_counter = 0; LRESULT ret; struct message msg; @@ -606,24 +573,20 @@ static LRESULT WINAPI editbox_subclass_proc(HWND hwnd, UINT message, WPARAM wPar } defwndproc_counter++; - ret = CallWindowProcA(info->oldproc, hwnd, message, wParam, lParam); + ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam); defwndproc_counter--; return ret; } static HWND subclass_editbox(HWND hwndListview) { - struct subclass_info *info; + WNDPROC oldproc; HWND hwnd; - info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info)); - if (!info) - return NULL; - hwnd = (HWND)SendMessage(hwndListview, LVM_GETEDITCONTROL, 0, 0); - info->oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, - (LONG_PTR)editbox_subclass_proc); - SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)info); + oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, + (LONG_PTR)editbox_subclass_proc); + SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc); return hwnd; } diff --git a/dlls/comctl32/tests/monthcal.c b/dlls/comctl32/tests/monthcal.c index 8d59e72f80b..c9b4decbbdd 100644 --- a/dlls/comctl32/tests/monthcal.c +++ b/dlls/comctl32/tests/monthcal.c @@ -39,11 +39,6 @@ #define PARENT_SEQ_INDEX 0 #define MONTHCAL_SEQ_INDEX 1 -struct subclass_info -{ - WNDPROC oldproc; -}; - static struct msg_sequence *sequences[NUM_MSG_SEQUENCES]; static HWND parent_wnd; @@ -581,7 +576,7 @@ static HWND create_parent_window(void) static LRESULT WINAPI monthcal_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - struct subclass_info *info = (struct subclass_info *)GetWindowLongPtrA(hwnd, GWLP_USERDATA); + WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA); static LONG defwndproc_counter = 0; LRESULT ret; struct message msg; @@ -602,7 +597,7 @@ static LRESULT WINAPI monthcal_subclass_proc(HWND hwnd, UINT message, WPARAM wPa } defwndproc_counter++; - ret = CallWindowProcA(info->oldproc, hwnd, message, wParam, lParam); + ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam); defwndproc_counter--; return ret; @@ -610,13 +605,9 @@ static LRESULT WINAPI monthcal_subclass_proc(HWND hwnd, UINT message, WPARAM wPa static HWND create_monthcal_control(DWORD style) { - struct subclass_info *info; + WNDPROC oldproc; HWND hwnd; - info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info)); - if (!info) - return NULL; - hwnd = CreateWindowEx(0, MONTHCAL_CLASS, "", @@ -624,15 +615,11 @@ static HWND create_monthcal_control(DWORD style) 0, 0, 300, 400, parent_wnd, NULL, GetModuleHandleA(NULL), NULL); - if (!hwnd) - { - HeapFree(GetProcessHeap(), 0, info); - return NULL; - } + if (!hwnd) return NULL; - info->oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, - (LONG_PTR)monthcal_subclass_proc); - SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)info); + oldproc = (WNDPROC)SetWindowLongPtrA(hwnd, GWLP_WNDPROC, + (LONG_PTR)monthcal_subclass_proc); + SetWindowLongPtrA(hwnd, GWLP_USERDATA, (LONG_PTR)oldproc); SendMessage(hwnd, WM_SETFONT, (WPARAM)GetStockObject(SYSTEM_FONT), 0); diff --git a/dlls/comctl32/tests/tab.c b/dlls/comctl32/tests/tab.c index f017b136c90..bab747a917c 100644 --- a/dlls/comctl32/tests/tab.c +++ b/dlls/comctl32/tests/tab.c @@ -374,14 +374,9 @@ static HWND createParentWindow(void) GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL); } -struct subclass_info -{ - WNDPROC oldproc; -}; - static LRESULT WINAPI tabSubclassProcess(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - struct subclass_info *info = (struct subclass_info *)GetWindowLongPtrA(hwnd, GWLP_USERDATA); + WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA); static LONG defwndproc_counter = 0; LRESULT ret; struct message msg; @@ -406,7 +401,7 @@ static LRESULT WINAPI tabSubclassProcess(HWND hwnd, UINT message, WPARAM wParam, } defwndproc_counter++; - ret = CallWindowProcA(info->oldproc, hwnd, message, wParam, lParam); + ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam); defwndproc_counter--; return ret; @@ -416,14 +411,10 @@ static HWND createFilledTabControl(HWND parent_wnd, DWORD style, DWORD mask, INT { HWND tabHandle; TCITEM tcNewTab; - struct subclass_info *info; + WNDPROC oldproc; RECT rect; INT i; - info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info)); - if (!info) - return NULL; - GetClientRect(parent_wnd, &rect); tabHandle = CreateWindow ( @@ -435,8 +426,8 @@ static HWND createFilledTabControl(HWND parent_wnd, DWORD style, DWORD mask, INT assert(tabHandle); - info->oldproc = (WNDPROC)SetWindowLongPtrA(tabHandle, GWLP_WNDPROC, (LONG_PTR)tabSubclassProcess); - SetWindowLongPtrA(tabHandle, GWLP_USERDATA, (LONG_PTR)info); + oldproc = (WNDPROC)SetWindowLongPtrA(tabHandle, GWLP_WNDPROC, (LONG_PTR)tabSubclassProcess); + SetWindowLongPtrA(tabHandle, GWLP_USERDATA, (LONG_PTR)oldproc); tcNewTab.mask = mask; diff --git a/dlls/comctl32/tests/trackbar.c b/dlls/comctl32/tests/trackbar.c index 22fbbfe40a2..68261d833fb 100644 --- a/dlls/comctl32/tests/trackbar.c +++ b/dlls/comctl32/tests/trackbar.c @@ -364,11 +364,6 @@ static const struct message ignore_selection_test_seq[] = { {0} }; -struct subclass_info -{ - WNDPROC oldproc; -}; - static LRESULT WINAPI parent_wnd_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){ static LONG defwndproc_counter = 0; LRESULT ret; @@ -430,7 +425,7 @@ static HWND create_parent_window(void){ } static LRESULT WINAPI trackbar_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam){ - struct subclass_info *info = (struct subclass_info *) GetWindowLongPtrA(hwnd, GWLP_USERDATA); + WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA); static LONG defwndproc_counter = 0; LRESULT ret; struct message msg; @@ -445,36 +440,27 @@ static LRESULT WINAPI trackbar_subclass_proc(HWND hwnd, UINT message, WPARAM wPa add_message(sequences, TRACKBAR_SEQ_INDEX, &msg); defwndproc_counter++; - ret = CallWindowProcA(info->oldproc, hwnd, message, wParam, lParam); + ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam); defwndproc_counter--; return ret; } static HWND create_trackbar(DWORD style, HWND parent){ - struct subclass_info *info; HWND hWndTrack; + WNDPROC oldproc; RECT rect; - info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info)); - if (!info) - return NULL; - GetClientRect(parent, &rect); hWndTrack = CreateWindowEx( 0, TRACKBAR_CLASS,"Trackbar Control", style, rect.right,rect.bottom, 100, 50, parent, NULL,GetModuleHandleA(NULL) ,NULL); - if (!hWndTrack) - { - HeapFree(GetProcessHeap(), 0, info); - return NULL; - } + if (!hWndTrack) return NULL; - info->oldproc = (WNDPROC)SetWindowLongPtrA(hWndTrack, GWLP_WNDPROC, (LONG_PTR)trackbar_subclass_proc); - - SetWindowLongPtrA(hWndTrack, GWLP_USERDATA, (LONG_PTR)info); + oldproc = (WNDPROC)SetWindowLongPtrA(hWndTrack, GWLP_WNDPROC, (LONG_PTR)trackbar_subclass_proc); + SetWindowLongPtrA(hWndTrack, GWLP_USERDATA, (LONG_PTR)oldproc); return hWndTrack; } diff --git a/dlls/comctl32/tests/updown.c b/dlls/comctl32/tests/updown.c index 253e9599823..85452aee437 100644 --- a/dlls/comctl32/tests/updown.c +++ b/dlls/comctl32/tests/updown.c @@ -217,14 +217,9 @@ static HWND create_parent_window(void) GetDesktopWindow(), NULL, GetModuleHandleA(NULL), NULL); } -struct subclass_info -{ - WNDPROC oldproc; -}; - static LRESULT WINAPI edit_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - struct subclass_info *info = (struct subclass_info *)GetWindowLongPtrA(hwnd, GWLP_USERDATA); + WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA); static LONG defwndproc_counter = 0; LRESULT ret; struct message msg; @@ -239,40 +234,32 @@ static LRESULT WINAPI edit_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, add_message(sequences, EDIT_SEQ_INDEX, &msg); defwndproc_counter++; - ret = CallWindowProcA(info->oldproc, hwnd, message, wParam, lParam); + ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam); defwndproc_counter--; return ret; } static HWND create_edit_control(void) { - struct subclass_info *info; + WNDPROC oldproc; RECT rect; - info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info)); - if (!info) - return NULL; - GetClientRect(parent_wnd, &rect); edit = CreateWindowExA(0, "EDIT", NULL, WS_CHILD | WS_BORDER | WS_VISIBLE, 0, 0, rect.right, rect.bottom, parent_wnd, NULL, GetModuleHandleA(NULL), NULL); - if (!edit) - { - HeapFree(GetProcessHeap(), 0, info); - return NULL; - } + if (!edit) return NULL; - info->oldproc = (WNDPROC)SetWindowLongPtrA(edit, GWLP_WNDPROC, - (LONG_PTR)edit_subclass_proc); - SetWindowLongPtrA(edit, GWLP_USERDATA, (LONG_PTR)info); + oldproc = (WNDPROC)SetWindowLongPtrA(edit, GWLP_WNDPROC, + (LONG_PTR)edit_subclass_proc); + SetWindowLongPtrA(edit, GWLP_USERDATA, (LONG_PTR)oldproc); return edit; } static LRESULT WINAPI updown_subclass_proc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { - struct subclass_info *info = (struct subclass_info *)GetWindowLongPtrA(hwnd, GWLP_USERDATA); + WNDPROC oldproc = (WNDPROC)GetWindowLongPtrA(hwnd, GWLP_USERDATA); static LONG defwndproc_counter = 0; LRESULT ret; struct message msg; @@ -287,7 +274,7 @@ static LRESULT WINAPI updown_subclass_proc(HWND hwnd, UINT message, WPARAM wPara add_message(sequences, UPDOWN_SEQ_INDEX, &msg); defwndproc_counter++; - ret = CallWindowProcA(info->oldproc, hwnd, message, wParam, lParam); + ret = CallWindowProcA(oldproc, hwnd, message, wParam, lParam); defwndproc_counter--; return ret; @@ -295,27 +282,19 @@ static LRESULT WINAPI updown_subclass_proc(HWND hwnd, UINT message, WPARAM wPara static HWND create_updown_control(DWORD style) { - struct subclass_info *info; + WNDPROC oldproc; HWND updown; RECT rect; - info = HeapAlloc(GetProcessHeap(), 0, sizeof(struct subclass_info)); - if (!info) - return NULL; - GetClientRect(parent_wnd, &rect); updown = CreateUpDownControl(WS_CHILD | WS_BORDER | WS_VISIBLE | UDS_ALIGNRIGHT | style, 0, 0, rect.right, rect.bottom, parent_wnd, 1, GetModuleHandleA(NULL), edit, 100, 0, 50); - if (!updown) - { - HeapFree(GetProcessHeap(), 0, info); - return NULL; - } + if (!updown) return NULL; - info->oldproc = (WNDPROC)SetWindowLongPtrA(updown, GWLP_WNDPROC, - (LONG_PTR)updown_subclass_proc); - SetWindowLongPtrA(updown, GWLP_USERDATA, (LONG_PTR)info); + oldproc = (WNDPROC)SetWindowLongPtrA(updown, GWLP_WNDPROC, + (LONG_PTR)updown_subclass_proc); + SetWindowLongPtrA(updown, GWLP_USERDATA, (LONG_PTR)oldproc); return updown; }