Author: jimtabor
Date: Thu Oct 27 12:17:44 2011
New Revision: 54259
URL:
http://svn.reactos.org/svn/reactos?rev=54259&view=rev
Log:
[User32]
- Fix function ids, setting of the death bit when in NC destroy.
- Implement get control brush and color.
- Patch by Alexander LAW, Replicate Windows behavior of WM_SETTEXT handler regarding
WM_CTLCOLOR*
Modified:
trunk/reactos/dll/win32/user32/controls/button.c
trunk/reactos/dll/win32/user32/controls/combo.c
trunk/reactos/dll/win32/user32/controls/edit.c
trunk/reactos/dll/win32/user32/controls/icontitle.c
trunk/reactos/dll/win32/user32/controls/listbox.c
trunk/reactos/dll/win32/user32/controls/scrollbar.c
trunk/reactos/dll/win32/user32/controls/static.c
trunk/reactos/dll/win32/user32/include/user32p.h
trunk/reactos/dll/win32/user32/misc/misc.c
trunk/reactos/dll/win32/user32/windows/defwnd.c
trunk/reactos/dll/win32/user32/windows/mdi.c
trunk/reactos/dll/win32/user32/windows/menu.c
Modified: trunk/reactos/dll/win32/user32/controls/button.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/controls/…
==============================================================================
--- trunk/reactos/dll/win32/user32/controls/button.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/controls/button.c [iso-8859-1] Thu Oct 27 12:17:44
2011
@@ -270,7 +270,7 @@
{
if (pWnd->fnid != FNID_BUTTON)
{
- ERR("Wrong window class for Button!\n");
+ ERR("Wrong window class for Button! fnId 0x%x\n",pWnd->fnid);
return 0;
}
}
@@ -321,9 +321,9 @@
return 0;
#ifdef __REACTOS__
- case WM_DESTROY:
case WM_NCDESTROY:
NtUserSetWindowFNID(hWnd, FNID_DESTROY);
+ case WM_DESTROY:
break;
#endif
@@ -442,27 +442,38 @@
case WM_SETTEXT:
{
/* Clear an old text here as Windows does */
- HDC hdc = GetDC(hWnd);
- HBRUSH hbrush;
- RECT client, rc;
- HWND parent = GetParent(hWnd);
-
- if (!parent) parent = hWnd;
- hbrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC,
- (WPARAM)hdc, (LPARAM)hWnd);
- if (!hbrush) /* did the app forget to call DefWindowProc ? */
- hbrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
- (WPARAM)hdc, (LPARAM)hWnd);
-
- GetClientRect(hWnd, &client);
- rc = client;
- BUTTON_CalcLabelRect(hWnd, hdc, &rc);
- /* Clip by client rect bounds */
- if (rc.right > client.right) rc.right = client.right;
- if (rc.bottom > client.bottom) rc.bottom = client.bottom;
- FillRect(hdc, &rc, hbrush);
- ReleaseDC(hWnd, hdc);
-
+//
+// wine Bug:
http://bugs.winehq.org/show_bug.cgi?id=25790
+// Patch:
http://source.winehq.org/patches/data/70889
+// By: Alexander LAW, Replicate Windows behavior of WM_SETTEXT handler regarding
WM_CTLCOLOR*
+//
+ if (style & WS_VISIBLE)
+ {
+ HDC hdc = GetDC(hWnd);
+ HBRUSH hbrush;
+ RECT client, rc;
+ HWND parent = GetParent(hWnd);
+ UINT ctlMessage=(btn_type == BS_PUSHBUTTON ||
+ btn_type == BS_DEFPUSHBUTTON ||
+ btn_type == BS_PUSHLIKE ||
+ btn_type == BS_USERBUTTON ||
+ btn_type == BS_OWNERDRAW) ?
+ WM_CTLCOLORBTN : WM_CTLCOLORSTATIC;
+
+ if (!parent) parent = hWnd;
+
+ hbrush = GetControlColor( parent, hWnd, hdc, ctlMessage);
+
+ GetClientRect(hWnd, &client);
+ rc = client;
+ BUTTON_CalcLabelRect(hWnd, hdc, &rc);
+ /* Clip by client rect bounds */
+ if (rc.right > client.right) rc.right = client.right;
+ if (rc.bottom > client.bottom) rc.bottom = client.bottom;
+ FillRect(hdc, &rc, hbrush);
+ ReleaseDC(hWnd, hdc);
+ }
+////
if (unicode) DefWindowProcW( hWnd, WM_SETTEXT, wParam, lParam );
else DefWindowProcA( hWnd, WM_SETTEXT, wParam, lParam );
if (btn_type == BS_GROUPBOX) /* Yes, only for BS_GROUPBOX */
@@ -974,11 +985,7 @@
parent = GetParent(hwnd);
if (!parent) parent = hwnd;
- hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC,
- (WPARAM)hDC, (LPARAM)hwnd);
- if (!hBrush) /* did the app forget to call defwindowproc ? */
- hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
- (WPARAM)hDC, (LPARAM)hwnd );
+ hBrush = GetControlColor( parent, hwnd, hDC, WM_CTLCOLORSTATIC);
setup_clipping( hwnd, hDC );
if (style & BS_LEFTTEXT)
@@ -1118,10 +1125,7 @@
/* GroupBox acts like static control, so it sends CTLCOLORSTATIC */
parent = GetParent(hwnd);
if (!parent) parent = hwnd;
- hbr = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)hwnd);
- if (!hbr) /* did the app forget to call defwindowproc ? */
- hbr = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
- (WPARAM)hDC, (LPARAM)hwnd);
+ hbr = GetControlColor( parent, hwnd, hDC, WM_CTLCOLORSTATIC);
setup_clipping( hwnd, hDC );
GetClientRect( hwnd, &rc);
Modified: trunk/reactos/dll/win32/user32/controls/combo.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/controls/…
==============================================================================
--- trunk/reactos/dll/win32/user32/controls/combo.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/controls/combo.c [iso-8859-1] Thu Oct 27 12:17:44 2011
@@ -867,9 +867,7 @@
*/
if (CB_DISABLED(lphc))
{
- hBkgBrush = (HBRUSH)SendMessageW(lphc->owner, WM_CTLCOLORSTATIC,
- (WPARAM)hDC, (LPARAM)lphc->self );
-
+ hBkgBrush = GetControlColor(lphc->owner, lphc->self, hDC, WM_CTLCOLORSTATIC);
/*
* We have to change the text color since WM_CTLCOLORSTATIC will
* set it to the "enabled" color. This is the same behavior as the
@@ -880,8 +878,7 @@
else
{
/* FIXME: In which cases WM_CTLCOLORLISTBOX should be sent? */
- hBkgBrush = (HBRUSH)SendMessageW(lphc->owner, WM_CTLCOLOREDIT,
- (WPARAM)hDC, (LPARAM)lphc->self );
+ hBkgBrush = GetControlColor(lphc->owner, lphc->self, hDC, WM_CTLCOLOREDIT);
}
/*
@@ -1847,7 +1844,7 @@
{
if (pWnd->fnid != FNID_COMBOBOX)
{
- ERR("Wrong window class for ComboBox!\n");
+ ERR("Wrong window class for ComboBox! fnId
0x%x\n",pWnd->fnid);
return 0;
}
}
Modified: trunk/reactos/dll/win32/user32/controls/edit.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/controls/…
==============================================================================
--- trunk/reactos/dll/win32/user32/controls/edit.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/controls/edit.c [iso-8859-1] Thu Oct 27 12:17:44 2011
@@ -228,9 +228,7 @@
msg = WM_CTLCOLOREDIT;
/* why do we notify to es->hwndParent, and we send this one to GetParent()? */
- hbrush = (HBRUSH)SendMessageW(GetParent(es->hwndSelf), msg, (WPARAM)hdc,
(LPARAM)es->hwndSelf);
- if (!hbrush)
- hbrush = (HBRUSH)DefWindowProcW(GetParent(es->hwndSelf), msg, (WPARAM)hdc,
(LPARAM)es->hwndSelf);
+ hbrush = GetControlBrush(es->hwndSelf, hdc, msg);
return hbrush;
}
@@ -4481,7 +4479,7 @@
{
if (pWnd->fnid != FNID_EDIT)
{
- ERR("Wrong window class for Edit!\n");
+ ERR("Wrong window class for Edit! fnId
0x%x\n",pWnd->fnid);
return 0;
}
}
Modified: trunk/reactos/dll/win32/user32/controls/icontitle.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/controls/…
==============================================================================
--- trunk/reactos/dll/win32/user32/controls/icontitle.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/controls/icontitle.c [iso-8859-1] Thu Oct 27 12:17:44
2011
@@ -224,8 +224,9 @@
}
return (hIconTitleFont ? 0 : -1);
#ifdef __REACTOS__
+ case WM_NCDESTROY:
+ NtUserSetWindowFNID(hWnd, FNID_DESTROY);
case WM_DESTROY:
- NtUserSetWindowFNID(hWnd, FNID_DESTROY);
break;
#endif
case WM_NCHITTEST:
Modified: trunk/reactos/dll/win32/user32/controls/listbox.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/controls/…
==============================================================================
--- trunk/reactos/dll/win32/user32/controls/listbox.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/controls/listbox.c [iso-8859-1] Thu Oct 27 12:17:44
2011
@@ -2588,7 +2588,7 @@
{
if (pWnd->fnid != FNID_LISTBOX)
{
- ERR("Wrong window class for listbox!\n");
+ ERR("Wrong window class for listbox! fnId 0x%x\n",pWnd->fnid);
return 0;
}
}
@@ -3008,9 +3008,6 @@
return 0;
case WM_DESTROY:
-#ifdef __REACTOS__
- NtUserSetWindowFNID(hwnd, FNID_DESTROY);
-#endif
return LISTBOX_Destroy( descr );
case WM_ENABLE:
@@ -3185,6 +3182,9 @@
case WM_NCDESTROY:
if( lphc && (lphc->dwStyle & CBS_DROPDOWNLIST) != CBS_SIMPLE )
lphc->hWndLBox = 0;
+#ifdef __REACTOS__
+ NtUserSetWindowFNID(hwnd, FNID_DESTROY);
+#endif
break;
case WM_NCACTIVATE:
Modified: trunk/reactos/dll/win32/user32/controls/scrollbar.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/controls/…
==============================================================================
--- trunk/reactos/dll/win32/user32/controls/scrollbar.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/controls/scrollbar.c [iso-8859-1] Thu Oct 27 12:17:44
2011
@@ -1277,8 +1277,11 @@
#ifdef __REACTOS__
case WM_DESTROY:
+ return DefWindowProc(Wnd, Msg, wParam, lParam );
+
+ case WM_NCDESTROY:
NtUserSetWindowFNID(Wnd, FNID_DESTROY);
- return DefWindowProc(Wnd, Msg, wParam, lParam );
+ break;
#endif
//#if 0 /* FIXME */
Modified: trunk/reactos/dll/win32/user32/controls/static.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/controls/…
==============================================================================
--- trunk/reactos/dll/win32/user32/controls/static.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/controls/static.c [iso-8859-1] Thu Oct 27 12:17:44
2011
@@ -324,33 +324,9 @@
}
}
-BOOL WINAPI GdiValidateHandle(HGDIOBJ hobj);
-
static HBRUSH STATIC_SendWmCtlColorStatic(HWND hwnd, HDC hdc)
{
- PWND pwnd;
- HBRUSH hBrush;
- HWND parent = GetParent(hwnd);
-
- if (!parent) parent = hwnd;
- // ReactOS
- pwnd = ValidateHwnd(parent);
- if (pwnd && !TestWindowProcess(pwnd))
- {
- return (HBRUSH)DefWindowProcW( parent, WM_CTLCOLORSTATIC, (WPARAM)hdc,
(LPARAM)hwnd);
- }
- ////
- hBrush = (HBRUSH) SendMessageW( parent,
- WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
- if (!hBrush || /* did the app forget to call DefWindowProc ? */
- !GdiValidateHandle(hBrush)) // ReactOS
- {
- /* FIXME: DefWindowProc should return different colors if a
- manifest is present */
- hBrush = (HBRUSH)DefWindowProcW( parent, WM_CTLCOLORSTATIC,
- (WPARAM)hdc, (LPARAM)hwnd);
- }
- return hBrush;
+ return GetControlBrush( hwnd, hdc, WM_CTLCOLORSTATIC);
}
static VOID STATIC_InitColours(void)
@@ -403,7 +379,7 @@
{
if (pWnd->fnid != FNID_STATIC)
{
- ERR("Wrong window class for Static!\n");
+ ERR("Wrong window class for Static! fnId 0x%x\n",pWnd->fnid);
return 0;
}
}
@@ -642,6 +618,7 @@
static void STATIC_PaintOwnerDrawfn( HWND hwnd, HDC hdc, DWORD style )
{
DRAWITEMSTRUCT dis;
+ HBRUSH hBrush;
HFONT font, oldFont = NULL;
UINT id = (UINT)GetWindowLongPtrW( hwnd, GWLP_ID );
@@ -657,7 +634,7 @@
font = (HFONT)GetWindowLongPtrW( hwnd, HFONT_GWL_OFFSET );
if (font) oldFont = SelectObject( hdc, font );
- SendMessageW( GetParent(hwnd), WM_CTLCOLORSTATIC, (WPARAM)hdc, (LPARAM)hwnd );
+ hBrush = STATIC_SendWmCtlColorStatic(hwnd, hdc);
SendMessageW( GetParent(hwnd), WM_DRAWITEM, id, (LPARAM)&dis );
if (font) SelectObject( hdc, oldFont );
}
Modified: trunk/reactos/dll/win32/user32/include/user32p.h
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/include/u…
==============================================================================
--- trunk/reactos/dll/win32/user32/include/user32p.h [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/include/user32p.h [iso-8859-1] Thu Oct 27 12:17:44
2011
@@ -99,5 +99,8 @@
BOOL UserDrawSysMenuButton( HWND hWnd, HDC hDC, LPRECT, BOOL down );
HWND* WIN_ListChildren (HWND hWndparent);
VOID DeleteFrameBrushes(VOID);
+BOOL WINAPI GdiValidateHandle(HGDIOBJ);
+HBRUSH FASTCALL GetControlColor(HWND,HWND,HDC,UINT);
+HBRUSH FASTCALL GetControlBrush(HWND,HDC,UINT);
/* EOF */
Modified: trunk/reactos/dll/win32/user32/misc/misc.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/misc/misc…
==============================================================================
--- trunk/reactos/dll/win32/user32/misc/misc.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/misc/misc.c [iso-8859-1] Thu Oct 27 12:17:44 2011
@@ -481,6 +481,45 @@
return ValidateHwnd(hwnd);
}
+HBRUSH
+FASTCALL
+GetControlColor(
+ HWND hwndParent,
+ HWND hwnd,
+ HDC hdc,
+ UINT CtlMsg)
+{
+ PWND pwnd;
+ HBRUSH hBrush;
+
+ if (!hwndParent) hwndParent = hwnd;
+
+ pwnd = ValidateHwnd(hwndParent);
+ if (pwnd && !TestWindowProcess(pwnd))
+ {
+ return (HBRUSH)DefWindowProcW( hwndParent, CtlMsg, (WPARAM)hdc, (LPARAM)hwnd);
+ }
+
+ hBrush = (HBRUSH)SendMessageW( hwndParent, CtlMsg, (WPARAM)hdc, (LPARAM)hwnd);
+
+ if (!hBrush || !GdiValidateHandle(hBrush))
+ {
+ hBrush = (HBRUSH)DefWindowProcW( hwndParent, CtlMsg, (WPARAM)hdc, (LPARAM)hwnd);
+ }
+ return hBrush;
+}
+
+HBRUSH
+FASTCALL
+GetControlBrush(
+ HWND hwnd,
+ HDC hdc,
+ UINT ctlType)
+{
+ HWND hwndParent = GetParent(hwnd);
+ return GetControlColor( hwndParent, hwnd, hdc, ctlType);
+}
+
/*
* @implemented
*/
Modified: trunk/reactos/dll/win32/user32/windows/defwnd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/d…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/defwnd.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/defwnd.c [iso-8859-1] Thu Oct 27 12:17:44 2011
@@ -1901,6 +1901,15 @@
LRESULT Result = 0;
PWND Wnd;
+ Wnd = ValidateHwnd(hWnd);
+
+ if ( !Wnd &&
+ Msg != WM_CTLCOLORMSGBOX &&
+ Msg != WM_CTLCOLORBTN &&
+ Msg != WM_CTLCOLORDLG &&
+ Msg != WM_CTLCOLORSTATIC )
+ return 0;
+
SPY_EnterMessage(SPY_DEFWNDPROC, hWnd, Msg, wParam, lParam);
switch (Msg)
{
@@ -1925,7 +1934,6 @@
PWSTR buf;
ULONG len;
- Wnd = ValidateHwnd(hWnd);
if (Wnd != NULL && Wnd->strName.Length != 0)
{
buf = DesktopPtrToUser(Wnd->strName.Buffer);
@@ -1948,7 +1956,6 @@
PSTR outbuf = (PSTR)lParam;
UINT copy;
- Wnd = ValidateHwnd(hWnd);
if (Wnd != NULL && wParam != 0)
{
if (Wnd->strName.Buffer != NULL)
@@ -2061,6 +2068,15 @@
LRESULT Result = 0;
PWND Wnd;
+ Wnd = ValidateHwnd(hWnd);
+
+ if ( !Wnd &&
+ Msg != WM_CTLCOLORMSGBOX &&
+ Msg != WM_CTLCOLORBTN &&
+ Msg != WM_CTLCOLORDLG &&
+ Msg != WM_CTLCOLORSTATIC )
+ return 0;
+
SPY_EnterMessage(SPY_DEFWNDPROC, hWnd, Msg, wParam, lParam);
switch (Msg)
{
@@ -2085,7 +2101,6 @@
PWSTR buf;
ULONG len;
- Wnd = ValidateHwnd(hWnd);
if (Wnd != NULL && Wnd->strName.Length != 0)
{
buf = DesktopPtrToUser(Wnd->strName.Buffer);
@@ -2107,7 +2122,6 @@
PWSTR buf = NULL;
PWSTR outbuf = (PWSTR)lParam;
- Wnd = ValidateHwnd(hWnd);
if (Wnd != NULL && wParam != 0)
{
if (Wnd->strName.Buffer != NULL)
Modified: trunk/reactos/dll/win32/user32/windows/mdi.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/m…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/mdi.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/mdi.c [iso-8859-1] Thu Oct 27 12:17:44 2011
@@ -1161,10 +1161,17 @@
#ifdef __REACTOS__
HeapFree( GetProcessHeap(), 0, ci );
SetWindowLongPtrW( hwnd, 0, 0 );
- NtUserSetWindowFNID(hwnd, FNID_DESTROY);
#endif
return 0;
}
+
+#ifdef __REACTOS__
+ case WM_NCDESTROY:
+ {
+ NtUserSetWindowFNID(hwnd, FNID_DESTROY);
+ return 0;
+ }
+#endif
case WM_MDIACTIVATE:
{
Modified: trunk/reactos/dll/win32/user32/windows/menu.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/dll/win32/user32/windows/m…
==============================================================================
--- trunk/reactos/dll/win32/user32/windows/menu.c [iso-8859-1] (original)
+++ trunk/reactos/dll/win32/user32/windows/menu.c [iso-8859-1] Thu Oct 27 12:17:44 2011
@@ -1852,10 +1852,13 @@
top_popup = NULL;
top_popup_hmenu = NULL;
}
+ break;
+
#ifdef __REACTOS__
+ case WM_NCDESTROY:
NtUserSetWindowFNID(Wnd, FNID_DESTROY);
+ break;
#endif
- break;
case WM_SHOWWINDOW:
if (0 != wParam)
@@ -1949,10 +1952,13 @@
top_popup = NULL;
top_popup_hmenu = NULL;
}
+ break;
+
#ifdef __REACTOS__
+ case WM_NCDESTROY:
NtUserSetWindowFNID(Wnd, FNID_DESTROY);
+ break;
#endif
- break;
case WM_SHOWWINDOW:
if (0 != wParam)