-#include <precomp.h>\r
-\r
-\r
-LRESULT WINAPI\r
-FlatComboProc(HWND hwnd,\r
- UINT msg,\r
- WPARAM wParam,\r
- LPARAM lParam)\r
-{\r
- HDC hdc;\r
- PAINTSTRUCT ps;\r
- RECT rect, rect2;\r
- POINT pt;\r
-\r
- WNDPROC OldComboProc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_USERDATA);\r
-\r
- static BOOL fMouseDown = FALSE;\r
- static BOOL fButtonDown = FALSE;\r
-\r
- switch(msg)\r
- {\r
- case WM_PAINT:\r
- {\r
- if(wParam == 0) hdc = BeginPaint(hwnd, &ps);\r
- else hdc = (HDC)wParam;\r
-\r
- /* mask off the borders and draw ComboBox normally */\r
- GetClientRect(hwnd, &rect);\r
-\r
- InflateRect(&rect,\r
- -GetSystemMetrics(SM_CXEDGE)*2,\r
- -GetSystemMetrics(SM_CYEDGE)*2);\r
-\r
- rect.right -= GetSystemMetrics(SM_CXVSCROLL);\r
-\r
- IntersectClipRect(hdc,\r
- rect.left,\r
- rect.top,\r
- rect.right,\r
- rect.bottom);\r
-\r
- /* Draw the ComboBox */\r
- CallWindowProc(OldComboProc,\r
- hwnd,\r
- msg,\r
- (WPARAM)hdc,\r
- lParam);\r
-\r
- /* Now mask off inside and draw the borders */\r
- SelectClipRgn(hdc,\r
- NULL);\r
- rect.right += GetSystemMetrics(SM_CXVSCROLL);\r
-\r
- ExcludeClipRect(hdc,\r
- rect.left,\r
- rect.top,\r
- rect.right,\r
- rect.bottom);\r
-\r
- /* draw borders */\r
- GetClientRect(hwnd,\r
- &rect2);\r
- FillRect(hdc,\r
- &rect2,\r
- //CreateSolidBrush(RGB(0,0,0)));\r
- GetSysColorBrush(COLOR_3DFACE));\r
-\r
- /* now draw the button */\r
- SelectClipRgn(hdc,\r
- NULL);\r
- rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);\r
-\r
- if(fButtonDown)\r
- {\r
- HBRUSH oldBrush;\r
- HPEN oldPen;\r
- POINT pt[3];\r
-\r
- FillRect(hdc, &rect, CreateSolidBrush(RGB(182,189,210)));\r
- rect.top -= 1;\r
- rect.bottom += 1;\r
- FrameRect(hdc, &rect, GetStockBrush(WHITE_BRUSH));\r
-\r
- pt[0].x = rect.right - ((GetSystemMetrics(SM_CXVSCROLL) / 2) + 2);\r
- pt[0].y = rect.bottom / 2;\r
- pt[1].x = pt[0].x + 4;\r
- pt[1].y = pt[0].y;\r
- pt[2].x = pt[1].x - 2;\r
- pt[2].y = pt[1].y + 2;\r
-\r
- oldPen = (HPEN) SelectObject(hdc, GetStockPen(WHITE_PEN));\r
- oldBrush = (HBRUSH) SelectObject(hdc, GetStockBrush(WHITE_BRUSH));\r
- Polygon(hdc, pt, 3);\r
-\r
- SelectObject(hdc, oldPen);\r
- SelectObject(hdc, oldBrush);\r
- }\r
- else\r
- {\r
- HBRUSH oldBrush;\r
- POINT pt[3];\r
-\r
- FillRect(hdc, &rect, GetSysColorBrush(COLOR_3DFACE));\r
- rect.top -= 1;\r
- rect.bottom += 1;\r
- FrameRect(hdc, &rect, GetStockBrush(WHITE_BRUSH));\r
-\r
- pt[0].x = rect.right - ((GetSystemMetrics(SM_CXVSCROLL) / 2) + 2);\r
- pt[0].y = rect.bottom / 2;\r
- pt[1].x = pt[0].x + 4;\r
- pt[1].y = pt[0].y;\r
- pt[2].x = pt[1].x - 2;\r
- pt[2].y = pt[1].y + 2;\r
-\r
- oldBrush = (HBRUSH) SelectObject(hdc, GetStockBrush(BLACK_BRUSH));\r
- Polygon(hdc, pt, 3);\r
-\r
- SelectObject(hdc, oldBrush);\r
- }\r
-\r
-\r
- if(wParam == 0)\r
- EndPaint(hwnd, &ps);\r
-\r
- return 0;\r
- }\r
-\r
- /* check if mouse is within drop-arrow area, toggle\r
- * a flag to say if the mouse is up/down. Then invalidate\r
- * the window so it redraws to show the changes. */\r
- case WM_LBUTTONDBLCLK:\r
- case WM_LBUTTONDOWN:\r
- {\r
-\r
- pt.x = (short)LOWORD(lParam);\r
- pt.y = (short)HIWORD(lParam);\r
-\r
- GetClientRect(hwnd, &rect);\r
-\r
- InflateRect(&rect,\r
- -GetSystemMetrics(SM_CXEDGE),\r
- -GetSystemMetrics(SM_CYEDGE));\r
- rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);\r
-\r
- if(PtInRect(&rect, pt))\r
- {\r
- /* we *should* call SetCapture, but the ComboBox does it for us */\r
- fMouseDown = TRUE;\r
- fButtonDown = TRUE;\r
- InvalidateRect(hwnd, 0, 0);\r
- }\r
- }\r
- break;\r
-\r
- /* mouse has moved. Check to see if it is in/out of the drop-arrow */\r
- case WM_MOUSEMOVE:\r
- {\r
-\r
- pt.x = (short)LOWORD(lParam);\r
- pt.y = (short)HIWORD(lParam);\r
-\r
- if(fMouseDown && (wParam & MK_LBUTTON))\r
- {\r
- GetClientRect(hwnd, &rect);\r
-\r
- InflateRect(&rect, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE));\r
- rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);\r
-\r
- if(fButtonDown != PtInRect(&rect, pt))\r
- {\r
- fButtonDown = PtInRect(&rect, pt);\r
- InvalidateRect(hwnd, 0, 0);\r
- }\r
- }\r
- }\r
- break;\r
-\r
- case WM_LBUTTONUP:\r
- {\r
-\r
- if(fMouseDown)\r
- {\r
- /* No need to call ReleaseCapture, the ComboBox does it for us */\r
- fMouseDown = FALSE;\r
- fButtonDown = FALSE;\r
- InvalidateRect(hwnd, 0, 0);\r
- }\r
- }\r
- break;\r
- }\r
-\r
- return CallWindowProc(OldComboProc,\r
- hwnd,\r
- msg,\r
- wParam,\r
- lParam);\r
-}\r
-\r
-VOID MakeFlatCombo(HWND hwndCombo)\r
-{\r
- LONG_PTR OldComboProc;\r
-\r
- /* Remember old window procedure */\r
- OldComboProc = GetWindowLongPtr(hwndCombo, GWLP_WNDPROC);\r
- SetWindowLongPtr(hwndCombo,\r
- GWLP_USERDATA,\r
- OldComboProc);\r
-\r
- /* Perform the subclass */\r
- SetWindowLongPtr(hwndCombo,\r
- GWLP_WNDPROC,\r
- (LONG_PTR)FlatComboProc);\r
-}\r
+#include <precomp.h>
+
+
+LRESULT WINAPI
+FlatComboProc(HWND hwnd,
+ UINT msg,
+ WPARAM wParam,
+ LPARAM lParam)
+{
+ HDC hdc;
+ PAINTSTRUCT ps;
+ RECT rect, rect2;
+ POINT pt;
+
+ WNDPROC OldComboProc = (WNDPROC)GetWindowLongPtr(hwnd, GWLP_USERDATA);
+
+ static BOOL fMouseDown = FALSE;
+ static BOOL fButtonDown = FALSE;
+
+ switch(msg)
+ {
+ case WM_PAINT:
+ {
+ if(wParam == 0) hdc = BeginPaint(hwnd, &ps);
+ else hdc = (HDC)wParam;
+
+ /* mask off the borders and draw ComboBox normally */
+ GetClientRect(hwnd, &rect);
+
+ InflateRect(&rect,
+ -GetSystemMetrics(SM_CXEDGE)*2,
+ -GetSystemMetrics(SM_CYEDGE)*2);
+
+ rect.right -= GetSystemMetrics(SM_CXVSCROLL);
+
+ IntersectClipRect(hdc,
+ rect.left,
+ rect.top,
+ rect.right,
+ rect.bottom);
+
+ /* Draw the ComboBox */
+ CallWindowProc(OldComboProc,
+ hwnd,
+ msg,
+ (WPARAM)hdc,
+ lParam);
+
+ /* Now mask off inside and draw the borders */
+ SelectClipRgn(hdc,
+ NULL);
+ rect.right += GetSystemMetrics(SM_CXVSCROLL);
+
+ ExcludeClipRect(hdc,
+ rect.left,
+ rect.top,
+ rect.right,
+ rect.bottom);
+
+ /* draw borders */
+ GetClientRect(hwnd,
+ &rect2);
+ FillRect(hdc,
+ &rect2,
+ //CreateSolidBrush(RGB(0,0,0)));
+ GetSysColorBrush(COLOR_3DFACE));
+
+ /* now draw the button */
+ SelectClipRgn(hdc,
+ NULL);
+ rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);
+
+ if(fButtonDown)
+ {
+ HBRUSH oldBrush;
+ HPEN oldPen;
+ POINT pt[3];
+
+ FillRect(hdc, &rect, CreateSolidBrush(RGB(182,189,210)));
+ rect.top -= 1;
+ rect.bottom += 1;
+ FrameRect(hdc, &rect, GetStockBrush(WHITE_BRUSH));
+
+ pt[0].x = rect.right - ((GetSystemMetrics(SM_CXVSCROLL) / 2) + 2);
+ pt[0].y = rect.bottom / 2;
+ pt[1].x = pt[0].x + 4;
+ pt[1].y = pt[0].y;
+ pt[2].x = pt[1].x - 2;
+ pt[2].y = pt[1].y + 2;
+
+ oldPen = (HPEN) SelectObject(hdc, GetStockPen(WHITE_PEN));
+ oldBrush = (HBRUSH) SelectObject(hdc, GetStockBrush(WHITE_BRUSH));
+ Polygon(hdc, pt, 3);
+
+ SelectObject(hdc, oldPen);
+ SelectObject(hdc, oldBrush);
+ }
+ else
+ {
+ HBRUSH oldBrush;
+ POINT pt[3];
+
+ FillRect(hdc, &rect, GetSysColorBrush(COLOR_3DFACE));
+ rect.top -= 1;
+ rect.bottom += 1;
+ FrameRect(hdc, &rect, GetStockBrush(WHITE_BRUSH));
+
+ pt[0].x = rect.right - ((GetSystemMetrics(SM_CXVSCROLL) / 2) + 2);
+ pt[0].y = rect.bottom / 2;
+ pt[1].x = pt[0].x + 4;
+ pt[1].y = pt[0].y;
+ pt[2].x = pt[1].x - 2;
+ pt[2].y = pt[1].y + 2;
+
+ oldBrush = (HBRUSH) SelectObject(hdc, GetStockBrush(BLACK_BRUSH));
+ Polygon(hdc, pt, 3);
+
+ SelectObject(hdc, oldBrush);
+ }
+
+
+ if(wParam == 0)
+ EndPaint(hwnd, &ps);
+
+ return 0;
+ }
+
+ /* check if mouse is within drop-arrow area, toggle
+ * a flag to say if the mouse is up/down. Then invalidate
+ * the window so it redraws to show the changes. */
+ case WM_LBUTTONDBLCLK:
+ case WM_LBUTTONDOWN:
+ {
+
+ pt.x = (short)LOWORD(lParam);
+ pt.y = (short)HIWORD(lParam);
+
+ GetClientRect(hwnd, &rect);
+
+ InflateRect(&rect,
+ -GetSystemMetrics(SM_CXEDGE),
+ -GetSystemMetrics(SM_CYEDGE));
+ rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);
+
+ if(PtInRect(&rect, pt))
+ {
+ /* we *should* call SetCapture, but the ComboBox does it for us */
+ fMouseDown = TRUE;
+ fButtonDown = TRUE;
+ InvalidateRect(hwnd, 0, 0);
+ }
+ }
+ break;
+
+ /* mouse has moved. Check to see if it is in/out of the drop-arrow */
+ case WM_MOUSEMOVE:
+ {
+
+ pt.x = (short)LOWORD(lParam);
+ pt.y = (short)HIWORD(lParam);
+
+ if(fMouseDown && (wParam & MK_LBUTTON))
+ {
+ GetClientRect(hwnd, &rect);
+
+ InflateRect(&rect, -GetSystemMetrics(SM_CXEDGE), -GetSystemMetrics(SM_CYEDGE));
+ rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);
+
+ if(fButtonDown != PtInRect(&rect, pt))
+ {
+ fButtonDown = PtInRect(&rect, pt);
+ InvalidateRect(hwnd, 0, 0);
+ }
+ }
+ }
+ break;
+
+ case WM_LBUTTONUP:
+ {
+
+ if(fMouseDown)
+ {
+ /* No need to call ReleaseCapture, the ComboBox does it for us */
+ fMouseDown = FALSE;
+ fButtonDown = FALSE;
+ InvalidateRect(hwnd, 0, 0);
+ }
+ }
+ break;
+ }
+
+ return CallWindowProc(OldComboProc,
+ hwnd,
+ msg,
+ wParam,
+ lParam);
+}
+
+VOID MakeFlatCombo(HWND hwndCombo)
+{
+ LONG_PTR OldComboProc;
+
+ /* Remember old window procedure */
+ OldComboProc = GetWindowLongPtr(hwndCombo, GWLP_WNDPROC);
+ SetWindowLongPtr(hwndCombo,
+ GWLP_USERDATA,
+ OldComboProc);
+
+ /* Perform the subclass */
+ SetWindowLongPtr(hwndCombo,
+ GWLP_WNDPROC,
+ (LONG_PTR)FlatComboProc);
+}