5 * WINCTL Custom Control Library
6 * Push button Custom Control
7 * This control implements a custom pushbutton control.
9 * 4/8/98 g haerr original version from control palette v2.00, Blaise Computing
12 #define GET_PBSTATE(h) (GetWindowWord(h, 0))
13 #define GET_PBCAPTURE(h) (GetWindowWord(h, 2))
14 #define GET_PBWASINSIDE(h) (GetWindowWord(h, 4))
15 #define GET_PBDELETEFONT(h) (GetWindowWord(h, 6))
16 #define GET_PBFONT(h) (GetWindowWord(h, 8))
18 #define SET_PBSTATE(h,x) (SetWindowWord(h, 0, x))
19 #define SET_PBCAPTURE(h,x) (SetWindowWord(h, 2, x))
20 #define SET_PBWASINSIDE(h,x) (SetWindowWord(h, 4, x))
21 #define SET_PBDELETEFONT(h,x) (SetWindowWord(h, 6, x))
22 #define SET_PBFONT(h,x) (SetWindowWord(h, 8, x))
24 #define PARENT(hwnd) ((HWND)GetWindowLong(hwnd,GWL_HWNDPARENT))
26 /* Internal state variable bit positions */
27 #define PUSH_UP 0x0000
28 #define PUSH_DOWN 0x0001 /* Button is down */
29 #define PUSH_FOCUS 0x0002 /* Button is focused */
30 #define PUSH_DISABLED 0x0004 /* Button is disabled */
31 #define PUSH_DEFAULT 0x0008 /* Button is currently a default */
32 #define PUSH_CHECKED 0x0010
34 /* Push Button states */
35 #define PBS_UP 0x0000 /* Normal button state. */
36 #define PBS_FOCUSDOWN 0x0001 /* Button pressed. */
37 #define PBS_FOCUSUP 0x0002 /* Focused state. */
38 #define PBS_DISABLED 0x0004 /* Disabled state. */
39 #define PBS_DEFAULT 0x0008 /* Default state. */
40 #define PBS_CHECKED 0x0010 /* checked state. */
42 #define WM_PAINT_SPECIAL WM_PAINT
43 #define HANDLE_WM_PAINT_SPECIAL(hwnd, wParam, lParam, fn) \
44 ((fn)((hwnd),(HDC)(wParam)), 0L)
46 /* BOOL Cls_OnGetState( HWND hwnd); */
47 #define HANDLE_BM_GETSTATE(hwnd, wParam, lParam, fn) ((fn)(hwnd))
48 #define FORWARD_BM_GETSTATE(hwnd) \
49 (LONG)(fn)((hwnd), BM_GETSTATE, (WPARAM)0, (LPARAM)0)
51 /* void Cls_OnSetState( HWND hwnd, WORD wState); */
52 #define HANDLE_BM_SETSTATE( hwnd, wParam, lParam, fn) \
53 ((fn)((hwnd), (WORD)wParam), 0)
54 #define FORWARD_BM_SETSTATE( hwnd, wState) \
55 (fn)((hwnd), BM_SETSTATE, (WPARAM)wState, (LPARAM)0)
57 /* void Cls_OnSetStyle( HWND hwnd, WORD style, BOOL bRedraw); */
58 #define HANDLE_BM_SETSTYLE( hwnd, wParam, lParam, fn) \
59 ((fn)((hwnd), (WORD)wParam, (BOOL)LOWORD(lParam)), 0)
60 #define FORWARD_BM_SETSTYLE( hwnd, style, bRedraw, fn) \
61 (fn)((hwnd), BM_SETSTYLE, (WPARAM)style, MAKELPARAM(bRedraw, 0))
64 void WINAPI CheckRadioButton(HWND hDlg, int nIDFirst,int nIDLast,
68 static void WINAPI cenButton_FnEnd( HWND, WORD);
69 static WORD WINAPI cenButton_FnStart( HWND);
70 static BOOL WINAPI cenButton_OnCreate( HWND, LPCREATESTRUCT);
71 /*static void WINAPI cenButton_OnDestroy( HWND);*/
72 /*static void WINAPI cenButton_OnEnable( HWND, BOOL);*/
73 static BOOL WINAPI cenButton_OnEraseBkgnd( HWND, HDC);
74 /*static UINT WINAPI cenButton_OnGetDlgCode( HWND, LPMSG);*/
75 static LONG WINAPI cenButton_OnGetState( HWND);
76 /*static void WINAPI cenButton_OnKey( HWND, UINT, BOOL, int, UINT);*/
77 static void WINAPI cenButton_OnKillFocus( HWND, HWND);
78 static void WINAPI cenButton_OnLButtonDown( HWND, BOOL, UINT, UINT, UINT);
79 static void WINAPI cenButton_OnLButtonUp( HWND, UINT, UINT, UINT);
80 static void WINAPI cenButton_OnMouseMove( HWND, UINT, UINT, UINT);
81 static void WINAPI cenButton_OnPaint( HWND, HDC);
82 static void WINAPI DrawPushButton(HWND hwnd,HDC hDCwParam,UINT wEnumState,
84 static void WINAPI DrawGroupBox(HWND hwnd,HDC hDCwParam, DWORD dwStyle);
85 static void WINAPI cenButton_OnSetFocus( HWND, HWND);
86 static void WINAPI cenButton_OnSetStyle( HWND, WORD, BOOL);
87 static void WINAPI cenButton_OnSetState( HWND, WORD);
88 static void WINAPI cenButton_SetState( HWND, WORD, BOOL);
89 static void WINAPI cenButton_OnSetText( HWND, LPCSTR);
96 if( wState != GET_PBSTATE( hwnd)) {
97 if( IsWindowVisible( hwnd))
106 return GET_PBSTATE( hwnd);
112 LPCREATESTRUCT lpCreate)
114 /* Set initial states */
115 /*SET_PBDELETEFONT( hwnd, FALSE);*/
116 /*SET_PBFONT( hwnd, NULL);*/
117 SET_PBSTATE( hwnd, PUSH_UP );
118 SET_PBCAPTURE( hwnd, FALSE );
119 SET_PBWASINSIDE( hwnd, FALSE );
121 if ((lpCreate->style & 0x0f) == BS_DEFPUSHBUTTON)
122 cenButton_SetState( hwnd, PUSH_DEFAULT, TRUE );
124 if (lpCreate->style & WS_DISABLED)
125 cenButton_SetState( hwnd, PUSH_DISABLED, TRUE );
135 if( GET_PBDELETEFONT( hwnd)) {
136 DeleteObject( GET_PBFONT( hwnd));
137 SET_PBDELETEFONT( hwnd, FALSE);
148 wState = cenButton_FnStart( hwnd);
149 cenButton_SetState( hwnd, PUSH_DISABLED, !bEnable);
150 cenButton_FnEnd( hwnd, wState);
155 cenButton_OnEraseBkgnd(
159 /* Background is erased at WM_PAINT time, so return TRUE*/
165 cenButton_OnGetDlgCode(
169 /* WM_GETDLGCODE is sent by the dialog manager to find */
170 /* what type/style of control is responding and/or to */
171 /* determine what keystrokes the control wants to process */
172 /* itself. In this case, the pushbutton identifies itself */
173 /* and also indicates whether it is currently the default */
176 /*return( DLGC_BUTTON | ((GET_PBSTATE( hwnd) & PUSH_DEFAULT) ?
177 DLGC_DEFPUSHBUTTON : DLGC_UNDEFPUSHBUTTON));*/
178 return( DLGC_BUTTON);
183 cenButton_OnGetState(
186 /* BM_GETSTATE is sent to enquire about the state of the */
187 /* control. It returns TRUE if the button is in the down */
190 return( ( GET_PBSTATE( hwnd) & PUSH_DOWN) == PUSH_DOWN);
204 wState = cenButton_FnStart( hwnd);
206 /* WM_KEYDOWN is sent when a non-system key is pressed. */
207 /* If a spacebar is detected and the previous key state */
208 /* was up, then the control should switch to the down */
211 if ( (vk == ' ') && !(HIBYTE(flag) & 0x40) )
212 cenButton_SetState( hwnd, PUSH_DOWN, TRUE );
215 /* WM_KEYUP is sent when a non-system key is released. */
216 /* If a space bar is detected, change to the up state. If */
217 /* the control is the focused control, send the BN_CLICKED */
218 /* notification message. */
221 { cenButton_SetState( hwnd, PUSH_DOWN, FALSE );
223 if (GET_PBSTATE( hwnd) & PUSH_FOCUS) {
224 FORWARD_WM_COMMAND( PARENT( hwnd), GetDlgCtrlID( hwnd),
225 hwnd, BN_CLICKED, SendMessage);
231 cenButton_FnEnd( hwnd, wState);
236 cenButton_OnKillFocus(
242 wState = cenButton_FnStart( hwnd);
243 cenButton_SetState( hwnd, PUSH_FOCUS, FALSE );
244 cenButton_FnEnd( hwnd, wState);
248 cenButton_OnLButtonDown(
257 wState = cenButton_FnStart( hwnd);
258 /* capture the mouse*/
260 /* set focus to ourself*/
262 SET_PBCAPTURE( hwnd, TRUE );
263 SET_PBWASINSIDE( hwnd, TRUE );
265 cenButton_SetState( hwnd, PUSH_DOWN, TRUE );
266 cenButton_FnEnd( hwnd, wState);
270 cenButton_OnLButtonUp(
279 dwStyle = GetWindowLong(hwnd, GWL_STYLE);
280 wState = cenButton_FnStart( hwnd);
282 /* only draw up state if we captured mouse*/
283 if(GetCapture() == hwnd)
284 cenButton_SetState( hwnd, PUSH_DOWN, FALSE );
285 /* release mouse capture*/
288 /* if cursor is inside control, send clicked notification to parent*/
289 if (GET_PBWASINSIDE( hwnd)) {
290 switch((int)(dwStyle & 0x0f)) {
291 case BS_AUTOCHECKBOX:
292 SendMessage(hwnd,BM_SETCHECK,(wState & PBS_CHECKED)?0:1,0L);
294 case BS_AUTORADIOBUTTON:
295 CheckRadioButton(PARENT(hwnd),0,0xffff,hwnd->id);
298 FORWARD_WM_COMMAND( PARENT( hwnd), GetDlgCtrlID( hwnd), hwnd,
299 BN_CLICKED, SendMessage);
304 SET_PBCAPTURE( hwnd, FALSE );
305 SET_PBWASINSIDE( hwnd, FALSE );
306 cenButton_FnEnd( hwnd, wState);
310 cenButton_OnMouseMove(
316 /* WM_MOUSEMOVE is sent at every discernable mouse */
317 /* movement. It is necessary to detect this because if */
318 /* the mouse has been captured (because of a button down */
319 /* message), the location of the cursor needs to be */
320 /* tracked. If it moves out of the confines of the */
321 /* control, the control should change to the focus/up */
322 /* state (and retain capture.) If the cursor then moves */
323 /* back into the control, change back to the down state. */
328 wState = cenButton_FnStart( hwnd);
329 dwStyle = GetWindowLong(hwnd, GWL_STYLE);
330 if( GET_PBCAPTURE( hwnd)) {
331 if( !PtInsideWindow( hwnd, x, y) ) {
332 if( GET_PBWASINSIDE( hwnd)) {
333 cenButton_SetState( hwnd, PUSH_DOWN, FALSE);
334 SET_PBWASINSIDE( hwnd, FALSE );
337 if( !GET_PBWASINSIDE( hwnd) ) {
338 cenButton_SetState( hwnd, PUSH_DOWN, TRUE );
339 SET_PBWASINSIDE( hwnd, TRUE );
343 cenButton_FnEnd( hwnd, wState);
354 if( GET_PBSTATE( hwnd) & PUSH_DISABLED)
355 wEnumState = PBS_DISABLED;
356 else if( GET_PBSTATE( hwnd) & PUSH_DOWN)
357 wEnumState = PBS_FOCUSDOWN;
358 else if( GET_PBSTATE( hwnd) & PUSH_CHECKED)
359 wEnumState = PBS_CHECKED;
362 if( GET_PBSTATE( hwnd) & PUSH_FOCUS)
363 wEnumState = PBS_FOCUSUP;
366 if( GET_PBSTATE( hwnd) & PUSH_DEFAULT)
367 wEnumState |= PBS_DEFAULT;
370 /* common draw code for button and checkbox*/
371 dwStyle = GetWindowLong(hwnd, GWL_STYLE);
372 switch((int)(dwStyle & 0x0f)) {
374 DrawGroupBox( hwnd, hDCwParam, dwStyle);
377 DrawPushButton( hwnd, hDCwParam, wEnumState, dwStyle);
382 DrawPushButton(HWND hwnd,HDC hDCwParam,UINT wEnumState,DWORD dwStyle)
402 #define uiWidthFrame 0
403 #define uiWidthShadow 2
405 hdc = BeginPaint(hwnd, &ps);
409 GetWindowText(hwnd, buf, sizeof(buf));
410 GetClientRect( hwnd, &rectClient );
411 uiWidth = rectClient.right - rectClient.left;
412 uiHeight = rectClient.bottom - rectClient.top;
414 hNewBrush = (HBRUSH) GetStockObject(LTGRAY_BRUSH);
415 crOld = SetTextColor( hdc, GetSysColor( COLOR_BTNTEXT));
416 crBkOld = SetBkColor( hdc, GetSysColor( COLOR_BTNFACE));
419 switch((int)(dwStyle & 0x0f)) {
421 case BS_DEFPUSHBUTTON:
422 if( wEnumState & PBS_FOCUSDOWN) {
423 Draw3dBox(hdc, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top,
424 GetSysColor(COLOR_WINDOWFRAME), GetSysColor(COLOR_WINDOWFRAME));
426 Draw3dBox(hdc, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top,
427 GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_BTNSHADOW));
429 FastFillRect(hdc, &rc, GetSysColor(COLOR_BTNFACE));
432 if(wEnumState & PBS_DEFAULT) {
433 Draw3dBox(hdc, rc.left, rc.top,
434 rc.right-rc.left, rc.bottom-rc.top,
435 GetSysColor(COLOR_WINDOWFRAME),
436 GetSysColor(COLOR_WINDOWFRAME));
439 Draw3dBox(hdc, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top,
440 GetSysColor(COLOR_BTNHIGHLIGHT),GetSysColor(COLOR_WINDOWFRAME));
442 Draw3dBox(hdc, rc.left, rc.top, rc.right-rc.left, rc.bottom-rc.top,
443 GetSysColor(COLOR_3DLIGHT), GetSysColor(COLOR_BTNSHADOW));
445 FastFillRect(hdc, &rc, GetSysColor(COLOR_BTNFACE));
451 case BS_AUTOCHECKBOX:
452 FastFillRect(hdc, &rc, GetSysColor(COLOR_BTNFACE));
455 rc.right = rc.left + 12;
456 rc.bottom = rc.top + 12;
457 /*Draw3dBox(hdc, rc.left, rc.top, 8, 8,
458 GetSysColor(COLOR_BTNSHADOW), GetSysColor(COLOR_3DLIGHT));*/
459 Draw3dInset(hdc, rc.left, rc.top, 12, 12);
461 FastFillRect(hdc, &rc, GetSysColor(COLOR_BTNHIGHLIGHT));
463 if(wEnumState & PBS_CHECKED) {
464 MoveToEx(hdc, rc.left, rc.top,NULL);
465 LineTo(hdc, rc.right, rc.bottom);
466 MoveToEx(hdc, rc.left, rc.bottom,NULL);
467 LineTo(hdc, rc.right, rc.top);
471 case BS_AUTORADIOBUTTON:
473 FastFillRect(hdc, &rc, GetSysColor(COLOR_BTNFACE));
476 rc.right = rc.left + 10;
477 rc.bottom = rc.top + 10;
479 SelectObject(hdc, GetStockObject(NULL_BRUSH));
480 hOldPen = SelectObject(hdc, CreatePen(PS_SOLID, 1,
481 GetSysColor(COLOR_BTNSHADOW)));
482 SelectObject(hdc, GetStockObject(WHITE_BRUSH));
483 Ellipse(hdc,rc.left,rc.top, rc.right,rc.bottom);
486 SelectObject(hdc, GetStockObject(WHITE_BRUSH));
487 DeleteObject(SelectObject(hdc,
488 CreatePen(PS_SOLID, 1,GetSysColor(COLOR_WINDOWFRAME))));
489 Ellipse(hdc,rc.left,rc.top, rc.right,rc.bottom);
490 DeleteObject(SelectObject(hdc, hOldPen));
493 if(wEnumState & PBS_CHECKED)
494 Ellipse(hdc, rc.left+2, rc.top+2, rc.right-2,
503 hNewFont = GetStockObject( DEFAULT_GUI_FONT);
504 hOldFont = SelectObject( hdc, hNewFont);
506 /* calculate text bounding rect*/
509 DrawText( hdc, buf, -1, &rect, DT_CALCRECT | DT_LEFT |
510 DT_SINGLELINE | DT_TOP);
514 * calculate text draw location
516 switch((int)(dwStyle & (BS_LEFT|BS_CENTER|BS_RIGHT))) {
519 rect.left = (uiWidth - (rect.right - rect.left)) / 2
523 rect.left = uiWidthFrame + uiWidthShadow + 2
527 rect.left = (rect.right - rect.left) + uiWidthFrame
528 + uiWidthShadow + 4 + iFaceOffset;
532 switch((int)(dwStyle & 0x0f)) {
534 case BS_AUTOCHECKBOX:
535 case BS_AUTORADIOBUTTON:
541 rect.right += rect.left - rectSave.left;
543 switch((int)(dwStyle & (BS_TOP|BS_VCENTER|BS_BOTTOM))) {
546 rect.top = (uiHeight - (rect.bottom - rect.top)) / 2
550 rect.top = 2 + uiWidthFrame + uiWidthShadow
554 rect.top = uiHeight - uiWidthFrame - uiWidthShadow -
555 (rect.bottom - rect.top) - 1 + iFaceOffset;
558 switch((int)(dwStyle & 0x0f)) {
560 case BS_AUTOCHECKBOX:
561 case BS_AUTORADIOBUTTON:
566 rect.bottom += rect.top - rectSave.top;
568 oldBkMode = SetBkMode( hdc, TRANSPARENT);
569 if(wEnumState & PBS_DISABLED)
570 hOldColor = SetTextColor( hdc,
571 GetSysColor( COLOR_GRAYTEXT));
573 hOldColor = SetTextColor( hdc,
574 GetSysColor( COLOR_BTNTEXT));
576 DrawText( hdc, buf, -1, &rect,DT_LEFT | DT_SINGLELINE | DT_TOP);
578 SetBkMode( hdc, oldBkMode);
579 SetTextColor( hdc, hOldColor);
580 SelectObject( hdc, hOldFont);
584 if( (!(wEnumState&PBS_CHECKED) && (wEnumState&PBS_FOCUSDOWN)) ||
585 (wEnumState & PBS_FOCUSUP)) {
587 uiWidth = uiWidthFrame + uiWidthShadow + 2;
588 rect.left += uiWidth;
590 rect.right -= uiWidth;
591 rect.bottom -= uiWidth;
592 if((dwStyle & (BS_FLAT|BS_NOFOCUSRECT)) == 0)
593 DrawFocusRect( hdc, &rect);
597 SetTextColor( hdc, crOld);
598 SetBkColor( hdc, crBkOld);
605 cenButton_OnSetFocus(
609 /* WM_SETFOCUS is sent when the user clicks on the control */
610 /* or when the dialog manager determines that a keystroke */
611 /* should cause the control to be focused. This affects */
612 /* the appearance of the control so the state is saved for */
613 /* future drawing. */
617 wState = cenButton_FnStart( hwnd);
618 /*if(!IsWindowEnabled(hwnd))
619 cenButton_SetState( hwnd, PUSH_FOCUS, TRUE );*/
620 cenButton_FnEnd( hwnd, wState);
624 cenButton_OnSetStyle(
631 wState = cenButton_FnStart( hwnd);
632 cenButton_SetState( hwnd, PUSH_DEFAULT,
633 (style & 0x0f) == BS_DEFPUSHBUTTON);
634 cenButton_FnEnd( hwnd, wState);
638 cenButton_OnSetState(
644 wStateOld = cenButton_FnStart( hwnd);
645 cenButton_SetState( hwnd, PUSH_DOWN, (wState ? TRUE : FALSE ) );
646 cenButton_FnEnd( hwnd, wStateOld);
655 /* Turn on/off state bits according to the bEnable flag. If the */
656 /* new state is different, invalidate the client window so that */
657 /* the proper bitmap is displayed. */
663 wOldState = GET_PBSTATE( hwnd);
664 wNewState = (bEnable ? (wOldState | wState) : (wOldState & ~wState));
666 if (wOldState != wNewState)
667 { SET_PBSTATE( hwnd, wNewState );
668 GetClientRect(hwnd, &rectClient);
669 InvalidateRect(hwnd, &rectClient, FALSE);
680 BOOL bDeleteFont = FALSE;
684 /* create a thin font*/
685 if( GetObject( hFont, sizeof( logFont), &logFont) != 0) {
686 if( logFont.lfWeight != FW_NORMAL) {
687 logFont.lfWeight = FW_NORMAL;
688 if( ( hFontNew = CreateFontIndirect( &logFont)) != 0) {
695 if( GET_PBDELETEFONT( hwnd))
696 DeleteObject( GET_PBFONT( hwnd));
698 SET_PBDELETEFONT( hwnd, bDeleteFont);
699 SET_PBFONT( hwnd, hFont);
701 FORWARD_WM_SETFONT( hwnd, hFont, bRedraw, DefWindowProc);
710 /* WM_SETTEXT is sent to change the text of the button */
711 /* control. In this case we allow the default window proc */
712 /* to handle the message first. But this only affects the */
713 /* internal Windows data structure of the control, it does */
714 /* not display the change. To do this we invalidate and */
715 /* update the client area of the control which displays */
718 FORWARD_WM_SETTEXT( hwnd, lpszText, DefWindowProc);
719 InvalidateRect( hwnd, NULL, FALSE);
730 /* This is the window proc for the pushbutton control. Most of */
731 /* the drawing is accomplished in the DrawPushButton() function. */
732 /* The code below is mainly concerned with the keyboard and mouse */
733 /* events that the control detects. */
736 HANDLE_MSG( hwnd, WM_CREATE, cenButton_OnCreate);
737 /*HANDLE_MSG( hwnd, WM_ENABLE, cenButton_OnEnable);*/
738 HANDLE_MSG( hwnd, WM_SETFOCUS, cenButton_OnSetFocus);
739 HANDLE_MSG( hwnd, WM_KILLFOCUS, cenButton_OnKillFocus);
740 HANDLE_MSG( hwnd, WM_LBUTTONDOWN, cenButton_OnLButtonDown);
741 HANDLE_MSG( hwnd, WM_LBUTTONDBLCLK, cenButton_OnLButtonDown);
742 HANDLE_MSG( hwnd, WM_LBUTTONUP, cenButton_OnLButtonUp);
743 HANDLE_MSG( hwnd, WM_MOUSEMOVE, cenButton_OnMouseMove);
744 /*HANDLE_MSG( hwnd, WM_KEYDOWN, cenButton_OnKey);*/
745 /*HANDLE_MSG( hwnd, WM_KEYUP, cenButton_OnKey);*/
746 HANDLE_MSG( hwnd, WM_ERASEBKGND, cenButton_OnEraseBkgnd);
747 HANDLE_MSG( hwnd, WM_PAINT_SPECIAL, cenButton_OnPaint);
748 /*HANDLE_MSG( hwnd, WM_GETDLGCODE, cenButton_OnGetDlgCode);*/
749 HANDLE_MSG( hwnd, BM_SETSTYLE, cenButton_OnSetStyle);
750 HANDLE_MSG( hwnd, BM_GETSTATE, cenButton_OnGetState);
751 HANDLE_MSG( hwnd, BM_SETSTATE, cenButton_OnSetState);
752 /*HANDLE_MSG( hwnd, WM_DESTROY, cenButton_OnDestroy);*/
753 /*HANDLE_MSG( hwnd, WM_SETFONT, cenButton_OnSetFont);*/
754 HANDLE_MSG( hwnd, WM_SETTEXT, cenButton_OnSetText);
758 return cenButton_OnGetState(hwnd);
760 return( ( GET_PBSTATE(hwnd) & PUSH_CHECKED) == PUSH_CHECKED);
765 cenButton_OnSetState(hwnd, (WORD)wParam);
770 wStateOld = cenButton_FnStart( hwnd);
771 cenButton_SetState( hwnd, PUSH_CHECKED,
772 ((WORD)wParam ? TRUE : FALSE) );
773 cenButton_FnEnd( hwnd, wStateOld);
779 return DefWindowProc( hwnd, message, wParam, lParam);
782 /* backwards compatibility*/
784 MwButtonRegister(HINSTANCE hInstance)
786 return MwRegisterButtonControl(hInstance);
790 MwRegisterButtonControl(HINSTANCE hInstance)
794 wc.style = CS_HREDRAW | CS_VREDRAW | CS_DBLCLKS | CS_GLOBALCLASS;
795 wc.lpfnWndProc = (WNDPROC)cenButtonWndFn;
798 wc.hInstance = hInstance;
800 wc.hCursor = 0; /*LoadCursor(NULL, IDC_ARROW);*/
801 wc.hbrBackground= GetStockObject(LTGRAY_BRUSH);
802 wc.lpszMenuName = NULL;
803 wc.lpszClassName= "BUTTON";
805 return RegisterClass(&wc);
809 DrawGroupBox(HWND hwnd,HDC hDCwParam,DWORD dwStyle)
818 HPEN hPenTop, hPenBottom, holdPen;
819 COLORREF crTop,crBottom;
822 hdc = BeginPaint(hwnd, &ps);
826 GetWindowText(hwnd, buf, sizeof(buf));
827 GetClientRect( hwnd, &rcClient );
829 hFont = GetStockObject( DEFAULT_GUI_FONT);
831 hFont = SelectObject(hdc,hFont);
835 DrawText( hdc, buf, -1, &rc, DT_CALCRECT);
838 SetTextColor(hdc,GetSysColor(COLOR_WINDOWTEXT));
839 SetBkMode(hdc,TRANSPARENT);
840 SetRect(&rcText,8,2,rc.right+8,rc.bottom+2);
841 DrawText(hdc,buf,-1,&rcText,DT_CENTER);
844 crTop=GetSysColor(COLOR_BTNHIGHLIGHT);
845 crBottom=GetSysColor(COLOR_BTNSHADOW);
847 hPenTop = CreatePen( PS_SOLID, 1, crTop);
848 hPenBottom = CreatePen( PS_SOLID, 1, crBottom);
849 holdPen = SelectObject( hdc, hPenTop);
851 MoveToEx(hdc,0,rc.bottom/2,NULL);
854 LineTo(hdc,5,rc.bottom/2);
855 MoveToEx(hdc,rc.right+11,rc.bottom/2,NULL);
856 LineTo(hdc,rcClient.right-1,rc.bottom/2);
859 LineTo(hdc,rcClient.right-1,rc.bottom/2);
861 LineTo(hdc,rcClient.right-1,rcClient.bottom-1);
863 SelectObject( hdc, hPenBottom);
864 LineTo(hdc,rcClient.left,rcClient.bottom-1);
865 LineTo(hdc,rcClient.left,rc.bottom/2);
867 SelectObject( hdc, holdPen);
868 DeleteObject( hPenTop);
869 DeleteObject( hPenBottom);
872 SelectObject(hdc,hFont);
878 /* temporarily here, should move to winuser.c*/
880 CheckRadioButton(HWND hDlg, int nIDFirst,int nIDLast,int nIDCheckButton)
882 HWND hWndCheck,hWndTemp;
885 if (!(hWndCheck = GetDlgItem(hDlg,nIDCheckButton)))
888 for(hWndTemp=hDlg->children; hWndTemp; hWndTemp=hWndTemp->siblings) {
889 if(hWndCheck == hWndTemp) continue;
890 dwStyle = GetWindowLong(hWndTemp,GWL_STYLE);
891 if ((hWndTemp->id >= (WORD)nIDFirst) &&
892 (hWndTemp->id <= (WORD)nIDLast) &&
893 ((LOWORD(dwStyle) == BS_RADIOBUTTON) ||
894 (LOWORD(dwStyle) == BS_AUTORADIOBUTTON)))
895 SendMessage(hWndTemp,BM_SETCHECK,FALSE,0);
897 SendMessage(hWndCheck,BM_SETCHECK,TRUE,0);