ReactOS  0.4.14-dev-49-gfb4591c
custcombo.c
Go to the documentation of this file.
1 #include <precomp.h>
2 
3 
6  UINT msg,
9 {
10  HDC hdc;
11  PAINTSTRUCT ps;
12  RECT rect, rect2;
13  POINT pt;
14 
16 
17  static BOOL fMouseDown = FALSE;
18  static BOOL fButtonDown = FALSE;
19 
20  switch(msg)
21  {
22  case WM_PAINT:
23  {
24  if(wParam == 0) hdc = BeginPaint(hwnd, &ps);
25  else hdc = (HDC)wParam;
26 
27  /* mask off the borders and draw ComboBox normally */
29 
33 
35 
37  rect.left,
38  rect.top,
39  rect.right,
40  rect.bottom);
41 
42  /* Draw the ComboBox */
43  CallWindowProc(OldComboProc,
44  hwnd,
45  msg,
46  (WPARAM)hdc,
47  lParam);
48 
49  /* Now mask off inside and draw the borders */
51  NULL);
53 
55  rect.left,
56  rect.top,
57  rect.right,
58  rect.bottom);
59 
60  /* draw borders */
62  &rect2);
63  FillRect(hdc,
64  &rect2,
65  //CreateSolidBrush(RGB(0,0,0)));
67 
68  /* now draw the button */
70  NULL);
71  rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);
72 
73  if(fButtonDown)
74  {
75  HBRUSH oldBrush;
76  HPEN oldPen;
77  POINT pt[3];
78 
79  FillRect(hdc, &rect, CreateSolidBrush(RGB(182,189,210)));
80  rect.top -= 1;
81  rect.bottom += 1;
83 
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;
87  pt[1].y = pt[0].y;
88  pt[2].x = pt[1].x - 2;
89  pt[2].y = pt[1].y + 2;
90 
91  oldPen = (HPEN) SelectObject(hdc, GetStockPen(WHITE_PEN));
92  oldBrush = (HBRUSH) SelectObject(hdc, GetStockBrush(WHITE_BRUSH));
93  Polygon(hdc, pt, 3);
94 
95  SelectObject(hdc, oldPen);
96  SelectObject(hdc, oldBrush);
97  }
98  else
99  {
100  HBRUSH oldBrush;
101  POINT pt[3];
102 
104  rect.top -= 1;
105  rect.bottom += 1;
107 
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;
111  pt[1].y = pt[0].y;
112  pt[2].x = pt[1].x - 2;
113  pt[2].y = pt[1].y + 2;
114 
115  oldBrush = (HBRUSH) SelectObject(hdc, GetStockBrush(BLACK_BRUSH));
116  Polygon(hdc, pt, 3);
117 
118  SelectObject(hdc, oldBrush);
119  }
120 
121 
122  if(wParam == 0)
123  EndPaint(hwnd, &ps);
124 
125  return 0;
126  }
127 
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:
132  case WM_LBUTTONDOWN:
133  {
134 
135  pt.x = (short)LOWORD(lParam);
136  pt.y = (short)HIWORD(lParam);
137 
139 
140  InflateRect(&rect,
143  rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);
144 
145  if(PtInRect(&rect, pt))
146  {
147  /* we *should* call SetCapture, but the ComboBox does it for us */
148  fMouseDown = TRUE;
149  fButtonDown = TRUE;
150  InvalidateRect(hwnd, 0, 0);
151  }
152  }
153  break;
154 
155  /* mouse has moved. Check to see if it is in/out of the drop-arrow */
156  case WM_MOUSEMOVE:
157  {
158 
159  pt.x = (short)LOWORD(lParam);
160  pt.y = (short)HIWORD(lParam);
161 
162  if(fMouseDown && (wParam & MK_LBUTTON))
163  {
165 
167  rect.left = rect.right - GetSystemMetrics(SM_CXVSCROLL);
168 
169  if(fButtonDown != PtInRect(&rect, pt))
170  {
171  fButtonDown = PtInRect(&rect, pt);
172  InvalidateRect(hwnd, 0, 0);
173  }
174  }
175  }
176  break;
177 
178  case WM_LBUTTONUP:
179  {
180 
181  if(fMouseDown)
182  {
183  /* No need to call ReleaseCapture, the ComboBox does it for us */
184  fMouseDown = FALSE;
185  fButtonDown = FALSE;
186  InvalidateRect(hwnd, 0, 0);
187  }
188  }
189  break;
190  }
191 
192  return CallWindowProc(OldComboProc,
193  hwnd,
194  msg,
195  wParam,
196  lParam);
197 }
198 
200 {
201  LONG_PTR OldComboProc;
202 
203  /* Remember old window procedure */
204  OldComboProc = GetWindowLongPtr(hwndCombo, GWLP_WNDPROC);
205  SetWindowLongPtr(hwndCombo,
207  OldComboProc);
208 
209  /* Perform the subclass */
210  SetWindowLongPtr(hwndCombo,
211  GWLP_WNDPROC,
213 }
#define CallWindowProc
Definition: winuser.h:5636
RECT rect2
Definition: edittest.c:51
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
BOOL WINAPI InflateRect(_Inout_ LPRECT, _In_ int, _In_ int)
#define TRUE
Definition: types.h:120
int WINAPI SelectClipRgn(_In_ HDC, _In_opt_ HRGN)
#define WM_LBUTTONDOWN
Definition: winuser.h:1758
BOOL Polygon(CONST PPOINT UnsafePoints, int Count, int polyFillMode)
Definition: polytest.cpp:730
#define MK_LBUTTON
Definition: winuser.h:2342
#define pt(x, y)
Definition: drawing.c:79
#define WHITE_PEN
Definition: wingdi.h:904
static HDC
Definition: imagelist.c:92
int WINAPI IntersectClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
#define SM_CXEDGE
Definition: winuser.h:998
#define WHITE_BRUSH
Definition: wingdi.h:901
UINT_PTR WPARAM
Definition: windef.h:207
BOOL WINAPI EndPaint(_In_ HWND, _In_ const PAINTSTRUCT *)
#define SetWindowLongPtr
Definition: treelist.c:70
& rect
Definition: startmenu.cpp:1413
WPARAM wParam
Definition: combotst.c:138
unsigned short(__cdecl typeof(TIFFCurrentDirectory))(struct tiff *)
Definition: typeof.h:93
#define COLOR_3DFACE
Definition: winuser.h:919
unsigned int BOOL
Definition: ntddk_ex.h:94
HDC WINAPI BeginPaint(_In_ HWND, _Out_ LPPAINTSTRUCT)
#define GWLP_USERDATA
Definition: treelist.c:63
smooth NULL
Definition: ftsmooth.c:416
LONG_PTR LPARAM
Definition: windef.h:208
#define SM_CYEDGE
Definition: winuser.h:999
#define BLACK_BRUSH
Definition: wingdi.h:895
#define GetStockBrush(i)
Definition: windowsx.h:282
#define RGB(r, g, b)
Definition: wingdi.h:2935
#define WINAPI
Definition: msvc.h:8
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
int WINAPI GetSystemMetrics(_In_ int)
#define GetStockPen(i)
Definition: windowsx.h:284
#define WM_PAINT
Definition: winuser.h:1602
LRESULT WINAPI FlatComboProc(HWND hwnd, UINT msg, WPARAM wParam, LPARAM lParam)
Definition: custcombo.c:5
HDC hdc
Definition: main.c:9
#define WM_LBUTTONDBLCLK
Definition: winuser.h:1760
VOID MakeFlatCombo(HWND hwndCombo)
Definition: custcombo.c:199
#define GWLP_WNDPROC
Definition: treelist.c:66
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2880
BOOL WINAPI GetClientRect(_In_ HWND, _Out_ LPRECT)
int WINAPI ExcludeClipRect(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define WM_LBUTTONUP
Definition: winuser.h:1759
__int3264 LONG_PTR
Definition: mstsclib_h.h:276
unsigned int UINT
Definition: ndis.h:50
#define WM_MOUSEMOVE
Definition: winuser.h:1757
HBRUSH WINAPI CreateSolidBrush(_In_ COLORREF)
#define SM_CXVSCROLL
Definition: winuser.h:951
BOOL WINAPI PtInRect(_In_ LPCRECT, _In_ POINT)
#define msg(x)
Definition: auth_time.c:54
#define HIWORD(l)
Definition: typedefs.h:246
#define GetWindowLongPtr
Definition: treelist.c:73
LONG_PTR LRESULT
Definition: windef.h:209
int WINAPI FillRect(HDC, LPCRECT, HBRUSH)
HBRUSH WINAPI GetSysColorBrush(_In_ int)
LPARAM lParam
Definition: combotst.c:139
#define LOWORD(l)
Definition: pedump.c:82
int WINAPI FrameRect(_In_ HDC, _In_ LPCRECT, _In_ HBRUSH)