26 typedef struct _PHP_COLORBOX_CONTEXT
28 COLORREF SelectedColor;
44 WNDCLASSEX c = {
sizeof(c) };
46 c.style = CS_GLOBALCLASS;
49 c.cbWndExtra =
sizeof(PVOID);
52 c.hCursor = LoadCursor(NULL, IDC_ARROW);
53 c.hbrBackground = NULL;
54 c.lpszMenuName = NULL;
58 if (!RegisterClassEx(&c))
87 CHOOSECOLOR chooseColor = {
sizeof(chooseColor) };
88 COLORREF customColors[16] = { 0 };
90 chooseColor.hwndOwner = hwnd;
91 chooseColor.rgbResult = Context->SelectedColor;
92 chooseColor.lpCustColors = customColors;
93 chooseColor.Flags = CC_ANYCOLOR | CC_FULLOPEN | CC_RGBINIT;
95 if (ChooseColor(&chooseColor))
97 Context->SelectedColor = chooseColor.rgbResult;
98 InvalidateRect(hwnd, NULL,
TRUE);
113 if (uMsg == WM_CREATE)
116 SetWindowLongPtr(hwnd, 0, (LONG_PTR)context);
120 return DefWindowProc(hwnd, uMsg, wParam, lParam);
132 SetWindowLongPtr(hwnd, 0, (LONG_PTR)NULL);
137 PAINTSTRUCT paintStruct;
141 if (hdc = BeginPaint(hwnd, &paintStruct))
143 GetClientRect(hwnd, &clientRect);
146 SetDCPenColor(hdc, RGB(0x44, 0x44, 0x44));
149 if (!context->Hot && !context->HasFocus)
150 SetDCBrushColor(hdc, context->SelectedColor);
155 SelectObject(hdc, GetStockObject(DC_PEN));
156 SelectObject(hdc, GetStockObject(DC_BRUSH));
157 Rectangle(hdc, clientRect.left, clientRect.top, clientRect.right, clientRect.bottom);
159 EndPaint(hwnd, &paintStruct);
169 TRACKMOUSEEVENT trackMouseEvent = {
sizeof(trackMouseEvent) };
172 InvalidateRect(hwnd, NULL,
TRUE);
174 trackMouseEvent.dwFlags = TME_LEAVE;
175 trackMouseEvent.hwndTrack = hwnd;
176 TrackMouseEvent(&trackMouseEvent);
182 context->Hot =
FALSE;
183 InvalidateRect(hwnd, NULL,
TRUE);
193 context->HasFocus =
TRUE;
194 InvalidateRect(hwnd, NULL,
TRUE);
199 context->HasFocus =
FALSE;
200 InvalidateRect(hwnd, NULL,
TRUE);
204 if (wParam == VK_RETURN)
205 return DLGC_WANTMESSAGE;
219 context->SelectedColor = (COLORREF)wParam;
222 return (LRESULT)context->SelectedColor;
225 return DefWindowProc(hwnd, uMsg, wParam, lParam);