Author: jimtabor Date: Sat May 5 02:49:17 2012 New Revision: 56502
URL: http://svn.reactos.org/svn/reactos?rev=56502&view=rev Log: [Win32k] - Add alerts and set window state to message box windows. Expands bug 5281.
Modified: trunk/reactos/win32ss/user/ntuser/simplecall.c trunk/reactos/win32ss/user/user32/include/ntwrapper.h trunk/reactos/win32ss/user/user32/windows/dialog.c trunk/reactos/win32ss/user/user32/windows/messagebox.c
Modified: trunk/reactos/win32ss/user/ntuser/simplecall.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/simplec... ============================================================================== --- trunk/reactos/win32ss/user/ntuser/simplecall.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/ntuser/simplecall.c [iso-8859-1] Sat May 5 02:49:17 2012 @@ -648,6 +648,17 @@ if (IntIsWindow(hWnd)) return IntDeRegisterShellHookWindow(hWnd); return FALSE; + case HWND_ROUTINE_SETMSGBOX: + { + PWND Window; + UserEnterExclusive(); + if ((Window = UserGetWindowObject(hWnd))) + { + Window->state |= WNDS_MSGBOX; + } + UserLeave(); + return FALSE; + } } STUB;
Modified: trunk/reactos/win32ss/user/user32/include/ntwrapper.h URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/include... ============================================================================== --- trunk/reactos/win32ss/user/user32/include/ntwrapper.h [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/include/ntwrapper.h [iso-8859-1] Sat May 5 02:49:17 2012 @@ -727,6 +727,11 @@ return NtUserCallHwnd(hWnd, HWND_ROUTINE_REGISTERSHELLHOOKWINDOW); }
+EXTINLINE BOOL NtUserxSetMessageBox(HWND hWnd) +{ + return NtUserCallHwnd(hWnd, HWND_ROUTINE_SETMSGBOX); +} + EXTINLINE HWND NtUserxSetTaskmanWindow(HWND hWnd) { return NtUserCallHwndOpt(hWnd, HWNDOPT_ROUTINE_SETTASKMANWINDOW);
Modified: trunk/reactos/win32ss/user/user32/windows/dialog.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/windows... ============================================================================== --- trunk/reactos/win32ss/user/user32/windows/dialog.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/windows/dialog.c [iso-8859-1] Sat May 5 02:49:17 2012 @@ -549,6 +549,10 @@ INT retval; HWND ownerMsg = GetAncestor( owner, GA_ROOT ); BOOL bFirstEmpty; + PWND pWnd; + + pWnd = ValidateHwnd(hwnd); + if (!pWnd) return -1;
if (!(dlgInfo = GETDLGINFO(hwnd))) return -1;
@@ -582,9 +586,10 @@
/* * If the user is pressing Ctrl+C, send a WM_COPY message. - * TODO: Is there another way to check if the Dialog it's a MessageBox?. + * Guido Pola, Bug 5281, Is there another way to check if the Dialog it's a MessageBox? */ - if( msg.message == WM_KEYDOWN && GetPropW(hwnd, L"ROS_MSGBOX") != NULL && + if( msg.message == WM_KEYDOWN && + pWnd->state & WNDS_MSGBOX && // Yes! GetForegroundWindow() == hwnd ) { if( msg.wParam == L'C' && GetKeyState(VK_CONTROL) < 0 )
Modified: trunk/reactos/win32ss/user/user32/windows/messagebox.c URL: http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/user32/windows... ============================================================================== --- trunk/reactos/win32ss/user/user32/windows/messagebox.c [iso-8859-1] (original) +++ trunk/reactos/win32ss/user/user32/windows/messagebox.c [iso-8859-1] Sat May 5 02:49:17 2012 @@ -63,11 +63,10 @@ #define MSGBOXEX_MAXBTNS (4)
typedef struct _MSGBOXINFO { + MSGBOXPARAMSW; // Wine passes this too. + // ReactOS HICON Icon; HFONT Font; - DWORD ContextHelpId; - MSGBOXCALLBACK Callback; - DWORD Style; int DefBtn; int nButtons; LONG *Btns; @@ -187,7 +186,7 @@ static INT_PTR CALLBACK MessageBoxProc( HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam ) { - int i; + int i, Alert; PMSGBOXINFO mbi; HELPINFO hi; HWND owner; @@ -195,12 +194,42 @@ switch(message) { case WM_INITDIALOG: mbi = (PMSGBOXINFO)lParam; + + SetWindowLongPtrW(hwnd, GWLP_USERDATA, (LONG_PTR)mbi); + NtUserxSetMessageBox(hwnd); + if(!GetPropW(hwnd, L"ROS_MSGBOX")) { SetPropW(hwnd, L"ROS_MSGBOX", (HANDLE)lParam); - if(mbi->Icon) + + if (mbi->dwContextHelpId) + SetWindowContextHelpId(hwnd, mbi->dwContextHelpId); + + if (mbi->Icon) + { SendDlgItemMessageW(hwnd, MSGBOX_IDICON, STM_SETICON, (WPARAM)mbi->Icon, 0); - SetWindowContextHelpId(hwnd, mbi->ContextHelpId); + Alert = ALERT_SYSTEM_WARNING; + } + else // Setup the rest of the alerts. + { + switch(mbi->dwStyle & MB_ICONMASK) + { + case MB_ICONWARNING: + Alert = ALERT_SYSTEM_WARNING; + break; + case MB_ICONERROR: + Alert = ALERT_SYSTEM_ERROR; + break; + case MB_ICONQUESTION: + Alert = ALERT_SYSTEM_QUERY; + break; + default: + Alert = ALERT_SYSTEM_INFORMATIONAL; + /* fall through */ + } + } + /* Send out the alert notifications. */ + NotifyWinEvent(EVENT_SYSTEM_ALERT, hwnd, OBJID_ALERT, Alert);
/* set control fonts */ SendDlgItemMessageW(hwnd, MSGBOX_IDTEXT, WM_SETFONT, (WPARAM)mbi->Font, 0); @@ -208,7 +237,7 @@ { SendDlgItemMessageW(hwnd, mbi->Btns[i], WM_SETFONT, (WPARAM)mbi->Font, 0); } - switch(mbi->Style & MB_TYPEMASK) + switch(mbi->dwStyle & MB_TYPEMASK) { case MB_ABORTRETRYIGNORE: case MB_YESNO: @@ -259,8 +288,8 @@ memcpy(&hi, (void *)lParam, sizeof(hi)); hi.dwContextId = GetWindowContextHelpId(hwnd);
- if (mbi->Callback) - mbi->Callback(&hi); + if (mbi->lpfnMsgBoxCallback) + mbi->lpfnMsgBoxCallback(&hi); else { owner = GetWindow(hwnd, GW_OWNER); @@ -273,7 +302,7 @@ mbi = (PMSGBOXINFO)GetPropW(hwnd, L"ROS_MSGBOX"); if(!mbi) return 0; - switch(mbi->Style & MB_TYPEMASK) + switch(mbi->dwStyle & MB_TYPEMASK) { case MB_ABORTRETRYIGNORE: case MB_YESNO: @@ -703,12 +732,21 @@ /* finally show the messagebox */ mbi.Icon = Icon; mbi.Font = hFont; - mbi.ContextHelpId = lpMsgBoxParams->dwContextHelpId; - mbi.Callback = lpMsgBoxParams->lpfnMsgBoxCallback; - mbi.Style = lpMsgBoxParams->dwStyle; + mbi.dwContextHelpId = lpMsgBoxParams->dwContextHelpId; + mbi.lpfnMsgBoxCallback = lpMsgBoxParams->lpfnMsgBoxCallback; + mbi.dwStyle = lpMsgBoxParams->dwStyle; mbi.nButtons = nButtons; mbi.Btns = &Buttons[0]; mbi.Timeout = Timeout; + + /* Pass on to Justin Case so he can peek the message? */ + mbi.cbSize = lpMsgBoxParams->cbSize; + mbi.hwndOwner = lpMsgBoxParams->hwndOwner; + mbi.hInstance = lpMsgBoxParams->hInstance; + mbi.lpszText = lpMsgBoxParams->lpszText; + mbi.lpszCaption = lpMsgBoxParams->lpszCaption; + mbi.lpszIcon = lpMsgBoxParams->lpszIcon; + mbi.dwLanguageId = lpMsgBoxParams->dwLanguageId;
if(hDC) DeleteDC(hDC);