reactos/lib/user32/controls
diff -u -r1.18 -r1.19
--- button.c 24 Jul 2004 00:45:31 -0000 1.18
+++ button.c 10 Aug 2004 19:09:37 -0000 1.19
@@ -169,9 +169,9 @@
/* retrieve the button text; returned buffer must be freed by caller */
inline static WCHAR *get_button_text( HWND hwnd )
{
- INT len = GetWindowTextLengthW( hwnd );
+ INT len = 512;
WCHAR *buffer = HeapAlloc( GetProcessHeap(), 0, (len + 1) * sizeof(WCHAR) );
- if (buffer) GetWindowTextW( hwnd, buffer, len + 1 );
+ if (buffer) InternalGetWindowText( hwnd, buffer, len + 1 );
return buffer;
}
@@ -226,9 +226,12 @@
{
HDC hdc = (HDC)wParam;
RECT rc;
- HBRUSH hBrush = (HBRUSH)SendMessageW(GetParent(hWnd), WM_CTLCOLORBTN, (WPARAM)hdc, (LPARAM)hWnd);
+ HBRUSH hBrush;
+ HWND parent = GetParent(hWnd);
+ if (!parent) parent = hWnd;
+ hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hdc, (LPARAM)hWnd);
if (!hBrush) /* did the app forget to call defwindowproc ? */
- hBrush = (HBRUSH)DefWindowProcW(GetParent(hWnd), WM_CTLCOLORBTN,
+ hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN,
(WPARAM)hdc, (LPARAM)hWnd);
GetClientRect(hWnd, &rc);
FillRect(hdc, &rc, hBrush);
@@ -336,11 +339,13 @@
HDC hdc = GetDC(hWnd);
HBRUSH hbrush;
RECT client, rc;
+ HWND parent = GetParent(hWnd);
- hbrush = (HBRUSH)SendMessageW(GetParent(hWnd), WM_CTLCOLORSTATIC,
+ 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(GetParent(hWnd), WM_CTLCOLORSTATIC,
+ hbrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
(WPARAM)hdc, (LPARAM)hWnd);
GetClientRect(hWnd, &client);
@@ -370,16 +375,6 @@
return (LRESULT)get_button_font( hWnd );
case WM_SETFOCUS:
- if ((btn_type == BS_RADIOBUTTON || btn_type == BS_AUTORADIOBUTTON) && (GetCapture() != hWnd) &&
- !(SendMessageW(hWnd, BM_GETCHECK, 0, 0) & BST_CHECKED))
- {
- /* The notification is sent when the button (BS_AUTORADIOBUTTON)
- is unchecked and the focus was not given by a mouse click. */
- if (btn_type == BS_AUTORADIOBUTTON)
- SendMessageW( hWnd, BM_SETCHECK, BUTTON_CHECKED, 0 );
- SendMessageW( GetParent(hWnd), WM_COMMAND,
- MAKEWPARAM( GetWindowLongA(hWnd,GWL_ID), BN_CLICKED ), (LPARAM)hWnd);
- }
set_button_state( hWnd, get_button_state(hWnd) | BUTTON_HASFOCUS );
paint_button( hWnd, btn_type, ODA_FOCUS );
break;
@@ -387,7 +382,6 @@
case WM_KILLFOCUS:
set_button_state( hWnd, get_button_state(hWnd) & ~BUTTON_HASFOCUS );
paint_button( hWnd, btn_type, ODA_FOCUS );
- InvalidateRect( hWnd, NULL, TRUE );
break;
case WM_SYSCOLORCHANGE:
@@ -752,12 +746,15 @@
LONG state = get_button_state( hwnd );
LONG style = GetWindowLongA( hwnd, GWL_STYLE );
BOOL pushedState = (state & BUTTON_HIGHLIGHTED);
+ HWND parent;
GetClientRect( hwnd, &rc );
/* Send WM_CTLCOLOR to allow changing the font (the colors are fixed) */
if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
- SendMessageW( GetParent(hwnd), WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd );
+ parent = GetParent(hwnd);
+ if (!parent) parent = hwnd;
+ SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd );
#ifdef __REACTOS__
hOldPen = (HPEN)SelectObject(hDC, GetSysColorPen(COLOR_WINDOWFRAME));
#else
@@ -839,6 +836,7 @@
HFONT hFont;
LONG state = get_button_state( hwnd );
LONG style = GetWindowLongA( hwnd, GWL_STYLE );
+ HWND parent;
if (style & BS_PUSHLIKE)
{
@@ -851,10 +849,12 @@
if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
- hBrush = (HBRUSH)SendMessageW(GetParent(hwnd), WM_CTLCOLORSTATIC,
+ 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(GetParent(hwnd), WM_CTLCOLORSTATIC,
+ hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
(WPARAM)hDC, (LPARAM)hwnd );
if (style & BS_LEFTTEXT)
@@ -984,14 +984,15 @@
UINT dtFlags;
TEXTMETRICW tm;
LONG style = GetWindowLongA( hwnd, GWL_STYLE );
-
- if (action != ODA_DRAWENTIRE) return;
+ HWND parent;
if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
/* GroupBox acts like static control, so it sends CTLCOLORSTATIC */
- hbr = (HBRUSH)SendMessageW(GetParent(hwnd), WM_CTLCOLORSTATIC, (WPARAM)hDC, (LPARAM)hwnd);
+ 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(GetParent(hwnd), WM_CTLCOLORSTATIC,
+ hbr = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
(WPARAM)hDC, (LPARAM)hwnd);
GetClientRect( hwnd, &rc);
@@ -1031,6 +1032,7 @@
HBRUSH hBrush;
HFONT hFont;
LONG state = get_button_state( hwnd );
+ HWND parent;
if (action == ODA_SELECT) return;
@@ -1038,9 +1040,11 @@
if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
- hBrush = (HBRUSH)SendMessageW(GetParent(hwnd), WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd);
+ parent = GetParent(hwnd);
+ if (!parent) parent = hwnd;
+ hBrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd);
if (!hBrush) /* did the app forget to call defwindowproc ? */
- hBrush = (HBRUSH)DefWindowProcW(GetParent(hwnd), WM_CTLCOLORBTN,
+ hBrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORBTN,
(WPARAM)hDC, (LPARAM)hwnd);
FillRect( hDC, &rc, hBrush );
@@ -1061,6 +1065,7 @@
HRGN clipRegion;
RECT clipRect;
UINT id = GetWindowLongA( hwnd, GWL_ID );
+ HWND parent;
dis.CtlType = ODT_BUTTON;
dis.CtlID = id;
@@ -1084,7 +1089,9 @@
DPtoLP(hDC, (LPPOINT) &clipRect, 2);
IntersectClipRect(hDC, clipRect.left, clipRect.top, clipRect.right, clipRect.bottom);
- SetBkColor( hDC, GetSysColor( COLOR_BTNFACE ) );
+ parent = GetParent(hwnd);
+ if (!parent) parent = hwnd;
+ SendMessageW( parent, WM_CTLCOLORBTN, (WPARAM)hDC, (LPARAM)hwnd );
SendMessageW( GetParent(hwnd), WM_DRAWITEM, id, (LPARAM)&dis );
SelectClipRgn(hDC, clipRegion);
}