Skip to content

Commit cf98f01

Browse files
committed
[USER32] - Sync with Wine Staging 1.9.18.
svn path=/trunk/; revision=72650
1 parent 50ce1f1 commit cf98f01

File tree

1 file changed

+42
-39
lines changed
  • reactos/win32ss/user/user32/controls

1 file changed

+42
-39
lines changed

reactos/win32ss/user/user32/controls/button.c

Lines changed: 42 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -135,10 +135,6 @@ static const pfPaint btnPaintFunc[MAX_BTN_TYPE] =
135135
OB_Paint /* BS_OWNERDRAW */
136136
};
137137

138-
static HBITMAP hbitmapCheckBoxes = 0;
139-
static WORD checkBoxWidth = 0, checkBoxHeight = 0;
140-
141-
142138
/*********************************************************************
143139
* button class descriptor
144140
*/
@@ -272,7 +268,8 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
272268
}
273269
}
274270
}
275-
271+
else
272+
return 0;
276273
#else
277274
if (!IsWindow( hWnd )) return 0;
278275
#endif
@@ -299,14 +296,6 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
299296
break;
300297

301298
case WM_CREATE:
302-
if (!hbitmapCheckBoxes)
303-
{
304-
BITMAP bmp;
305-
hbitmapCheckBoxes = LoadBitmapW(0, MAKEINTRESOURCEW(OBM_CHECKBOXES));
306-
GetObjectW( hbitmapCheckBoxes, sizeof(bmp), &bmp );
307-
checkBoxWidth = bmp.bmWidth / 4;
308-
checkBoxHeight = bmp.bmHeight / 3;
309-
}
310299
if (btn_type >= MAX_BTN_TYPE)
311300
return -1; /* abort */
312301

@@ -400,8 +389,9 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
400389
break;
401390
/* fall through */
402391
case WM_LBUTTONUP:
403-
{
392+
#ifdef _REACTOS_
404393
BOOL TellParent = FALSE; //// ReactOS see note below.
394+
#endif
405395
state = get_button_state( hWnd );
406396
if (!(state & BUTTON_BTNPRESSED)) break;
407397
state &= BUTTON_NSTATES;
@@ -429,15 +419,27 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
429419
(state & BST_INDETERMINATE) ? 0 : ((state & 3) + 1), 0 );
430420
break;
431421
}
422+
#ifdef _REACTOS_
432423
TellParent = TRUE; // <---- Fix CORE-10194, Notify parent after capture is released.
424+
#else
425+
ReleaseCapture();
426+
BUTTON_NOTIFY_PARENT(hWnd, BN_CLICKED);
427+
#endif
433428
}
429+
#ifdef _REACTOS_
434430
ReleaseCapture();
435431
if (TellParent) BUTTON_NOTIFY_PARENT(hWnd, BN_CLICKED);
436-
}
432+
#else
433+
else
434+
{
435+
ReleaseCapture();
436+
}
437+
#endif
437438
break;
438439

