@@ -135,10 +135,6 @@ static const pfPaint btnPaintFunc[MAX_BTN_TYPE] =
135
135
OB_Paint /* BS_OWNERDRAW */
136
136
};
137
137
138
- static HBITMAP hbitmapCheckBoxes = 0 ;
139
- static WORD checkBoxWidth = 0 , checkBoxHeight = 0 ;
140
-
141
-
142
138
/*********************************************************************
143
139
* button class descriptor
144
140
*/
@@ -272,7 +268,8 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
272
268
}
273
269
}
274
270
}
275
-
271
+ else
272
+ return 0 ;
276
273
#else
277
274
if (!IsWindow ( hWnd )) return 0 ;
278
275
#endif
@@ -299,14 +296,6 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
299
296
break ;
300
297
301
298
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
- }
310
299
if (btn_type >= MAX_BTN_TYPE )
311
300
return -1 ; /* abort */
312
301
@@ -400,8 +389,9 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
400
389
break ;
401
390
/* fall through */
402
391
case WM_LBUTTONUP :
403
- {
392
+ #ifdef _REACTOS_
404
393
BOOL TellParent = FALSE; //// ReactOS see note below.
394
+ #endif
405
395
state = get_button_state ( hWnd );
406
396
if (!(state & BUTTON_BTNPRESSED )) break ;
407
397
state &= BUTTON_NSTATES ;
@@ -429,15 +419,27 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
429
419
(state & BST_INDETERMINATE ) ? 0 : ((state & 3 ) + 1 ), 0 );
430
420
break ;
431
421
}
422
+ #ifdef _REACTOS_
432
423
TellParent = TRUE; // <---- Fix CORE-10194, Notify parent after capture is released.
424
+ #else
425
+ ReleaseCapture ();
426
+ BUTTON_NOTIFY_PARENT (hWnd , BN_CLICKED );
427
+ #endif
433
428
}
429
+ #ifdef _REACTOS_
434
430
ReleaseCapture ();
435
431
if (TellParent ) BUTTON_NOTIFY_PARENT (hWnd , BN_CLICKED );
436
- }
432
+ #else
433
+ else
434
+ {
435
+ ReleaseCapture ();
436
+ }
437
+ #endif
437
438
break ;
438
439
439
440
case WM_CAPTURECHANGED :
440
441
TRACE ("WM_CAPTURECHANGED %p\n" , hWnd );
442
+ if (hWnd == (HWND )lParam ) break ;
441
443
state = get_button_state ( hWnd );
442
444
if (state & BUTTON_BTNPRESSED )
443
445
{
@@ -459,36 +461,37 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
459
461
{
460
462
/* Clear an old text here as Windows does */
461
463
//
464
+ // ReactOS Note :
462
465
// wine Bug: http://bugs.winehq.org/show_bug.cgi?id=25790
463
466
// Patch: http://source.winehq.org/patches/data/70889
464
467
// By: Alexander LAW, Replicate Windows behavior of WM_SETTEXT handler regarding WM_CTLCOLOR*
465
468
//
466
469
#ifdef __REACTOS__
467
470
if (style & WS_VISIBLE )
468
- {
471
+ #else
472
+ if (IsWindowVisible (hWnd ))
469
473
#endif
474
+ {
470
475
HDC hdc = GetDC (hWnd );
471
476
HBRUSH hbrush ;
472
477
RECT client , rc ;
473
478
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 ;
482
485
483
486
if (!parent ) parent = hWnd ;
484
487
#ifdef __REACTOS__
485
- hbrush = GetControlColor (parent , hWnd , hdc , ctlMessage );
488
+ hbrush = GetControlColor (parent , hWnd , hdc , message );
486
489
#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 );
492
495
#endif
493
496
494
497
GetClientRect (hWnd , & client );
@@ -499,9 +502,7 @@ LRESULT WINAPI ButtonWndProc_common(HWND hWnd, UINT uMsg,
499
502
if (rc .bottom > client .bottom ) rc .bottom = client .bottom ;
500
503
FillRect (hdc , & rc , hbrush );
501
504
ReleaseDC (hWnd , hdc );
502
- #ifdef __REACTOS__
503
505
}
504
- #endif
505
506
506
507
if (unicode ) DefWindowProcW ( hWnd , WM_SETTEXT , wParam , lParam );
507
508
else DefWindowProcA ( hWnd , WM_SETTEXT , wParam , lParam );
@@ -842,11 +843,8 @@ static UINT BUTTON_CalcLabelRect(HWND hwnd, HDC hdc, RECT *rc)
842
843
static BOOL CALLBACK BUTTON_DrawTextCallback (HDC hdc , LPARAM lp , WPARAM wp , int cx , int cy )
843
844
{
844
845
RECT rc ;
845
- rc .left = 0 ;
846
- rc .top = 0 ;
847
- rc .right = cx ;
848
- rc .bottom = cy ;
849
846
847
+ SetRect (& rc , 0 , 0 , cx , cy );
850
848
DrawTextW (hdc , (LPCWSTR )lp , -1 , & rc , (UINT )wp );
851
849
return TRUE;
852
850
}
@@ -1026,7 +1024,7 @@ static void CB_Paint( HWND hwnd, HDC hDC, UINT action )
1026
1024
{
1027
1025
RECT rbox , rtext , client ;
1028
1026
HBRUSH hBrush ;
1029
- int delta ;
1027
+ int delta , text_offset , checkBoxWidth , checkBoxHeight ;
1030
1028
UINT dtFlags ;
1031
1029
HFONT hFont ;
1032
1030
LONG state = get_button_state ( hwnd );
@@ -1043,7 +1041,12 @@ static void CB_Paint( HWND hwnd, HDC hDC, UINT action )
1043
1041
GetClientRect (hwnd , & client );
1044
1042
rbox = rtext = client ;
1045
1043
1044
+ checkBoxWidth = 12 * GetDeviceCaps ( hDC , LOGPIXELSX ) / 96 + 1 ;
1045
+ checkBoxHeight = 12 * GetDeviceCaps ( hDC , LOGPIXELSY ) / 96 + 1 ;
1046
+
1046
1047
if ((hFont = get_button_font ( hwnd ))) SelectObject ( hDC , hFont );
1048
+ GetCharWidthW ( hDC , '0' , '0' , & text_offset );
1049
+ text_offset /= 2 ;
1047
1050
1048
1051
parent = GetParent (hwnd );
1049
1052
if (!parent ) parent = hwnd ;
@@ -1062,12 +1065,12 @@ static void CB_Paint( HWND hwnd, HDC hDC, UINT action )
1062
1065
{
1063
1066
/* magic +4 is what CTL3D expects */
1064
1067
1065
- rtext .right -= checkBoxWidth + 4 ;
1068
+ rtext .right -= checkBoxWidth + text_offset ; ;
1066
1069
rbox .left = rbox .right - checkBoxWidth ;
1067
1070
}
1068
1071
else
1069
1072
{
1070
- rtext .left += checkBoxWidth + 4 ;
1073
+ rtext .left += checkBoxWidth + text_offset ; ;
1071
1074
rbox .right = checkBoxWidth ;
1072
1075
}
1073
1076
0 commit comments