5 FlatComboProc(HWND hwnd
,
15 WNDPROC OldComboProc
= (WNDPROC
)GetWindowLongPtr(hwnd
, GWLP_USERDATA
);
17 static BOOL fMouseDown
= FALSE
;
18 static BOOL fButtonDown
= FALSE
;
24 if(wParam
== 0) hdc
= BeginPaint(hwnd
, &ps
);
25 else hdc
= (HDC
)wParam
;
27 /* mask off the borders and draw ComboBox normally */
28 GetClientRect(hwnd
, &rect
);
31 -GetSystemMetrics(SM_CXEDGE
)*2,
32 -GetSystemMetrics(SM_CYEDGE
)*2);
34 rect
.right
-= GetSystemMetrics(SM_CXVSCROLL
);
36 IntersectClipRect(hdc
,
42 /* Draw the ComboBox */
43 CallWindowProc(OldComboProc
,
49 /* Now mask off inside and draw the borders */
52 rect
.right
+= GetSystemMetrics(SM_CXVSCROLL
);
65 //CreateSolidBrush(RGB(0,0,0)));
66 GetSysColorBrush(COLOR_3DFACE
));
68 /* now draw the button */
71 rect
.left
= rect
.right
- GetSystemMetrics(SM_CXVSCROLL
);
79 FillRect(hdc
, &rect
, CreateSolidBrush(RGB(182,189,210)));
82 FrameRect(hdc
, &rect
, GetStockBrush(WHITE_BRUSH
));
84 pt
[0].x
= rect
.right
- ((GetSystemMetrics(SM_CXVSCROLL
) / 2) + 2);
85 pt
[0].y
= rect
.bottom
/ 2;
86 pt
[1].x
= pt
[0].x
+ 4;
88 pt
[2].x
= pt
[1].x
- 2;
89 pt
[2].y
= pt
[1].y
+ 2;
91 oldPen
= (HPEN
) SelectObject(hdc
, GetStockPen(WHITE_PEN
));
92 oldBrush
= (HBRUSH
) SelectObject(hdc
, GetStockBrush(WHITE_BRUSH
));
95 SelectObject(hdc
, oldPen
);
96 SelectObject(hdc
, oldBrush
);
103 FillRect(hdc
, &rect
, GetSysColorBrush(COLOR_3DFACE
));
106 FrameRect(hdc
, &rect
, GetStockBrush(WHITE_BRUSH
));
108 pt
[0].x
= rect
.right
- ((GetSystemMetrics(SM_CXVSCROLL
) / 2) + 2);
109 pt
[0].y
= rect
.bottom
/ 2;
110 pt
[1].x
= pt
[0].x
+ 4;
112 pt
[2].x
= pt
[1].x
- 2;
113 pt
[2].y
= pt
[1].y
+ 2;
115 oldBrush
= (HBRUSH
) SelectObject(hdc
, GetStockBrush(BLACK_BRUSH
));
118 SelectObject(hdc
, oldBrush
);
128 /* check if mouse is within drop-arrow area, toggle
129 * a flag to say if the mouse is up/down. Then invalidate
130 * the window so it redraws to show the changes. */
131 case WM_LBUTTONDBLCLK
:
135 pt
.x
= (short)LOWORD(lParam
);
136 pt
.y
= (short)HIWORD(lParam
);
138 GetClientRect(hwnd
, &rect
);
141 -GetSystemMetrics(SM_CXEDGE
),
142 -GetSystemMetrics(SM_CYEDGE
));
143 rect
.left
= rect
.right
- GetSystemMetrics(SM_CXVSCROLL
);
145 if(PtInRect(&rect
, pt
))
147 /* we *should* call SetCapture, but the ComboBox does it for us */
150 InvalidateRect(hwnd
, 0, 0);
155 /* mouse has moved. Check to see if it is in/out of the drop-arrow */
159 pt
.x
= (short)LOWORD(lParam
);
160 pt
.y
= (short)HIWORD(lParam
);
162 if(fMouseDown
&& (wParam
& MK_LBUTTON
))
164 GetClientRect(hwnd
, &rect
);
166 InflateRect(&rect
, -GetSystemMetrics(SM_CXEDGE
), -GetSystemMetrics(SM_CYEDGE
));
167 rect
.left
= rect
.right
- GetSystemMetrics(SM_CXVSCROLL
);
169 if(fButtonDown
!= PtInRect(&rect
, pt
))
171 fButtonDown
= PtInRect(&rect
, pt
);
172 InvalidateRect(hwnd
, 0, 0);
183 /* No need to call ReleaseCapture, the ComboBox does it for us */
186 InvalidateRect(hwnd
, 0, 0);
192 return CallWindowProc(OldComboProc
,
199 VOID
MakeFlatCombo(HWND hwndCombo
)
201 LONG_PTR OldComboProc
;
203 /* Remember old window procedure */
204 OldComboProc
= GetWindowLongPtr(hwndCombo
, GWLP_WNDPROC
);
205 SetWindowLongPtr(hwndCombo
,
209 /* Perform the subclass */
210 SetWindowLongPtr(hwndCombo
,
212 (LONG_PTR
)FlatComboProc
);