diff --git a/reactos/iface/addsys/w32ksvc.db b/reactos/iface/addsys/w32ksvc.db index f3af58da276..6fdb1c8bafd 100644 --- a/reactos/iface/addsys/w32ksvc.db +++ b/reactos/iface/addsys/w32ksvc.db @@ -470,7 +470,7 @@ NtUserSBGetParms 4 NtUserScrollDC 7 NtUserScrollWindowEx 8 NtUserSendInput 3 -NtUserSendMessage 4 +NtUserSendMessage 5 NtUserSendMessageCallback 6 NtUserSendNotifyMessage 4 NtUserSetActiveWindow 1 diff --git a/reactos/include/win32k/ntuser.h b/reactos/include/win32k/ntuser.h index bd30b8e3109..c9d1bf3d953 100644 --- a/reactos/include/win32k/ntuser.h +++ b/reactos/include/win32k/ntuser.h @@ -1259,11 +1259,19 @@ NtUserSendInput( DWORD Unknown1, DWORD Unknown2); +typedef struct tagNTUSERSENDMESSAGEINFO +{ + BOOL HandledByKernel; + BOOL Ansi; + WNDPROC Proc; +} NTUSERSENDMESSAGEINFO, *PNTUSERSENDMESSAGEINFO; + LRESULT STDCALL NtUserSendMessage(HWND hWnd, UINT Msg, WPARAM wParam, - LPARAM lParam); + LPARAM lParam, + PNTUSERSENDMESSAGEINFO Info); BOOL STDCALL diff --git a/reactos/lib/user32/controls/scrollbar.c b/reactos/lib/user32/controls/scrollbar.c index f72c42620e8..724acd5da26 100644 --- a/reactos/lib/user32/controls/scrollbar.c +++ b/reactos/lib/user32/controls/scrollbar.c @@ -1,4 +1,4 @@ -/* $Id: scrollbar.c,v 1.20 2003/11/24 16:15:00 gvg Exp $ +/* $Id: scrollbar.c,v 1.21 2003/12/14 11:36:42 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -142,7 +142,7 @@ arrowSize, PSCROLLBARINFO psbi) */ if ( nBar == SB_CTL ) { - hBrush = (HBRUSH) NtUserSendMessage (GetParent (hwnd), WM_CTLCOLORSCROLLBAR, (WPARAM) hdc, (LPARAM) hwnd); + hBrush = (HBRUSH) SendMessageW(GetParent (hwnd), WM_CTLCOLORSCROLLBAR, (WPARAM) hdc, (LPARAM) hwnd); if(!hBrush) hBrush = GetSysColorBrush(COLOR_SCROLLBAR); } diff --git a/reactos/lib/user32/windows/message.c b/reactos/lib/user32/windows/message.c index 07e462d5c59..78ba9be5b9d 100644 --- a/reactos/lib/user32/windows/message.c +++ b/reactos/lib/user32/windows/message.c @@ -1,4 +1,4 @@ -/* $Id: message.c,v 1.28 2003/11/19 13:19:39 weiden Exp $ +/* $Id: message.c,v 1.29 2003/12/14 11:36:42 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS user32.dll @@ -194,31 +194,14 @@ MsgiAnsiToUnicodeMessage(LPMSG UnicodeMsg, LPMSG AnsiMsg) BOOL -MsgiAnsiToUnicodeReply(LPMSG UnicodeMsg, LPMSG AnsiMsg, LRESULT *Result) +MsgiAnsiToUnicodeCleanup(LPMSG UnicodeMsg, LPMSG AnsiMsg) { switch (AnsiMsg->message) { case WM_GETTEXT: case WM_ASKCBFORMATNAME: { - LPWSTR Buffer = (LPWSTR)UnicodeMsg->lParam; - LPSTR AnsiBuffer = (LPSTR)AnsiMsg->lParam; - if (UnicodeMsg->wParam > 0 && - !WideCharToMultiByte(CP_ACP, 0, Buffer, -1, - AnsiBuffer, UnicodeMsg->wParam, NULL, NULL)) - { - AnsiBuffer[UnicodeMsg->wParam - 1] = 0; - } - HeapFree(GetProcessHeap(), 0, Buffer); - break; - } - - case WM_GETTEXTLENGTH: - case CB_GETLBTEXTLEN: - case LB_GETTEXTLEN: - { - /* FIXME: There may be one DBCS char for each Unicode char */ - *Result *= 2; + HeapFree(GetProcessHeap(), 0, (PVOID) UnicodeMsg->lParam); break; } @@ -283,6 +266,41 @@ MsgiAnsiToUnicodeReply(LPMSG UnicodeMsg, LPMSG AnsiMsg, LRESULT *Result) } +BOOL +MsgiAnsiToUnicodeReply(LPMSG UnicodeMsg, LPMSG AnsiMsg, LRESULT *Result) +{ + switch (AnsiMsg->message) + { + case WM_GETTEXT: + case WM_ASKCBFORMATNAME: + { + LPWSTR Buffer = (LPWSTR)UnicodeMsg->lParam; + LPSTR AnsiBuffer = (LPSTR)AnsiMsg->lParam; + if (UnicodeMsg->wParam > 0 && + !WideCharToMultiByte(CP_ACP, 0, Buffer, -1, + AnsiBuffer, UnicodeMsg->wParam, NULL, NULL)) + { + AnsiBuffer[UnicodeMsg->wParam - 1] = 0; + } + break; + } + + case WM_GETTEXTLENGTH: + case CB_GETLBTEXTLEN: + case LB_GETTEXTLEN: + { + /* FIXME: There may be one DBCS char for each Unicode char */ + *Result *= 2; + break; + } + } + + MsgiAnsiToUnicodeCleanup(UnicodeMsg, AnsiMsg); + + return TRUE; +} + + VOID STATIC User32ConvertToAsciiMessage(UINT* Msg, WPARAM* wParam, LPARAM* lParam) { @@ -383,6 +401,65 @@ User32FreeAsciiConvertedMessage(UINT Msg, WPARAM wParam, LPARAM lParam) } } +STATIC LRESULT FASTCALL +IntCallWindowProcW(BOOL IsAnsiProc, + WNDPROC WndProc, + HWND hWnd, + UINT Msg, + WPARAM wParam, + LPARAM lParam) +{ + LRESULT Result; + + if (IsAnsiProc) + { + User32ConvertToAsciiMessage(&Msg, &wParam, &lParam); + Result = WndProc(hWnd, Msg, wParam, lParam); + User32FreeAsciiConvertedMessage(Msg, wParam, lParam); + return Result; + } + else + { + return WndProc(hWnd, Msg, wParam, lParam); + } +} + +STATIC LRESULT FASTCALL +IntCallWindowProcA(BOOL IsAnsiProc, + WNDPROC WndProc, + HWND hWnd, + UINT Msg, + WPARAM wParam, + LPARAM lParam) +{ + MSG AnsiMsg; + MSG UnicodeMsg; + LRESULT Result; + + if (IsAnsiProc) + { + return WndProc(hWnd, Msg, wParam, lParam); + } + else + { + AnsiMsg.hwnd = hWnd; + AnsiMsg.message = Msg; + AnsiMsg.wParam = wParam; + AnsiMsg.lParam = lParam; + if (! MsgiAnsiToUnicodeMessage(&UnicodeMsg, &AnsiMsg)) + { + return FALSE; + } + Result = WndProc(UnicodeMsg.hwnd, UnicodeMsg.message, + UnicodeMsg.wParam, UnicodeMsg.lParam); + if (! MsgiAnsiToUnicodeReply(&UnicodeMsg, &AnsiMsg, &Result)) + { + return FALSE; + } + return Result; + } +} + /* * @implemented @@ -394,39 +471,18 @@ CallWindowProcA(WNDPROC lpPrevWndFunc, WPARAM wParam, LPARAM lParam) { - MSG AnsiMsg; - MSG UnicodeMsg; - LRESULT Result; BOOL IsHandle; WndProcHandle wphData; IsHandle = NtUserDereferenceWndProcHandle(lpPrevWndFunc,&wphData); - AnsiMsg.hwnd = hWnd; - AnsiMsg.message = Msg; - AnsiMsg.wParam = wParam; - AnsiMsg.lParam = lParam; - if (!IsHandle) - { - return(lpPrevWndFunc(hWnd, Msg, wParam, lParam)); - } else { - if (wphData.IsUnicode) + if (! IsHandle) { - if (!MsgiAnsiToUnicodeMessage(&UnicodeMsg, &AnsiMsg)) - { - return(FALSE); - } - Result = wphData.WindowProc(UnicodeMsg.hwnd, UnicodeMsg.message, - UnicodeMsg.wParam, UnicodeMsg.lParam); - if (!MsgiAnsiToUnicodeReply(&UnicodeMsg, &AnsiMsg, &Result)) - { - return(FALSE); - } - return(Result); + return IntCallWindowProcA(TRUE, lpPrevWndFunc, hWnd, Msg, wParam, lParam); } else { - return(wphData.WindowProc(hWnd, Msg, wParam, lParam)); - } + return IntCallWindowProcA(! wphData.IsUnicode, wphData.WindowProc, + hWnd, Msg, wParam, lParam); } } @@ -445,22 +501,14 @@ CallWindowProcW(WNDPROC lpPrevWndFunc, WndProcHandle wphData; IsHandle = NtUserDereferenceWndProcHandle(lpPrevWndFunc,&wphData); - if (!IsHandle) - { - return(lpPrevWndFunc(hWnd, Msg, wParam, lParam)); - } else { - if (!wphData.IsUnicode) + if (! IsHandle) { - LRESULT Result; - User32ConvertToAsciiMessage(&Msg, &wParam, &lParam); - Result = wphData.WindowProc(hWnd, Msg, wParam, lParam); - User32FreeAsciiConvertedMessage(Msg, wParam, lParam); - return(Result); + return IntCallWindowProcW(FALSE, lpPrevWndFunc, hWnd, Msg, wParam, lParam); } else { - return(wphData.WindowProc(hWnd, Msg, wParam, lParam)); - } + return IntCallWindowProcW(! wphData.IsUnicode, wphData.WindowProc, + hWnd, Msg, wParam, lParam); } } @@ -649,12 +697,22 @@ PostThreadMessageW( * @implemented */ LRESULT STDCALL -SendMessageW(HWND hWnd, +SendMessageW(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam) { - return(NtUserSendMessage(hWnd, Msg, wParam, lParam)); + NTUSERSENDMESSAGEINFO Info; + LRESULT Result; + + Result = NtUserSendMessage(Wnd, Msg, wParam, lParam, &Info); + if (! Info.HandledByKernel) + { + /* We need to send the message ourselves */ + Result = IntCallWindowProcW(Info.Ansi, Info.Proc, Wnd, Msg, wParam, lParam); + } + + return Result; } @@ -662,27 +720,49 @@ SendMessageW(HWND hWnd, * @implemented */ LRESULT STDCALL -SendMessageA(HWND hWnd, UINT Msg, WPARAM wParam, LPARAM lParam) +SendMessageA(HWND Wnd, UINT Msg, WPARAM wParam, LPARAM lParam) { MSG AnsiMsg; MSG UcMsg; LRESULT Result; + NTUSERSENDMESSAGEINFO Info; - AnsiMsg.hwnd = hWnd; + AnsiMsg.hwnd = Wnd; AnsiMsg.message = Msg; AnsiMsg.wParam = wParam; AnsiMsg.lParam = lParam; + if (! MsgiAnsiToUnicodeMessage(&UcMsg, &AnsiMsg)) + { + return FALSE; + } - if (!MsgiAnsiToUnicodeMessage(&UcMsg, &AnsiMsg)) + Result = NtUserSendMessage(UcMsg.hwnd, UcMsg.message, + UcMsg.wParam, UcMsg.lParam, &Info); + if (! Info.HandledByKernel) { - return(FALSE); + /* We need to send the message ourselves */ + if (Info.Ansi) + { + /* Ansi message and Ansi window proc, that's easy. Clean up + the Unicode message though */ + MsgiAnsiToUnicodeCleanup(&UcMsg, &AnsiMsg); + Result = IntCallWindowProcA(Info.Ansi, Info.Proc, Wnd, Msg, wParam, lParam); + } + else + { + /* Unicode winproc. Although we started out with an Ansi message we + already converted it to Unicode for the kernel call. Reuse that + message to avoid another conversion */ + Result = IntCallWindowProcW(Info.Ansi, Info.Proc, UcMsg.hwnd, + UcMsg.message, UcMsg.wParam, UcMsg.lParam); + if (! MsgiAnsiToUnicodeReply(&UcMsg, &AnsiMsg, &Result)) + { + return FALSE; + } + } } - Result = SendMessageW(UcMsg.hwnd, UcMsg.message, UcMsg.wParam, UcMsg.lParam); - if (!MsgiAnsiToUnicodeReply(&UcMsg, &AnsiMsg, &Result)) - { - return(FALSE); - } - return(Result); + + return Result; } diff --git a/reactos/subsys/win32k/ntuser/accelerator.c b/reactos/subsys/win32k/ntuser/accelerator.c index 3007a388633..35c16f676bb 100644 --- a/reactos/subsys/win32k/ntuser/accelerator.c +++ b/reactos/subsys/win32k/ntuser/accelerator.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: accelerator.c,v 1.4 2003/12/07 17:22:13 weiden Exp $ +/* $Id: accelerator.c,v 1.5 2003/12/14 11:36:42 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -145,7 +145,7 @@ NtUserCreateAcceleratorTable( NTSTATUS Status; HACCEL Handle; - DbgPrint("NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d)\n", + DPRINT("NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d)\n", Entries, EntriesCount); Status = IntValidateWindowStationHandle(NtUserGetProcessWindowStation(), @@ -155,7 +155,7 @@ NtUserCreateAcceleratorTable( if (!NT_SUCCESS(Status)) { SetLastNtError(STATUS_ACCESS_DENIED); - DbgPrint("E1\n"); + DPRINT1("E1\n"); return FALSE; } @@ -168,7 +168,7 @@ NtUserCreateAcceleratorTable( { ObDereferenceObject(WindowStation); SetLastNtError(STATUS_NO_MEMORY); - DbgPrint("E2\n"); + DPRINT1("E2\n"); return (HACCEL) 0; } @@ -181,7 +181,7 @@ NtUserCreateAcceleratorTable( ObmCloseHandle(WindowStation->HandleTable, Handle); ObDereferenceObject(WindowStation); SetLastNtError(Status); - DbgPrint("E3\n"); + DPRINT1("E3\n"); return (HACCEL) 0; } @@ -192,7 +192,7 @@ NtUserCreateAcceleratorTable( ObmCloseHandle(WindowStation->HandleTable, Handle); ObDereferenceObject(WindowStation); SetLastNtError(Status); - DbgPrint("E4\n"); + DPRINT1("E4\n"); return (HACCEL) 0; } } @@ -201,7 +201,7 @@ NtUserCreateAcceleratorTable( /* FIXME: Save HandleTable in a list somewhere so we can clean it up again */ - DbgPrint("NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d) = %x end\n", + DPRINT("NtUserCreateAcceleratorTable(Entries %p, EntriesCount %d) = %x end\n", Entries, EntriesCount, Handle); return (HACCEL) Handle; @@ -221,7 +221,7 @@ NtUserDestroyAcceleratorTable( FIXME: Destroy only tables created using CreateAcceleratorTable. */ - DbgPrint("NtUserDestroyAcceleratorTable(Table %x)\n", + DPRINT("NtUserDestroyAcceleratorTable(Table %x)\n", Table); Status = IntValidateWindowStationHandle(NtUserGetProcessWindowStation(), @@ -231,7 +231,7 @@ NtUserDestroyAcceleratorTable( if (!NT_SUCCESS(Status)) { SetLastNtError(STATUS_ACCESS_DENIED); - DbgPrint("E1\n"); + DPRINT1("E1\n"); return FALSE; } @@ -243,7 +243,7 @@ NtUserDestroyAcceleratorTable( { SetLastWin32Error(ERROR_INVALID_ACCEL_HANDLE); ObDereferenceObject(WindowStation); - DbgPrint("E2\n"); + DPRINT1("E2\n"); return FALSE; } @@ -256,7 +256,7 @@ NtUserDestroyAcceleratorTable( ObDereferenceObject(WindowStation); - DbgPrint("NtUserDestroyAcceleratorTable(Table %x)\n", + DPRINT("NtUserDestroyAcceleratorTable(Table %x)\n", Table); return TRUE; @@ -273,12 +273,12 @@ IntTranslateAccelerator(HWND hWnd, { UINT mesg = 0; - DbgPrint("IntTranslateAccelerator(hWnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x)\n", + DPRINT("IntTranslateAccelerator(hWnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x)\n", hWnd, message, wParam, lParam, fVirt, key, cmd); if (wParam != key) { - DbgPrint("T0\n"); + DPRINT1("T0\n"); return FALSE; } @@ -286,7 +286,7 @@ IntTranslateAccelerator(HWND hWnd, { if (!(fVirt & FALT) && !(fVirt & FVIRTKEY)) { - DbgPrint("found accel for WM_CHAR: ('%c')\n", wParam & 0xff); + DPRINT("found accel for WM_CHAR: ('%c')\n", wParam & 0xff); goto found; } } @@ -295,21 +295,21 @@ IntTranslateAccelerator(HWND hWnd, if ((fVirt & FVIRTKEY) > 0) { INT mask = 0; - DbgPrint("found accel for virt_key %04x (scan %04x)\n", + DPRINT("found accel for virt_key %04x (scan %04x)\n", wParam, 0xff & HIWORD(lParam)); - DbgPrint("NtUserGetKeyState(VK_SHIFT) = 0x%x\n", + DPRINT("NtUserGetKeyState(VK_SHIFT) = 0x%x\n", NtUserGetKeyState(VK_SHIFT)); - DbgPrint("NtUserGetKeyState(VK_CONTROL) = 0x%x\n", + DPRINT("NtUserGetKeyState(VK_CONTROL) = 0x%x\n", NtUserGetKeyState(VK_CONTROL)); - DbgPrint("NtUserGetKeyState(VK_MENU) = 0x%x\n", + DPRINT("NtUserGetKeyState(VK_MENU) = 0x%x\n", NtUserGetKeyState(VK_MENU)); if (NtUserGetKeyState(VK_SHIFT) & 0x8000) mask |= FSHIFT; if (NtUserGetKeyState(VK_CONTROL) & 0x8000) mask |= FCONTROL; if (NtUserGetKeyState(VK_MENU) & 0x8000) mask |= FALT; if (mask == (fVirt & (FSHIFT | FCONTROL | FALT))) goto found; - DbgPrint(", but incorrect SHIFT/CTRL/ALT-state\n"); + DPRINT("but incorrect SHIFT/CTRL/ALT-state\n"); } else { @@ -317,14 +317,14 @@ IntTranslateAccelerator(HWND hWnd, { if ((fVirt & FALT) && (lParam & 0x20000000)) { /* ^^ ALT pressed */ - DbgPrint("found accel for Alt-%c\n", wParam & 0xff); + DPRINT("found accel for Alt-%c\n", wParam & 0xff); goto found; } } } } - DbgPrint("IntTranslateAccelerator(hWnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x) = FALSE\n", + DPRINT("IntTranslateAccelerator(hWnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x) = FALSE\n", hWnd, message, wParam, lParam, fVirt, key, cmd); return FALSE; @@ -351,12 +351,12 @@ IntTranslateAccelerator(HWND hWnd, nPos = cmd; if(MENU_FindItem(&hSubMenu, &nPos, MF_BYCOMMAND)) { - NtUserSendMessage(hWnd, WM_INITMENU, (WPARAM)hSysMenu, 0L); + IntSendMessage(hWnd, WM_INITMENU, (WPARAM)hSysMenu, 0L, TRUE); if(hSubMenu != hSysMenu) { nPos = MENU_FindSubMenu(&hSysMenu, hSubMenu); TRACE_(accel)("hSysMenu = %p, hSubMenu = %p, nPos = %d\n", hSysMenu, hSubMenu, nPos); - NtUserSendMessage(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, TRUE)); + IntSendMessage(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, TRUE), TRUE); } uSysStat = GetMenuState(GetSubMenu(hSysMenu, 0), cmd, MF_BYCOMMAND); } @@ -366,12 +366,12 @@ IntTranslateAccelerator(HWND hWnd, nPos = cmd; if(MENU_FindItem(&hSubMenu, &nPos, MF_BYCOMMAND)) { - NtUserSendMessage(hWnd, WM_INITMENU, (WPARAM)hMenu, 0L); + IntSendMessage(hWnd, WM_INITMENU, (WPARAM)hMenu, 0L, TRUE); if(hSubMenu != hMenu) { nPos = MENU_FindSubMenu(&hMenu, hSubMenu); TRACE_(accel)("hMenu = %p, hSubMenu = %p, nPos = %d\n", hMenu, hSubMenu, nPos); - NtUserSendMessage(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, FALSE)); + IntSendMessage(hWnd, WM_INITMENUPOPUP, (WPARAM)hSubMenu, MAKELPARAM(nPos, FALSE), TRUE); } uStat = GetMenuState(hMenu, cmd, MF_BYCOMMAND); } @@ -411,13 +411,13 @@ IntTranslateAccelerator(HWND hWnd, if (mesg == WM_COMMAND) { - DbgPrint(", sending WM_COMMAND, wParam=%0x\n", 0x10000 | cmd); - NtUserSendMessage(hWnd, mesg, 0x10000 | cmd, 0L); + DPRINT(", sending WM_COMMAND, wParam=%0x\n", 0x10000 | cmd); + IntSendMessage(hWnd, mesg, 0x10000 | cmd, 0L, TRUE); } else if (mesg == WM_SYSCOMMAND) { - DbgPrint(", sending WM_SYSCOMMAND, wParam=%0x\n", cmd); - NtUserSendMessage(hWnd, mesg, cmd, 0x00010000L); + DPRINT(", sending WM_SYSCOMMAND, wParam=%0x\n", cmd); + IntSendMessage(hWnd, mesg, cmd, 0x00010000L, TRUE); } else { @@ -430,14 +430,14 @@ IntTranslateAccelerator(HWND hWnd, * #5: it's a menu option, but window is iconic * #6: it's a menu option, but disabled */ - DbgPrint(", but won't send WM_{SYS}COMMAND, reason is #%d\n", mesg); + DPRINT(", but won't send WM_{SYS}COMMAND, reason is #%d\n", mesg); if (mesg == 0) { - DbgPrint(" unknown reason - please report!"); + DPRINT1(" unknown reason - please report!"); } } - DbgPrint("IntTranslateAccelerator(hWnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x) = TRUE\n", + DPRINT("IntTranslateAccelerator(hWnd %x, message %x, wParam %x, lParam %x, fVirt %d, key %x, cmd %x) = TRUE\n", hWnd, message, wParam, lParam, fVirt, key, cmd); return TRUE; @@ -455,20 +455,20 @@ NtUserTranslateAccelerator( NTSTATUS Status; ULONG i; - DbgPrint("NtUserTranslateAccelerator(Window %x, Table %x, Message %p)\n", + DPRINT("NtUserTranslateAccelerator(Window %x, Table %x, Message %p)\n", Window, Table, Message); if (Message == NULL) { SetLastNtError(STATUS_INVALID_PARAMETER); - DbgPrint("E0a\n"); + DPRINT1("E0a\n"); return 0; } if (Table == NULL) { SetLastWin32Error(ERROR_INVALID_ACCEL_HANDLE); - DbgPrint("E0b\n"); + DPRINT1("E0b\n"); return 0; } @@ -478,7 +478,7 @@ NtUserTranslateAccelerator( (Message->message != WM_SYSKEYUP) && (Message->message != WM_CHAR)) { - DbgPrint("E0c\n"); + DPRINT1("E0c\n"); return 0; } @@ -489,7 +489,7 @@ NtUserTranslateAccelerator( if (!NT_SUCCESS(Status)) { SetLastNtError(STATUS_ACCESS_DENIED); - DbgPrint("E1\n"); + DPRINT1("E1\n"); return 0; } @@ -501,7 +501,7 @@ NtUserTranslateAccelerator( { SetLastWin32Error(ERROR_INVALID_ACCEL_HANDLE); ObDereferenceObject(WindowStation); - DbgPrint("E2\n"); + DPRINT1("E2\n"); return 0; } @@ -516,7 +516,7 @@ NtUserTranslateAccelerator( AcceleratorTable->Table[i].cmd)) { ObDereferenceObject(WindowStation); - DbgPrint("NtUserTranslateAccelerator(Window %x, Table %x, Message %p) = %i end\n", + DPRINT1("NtUserTranslateAccelerator(Window %x, Table %x, Message %p) = %i end\n", Window, Table, Message, 1); return 1; } @@ -529,7 +529,7 @@ NtUserTranslateAccelerator( ObDereferenceObject(WindowStation); - DbgPrint("NtUserTranslateAccelerator(Window %x, Table %x, Message %p) = %i end\n", + DPRINT1("NtUserTranslateAccelerator(Window %x, Table %x, Message %p) = %i end\n", Window, Table, Message, 0); return 0; diff --git a/reactos/subsys/win32k/ntuser/focus.c b/reactos/subsys/win32k/ntuser/focus.c index aecb32d5d31..6003649f7ab 100644 --- a/reactos/subsys/win32k/ntuser/focus.c +++ b/reactos/subsys/win32k/ntuser/focus.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: focus.c,v 1.4 2003/12/07 19:29:33 weiden Exp $ + * $Id: focus.c,v 1.5 2003/12/14 11:36:42 gvg Exp $ */ #include @@ -56,10 +56,10 @@ IntSendDeactivateMessages(HWND hWndPrev, HWND hWnd) { if (hWndPrev) { - NtUserSendMessage(hWndPrev, WM_NCACTIVATE, FALSE, 0); - NtUserSendMessage(hWndPrev, WM_ACTIVATE, + IntSendMessage(hWndPrev, WM_NCACTIVATE, FALSE, 0, TRUE); + IntSendMessage(hWndPrev, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, NtUserGetWindowLong(hWndPrev, GWL_STYLE, FALSE) & WS_MINIMIZE), - (LPARAM)NULL); + (LPARAM)NULL, TRUE); } } @@ -69,10 +69,10 @@ IntSendActivateMessages(HWND hWndPrev, HWND hWnd) if (hWnd) { /* Send palette messages */ - if (NtUserSendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0)) + if (IntSendMessage(hWnd, WM_QUERYNEWPALETTE, 0, 0, TRUE)) { - NtUserSendMessage(HWND_BROADCAST, WM_PALETTEISCHANGING, - (WPARAM)hWnd, 0); + IntSendMessage(HWND_BROADCAST, WM_PALETTEISCHANGING, + (WPARAM)hWnd, 0, TRUE); } WinPosSetWindowPos(hWnd, HWND_TOP, 0, 0, 0, 0, @@ -80,11 +80,11 @@ IntSendActivateMessages(HWND hWndPrev, HWND hWnd) /* FIXME: IntIsWindow */ - NtUserSendMessage(hWnd, WM_NCACTIVATE, (WPARAM)(hWnd == NtUserGetForegroundWindow()), 0); + IntSendMessage(hWnd, WM_NCACTIVATE, (WPARAM)(hWnd == NtUserGetForegroundWindow()), 0, TRUE); /* FIXME: WA_CLICKACTIVE */ - NtUserSendMessage(hWnd, WM_ACTIVATE, + IntSendMessage(hWnd, WM_ACTIVATE, MAKEWPARAM(WA_INACTIVE, NtUserGetWindowLong(hWnd, GWL_STYLE, FALSE) & WS_MINIMIZE), - (LPARAM)hWndPrev); + (LPARAM)hWndPrev, TRUE); } } @@ -93,7 +93,7 @@ IntSendKillFocusMessages(HWND hWndPrev, HWND hWnd) { if (hWndPrev) { - NtUserSendMessage(hWndPrev, WM_KILLFOCUS, (WPARAM)hWnd, 0); + IntSendMessage(hWndPrev, WM_KILLFOCUS, (WPARAM)hWnd, 0, TRUE); } } @@ -102,7 +102,7 @@ IntSendSetFocusMessages(HWND hWndPrev, HWND hWnd) { if (hWnd) { - NtUserSendMessage(hWnd, WM_SETFOCUS, (WPARAM)hWndPrev, 0); + IntSendMessage(hWnd, WM_SETFOCUS, (WPARAM)hWndPrev, 0, TRUE); } } @@ -326,7 +326,7 @@ NtUserSetCapture(HWND hWnd) } } hWndPrev = ThreadQueue->CaptureWindow; - NtUserSendMessage(hWndPrev, WM_CAPTURECHANGED, 0, (LPARAM)hWnd); + IntSendMessage(hWndPrev, WM_CAPTURECHANGED, 0, (LPARAM)hWnd, TRUE); /* ExAcquireFastMutex(&ThreadQueue->Lock);*/ ThreadQueue->CaptureWindow = hWnd; /* ExReleaseFastMutex(&ThreadQueue->Lock);*/ diff --git a/reactos/subsys/win32k/ntuser/message.c b/reactos/subsys/win32k/ntuser/message.c index dd0a6938530..44ff3f5cc4a 100644 --- a/reactos/subsys/win32k/ntuser/message.c +++ b/reactos/subsys/win32k/ntuser/message.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: message.c,v 1.36 2003/11/24 00:22:53 arty Exp $ +/* $Id: message.c,v 1.37 2003/12/14 11:36:43 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -516,9 +516,70 @@ LRESULT STDCALL NtUserSendMessage(HWND Wnd, UINT Msg, WPARAM wParam, - LPARAM lParam) + LPARAM lParam, + PNTUSERSENDMESSAGEINFO UnsafeInfo) { - return IntSendMessage(Wnd, Msg, wParam, lParam, FALSE); + LRESULT Result; + NTSTATUS Status; + PWINDOW_OBJECT Window; + NTUSERSENDMESSAGEINFO Info; + + /* FIXME: Check for a broadcast or topmost destination. */ + + /* FIXME: Call hooks. */ + Window = IntGetWindowObject(Wnd); + if (NULL == Window) + { + SetLastWin32Error(ERROR_INVALID_WINDOW_HANDLE); + return 0; + } + + /* FIXME: Check for an exiting window. */ + + /* See if the current thread can handle the message */ + if (NULL != PsGetWin32Thread() && + Window->MessageQueue == PsGetWin32Thread()->MessageQueue) + { + /* Gather the information usermode needs to call the window proc directly */ + Info.HandledByKernel = FALSE; + if (0xFFFF0000 != ((DWORD) Window->WndProcW & 0xFFFF0000)) + { + if (0xFFFF0000 != ((DWORD) Window->WndProcA & 0xFFFF0000)) + { + /* Both Unicode and Ansi winprocs are real */ + Info.Ansi = ! Window->Unicode; + Info.Proc = (Window->Unicode ? Window->WndProcW : Window->WndProcA); + } + else + { + /* Real Unicode winproc */ + Info.Ansi = FALSE; + Info.Proc = Window->WndProcW; + } + } + else + { + /* Must have real Ansi winproc */ + Info.Ansi = TRUE; + Info.Proc = Window->WndProcA; + } + IntReleaseWindowObject(Window); + } + else + { + /* Must be handled by other thread */ + IntReleaseWindowObject(Window); + Info.HandledByKernel = TRUE; + Result = IntSendMessage(Wnd, Msg, wParam, lParam, FALSE); + } + + Status = MmCopyToCaller(UnsafeInfo, &Info, sizeof(NTUSERSENDMESSAGEINFO)); + if (! NT_SUCCESS(Status)) + { + SetLastWin32Error(ERROR_INVALID_PARAMETER); + } + + return Result; } BOOL STDCALL diff --git a/reactos/subsys/win32k/ntuser/msgqueue.c b/reactos/subsys/win32k/ntuser/msgqueue.c index 2cf5a30283c..b48602f32d6 100644 --- a/reactos/subsys/win32k/ntuser/msgqueue.c +++ b/reactos/subsys/win32k/ntuser/msgqueue.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: msgqueue.c,v 1.43 2003/12/14 00:45:39 weiden Exp $ +/* $Id: msgqueue.c,v 1.44 2003/12/14 11:36:43 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -234,7 +234,7 @@ MsqTranslateMouseMessage(HWND hWnd, UINT FilterLow, UINT FilterHigh, if(Window) { - Result = NtUserSendMessage(Wnd, WM_MOUSEACTIVATE, (WPARAM)NtUserGetParent(Window->Self), (LPARAM)SpareLParam); + Result = IntSendMessage(Wnd, WM_MOUSEACTIVATE, (WPARAM)NtUserGetParent(Window->Self), (LPARAM)SpareLParam, TRUE); switch (Result) { diff --git a/reactos/subsys/win32k/ntuser/painting.c b/reactos/subsys/win32k/ntuser/painting.c index 130e196539b..0748b01ab6d 100644 --- a/reactos/subsys/win32k/ntuser/painting.c +++ b/reactos/subsys/win32k/ntuser/painting.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * - * $Id: painting.c,v 1.46 2003/12/13 12:12:41 weiden Exp $ + * $Id: painting.c,v 1.47 2003/12/14 11:36:43 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -159,7 +159,7 @@ IntPaintWindows(PWINDOW_OBJECT Window, ULONG Flags) { if (Window->Flags & WINDOWOBJECT_NEED_NCPAINT) { - NtUserSendMessage(hWnd, WM_NCPAINT, (WPARAM)IntGetNCUpdateRegion(Window, TRUE), 0); + IntSendMessage(hWnd, WM_NCPAINT, (WPARAM)IntGetNCUpdateRegion(Window, TRUE), 0, TRUE); } if (Window->Flags & WINDOWOBJECT_NEED_ERASEBKGND) @@ -170,7 +170,7 @@ IntPaintWindows(PWINDOW_OBJECT Window, ULONG Flags) DCX_INTERSECTUPDATE); if (hDC != NULL) { - if (NtUserSendMessage(hWnd, WM_ERASEBKGND, (WPARAM)hDC, 0)) + if (IntSendMessage(hWnd, WM_ERASEBKGND, (WPARAM)hDC, 0, TRUE)) { Window->Flags &= ~WINDOWOBJECT_NEED_ERASEBKGND; } @@ -184,7 +184,7 @@ IntPaintWindows(PWINDOW_OBJECT Window, ULONG Flags) if (Window->UpdateRegion != NULL || Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT) { - NtUserSendMessage(hWnd, WM_PAINT, 0, 0); + IntSendMessage(hWnd, WM_PAINT, 0, 0, TRUE); if (Window->Flags & WINDOWOBJECT_NEED_INTERNALPAINT) { Window->Flags &= ~WINDOWOBJECT_NEED_INTERNALPAINT; @@ -775,7 +775,7 @@ NtUserBeginPaint(HWND hWnd, PAINTSTRUCT* lPs) if (Window->Flags & WINDOWOBJECT_NEED_ERASEBKGND) { Window->Flags &= ~WINDOWOBJECT_NEED_ERASEBKGND; - lPs->fErase = !NtUserSendMessage(hWnd, WM_ERASEBKGND, (WPARAM)lPs->hdc, 0); + lPs->fErase = !IntSendMessage(hWnd, WM_ERASEBKGND, (WPARAM)lPs->hdc, 0, TRUE); } else { diff --git a/reactos/subsys/win32k/ntuser/window.c b/reactos/subsys/win32k/ntuser/window.c index 1aa8e7300a8..01524426435 100644 --- a/reactos/subsys/win32k/ntuser/window.c +++ b/reactos/subsys/win32k/ntuser/window.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: window.c,v 1.159 2003/12/12 18:18:21 weiden Exp $ +/* $Id: window.c,v 1.160 2003/12/14 11:36:43 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -308,7 +308,7 @@ static LRESULT IntDestroyWindow(PWINDOW_OBJECT Window, /* * Send the WM_NCDESTROY to the window being destroyed. */ - NtUserSendMessage(Window->Self, WM_NCDESTROY, 0, 0); + IntSendMessage(Window->Self, WM_NCDESTROY, 0, 0, TRUE); } /* reset shell window handles */ @@ -746,7 +746,7 @@ static void IntSendDestroyMsg(HWND Wnd) /* * Send the WM_DESTROY to the window. */ - NtUserSendMessage(Wnd, WM_DESTROY, 0, 0); + IntSendMessage(Wnd, WM_DESTROY, 0, 0, TRUE); /* * This WM_DESTROY message can trigger re-entrant calls to DestroyWindow diff --git a/reactos/subsys/win32k/ntuser/winpos.c b/reactos/subsys/win32k/ntuser/winpos.c index 1cc69c2295e..d734d4d85a2 100644 --- a/reactos/subsys/win32k/ntuser/winpos.c +++ b/reactos/subsys/win32k/ntuser/winpos.c @@ -16,7 +16,7 @@ * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. */ -/* $Id: winpos.c,v 1.54 2003/12/13 18:42:52 gvg Exp $ +/* $Id: winpos.c,v 1.55 2003/12/14 11:36:43 gvg Exp $ * * COPYRIGHT: See COPYING in the top level directory * PROJECT: ReactOS kernel @@ -160,7 +160,7 @@ WinPosShowIconTitle(PWINDOW_OBJECT WindowObject, BOOL Show) { if (!(IconWindow->Style & WS_VISIBLE)) { - NtUserSendMessage(hWnd, WM_SHOWWINDOW, TRUE, 0); + IntSendMessage(hWnd, WM_SHOWWINDOW, TRUE, 0, TRUE); WinPosSetWindowPos(hWnd, 0, 0, 0, 0, 0, SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOZORDER | SWP_SHOWWINDOW); @@ -221,7 +221,7 @@ WinPosMinMaximize(PWINDOW_OBJECT WindowObject, UINT ShowFlag, RECT* NewPos) { if (WindowObject->Style & WS_MINIMIZE) { - if (!NtUserSendMessage(WindowObject->Self, WM_QUERYOPEN, 0, 0)) + if (!IntSendMessage(WindowObject->Self, WM_QUERYOPEN, 0, 0, TRUE)) { return(SWP_NOSIZE | SWP_NOMOVE); } @@ -383,11 +383,12 @@ WinPosChangeActiveWindow(HWND hWnd, BOOL MouseMsg) } #if 0 - NtUserSendMessage(hWnd, - WM_ACTIVATE, - MAKELONG(MouseMsg ? WA_CLICKACTIVE : WA_CLICKACTIVE, + IntSendMessage(hWnd, + WM_ACTIVATE, + MAKELONG(MouseMsg ? WA_CLICKACTIVE : WA_CLICKACTIVE, (WindowObject->Style & WS_MINIMIZE) ? 1 : 0), - (LPARAM)IntGetDesktopWindow()); /* FIXME: Previous active window */ + (LPARAM)IntGetDesktopWindow(), /* FIXME: Previous active window */ + TRUE); #endif IntSetForegroundWindow(WindowObject); @@ -975,7 +976,7 @@ WinPosSetWindowPos(HWND Wnd, HWND WndInsertAfter, INT x, INT y, INT cx, { if ((Window->Style & (WS_CHILD | WS_POPUP)) == WS_CHILD) { - NtUserSendMessage(WinPos.hwnd, WM_CHILDACTIVATE, 0, 0); + IntSendMessage(WinPos.hwnd, WM_CHILDACTIVATE, 0, 0, TRUE); } else { @@ -1098,7 +1099,7 @@ WinPosShowWindow(HWND Wnd, INT Cmd) ShowFlag = (Cmd != SW_HIDE); if (ShowFlag != WasVisible) { - NtUserSendMessage(Wnd, WM_SHOWWINDOW, ShowFlag, 0); + IntSendMessage(Wnd, WM_SHOWWINDOW, ShowFlag, 0, TRUE); /* * FIXME: Need to check the window wasn't destroyed during the * window procedure. @@ -1156,14 +1157,14 @@ WinPosShowWindow(HWND Wnd, INT Cmd) wParam = SIZE_MINIMIZED; } - NtUserSendMessage(Wnd, WM_SIZE, wParam, - MAKELONG(Window->ClientRect.right - - Window->ClientRect.left, - Window->ClientRect.bottom - - Window->ClientRect.top)); - NtUserSendMessage(Wnd, WM_MOVE, 0, - MAKELONG(Window->ClientRect.left, - Window->ClientRect.top)); + IntSendMessage(Wnd, WM_SIZE, wParam, + MAKELONG(Window->ClientRect.right - + Window->ClientRect.left, + Window->ClientRect.bottom - + Window->ClientRect.top), TRUE); + IntSendMessage(Wnd, WM_MOVE, 0, + MAKELONG(Window->ClientRect.left, + Window->ClientRect.top), TRUE); } /* Activate the window if activation is not requested and the window is not minimized */