439440
case WM_CAPTURECHANGED:
440441
TRACE("WM_CAPTURECHANGED %p\n", hWnd);
442+
if (hWnd == (HWND)lParam) break;
441443
state = get_button_state( hWnd );
442444
if (state & BUTTON_BTNPRESSED)
443445
{
@@ -459,36 +461,37 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
459461
{
460462
/* Clear an old text here as Windows does */
461463
//
464+
// ReactOS Note :
462465
// wine Bug: http://bugs.winehq.org/show_bug.cgi?id=25790
463466
// Patch: http://source.winehq.org/patches/data/70889
464467
// By: Alexander LAW, Replicate Windows behavior of WM_SETTEXT handler regarding WM_CTLCOLOR*
465468
//
466469
#ifdef __REACTOS__
467470
if (style & WS_VISIBLE)
468-
{
471+
#else
472+
if (IsWindowVisible(hWnd))
469473
#endif
474+
{
470475
HDC hdc = GetDC(hWnd);
471476
HBRUSH hbrush;
472477
RECT client, rc;
473478
HWND parent = GetParent(hWnd);
474-
#ifdef __REACTOS__
475-
UINT ctlMessage = (btn_type == BS_PUSHBUTTON ||
476-
btn_type == BS_DEFPUSHBUTTON ||
477-
btn_type == BS_PUSHLIKE ||
478-
btn_type == BS_USERBUTTON ||
479-
btn_type == BS_OWNERDRAW) ?
480-
WM_CTLCOLORBTN : WM_CTLCOLORSTATIC;
481-
#endif
479+
UINT message = (btn_type == BS_PUSHBUTTON ||
480+
btn_type == BS_DEFPUSHBUTTON ||
481+
btn_type == BS_PUSHLIKE ||
482+
btn_type == BS_USERBUTTON ||
483+
btn_type == BS_OWNERDRAW) ?
484+
WM_CTLCOLORBTN : WM_CTLCOLORSTATIC;
482485

483486
if (!parent) parent = hWnd;
484487
#ifdef __REACTOS__
485-
hbrush = GetControlColor(parent, hWnd, hdc, ctlMessage);
488+
hbrush = GetControlColor(parent, hWnd, hdc, message);
486489
#else
487-
hbrush = (HBRUSH)SendMessageW(parent, WM_CTLCOLORSTATIC,
488-
(WPARAM)hdc, (LPARAM)hWnd);
489-
if (!hbrush) /* did the app forget to call DefWindowProc ? */
490-
hbrush = (HBRUSH)DefWindowProcW(parent, WM_CTLCOLORSTATIC,
491-
(WPARAM)hdc, (LPARAM)hWnd);
490+
hbrush = (HBRUSH)SendMessageW(parent, message,
491+
(WPARAM)hdc, (LPARAM)hWnd);
492+
if (!hbrush) /* did the app forget to call DefWindowProc ? */
493+
hbrush = (HBRUSH)DefWindowProcW(parent, message,
494+
(WPARAM)hdc, (LPARAM)hWnd);
492495
#endif
493496

494497
GetClientRect(hWnd, &client);
@@ -499,9 +502,7 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
499502
if (rc.bottom > client.bottom) rc.bottom = client.bottom;
500503
FillRect(hdc, &rc, hbrush);
501504
ReleaseDC(hWnd, hdc);
502-
#ifdef __REACTOS__
503505
}
504-
#endif
505506

506507
if (unicode) DefWindowProcW( hWnd, WM_SETTEXT, wParam, lParam );
507508
else DefWindowProcA( hWnd, WM_SETTEXT, wParam, lParam );
@@ -842,11 +843,8 @@ static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc)
842843
static BOOL CALLBACK BUTTON_DrawTextCallback(HDC hdc, LPARAM lp, WPARAM wp, int cx, int cy)
843844
{
844845
RECT rc;
845-
rc.left = 0;
846-
rc.top = 0;
847-
rc.right = cx;
848-
rc.bottom = cy;
849846

847+
SetRect(&rc, 0, 0, cx, cy);
850848
DrawTextW(hdc, (LPCWSTR)lp, -1, &rc, (UINT)wp);
851849
return TRUE;
852850
}
@@ -1026,7 +1024,7 @@ static void CB_Paint( HWND hwnd, HDC hDC, UINT action )
10261024
{
10271025
RECT rbox, rtext, client;
10281026
HBRUSH hBrush;
1029-
int delta;
1027+
int delta, text_offset, checkBoxWidth, checkBoxHeight;
10301028
UINT dtFlags;
10311029
HFONT hFont;
10321030
LONG state = get_button_state( hwnd );
@@ -1043,7 +1041,12 @@ static void CB_Paint( HWND hwnd, HDC hDC, UINT action )
10431041
GetClientRect(hwnd, &client);
10441042
rbox = rtext = client;
10451043

1044+
checkBoxWidth = 12 * GetDeviceCaps( hDC, LOGPIXELSX ) / 96 + 1;
1045+
checkBoxHeight = 12 * GetDeviceCaps( hDC, LOGPIXELSY ) / 96 + 1;
1046+
10461047
if ((hFont = get_button_font( hwnd ))) SelectObject( hDC, hFont );
1048+
GetCharWidthW( hDC, '0', '0', &text_offset );
1049+
text_offset /= 2;
10471050

10481051
parent = GetParent(hwnd);
10491052
if (!parent) parent = hwnd;
@@ -1062,12 +1065,12 @@ static void CB_Paint( HWND hwnd, HDC hDC, UINT action )
10621065
{
10631066
/* magic +4 is what CTL3D expects */
10641067

1065-
rtext.right -= checkBoxWidth + 4;
1068+
rtext.right -= checkBoxWidth + text_offset;;
10661069
rbox.left = rbox.right - checkBoxWidth;
10671070
}
10681071
else
10691072
{
1070-
rtext.left += checkBoxWidth + 4;
1073+
rtext.left += checkBoxWidth + text_offset;;
10711074
rbox.right = checkBoxWidth;
10721075
}
10731076

0 commit comments

Comments
 (0)