user32: Recurse into WS_EX_CONTROLPARENT controls when searching the default button
André Hentschel
nerv at dawncrow.de
Thu Jul 1 15:13:57 CDT 2010
This fixes bug 22862 which blocks bug 12804 (1.2)
This time i hope it is obvious enough as we also do the recursion in DEFDLG_FindDefButton and GetNextDlgGroupItem
Thanks Alex Balut very much for the testing with the stripped winecfg and for the testcase!
see also:
http://bugs.winehq.org/show_bug.cgi?id=22862
http://bugs.winehq.org/show_bug.cgi?id=12804
---
dlls/comctl32/tests/propsheet.c | 1 -
dlls/user32/controls.h | 1 +
dlls/user32/defdlg.c | 2 +-
dlls/user32/dialog.c | 29 ++++++++++++++++++++++++++++-
4 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/dlls/comctl32/tests/propsheet.c b/dlls/comctl32/tests/propsheet.c
index bfbaaa0..00a5573 100644
--- a/dlls/comctl32/tests/propsheet.c
+++ b/dlls/comctl32/tests/propsheet.c
@@ -519,7 +519,6 @@ static void test_custom_default_button(void)
}
}
- todo_wine
ok(add_button_has_been_pressed, "The Add button has not been pressed!\n");
DestroyWindow(hdlg);
diff --git a/dlls/user32/controls.h b/dlls/user32/controls.h
index f6653fd..217d2a3 100644
--- a/dlls/user32/controls.h
+++ b/dlls/user32/controls.h
@@ -242,5 +242,6 @@ typedef struct tagDIALOGINFO
extern DIALOGINFO *DIALOG_get_info( HWND hwnd, BOOL create ) DECLSPEC_HIDDEN;
extern INT DIALOG_DoDialogBox( HWND hwnd, HWND owner ) DECLSPEC_HIDDEN;
+extern HWND DIALOG_GetDlgItemRecurse( HWND hwndDlg, INT id );
#endif /* __WINE_CONTROLS_H */
diff --git a/dlls/user32/defdlg.c b/dlls/user32/defdlg.c
index fecd417..708633e 100644
--- a/dlls/user32/defdlg.c
+++ b/dlls/user32/defdlg.c
@@ -141,7 +141,7 @@ static HWND DEFDLG_FindDefButton( HWND hwndDlg )
static BOOL DEFDLG_SetDefId( HWND hwndDlg, DIALOGINFO *dlgInfo, WPARAM wParam)
{
DWORD dlgcode=0; /* initialize just to avoid a warning */
- HWND hwndOld, hwndNew = GetDlgItem(hwndDlg, wParam);
+ HWND hwndOld, hwndNew = DIALOG_GetDlgItemRecurse(hwndDlg, wParam);
INT old_id = dlgInfo->idResult;
dlgInfo->idResult = wParam;
diff --git a/dlls/user32/dialog.c b/dlls/user32/dialog.c
index aac8a4d..a6882e6 100644
--- a/dlls/user32/dialog.c
+++ b/dlls/user32/dialog.c
@@ -1220,7 +1220,7 @@ BOOL WINAPI IsDialogMessageW( HWND hwndDlg, LPMSG msg )
}
else if (DC_HASDEFID == HIWORD(dw = SendMessageW (hwndDlg, DM_GETDEFID, 0, 0)))
{
- HWND hwndDef = GetDlgItem(hwndDlg, LOWORD(dw));
+ HWND hwndDef = DIALOG_GetDlgItemRecurse(hwndDlg, LOWORD(dw));
if (!hwndDef || !IsWindowEnabled(hwndDef))
return TRUE;
SendMessageW( hwndDlg, WM_COMMAND, MAKEWPARAM( LOWORD(dw), BN_CLICKED ),
@@ -1286,6 +1286,33 @@ HWND WINAPI GetDlgItem( HWND hwndDlg, INT id )
return ret;
}
+HWND DIALOG_GetDlgItemRecurse( HWND hwndDlg, INT id )
+{
+ int i;
+ HWND *list = WIN_ListChildren( hwndDlg );
+ HWND ret = 0;
+
+ if (!list) return 0;
+
+ for (i = 0; list[i]; i++)
+ {
+ if (GetWindowLongPtrW( list[i], GWLP_ID ) == id)
+ {
+ ret = list[i];
+ break;
+ }
+
+ /* Recurse into WS_EX_CONTROLPARENT controls */
+ if (GetWindowLongW( list[i], GWL_EXSTYLE ) & WS_EX_CONTROLPARENT)
+ {
+ ret = DIALOG_GetDlgItemRecurse( list[i], id );
+ if (ret) break;
+ }
+ }
+
+ HeapFree( GetProcessHeap(), 0, list );
+ return ret;
+}
/*******************************************************************
* SendDlgItemMessageA (USER32.@)
--
Best Regards, André Hentschel
More information about the wine-patches
mailing list