2 * COMMDLG - Color Dialog
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
22 /* BUGS : still seems to not refresh correctly
23 sometimes, especially when 2 instances of the
24 dialog are loaded at the same time */
34 #include "wine/debug.h"
38 WINE_DEFAULT_DEBUG_CHANNEL(commdlg
);
40 static INT_PTR CALLBACK
ColorDlgProc( HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
);
42 #define CONV_LPARAMTOPOINT(lp,p) do { (p)->x = (short)LOWORD(lp); (p)->y = (short)HIWORD(lp); } while(0)
44 static const COLORREF predefcolors
[6][8]=
46 { 0x008080FFL
, 0x0080FFFFL
, 0x0080FF80L
, 0x0080FF00L
,
47 0x00FFFF80L
, 0x00FF8000L
, 0x00C080FFL
, 0x00FF80FFL
},
48 { 0x000000FFL
, 0x0000FFFFL
, 0x0000FF80L
, 0x0040FF00L
,
49 0x00FFFF00L
, 0x00C08000L
, 0x00C08080L
, 0x00FF00FFL
},
51 { 0x00404080L
, 0x004080FFL
, 0x0000FF00L
, 0x00808000L
,
52 0x00804000L
, 0x00FF8080L
, 0x00400080L
, 0x008000FFL
},
53 { 0x00000080L
, 0x000080FFL
, 0x00008000L
, 0x00408000L
,
54 0x00FF0000L
, 0x00A00000L
, 0x00800080L
, 0x00FF0080L
},
56 { 0x00000040L
, 0x00004080L
, 0x00004000L
, 0x00404000L
,
57 0x00800000L
, 0x00400000L
, 0x00400040L
, 0x00800040L
},
58 { 0x00000000L
, 0x00008080L
, 0x00408080L
, 0x00808080L
,
59 0x00808040L
, 0x00C0C0C0L
, 0x00400040L
, 0x00FFFFFFL
},
62 static const WCHAR szColourDialogProp
[] = {
63 'c','o','l','o','u','r','d','i','a','l','o','g','p','r','o','p',0 };
65 /* Chose Color PRIVATE Structure:
67 * This structure is duplicated in the 16 bit code with
71 typedef struct CCPRIVATE
73 LPCHOOSECOLORW lpcc
; /* points to public known data structure */
74 HWND hwndSelf
; /* dialog window */
75 int nextuserdef
; /* next free place in user defined color array */
76 HDC hdcMem
; /* color graph used for BitBlt() */
77 HBITMAP hbmMem
; /* color graph bitmap */
78 RECT fullsize
; /* original dialog window size */
79 UINT msetrgb
; /* # of SETRGBSTRING message (today not used) */
80 RECT old3angle
; /* last position of l-marker */
81 RECT oldcross
; /* last position of color/saturation marker */
82 BOOL updating
; /* to prevent recursive WM_COMMAND/EN_UPDATE processing */
85 int l
; /* for temporary storing of hue,sat,lum */
86 int capturedGraph
; /* control mouse captured */
87 RECT focusRect
; /* rectangle last focused item */
88 HWND hwndFocus
; /* handle last focused item */
91 static int hsl_to_x(int hue
, int sat
, int lum
)
96 maxrgb
= (256 * min(120,lum
)) / 120; /* 0 .. 256 */
102 res
= (hue
- 80) * maxrgb
; /* 0...10240 */
103 res
/= 40; /* 0...256 */
110 res
= (240 - hue
) * maxrgb
;
113 res
= res
- maxrgb
/ 2; /* -128...128 */
116 res
= maxrgb
/ 2 + (sat
* res
) / 240; /* 0..256 */
119 if (lum
> 120 && res
< 256)
120 res
+= ((lum
- 120) * (256 - res
)) / 120;
122 return min(res
, 255);
125 /***********************************************************************
126 * CC_HSLtoRGB [internal]
128 static COLORREF
CC_HSLtoRGB(int hue
, int sat
, int lum
)
133 h
= hue
> 80 ? hue
-80 : hue
+160;
134 r
= hsl_to_x(h
, sat
, lum
);
136 h
= hue
> 160 ? hue
-160 : hue
+80;
137 g
= hsl_to_x(h
, sat
, lum
);
139 b
= hsl_to_x(hue
, sat
, lum
);
144 /***********************************************************************
145 * CC_RGBtoHSL [internal]
147 static int CC_RGBtoHSL(char c
, COLORREF rgb
)
149 WORD maxi
, mini
, mmsum
, mmdif
, result
= 0;
150 int iresult
= 0, r
, g
, b
;
167 case 'L': mmsum
*= 120; /* 0...61200=(255+255)*120 */
168 result
= mmsum
/ 255; /* 0...240 */
171 case 'S': if (!mmsum
)
174 if (!mini
|| maxi
== 255)
178 result
= mmdif
* 240; /* 0...61200=255*240 */
179 result
/= (mmsum
> 255 ? 510 - mmsum
: mmsum
); /* 0..255 */
183 case 'H': if (!mmdif
)
189 iresult
= 40 * (g
- b
); /* -10200 ... 10200 */
190 iresult
/= (int) mmdif
; /* -40 .. 40 */
192 iresult
+= 240; /* 0..40 and 200..240 */
197 iresult
= 40 * (b
- r
);
198 iresult
/= (int) mmdif
;
199 iresult
+= 80; /* 40 .. 120 */
204 iresult
= 40 * (r
- g
);
205 iresult
/= (int) mmdif
;
206 iresult
+= 160; /* 120 .. 200 */
212 return result
; /* is this integer arithmetic precise enough ? */
216 /***********************************************************************
217 * CC_DrawCurrentFocusRect [internal]
219 static void CC_DrawCurrentFocusRect( const CCPRIV
*lpp
)
223 HDC hdc
= GetDC(lpp
->hwndFocus
);
224 DrawFocusRect(hdc
, &lpp
->focusRect
);
225 ReleaseDC(lpp
->hwndFocus
, hdc
);
229 /***********************************************************************
230 * CC_DrawFocusRect [internal]
232 static void CC_DrawFocusRect(CCPRIV
*lpp
, HWND hwnd
, int x
, int y
, int rows
, int cols
)
238 CC_DrawCurrentFocusRect(lpp
); /* remove current focus rect */
239 /* calculate new rect */
240 GetClientRect(hwnd
, &rect
);
241 dx
= (rect
.right
- rect
.left
) / cols
;
242 dy
= (rect
.bottom
- rect
.top
) / rows
;
243 rect
.left
+= (x
* dx
) - 2;
244 rect
.top
+= (y
* dy
) - 2;
245 rect
.right
= rect
.left
+ dx
;
246 rect
.bottom
= rect
.top
+ dy
;
249 DrawFocusRect(hdc
, &rect
);
250 lpp
->focusRect
= rect
;
251 lpp
->hwndFocus
= hwnd
;
252 ReleaseDC(hwnd
, hdc
);
257 /***********************************************************************
258 * CC_MouseCheckPredefColorArray [internal]
259 * returns TRUE if one of the predefined colors is clicked
261 static BOOL
CC_MouseCheckPredefColorArray(CCPRIV
*lpp
, int rows
, int cols
, LPARAM lParam
)
268 CONV_LPARAMTOPOINT(lParam
, &point
);
269 ClientToScreen(lpp
->hwndSelf
, &point
);
270 hwnd
= GetDlgItem(lpp
->hwndSelf
, IDC_COLOR_PREDEF
);
271 GetWindowRect(hwnd
, &rect
);
272 if (PtInRect(&rect
, point
))
274 dx
= (rect
.right
- rect
.left
) / cols
;
275 dy
= (rect
.bottom
- rect
.top
) / rows
;
276 ScreenToClient(hwnd
, &point
);
278 if (point
.x
% dx
< ( dx
- DISTANCE
) && point
.y
% dy
< ( dy
- DISTANCE
))
282 lpp
->lpcc
->rgbResult
= predefcolors
[y
][x
];
283 CC_DrawFocusRect(lpp
, hwnd
, x
, y
, rows
, cols
);
290 /***********************************************************************
291 * CC_MouseCheckUserColorArray [internal]
292 * return TRUE if the user clicked a color
294 static BOOL
CC_MouseCheckUserColorArray(CCPRIV
*lpp
, int rows
, int cols
, LPARAM lParam
)
300 COLORREF
*crarr
= lpp
->lpcc
->lpCustColors
;
302 CONV_LPARAMTOPOINT(lParam
, &point
);
303 ClientToScreen(lpp
->hwndSelf
, &point
);
304 hwnd
= GetDlgItem(lpp
->hwndSelf
, IDC_COLOR_USRDEF
);
305 GetWindowRect(hwnd
, &rect
);
306 if (PtInRect(&rect
, point
))
308 dx
= (rect
.right
- rect
.left
) / cols
;
309 dy
= (rect
.bottom
- rect
.top
) / rows
;
310 ScreenToClient(hwnd
, &point
);
312 if (point
.x
% dx
< (dx
- DISTANCE
) && point
.y
% dy
< (dy
- DISTANCE
))
316 lpp
->lpcc
->rgbResult
= crarr
[x
+ (cols
* y
) ];
317 CC_DrawFocusRect(lpp
, hwnd
, x
, y
, rows
, cols
);
327 /* 240 ^...... ^^ 240
334 /***********************************************************************
335 * CC_MouseCheckColorGraph [internal]
337 static BOOL
CC_MouseCheckColorGraph( HWND hDlg
, int dlgitem
, int *hori
, int *vert
, LPARAM lParam
)
344 CONV_LPARAMTOPOINT(lParam
, &point
);
345 ClientToScreen(hDlg
, &point
);
346 hwnd
= GetDlgItem( hDlg
, dlgitem
);
347 GetWindowRect(hwnd
, &rect
);
349 if (!PtInRect(&rect
, point
))
352 GetClientRect(hwnd
, &rect
);
353 ScreenToClient(hwnd
, &point
);
355 x
= (long) point
.x
* MAXHORI
;
357 y
= (long) (rect
.bottom
- point
.y
) * MAXVERT
;
362 if (x
> MAXHORI
) x
= MAXHORI
;
363 if (y
> MAXVERT
) y
= MAXVERT
;
372 /***********************************************************************
373 * CC_MouseCheckResultWindow [internal]
374 * test if double click one of the result colors
376 static BOOL
CC_MouseCheckResultWindow( HWND hDlg
, LPARAM lParam
)
382 CONV_LPARAMTOPOINT(lParam
, &point
);
383 ClientToScreen(hDlg
, &point
);
384 hwnd
= GetDlgItem(hDlg
, IDC_COLOR_RESULT
);
385 GetWindowRect(hwnd
, &rect
);
386 if (PtInRect(&rect
, point
))
388 PostMessageA(hDlg
, WM_COMMAND
, IDC_COLOR_RES
, 0);
394 /***********************************************************************
395 * CC_CheckDigitsInEdit [internal]
397 static int CC_CheckDigitsInEdit( HWND hwnd
, int maxval
)
399 int i
, k
, m
, result
, value
;
403 GetWindowTextA(hwnd
, buffer
, sizeof(buffer
));
407 for (i
= 0 ; i
< m
; i
++)
408 if (buffer
[i
] < '0' || buffer
[i
] > '9')
410 for (k
= i
+ 1; k
<= m
; k
++) /* delete bad character */
412 buffer
[i
] = buffer
[k
];
419 value
= atoi(buffer
);
420 if (value
> maxval
) /* build a new string */
422 sprintf(buffer
, "%d", maxval
);
427 editpos
= SendMessageA(hwnd
, EM_GETSEL
, 0, 0);
428 SetWindowTextA(hwnd
, buffer
);
429 SendMessageA(hwnd
, EM_SETSEL
, 0, editpos
);
436 /***********************************************************************
437 * CC_PaintSelectedColor [internal]
439 static void CC_PaintSelectedColor(const CCPRIV
*infoPtr
)
441 if (IsWindowVisible( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
) )) /* if full size */
446 HWND hwnd
= GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_RESULT
);
449 GetClientRect(hwnd
, &rect
) ;
450 hBrush
= CreateSolidBrush(infoPtr
->lpcc
->rgbResult
);
453 FillRect(hdc
, &rect
, hBrush
);
454 DrawEdge(hdc
, &rect
, BDR_SUNKENOUTER
, BF_RECT
);
455 DeleteObject(hBrush
);
457 ReleaseDC(hwnd
, hdc
);
461 /***********************************************************************
462 * CC_PaintTriangle [internal]
464 static void CC_PaintTriangle(CCPRIV
*infoPtr
)
468 int w
= LOWORD(GetDialogBaseUnits()) / 2;
474 HWND hwnd
= GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_LUMBAR
);
476 if (IsWindowVisible( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
))) /* if full size */
478 GetClientRect(hwnd
, &rect
);
479 height
= rect
.bottom
;
480 hDC
= GetDC(infoPtr
->hwndSelf
);
481 points
[0].y
= rect
.top
;
482 points
[0].x
= rect
.right
; /* | /| */
483 ClientToScreen(hwnd
, points
); /* | / | */
484 ScreenToClient(infoPtr
->hwndSelf
, points
); /* |< | */
485 oben
= points
[0].y
; /* | \ | */
487 temp
= (long)height
* (long)infoPtr
->l
;
489 points
[0].y
= oben
+ height
- temp
/ (long)MAXVERT
;
490 points
[1].y
= points
[0].y
+ w
;
491 points
[2].y
= points
[0].y
- w
;
492 points
[2].x
= points
[1].x
= points
[0].x
+ w
;
494 hbr
= (HBRUSH
)GetClassLongPtrW( hwnd
, GCLP_HBRBACKGROUND
);
495 if (!hbr
) hbr
= GetSysColorBrush(COLOR_BTNFACE
);
496 FillRect(hDC
, &infoPtr
->old3angle
, hbr
);
497 infoPtr
->old3angle
.left
= points
[0].x
;
498 infoPtr
->old3angle
.right
= points
[1].x
+ 1;
499 infoPtr
->old3angle
.top
= points
[2].y
- 1;
500 infoPtr
->old3angle
.bottom
= points
[1].y
+ 1;
502 hbr
= SelectObject(hDC
, GetStockObject(BLACK_BRUSH
));
503 Polygon(hDC
, points
, 3);
504 SelectObject(hDC
, hbr
);
506 ReleaseDC(infoPtr
->hwndSelf
, hDC
);
511 /***********************************************************************
512 * CC_PaintCross [internal]
514 static void CC_PaintCross(CCPRIV
*infoPtr
)
516 HWND hwnd
= GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
);
518 if (IsWindowVisible(hwnd
)) /* if full size */
521 int w
= GetDialogBaseUnits() - 1;
522 int wc
= GetDialogBaseUnits() * 3 / 4;
531 GetClientRect(hwnd
, &rect
);
533 SelectClipRgn( hDC
, CreateRectRgnIndirect(&rect
));
535 point
.x
= ((long)rect
.right
* (long)x
) / (long)MAXHORI
;
536 point
.y
= rect
.bottom
- ((long)rect
.bottom
* (long)y
) / (long)MAXVERT
;
537 if ( infoPtr
->oldcross
.left
!= infoPtr
->oldcross
.right
)
538 BitBlt(hDC
, infoPtr
->oldcross
.left
, infoPtr
->oldcross
.top
,
539 infoPtr
->oldcross
.right
- infoPtr
->oldcross
.left
,
540 infoPtr
->oldcross
.bottom
- infoPtr
->oldcross
.top
,
541 infoPtr
->hdcMem
, infoPtr
->oldcross
.left
, infoPtr
->oldcross
.top
, SRCCOPY
);
542 infoPtr
->oldcross
.left
= point
.x
- w
- 1;
543 infoPtr
->oldcross
.right
= point
.x
+ w
+ 1;
544 infoPtr
->oldcross
.top
= point
.y
- w
- 1;
545 infoPtr
->oldcross
.bottom
= point
.y
+ w
+ 1;
547 hPen
= CreatePen(PS_SOLID
, 3, RGB(0, 0, 0)); /* -black- color */
548 hPen
= SelectObject(hDC
, hPen
);
549 MoveToEx(hDC
, point
.x
- w
, point
.y
, &p
);
550 LineTo(hDC
, point
.x
- wc
, point
.y
);
551 MoveToEx(hDC
, point
.x
+ wc
, point
.y
, &p
);
552 LineTo(hDC
, point
.x
+ w
, point
.y
);
553 MoveToEx(hDC
, point
.x
, point
.y
- w
, &p
);
554 LineTo(hDC
, point
.x
, point
.y
- wc
);
555 MoveToEx(hDC
, point
.x
, point
.y
+ wc
, &p
);
556 LineTo(hDC
, point
.x
, point
.y
+ w
);
557 DeleteObject( SelectObject(hDC
, hPen
));
559 ReleaseDC(hwnd
, hDC
);
568 /***********************************************************************
569 * CC_PrepareColorGraph [internal]
571 static void CC_PrepareColorGraph(CCPRIV
*infoPtr
)
573 int sdif
, hdif
, xdif
, ydif
, hue
, sat
;
574 HWND hwnd
= GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
);
578 HCURSOR hcursor
= SetCursor( LoadCursorW(0, (LPCWSTR
)IDC_WAIT
) );
580 GetClientRect(hwnd
, &client
);
582 infoPtr
->hdcMem
= CreateCompatibleDC(hdc
);
583 infoPtr
->hbmMem
= CreateCompatibleBitmap(hdc
, client
.right
, client
.bottom
);
584 SelectObject(infoPtr
->hdcMem
, infoPtr
->hbmMem
);
586 xdif
= client
.right
/ XSTEPS
;
587 ydif
= client
.bottom
/ YSTEPS
+1;
590 for (rect
.left
= hue
= 0; hue
< 239 + hdif
; hue
+= hdif
)
592 rect
.right
= rect
.left
+ xdif
;
593 rect
.bottom
= client
.bottom
;
594 for(sat
= 0; sat
< 240 + sdif
; sat
+= sdif
)
596 rect
.top
= rect
.bottom
- ydif
;
597 hbrush
= CreateSolidBrush(CC_HSLtoRGB(hue
, sat
, 120));
598 FillRect(infoPtr
->hdcMem
, &rect
, hbrush
);
599 DeleteObject(hbrush
);
600 rect
.bottom
= rect
.top
;
602 rect
.left
= rect
.right
;
604 ReleaseDC(hwnd
, hdc
);
608 /***********************************************************************
609 * CC_PaintColorGraph [internal]
611 static void CC_PaintColorGraph(CCPRIV
*infoPtr
)
613 HWND hwnd
= GetDlgItem( infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
);
617 if (IsWindowVisible(hwnd
)) /* if full size */
619 if (!infoPtr
->hdcMem
)
620 CC_PrepareColorGraph(infoPtr
); /* should not be necessary */
623 GetClientRect(hwnd
, &rect
);
625 BitBlt(hDC
, 0, 0, rect
.right
, rect
.bottom
, infoPtr
->hdcMem
, 0, 0, SRCCOPY
);
627 WARN("choose color: hdcMem is not defined\n");
628 ReleaseDC(hwnd
, hDC
);
632 /***********************************************************************
633 * CC_PaintLumBar [internal]
635 static void CC_PaintLumBar(const CCPRIV
*infoPtr
)
637 HWND hwnd
= GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_LUMBAR
);
643 if (IsWindowVisible(hwnd
))
646 GetClientRect(hwnd
, &client
);
650 ydif
= client
.bottom
/ YSTEPS
+1;
651 for (lum
= 0; lum
< 240 + ldif
; lum
+= ldif
)
653 rect
.top
= max(0, rect
.bottom
- ydif
);
654 hbrush
= CreateSolidBrush(CC_HSLtoRGB(infoPtr
->h
, infoPtr
->s
, lum
));
655 FillRect(hDC
, &rect
, hbrush
);
656 DeleteObject(hbrush
);
657 rect
.bottom
= rect
.top
;
659 GetClientRect(hwnd
, &rect
);
660 DrawEdge(hDC
, &rect
, BDR_SUNKENOUTER
, BF_RECT
);
661 ReleaseDC(hwnd
, hDC
);
665 /***********************************************************************
666 * CC_EditSetRGB [internal]
668 static void CC_EditSetRGB( CCPRIV
*infoPtr
)
670 if (IsWindowVisible( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
) )) /* if full size */
672 COLORREF cr
= infoPtr
->lpcc
->rgbResult
;
673 int r
= GetRValue(cr
);
674 int g
= GetGValue(cr
);
675 int b
= GetBValue(cr
);
677 infoPtr
->updating
= TRUE
;
678 SetDlgItemInt(infoPtr
->hwndSelf
, IDC_COLOR_EDIT_R
, r
, TRUE
);
679 SetDlgItemInt(infoPtr
->hwndSelf
, IDC_COLOR_EDIT_G
, g
, TRUE
);
680 SetDlgItemInt(infoPtr
->hwndSelf
, IDC_COLOR_EDIT_B
, b
, TRUE
);
681 infoPtr
->updating
= FALSE
;
685 /***********************************************************************
686 * CC_EditSetHSL [internal]
688 static void CC_EditSetHSL( CCPRIV
*infoPtr
)
690 if (IsWindowVisible( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
) )) /* if full size */
692 infoPtr
->updating
= TRUE
;
693 SetDlgItemInt(infoPtr
->hwndSelf
, IDC_COLOR_EDIT_H
, infoPtr
->h
, TRUE
);
694 SetDlgItemInt(infoPtr
->hwndSelf
, IDC_COLOR_EDIT_S
, infoPtr
->s
, TRUE
);
695 SetDlgItemInt(infoPtr
->hwndSelf
, IDC_COLOR_EDIT_L
, infoPtr
->l
, TRUE
);
696 infoPtr
->updating
= FALSE
;
698 CC_PaintLumBar(infoPtr
);
701 /***********************************************************************
702 * CC_SwitchToFullSize [internal]
704 static void CC_SwitchToFullSize( CCPRIV
*infoPtr
, const RECT
*lprect
)
708 EnableWindow( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_DEFINE
), FALSE
);
709 CC_PrepareColorGraph(infoPtr
);
710 for (i
= IDC_COLOR_EDIT_H
; i
<= IDC_COLOR_EDIT_B
; i
++)
711 ShowWindow( GetDlgItem(infoPtr
->hwndSelf
, i
), SW_SHOW
);
712 for (i
= IDC_COLOR_HL
; i
<= IDC_COLOR_BL
; i
++)
713 ShowWindow( GetDlgItem(infoPtr
->hwndSelf
, i
), SW_SHOW
);
714 ShowWindow( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_RES
), SW_SHOW
);
715 ShowWindow( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_ADD
), SW_SHOW
);
716 ShowWindow( GetDlgItem(infoPtr
->hwndSelf
, 1090), SW_SHOW
);
719 SetWindowPos(infoPtr
->hwndSelf
, 0, 0, 0, lprect
->right
-lprect
->left
,
720 lprect
->bottom
-lprect
->top
, SWP_NOMOVE
|SWP_NOZORDER
);
722 ShowWindow( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_LUMBAR
), SW_SHOW
);
723 ShowWindow( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_RESULT
), SW_SHOW
);
725 CC_EditSetRGB(infoPtr
);
726 CC_EditSetHSL(infoPtr
);
727 ShowWindow( GetDlgItem( infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
), SW_SHOW
);
728 UpdateWindow( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
) );
731 /***********************************************************************
732 * CC_PaintPredefColorArray [internal]
733 * Paints the default standard 48 colors
735 static void CC_PaintPredefColorArray(const CCPRIV
*infoPtr
, int rows
, int cols
)
737 HWND hwnd
= GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_PREDEF
);
738 RECT rect
, blockrect
;
743 GetClientRect(hwnd
, &rect
);
744 dx
= rect
.right
/ cols
;
745 dy
= rect
.bottom
/ rows
;
749 GetClientRect(hwnd
, &rect
);
750 hBrush
= (HBRUSH
)GetClassLongPtrW( hwnd
, GCLP_HBRBACKGROUND
);
751 if (!hBrush
) hBrush
= GetSysColorBrush(COLOR_BTNFACE
);
752 FillRect(hdc
, &rect
, hBrush
);
753 for ( j
= 0; j
< rows
; j
++ )
755 for ( i
= 0; i
< cols
; i
++ )
757 hBrush
= CreateSolidBrush(predefcolors
[j
][i
]);
760 blockrect
.left
= rect
.left
;
761 blockrect
.top
= rect
.top
;
762 blockrect
.right
= rect
.left
+ dx
- DISTANCE
;
763 blockrect
.bottom
= rect
.top
+ dy
- DISTANCE
;
764 FillRect(hdc
, &blockrect
, hBrush
);
765 DrawEdge(hdc
, &blockrect
, BDR_SUNKEN
, BF_RECT
);
766 DeleteObject(hBrush
);
773 ReleaseDC(hwnd
, hdc
);
774 if (infoPtr
->hwndFocus
== hwnd
)
775 CC_DrawCurrentFocusRect(infoPtr
);
777 /***********************************************************************
778 * CC_PaintUserColorArray [internal]
779 * Paint the 16 user-selected colors
781 static void CC_PaintUserColorArray(const CCPRIV
*infoPtr
, int rows
, int cols
)
783 HWND hwnd
= GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_USRDEF
);
784 RECT rect
, blockrect
;
789 GetClientRect(hwnd
, &rect
);
791 dx
= rect
.right
/ cols
;
792 dy
= rect
.bottom
/ rows
;
798 hBrush
= (HBRUSH
)GetClassLongPtrW( hwnd
, GCLP_HBRBACKGROUND
);
799 if (!hBrush
) hBrush
= GetSysColorBrush(COLOR_BTNFACE
);
800 FillRect( hdc
, &rect
, hBrush
);
801 for (j
= 0; j
< rows
; j
++)
803 for (i
= 0; i
< cols
; i
++)
805 hBrush
= CreateSolidBrush(infoPtr
->lpcc
->lpCustColors
[i
+j
*cols
]);
808 blockrect
.left
= rect
.left
;
809 blockrect
.top
= rect
.top
;
810 blockrect
.right
= rect
.left
+ dx
- DISTANCE
;
811 blockrect
.bottom
= rect
.top
+ dy
- DISTANCE
;
812 FillRect(hdc
, &blockrect
, hBrush
);
813 DrawEdge(hdc
, &blockrect
, BDR_SUNKEN
, BF_RECT
);
814 DeleteObject(hBrush
);
821 ReleaseDC(hwnd
, hdc
);
823 if (infoPtr
->hwndFocus
== hwnd
)
824 CC_DrawCurrentFocusRect(infoPtr
);
828 /***********************************************************************
829 * CC_HookCallChk [internal]
831 static BOOL
CC_HookCallChk( const CHOOSECOLORW
*lpcc
)
834 if(lpcc
->Flags
& CC_ENABLEHOOK
)
840 /***********************************************************************
841 * CC_WMInitDialog [internal]
843 static LRESULT
CC_WMInitDialog( HWND hDlg
, WPARAM wParam
, LPARAM lParam
)
845 CHOOSECOLORW
*cc
= (CHOOSECOLORW
*)lParam
;
853 TRACE("WM_INITDIALOG lParam=%08lX\n", lParam
);
855 if (cc
->lStructSize
!= sizeof(CHOOSECOLORW
))
861 lpp
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(struct CCPRIVATE
) );
863 lpp
->hwndSelf
= hDlg
;
865 SetPropW( hDlg
, szColourDialogProp
, lpp
);
867 if (!(lpp
->lpcc
->Flags
& CC_SHOWHELP
))
868 ShowWindow(GetDlgItem(hDlg
, pshHelp
), SW_HIDE
);
869 lpp
->msetrgb
= RegisterWindowMessageA(SETRGBSTRINGA
);
872 cpos
= MAKELONG(5,7); /* init */
873 if (lpp
->lpcc
->Flags
& CC_RGBINIT
)
875 for (i
= 0; i
< 6; i
++)
876 for (j
= 0; j
< 8; j
++)
877 if (predefcolors
[i
][j
] == lpp
->lpcc
->rgbResult
)
879 cpos
= MAKELONG(i
,j
);
884 /* FIXME: Draw_a_focus_rect & set_init_values */
887 GetWindowRect(hDlg
, &lpp
->fullsize
);
888 if (lpp
->lpcc
->Flags
& CC_FULLOPEN
|| lpp
->lpcc
->Flags
& CC_PREVENTFULLOPEN
)
890 hwnd
= GetDlgItem(hDlg
, IDC_COLOR_DEFINE
);
891 EnableWindow(hwnd
, FALSE
);
893 if (!(lpp
->lpcc
->Flags
& CC_FULLOPEN
) || lpp
->lpcc
->Flags
& CC_PREVENTFULLOPEN
)
895 rect
= lpp
->fullsize
;
896 res
= rect
.bottom
- rect
.top
;
897 hwnd
= GetDlgItem(hDlg
, IDC_COLOR_GRAPH
); /* cut at left border */
898 point
.x
= point
.y
= 0;
899 ClientToScreen(hwnd
, &point
);
900 ScreenToClient(hDlg
,&point
);
901 GetClientRect(hDlg
, &rect
);
902 point
.x
+= GetSystemMetrics(SM_CXDLGFRAME
);
903 SetWindowPos(hDlg
, 0, 0, 0, point
.x
, res
, SWP_NOMOVE
|SWP_NOZORDER
);
905 for (i
= IDC_COLOR_EDIT_H
; i
<= IDC_COLOR_EDIT_B
; i
++)
906 ShowWindow( GetDlgItem(hDlg
, i
), SW_HIDE
);
907 for (i
= IDC_COLOR_HL
; i
<= IDC_COLOR_BL
; i
++)
908 ShowWindow( GetDlgItem(hDlg
, i
), SW_HIDE
);
909 ShowWindow( GetDlgItem(hDlg
, IDC_COLOR_RES
), SW_HIDE
);
910 ShowWindow( GetDlgItem(hDlg
, IDC_COLOR_ADD
), SW_HIDE
);
911 ShowWindow( GetDlgItem(hDlg
, IDC_COLOR_GRAPH
), SW_HIDE
);
912 ShowWindow( GetDlgItem(hDlg
, IDC_COLOR_RESULT
), SW_HIDE
);
913 ShowWindow( GetDlgItem(hDlg
, 1090 ), SW_HIDE
);
916 CC_SwitchToFullSize(lpp
, NULL
);
918 for (i
= IDC_COLOR_EDIT_H
; i
<= IDC_COLOR_EDIT_B
; i
++)
919 SendMessageA( GetDlgItem(hDlg
, i
), EM_LIMITTEXT
, 3, 0); /* max 3 digits: xyz */
920 if (CC_HookCallChk(lpp
->lpcc
))
922 res
= CallWindowProcA( (WNDPROC
)lpp
->lpcc
->lpfnHook
, hDlg
, WM_INITDIALOG
, wParam
, lParam
);
925 /* Set the initial values of the color chooser dialog */
926 r
= GetRValue(lpp
->lpcc
->rgbResult
);
927 g
= GetGValue(lpp
->lpcc
->rgbResult
);
928 b
= GetBValue(lpp
->lpcc
->rgbResult
);
930 CC_PaintSelectedColor(lpp
);
931 lpp
->h
= CC_RGBtoHSL('H', lpp
->lpcc
->rgbResult
);
932 lpp
->s
= CC_RGBtoHSL('S', lpp
->lpcc
->rgbResult
);
933 lpp
->l
= CC_RGBtoHSL('L', lpp
->lpcc
->rgbResult
);
935 /* Doing it the long way because CC_EditSetRGB/HSL doesn't seem to work */
936 SetDlgItemInt(hDlg
, IDC_COLOR_EDIT_H
, lpp
->h
, TRUE
);
937 SetDlgItemInt(hDlg
, IDC_COLOR_EDIT_S
, lpp
->s
, TRUE
);
938 SetDlgItemInt(hDlg
, IDC_COLOR_EDIT_L
, lpp
->l
, TRUE
);
939 SetDlgItemInt(hDlg
, IDC_COLOR_EDIT_R
, r
, TRUE
);
940 SetDlgItemInt(hDlg
, IDC_COLOR_EDIT_G
, g
, TRUE
);
941 SetDlgItemInt(hDlg
, IDC_COLOR_EDIT_B
, b
, TRUE
);
944 CC_PaintTriangle(lpp
);
950 /***********************************************************************
951 * CC_WMCommand [internal]
953 static LRESULT
CC_WMCommand(CCPRIV
*lpp
, WPARAM wParam
, LPARAM lParam
, WORD notifyCode
, HWND hwndCtl
)
960 TRACE("CC_WMCommand wParam=%lx lParam=%lx\n", wParam
, lParam
);
961 switch (LOWORD(wParam
))
963 case IDC_COLOR_EDIT_R
: /* edit notify RGB */
964 case IDC_COLOR_EDIT_G
:
965 case IDC_COLOR_EDIT_B
:
966 if (notifyCode
== EN_UPDATE
&& !lpp
->updating
)
968 i
= CC_CheckDigitsInEdit(hwndCtl
, 255);
969 r
= GetRValue(lpp
->lpcc
->rgbResult
);
970 g
= GetGValue(lpp
->lpcc
->rgbResult
);
971 b
= GetBValue(lpp
->lpcc
->rgbResult
);
973 switch (LOWORD(wParam
))
975 case IDC_COLOR_EDIT_R
: if ((xx
= (i
!= r
))) r
= i
; break;
976 case IDC_COLOR_EDIT_G
: if ((xx
= (i
!= g
))) g
= i
; break;
977 case IDC_COLOR_EDIT_B
: if ((xx
= (i
!= b
))) b
= i
; break;
979 if (xx
) /* something has changed */
981 lpp
->lpcc
->rgbResult
= RGB(r
, g
, b
);
982 CC_PaintSelectedColor(lpp
);
983 lpp
->h
= CC_RGBtoHSL('H', lpp
->lpcc
->rgbResult
);
984 lpp
->s
= CC_RGBtoHSL('S', lpp
->lpcc
->rgbResult
);
985 lpp
->l
= CC_RGBtoHSL('L', lpp
->lpcc
->rgbResult
);
988 CC_PaintTriangle(lpp
);
993 case IDC_COLOR_EDIT_H
: /* edit notify HSL */
994 case IDC_COLOR_EDIT_S
:
995 case IDC_COLOR_EDIT_L
:
996 if (notifyCode
== EN_UPDATE
&& !lpp
->updating
)
998 i
= CC_CheckDigitsInEdit(hwndCtl
, LOWORD(wParam
) == IDC_COLOR_EDIT_H
? 239 : 240);
1000 switch (LOWORD(wParam
))
1002 case IDC_COLOR_EDIT_H
: if ((xx
= ( i
!= lpp
->h
))) lpp
->h
= i
; break;
1003 case IDC_COLOR_EDIT_S
: if ((xx
= ( i
!= lpp
->s
))) lpp
->s
= i
; break;
1004 case IDC_COLOR_EDIT_L
: if ((xx
= ( i
!= lpp
->l
))) lpp
->l
= i
; break;
1006 if (xx
) /* something has changed */
1008 lpp
->lpcc
->rgbResult
= CC_HSLtoRGB(lpp
->h
, lpp
->s
, lpp
->l
);
1009 CC_PaintSelectedColor(lpp
);
1012 CC_PaintTriangle(lpp
);
1017 case IDC_COLOR_DEFINE
:
1018 CC_SwitchToFullSize(lpp
, &lpp
->fullsize
);
1019 SetFocus( GetDlgItem(lpp
->hwndSelf
, IDC_COLOR_EDIT_H
));
1022 case IDC_COLOR_ADD
: /* add colors ... column by column */
1023 cr
= lpp
->lpcc
->lpCustColors
;
1024 cr
[(lpp
->nextuserdef
% 2) * 8 + lpp
->nextuserdef
/ 2] = lpp
->lpcc
->rgbResult
;
1025 if (++lpp
->nextuserdef
== 16)
1026 lpp
->nextuserdef
= 0;
1027 CC_PaintUserColorArray(lpp
, 2, 8);
1030 case IDC_COLOR_RES
: /* resulting color */
1031 hdc
= GetDC(lpp
->hwndSelf
);
1032 lpp
->lpcc
->rgbResult
= GetNearestColor(hdc
, lpp
->lpcc
->rgbResult
);
1033 ReleaseDC(lpp
->hwndSelf
, hdc
);
1035 CC_PaintSelectedColor(lpp
);
1036 lpp
->h
= CC_RGBtoHSL('H', lpp
->lpcc
->rgbResult
);
1037 lpp
->s
= CC_RGBtoHSL('S', lpp
->lpcc
->rgbResult
);
1038 lpp
->l
= CC_RGBtoHSL('L', lpp
->lpcc
->rgbResult
);
1041 CC_PaintTriangle(lpp
);
1044 case pshHelp
: /* Help! */ /* The Beatles, 1965 ;-) */
1045 i
= RegisterWindowMessageA(HELPMSGSTRINGA
);
1046 if (lpp
->lpcc
->hwndOwner
)
1047 SendMessageA(lpp
->lpcc
->hwndOwner
, i
, 0, (LPARAM
)lpp
->lpcc
);
1048 if ( CC_HookCallChk(lpp
->lpcc
))
1049 CallWindowProcA( (WNDPROC
) lpp
->lpcc
->lpfnHook
, lpp
->hwndSelf
,
1050 WM_COMMAND
, psh15
, (LPARAM
)lpp
->lpcc
);
1054 cokmsg
= RegisterWindowMessageA(COLOROKSTRINGA
);
1055 if (lpp
->lpcc
->hwndOwner
)
1056 if (SendMessageA(lpp
->lpcc
->hwndOwner
, cokmsg
, 0, (LPARAM
)lpp
->lpcc
))
1057 break; /* do NOT close */
1058 EndDialog(lpp
->hwndSelf
, 1) ;
1062 EndDialog(lpp
->hwndSelf
, 0) ;
1069 /***********************************************************************
1070 * CC_WMPaint [internal]
1072 static LRESULT
CC_WMPaint( CCPRIV
*lpp
)
1076 BeginPaint(lpp
->hwndSelf
, &ps
);
1077 /* we have to paint dialog children except text and buttons */
1078 CC_PaintPredefColorArray(lpp
, 6, 8);
1079 CC_PaintUserColorArray(lpp
, 2, 8);
1080 CC_PaintLumBar(lpp
);
1081 CC_PaintTriangle(lpp
);
1082 CC_PaintSelectedColor(lpp
);
1083 CC_PaintColorGraph(lpp
);
1085 EndPaint(lpp
->hwndSelf
, &ps
);
1090 /***********************************************************************
1091 * CC_WMLButtonUp [internal]
1093 static LRESULT
CC_WMLButtonUp( CCPRIV
*infoPtr
)
1095 if (infoPtr
->capturedGraph
)
1097 infoPtr
->capturedGraph
= 0;
1099 CC_PaintCross(infoPtr
);
1105 /***********************************************************************
1106 * CC_WMMouseMove [internal]
1108 static LRESULT
CC_WMMouseMove( CCPRIV
*infoPtr
, LPARAM lParam
)
1110 if (infoPtr
->capturedGraph
)
1112 int *ptrh
= NULL
, *ptrs
= &infoPtr
->l
;
1113 if (infoPtr
->capturedGraph
== IDC_COLOR_GRAPH
)
1118 if (CC_MouseCheckColorGraph( infoPtr
->hwndSelf
, infoPtr
->capturedGraph
, ptrh
, ptrs
, lParam
))
1120 infoPtr
->lpcc
->rgbResult
= CC_HSLtoRGB(infoPtr
->h
, infoPtr
->s
, infoPtr
->l
);
1121 CC_EditSetRGB(infoPtr
);
1122 CC_EditSetHSL(infoPtr
);
1123 CC_PaintCross(infoPtr
);
1124 CC_PaintTriangle(infoPtr
);
1125 CC_PaintSelectedColor(infoPtr
);
1130 infoPtr
->capturedGraph
= 0;
1137 /***********************************************************************
1138 * CC_WMLButtonDown [internal]
1140 static LRESULT
CC_WMLButtonDown( CCPRIV
*infoPtr
, LPARAM lParam
)
1144 if (CC_MouseCheckPredefColorArray(infoPtr
, 6, 8, lParam
))
1147 if (CC_MouseCheckUserColorArray(infoPtr
, 2, 8, lParam
))
1150 if (CC_MouseCheckColorGraph(infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
, &infoPtr
->h
, &infoPtr
->s
, lParam
))
1153 infoPtr
->capturedGraph
= IDC_COLOR_GRAPH
;
1156 if (CC_MouseCheckColorGraph(infoPtr
->hwndSelf
, IDC_COLOR_LUMBAR
, NULL
, &infoPtr
->l
, lParam
))
1159 infoPtr
->capturedGraph
= IDC_COLOR_LUMBAR
;
1163 SetCapture(infoPtr
->hwndSelf
);
1164 infoPtr
->lpcc
->rgbResult
= CC_HSLtoRGB(infoPtr
->h
, infoPtr
->s
, infoPtr
->l
);
1168 infoPtr
->h
= CC_RGBtoHSL('H', infoPtr
->lpcc
->rgbResult
);
1169 infoPtr
->s
= CC_RGBtoHSL('S', infoPtr
->lpcc
->rgbResult
);
1170 infoPtr
->l
= CC_RGBtoHSL('L', infoPtr
->lpcc
->rgbResult
);
1174 CC_EditSetRGB(infoPtr
);
1175 CC_EditSetHSL(infoPtr
);
1176 CC_PaintCross(infoPtr
);
1177 CC_PaintTriangle(infoPtr
);
1178 CC_PaintSelectedColor(infoPtr
);
1184 /***********************************************************************
1185 * ColorDlgProc32 [internal]
1188 static INT_PTR CALLBACK
ColorDlgProc( HWND hDlg
, UINT message
,
1189 WPARAM wParam
, LPARAM lParam
)
1193 CCPRIV
*lpp
= GetPropW( hDlg
, szColourDialogProp
);
1195 if (message
!= WM_INITDIALOG
)
1200 if (CC_HookCallChk(lpp
->lpcc
))
1201 res
= CallWindowProcA( (WNDPROC
)lpp
->lpcc
->lpfnHook
, hDlg
, message
, wParam
, lParam
);
1206 /* FIXME: SetRGB message
1207 if (message && message == msetrgb)
1208 return HandleSetRGB(hDlg, lParam);
1214 return CC_WMInitDialog(hDlg
, wParam
, lParam
);
1216 DeleteDC(lpp
->hdcMem
);
1217 DeleteObject(lpp
->hbmMem
);
1218 HeapFree(GetProcessHeap(), 0, lpp
);
1219 RemovePropW( hDlg
, szColourDialogProp
);
1222 if (CC_WMCommand(lpp
, wParam
, lParam
, HIWORD(wParam
), (HWND
) lParam
))
1226 if (CC_WMPaint(lpp
))
1229 case WM_LBUTTONDBLCLK
:
1230 if (CC_MouseCheckResultWindow(hDlg
, lParam
))
1234 if (CC_WMMouseMove(lpp
, lParam
))
1237 case WM_LBUTTONUP
: /* FIXME: ClipCursor off (if in color graph)*/
1238 if (CC_WMLButtonUp(lpp
))
1241 case WM_LBUTTONDOWN
:/* FIXME: ClipCursor on (if in color graph)*/
1242 if (CC_WMLButtonDown(lpp
, lParam
))
1249 /***********************************************************************
1250 * ChooseColorW (COMDLG32.@)
1252 * Create a color dialog box.
1255 * lpChCol [I/O] in: information to initialize the dialog box.
1256 * out: User's color selection
1259 * TRUE: Ok button clicked.
1260 * FALSE: Cancel button clicked, or error.
1262 BOOL WINAPI
ChooseColorW( CHOOSECOLORW
*lpChCol
)
1264 HANDLE hDlgTmpl
= 0;
1265 const void *template;
1267 TRACE("(%p)\n", lpChCol
);
1269 if (!lpChCol
) return FALSE
;
1271 if (lpChCol
->Flags
& CC_ENABLETEMPLATEHANDLE
)
1273 if (!(template = LockResource(lpChCol
->hInstance
)))
1275 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
1279 else if (lpChCol
->Flags
& CC_ENABLETEMPLATE
)
1282 if (!(hResInfo
= FindResourceW((HINSTANCE
)lpChCol
->hInstance
,
1283 lpChCol
->lpTemplateName
,
1284 (LPWSTR
)RT_DIALOG
)))
1286 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE
);
1289 if (!(hDlgTmpl
= LoadResource((HINSTANCE
)lpChCol
->hInstance
, hResInfo
)) ||
1290 !(template = LockResource(hDlgTmpl
)))
1292 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
1300 static const WCHAR wszCHOOSE_COLOR
[] = {'C','H','O','O','S','E','_','C','O','L','O','R',0};
1301 if (!(hResInfo
= FindResourceW(COMDLG32_hInstance
, wszCHOOSE_COLOR
, (LPWSTR
)RT_DIALOG
)))
1303 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE
);
1306 if (!(hDlgTmpl
= LoadResource(COMDLG32_hInstance
, hResInfo
)) ||
1307 !(template = LockResource(hDlgTmpl
)))
1309 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
1314 return DialogBoxIndirectParamW(COMDLG32_hInstance
, template, lpChCol
->hwndOwner
,
1315 ColorDlgProc
, (LPARAM
)lpChCol
);
1318 /***********************************************************************
1319 * ChooseColorA (COMDLG32.@)
1323 BOOL WINAPI
ChooseColorA( LPCHOOSECOLORA lpChCol
)
1326 LPWSTR template_name
= NULL
;
1329 LPCHOOSECOLORW lpcc
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(CHOOSECOLORW
));
1330 lpcc
->lStructSize
= sizeof(*lpcc
);
1331 lpcc
->hwndOwner
= lpChCol
->hwndOwner
;
1332 lpcc
->hInstance
= lpChCol
->hInstance
;
1333 lpcc
->rgbResult
= lpChCol
->rgbResult
;
1334 lpcc
->lpCustColors
= lpChCol
->lpCustColors
;
1335 lpcc
->Flags
= lpChCol
->Flags
;
1336 lpcc
->lCustData
= lpChCol
->lCustData
;
1337 lpcc
->lpfnHook
= lpChCol
->lpfnHook
;
1338 if ((lpcc
->Flags
& CC_ENABLETEMPLATE
) && (lpChCol
->lpTemplateName
)) {
1339 if (!IS_INTRESOURCE(lpChCol
->lpTemplateName
)) {
1340 INT len
= MultiByteToWideChar( CP_ACP
, 0, lpChCol
->lpTemplateName
, -1, NULL
, 0);
1341 template_name
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) );
1342 MultiByteToWideChar( CP_ACP
, 0, lpChCol
->lpTemplateName
, -1, template_name
, len
);
1343 lpcc
->lpTemplateName
= template_name
;
1345 lpcc
->lpTemplateName
= (LPCWSTR
)lpChCol
->lpTemplateName
;
1349 ret
= ChooseColorW(lpcc
);
1352 lpChCol
->rgbResult
= lpcc
->rgbResult
;
1353 HeapFree(GetProcessHeap(), 0, template_name
);
1354 HeapFree(GetProcessHeap(), 0, lpcc
);