Author: mjmartin Date: Mon Oct 12 14:47:54 2009 New Revision: 43396
URL: http://svn.reactos.org/svn/reactos?rev=43396&view=rev Log: - Change DIALOG_CreateIndirect location in source to make DEFDLG_SaveFocus available for use. - DIALOG_CreateIndirect: The current window with focus could have been set in the dialog's procedure, so save the current focused window after sending WM_INITDIALOG and before any other message are sent that modify focus. - Fixes setting focus on Open and Close dialogs to the FileName edit control in OpenOffice.
Modified: trunk/reactos/dll/win32/user32/windows/dialog.c
Modified: trunk/reactos/dll/win32/user32/windows/dialog.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/di... ============================================================================== --- trunk/reactos/dll/win32/user32/windows/dialog.c [iso-8859-1] (original) +++ trunk/reactos/dll/win32/user32/windows/dialog.c [iso-8859-1] Mon Oct 12 14:47:54 2009 @@ -682,7 +682,59 @@ return (LPCSTR)((((UINT_PTR)p) + 3) & ~3); }
- /*********************************************************************** +/*********************************************************************** + * DEFDLG_SetFocus + * + * Set the focus to a control of the dialog, selecting the text if + * the control is an edit dialog. + */ +static void DEFDLG_SetFocus( HWND hwndDlg, HWND hwndCtrl ) +{ + if (SendMessageW( hwndCtrl, WM_GETDLGCODE, 0, 0 ) & DLGC_HASSETSEL) + SendMessageW( hwndCtrl, EM_SETSEL, 0, -1 ); + SetFocus( hwndCtrl ); +} + + +/*********************************************************************** + * DEFDLG_SaveFocus + */ +static void DEFDLG_SaveFocus( HWND hwnd ) +{ + DIALOGINFO *infoPtr; + HWND hwndFocus = GetFocus(); + + if (!hwndFocus || !IsChild( hwnd, hwndFocus )) return; + if (!(infoPtr = GETDLGINFO(hwnd))) return; + infoPtr->hwndFocus = hwndFocus; + /* Remove default button */ +} + + +/*********************************************************************** + * DEFDLG_RestoreFocus + */ +static void DEFDLG_RestoreFocus( HWND hwnd ) +{ + DIALOGINFO *infoPtr; + + if (IsIconic( hwnd )) return; + if (!(infoPtr = GETDLGINFO(hwnd))) return; + /* Don't set the focus back to controls if EndDialog is already called.*/ + if (infoPtr->flags & DF_END) return; + if (!IsWindow(infoPtr->hwndFocus) || infoPtr->hwndFocus == hwnd) { + /* If no saved focus control exists, set focus to the first visible, + non-disabled, WS_TABSTOP control in the dialog */ + infoPtr->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE ); + if (!IsWindow( infoPtr->hwndFocus )) return; + } + DEFDLG_SetFocus( hwnd, infoPtr->hwndFocus ); + + /* This used to set infoPtr->hwndFocus to NULL for no apparent reason, + sometimes losing focus when receiving WM_SETFOCUS messages. */ +} + +/*********************************************************************** * DIALOG_CreateIndirect * Creates a dialog box window * @@ -923,6 +975,9 @@ if( dlgInfo->hwndFocus ) SetFocus( dlgInfo->hwndFocus ); } +//// ReactOS + DEFDLG_SaveFocus( hwnd ); +//// } //// ReactOS Rev 30613 & 30644 if (!(GetWindowLongPtrW( hwnd, GWL_STYLE ) & WS_CHILD)) @@ -938,60 +993,6 @@ if( IsWindow(hwnd) ) DestroyWindow( hwnd ); return 0; } - - -/*********************************************************************** - * DEFDLG_SetFocus - * - * Set the focus to a control of the dialog, selecting the text if - * the control is an edit dialog. - */ -static void DEFDLG_SetFocus( HWND hwndDlg, HWND hwndCtrl ) -{ - if (SendMessageW( hwndCtrl, WM_GETDLGCODE, 0, 0 ) & DLGC_HASSETSEL) - SendMessageW( hwndCtrl, EM_SETSEL, 0, -1 ); - SetFocus( hwndCtrl ); -} - - -/*********************************************************************** - * DEFDLG_SaveFocus - */ -static void DEFDLG_SaveFocus( HWND hwnd ) -{ - DIALOGINFO *infoPtr; - HWND hwndFocus = GetFocus(); - - if (!hwndFocus || !IsChild( hwnd, hwndFocus )) return; - if (!(infoPtr = GETDLGINFO(hwnd))) return; - infoPtr->hwndFocus = hwndFocus; - /* Remove default button */ -} - - -/*********************************************************************** - * DEFDLG_RestoreFocus - */ -static void DEFDLG_RestoreFocus( HWND hwnd ) -{ - DIALOGINFO *infoPtr; - - if (IsIconic( hwnd )) return; - if (!(infoPtr = GETDLGINFO(hwnd))) return; - /* Don't set the focus back to controls if EndDialog is already called.*/ - if (infoPtr->flags & DF_END) return; - if (!IsWindow(infoPtr->hwndFocus) || infoPtr->hwndFocus == hwnd) { - /* If no saved focus control exists, set focus to the first visible, - non-disabled, WS_TABSTOP control in the dialog */ - infoPtr->hwndFocus = GetNextDlgTabItem( hwnd, 0, FALSE ); - if (!IsWindow( infoPtr->hwndFocus )) return; - } - DEFDLG_SetFocus( hwnd, infoPtr->hwndFocus ); - - /* This used to set infoPtr->hwndFocus to NULL for no apparent reason, - sometimes losing focus when receiving WM_SETFOCUS messages. */ -} -
/*********************************************************************** * DEFDLG_FindDefButton