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 */
28 static INT_PTR CALLBACK
ColorDlgProc( HWND hWnd
, UINT wMsg
, WPARAM wParam
, LPARAM lParam
);
30 #define CONV_LPARAMTOPOINT(lp,p) do { (p)->x = (short)LOWORD(lp); (p)->y = (short)HIWORD(lp); } while(0)
32 static const COLORREF predefcolors
[6][8]=
34 { 0x008080FFL
, 0x0080FFFFL
, 0x0080FF80L
, 0x0080FF00L
,
35 0x00FFFF80L
, 0x00FF8000L
, 0x00C080FFL
, 0x00FF80FFL
},
36 { 0x000000FFL
, 0x0000FFFFL
, 0x0000FF80L
, 0x0040FF00L
,
37 0x00FFFF00L
, 0x00C08000L
, 0x00C08080L
, 0x00FF00FFL
},
39 { 0x00404080L
, 0x004080FFL
, 0x0000FF00L
, 0x00808000L
,
40 0x00804000L
, 0x00FF8080L
, 0x00400080L
, 0x008000FFL
},
41 { 0x00000080L
, 0x000080FFL
, 0x00008000L
, 0x00408000L
,
42 0x00FF0000L
, 0x00A00000L
, 0x00800080L
, 0x00FF0080L
},
44 { 0x00000040L
, 0x00004080L
, 0x00004000L
, 0x00404000L
,
45 0x00800000L
, 0x00400000L
, 0x00400040L
, 0x00800040L
},
46 { 0x00000000L
, 0x00008080L
, 0x00408080L
, 0x00808080L
,
47 0x00808040L
, 0x00C0C0C0L
, 0x00400040L
, 0x00FFFFFFL
},
50 static const WCHAR szColourDialogProp
[] = {
51 'c','o','l','o','u','r','d','i','a','l','o','g','p','r','o','p',0 };
53 /* Chose Color PRIVATE Structure:
55 * This structure is duplicated in the 16 bit code with
59 typedef struct CCPRIVATE
61 LPCHOOSECOLORW lpcc
; /* points to public known data structure */
62 HWND hwndSelf
; /* dialog window */
63 int nextuserdef
; /* next free place in user defined color array */
64 HDC hdcMem
; /* color graph used for BitBlt() */
65 HBITMAP hbmMem
; /* color graph bitmap */
66 RECT fullsize
; /* original dialog window size */
67 UINT msetrgb
; /* # of SETRGBSTRING message (today not used) */
68 RECT old3angle
; /* last position of l-marker */
69 RECT oldcross
; /* last position of color/saturation marker */
70 BOOL updating
; /* to prevent recursive WM_COMMAND/EN_UPDATE processing */
73 int l
; /* for temporary storing of hue,sat,lum */
74 int capturedGraph
; /* control mouse captured */
75 RECT focusRect
; /* rectangle last focused item */
76 HWND hwndFocus
; /* handle last focused item */
79 static int hsl_to_x(int hue
, int sat
, int lum
)
84 maxrgb
= (256 * min(120,lum
)) / 120; /* 0 .. 256 */
90 res
= (hue
- 80) * maxrgb
; /* 0...10240 */
91 res
/= 40; /* 0...256 */
98 res
= (240 - hue
) * maxrgb
;
101 res
= res
- maxrgb
/ 2; /* -128...128 */
104 res
= maxrgb
/ 2 + (sat
* res
) / 240; /* 0..256 */
107 if (lum
> 120 && res
< 256)
108 res
+= ((lum
- 120) * (256 - res
)) / 120;
110 return min(res
, 255);
113 /***********************************************************************
114 * CC_HSLtoRGB [internal]
116 static COLORREF
CC_HSLtoRGB(int hue
, int sat
, int lum
)
121 h
= hue
> 80 ? hue
-80 : hue
+160;
122 r
= hsl_to_x(h
, sat
, lum
);
124 h
= hue
> 160 ? hue
-160 : hue
+80;
125 g
= hsl_to_x(h
, sat
, lum
);
127 b
= hsl_to_x(hue
, sat
, lum
);
132 /***********************************************************************
133 * CC_RGBtoHSL [internal]
135 static int CC_RGBtoHSL(char c
, COLORREF rgb
)
137 WORD maxi
, mini
, mmsum
, mmdif
, result
= 0;
138 int iresult
= 0, r
, g
, b
;
155 case 'L': mmsum
*= 120; /* 0...61200=(255+255)*120 */
156 result
= mmsum
/ 255; /* 0...240 */
159 case 'S': if (!mmsum
)
162 if (!mini
|| maxi
== 255)
166 result
= mmdif
* 240; /* 0...61200=255*240 */
167 result
/= (mmsum
> 255 ? 510 - mmsum
: mmsum
); /* 0..255 */
171 case 'H': if (!mmdif
)
177 iresult
= 40 * (g
- b
); /* -10200 ... 10200 */
178 iresult
/= (int) mmdif
; /* -40 .. 40 */
180 iresult
+= 240; /* 0..40 and 200..240 */
185 iresult
= 40 * (b
- r
);
186 iresult
/= (int) mmdif
;
187 iresult
+= 80; /* 40 .. 120 */
192 iresult
= 40 * (r
- g
);
193 iresult
/= (int) mmdif
;
194 iresult
+= 160; /* 120 .. 200 */
200 return result
; /* is this integer arithmetic precise enough ? */
204 /***********************************************************************
205 * CC_DrawCurrentFocusRect [internal]
207 static void CC_DrawCurrentFocusRect( const CCPRIV
*lpp
)
211 HDC hdc
= GetDC(lpp
->hwndFocus
);
212 DrawFocusRect(hdc
, &lpp
->focusRect
);
213 ReleaseDC(lpp
->hwndFocus
, hdc
);
217 /***********************************************************************
218 * CC_DrawFocusRect [internal]
220 static void CC_DrawFocusRect(CCPRIV
*lpp
, HWND hwnd
, int x
, int y
, int rows
, int cols
)
226 CC_DrawCurrentFocusRect(lpp
); /* remove current focus rect */
227 /* calculate new rect */
228 GetClientRect(hwnd
, &rect
);
229 dx
= (rect
.right
- rect
.left
) / cols
;
230 dy
= (rect
.bottom
- rect
.top
) / rows
;
231 rect
.left
+= (x
* dx
) - 2;
232 rect
.top
+= (y
* dy
) - 2;
233 rect
.right
= rect
.left
+ dx
;
234 rect
.bottom
= rect
.top
+ dy
;
237 DrawFocusRect(hdc
, &rect
);
238 CopyRect(&lpp
->focusRect
, &rect
);
239 lpp
->hwndFocus
= hwnd
;
240 ReleaseDC(hwnd
, hdc
);
245 /***********************************************************************
246 * CC_MouseCheckPredefColorArray [internal]
247 * returns TRUE if one of the predefined colors is clicked
249 static BOOL
CC_MouseCheckPredefColorArray(CCPRIV
*lpp
, int rows
, int cols
, LPARAM lParam
)
256 CONV_LPARAMTOPOINT(lParam
, &point
);
257 ClientToScreen(lpp
->hwndSelf
, &point
);
258 hwnd
= GetDlgItem(lpp
->hwndSelf
, IDC_COLOR_PREDEF
);
259 GetWindowRect(hwnd
, &rect
);
260 if (PtInRect(&rect
, point
))
262 dx
= (rect
.right
- rect
.left
) / cols
;
263 dy
= (rect
.bottom
- rect
.top
) / rows
;
264 ScreenToClient(hwnd
, &point
);
266 if (point
.x
% dx
< ( dx
- DISTANCE
) && point
.y
% dy
< ( dy
- DISTANCE
))
270 lpp
->lpcc
->rgbResult
= predefcolors
[y
][x
];
271 CC_DrawFocusRect(lpp
, hwnd
, x
, y
, rows
, cols
);
278 /***********************************************************************
279 * CC_MouseCheckUserColorArray [internal]
280 * return TRUE if the user clicked a color
282 static BOOL
CC_MouseCheckUserColorArray(CCPRIV
*lpp
, int rows
, int cols
, LPARAM lParam
)
288 COLORREF
*crarr
= lpp
->lpcc
->lpCustColors
;
290 CONV_LPARAMTOPOINT(lParam
, &point
);
291 ClientToScreen(lpp
->hwndSelf
, &point
);
292 hwnd
= GetDlgItem(lpp
->hwndSelf
, IDC_COLOR_USRDEF
);
293 GetWindowRect(hwnd
, &rect
);
294 if (PtInRect(&rect
, point
))
296 dx
= (rect
.right
- rect
.left
) / cols
;
297 dy
= (rect
.bottom
- rect
.top
) / rows
;
298 ScreenToClient(hwnd
, &point
);
300 if (point
.x
% dx
< (dx
- DISTANCE
) && point
.y
% dy
< (dy
- DISTANCE
))
304 lpp
->lpcc
->rgbResult
= crarr
[x
+ (cols
* y
) ];
305 CC_DrawFocusRect(lpp
, hwnd
, x
, y
, rows
, cols
);
315 /* 240 ^...... ^^ 240
322 /***********************************************************************
323 * CC_MouseCheckColorGraph [internal]
325 static BOOL
CC_MouseCheckColorGraph( HWND hDlg
, int dlgitem
, int *hori
, int *vert
, LPARAM lParam
)
332 CONV_LPARAMTOPOINT(lParam
, &point
);
333 ClientToScreen(hDlg
, &point
);
334 hwnd
= GetDlgItem( hDlg
, dlgitem
);
335 GetWindowRect(hwnd
, &rect
);
337 if (!PtInRect(&rect
, point
))
340 GetClientRect(hwnd
, &rect
);
341 ScreenToClient(hwnd
, &point
);
343 x
= (long) point
.x
* MAXHORI
;
345 y
= (long) (rect
.bottom
- point
.y
) * MAXVERT
;
350 if (x
> MAXHORI
) x
= MAXHORI
;
351 if (y
> MAXVERT
) y
= MAXVERT
;
360 /***********************************************************************
361 * CC_MouseCheckResultWindow [internal]
362 * test if double click one of the result colors
364 static BOOL
CC_MouseCheckResultWindow( HWND hDlg
, LPARAM lParam
)
370 CONV_LPARAMTOPOINT(lParam
, &point
);
371 ClientToScreen(hDlg
, &point
);
372 hwnd
= GetDlgItem(hDlg
, IDC_COLOR_RESULT
);
373 GetWindowRect(hwnd
, &rect
);
374 if (PtInRect(&rect
, point
))
376 PostMessageA(hDlg
, WM_COMMAND
, IDC_COLOR_RES
, 0);
382 /***********************************************************************
383 * CC_CheckDigitsInEdit [internal]
385 static int CC_CheckDigitsInEdit( HWND hwnd
, int maxval
)
387 int i
, k
, m
, result
, value
;
391 GetWindowTextA(hwnd
, buffer
, sizeof(buffer
));
395 for (i
= 0 ; i
< m
; i
++)
396 if (buffer
[i
] < '0' || buffer
[i
] > '9')
398 for (k
= i
+ 1; k
<= m
; k
++) /* delete bad character */
400 buffer
[i
] = buffer
[k
];
407 value
= atoi(buffer
);
408 if (value
> maxval
) /* build a new string */
410 sprintf(buffer
, "%d", maxval
);
415 editpos
= SendMessageA(hwnd
, EM_GETSEL
, 0, 0);
416 SetWindowTextA(hwnd
, buffer
);
417 SendMessageA(hwnd
, EM_SETSEL
, 0, editpos
);
424 /***********************************************************************
425 * CC_PaintSelectedColor [internal]
427 static void CC_PaintSelectedColor(const CCPRIV
*infoPtr
)
429 if (IsWindowVisible( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
) )) /* if full size */
434 HWND hwnd
= GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_RESULT
);
437 GetClientRect(hwnd
, &rect
) ;
438 hBrush
= CreateSolidBrush(infoPtr
->lpcc
->rgbResult
);
441 FillRect(hdc
, &rect
, hBrush
);
442 DrawEdge(hdc
, &rect
, BDR_SUNKENOUTER
, BF_RECT
);
443 DeleteObject(hBrush
);
445 ReleaseDC(hwnd
, hdc
);
449 /***********************************************************************
450 * CC_PaintTriangle [internal]
452 static void CC_PaintTriangle(CCPRIV
*infoPtr
)
456 int w
= LOWORD(GetDialogBaseUnits()) / 2;
462 HWND hwnd
= GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_LUMBAR
);
464 if (IsWindowVisible( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
))) /* if full size */
466 GetClientRect(hwnd
, &rect
);
467 height
= rect
.bottom
;
468 hDC
= GetDC(infoPtr
->hwndSelf
);
469 points
[0].y
= rect
.top
;
470 points
[0].x
= rect
.right
; /* | /| */
471 ClientToScreen(hwnd
, points
); /* | / | */
472 ScreenToClient(infoPtr
->hwndSelf
, points
); /* |< | */
473 oben
= points
[0].y
; /* | \ | */
475 temp
= (long)height
* (long)infoPtr
->l
;
477 points
[0].y
= oben
+ height
- temp
/ (long)MAXVERT
;
478 points
[1].y
= points
[0].y
+ w
;
479 points
[2].y
= points
[0].y
- w
;
480 points
[2].x
= points
[1].x
= points
[0].x
+ w
;
482 hbr
= (HBRUSH
)GetClassLongPtrW( hwnd
, GCLP_HBRBACKGROUND
);
483 if (!hbr
) hbr
= GetSysColorBrush(COLOR_BTNFACE
);
484 FillRect(hDC
, &infoPtr
->old3angle
, hbr
);
485 infoPtr
->old3angle
.left
= points
[0].x
;
486 infoPtr
->old3angle
.right
= points
[1].x
+ 1;
487 infoPtr
->old3angle
.top
= points
[2].y
- 1;
488 infoPtr
->old3angle
.bottom
= points
[1].y
+ 1;
490 hbr
= SelectObject(hDC
, GetStockObject(BLACK_BRUSH
));
491 Polygon(hDC
, points
, 3);
492 SelectObject(hDC
, hbr
);
494 ReleaseDC(infoPtr
->hwndSelf
, hDC
);
499 /***********************************************************************
500 * CC_PaintCross [internal]
502 static void CC_PaintCross(CCPRIV
*infoPtr
)
504 HWND hwnd
= GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
);
506 if (IsWindowVisible(hwnd
)) /* if full size */
509 int w
= GetDialogBaseUnits() - 1;
510 int wc
= GetDialogBaseUnits() * 3 / 4;
519 GetClientRect(hwnd
, &rect
);
521 SelectClipRgn( hDC
, CreateRectRgnIndirect(&rect
));
523 point
.x
= ((long)rect
.right
* (long)x
) / (long)MAXHORI
;
524 point
.y
= rect
.bottom
- ((long)rect
.bottom
* (long)y
) / (long)MAXVERT
;
525 if ( infoPtr
->oldcross
.left
!= infoPtr
->oldcross
.right
)
526 BitBlt(hDC
, infoPtr
->oldcross
.left
, infoPtr
->oldcross
.top
,
527 infoPtr
->oldcross
.right
- infoPtr
->oldcross
.left
,
528 infoPtr
->oldcross
.bottom
- infoPtr
->oldcross
.top
,
529 infoPtr
->hdcMem
, infoPtr
->oldcross
.left
, infoPtr
->oldcross
.top
, SRCCOPY
);
530 infoPtr
->oldcross
.left
= point
.x
- w
- 1;
531 infoPtr
->oldcross
.right
= point
.x
+ w
+ 1;
532 infoPtr
->oldcross
.top
= point
.y
- w
- 1;
533 infoPtr
->oldcross
.bottom
= point
.y
+ w
+ 1;
535 hPen
= CreatePen(PS_SOLID
, 3, RGB(0, 0, 0)); /* -black- color */
536 hPen
= SelectObject(hDC
, hPen
);
537 MoveToEx(hDC
, point
.x
- w
, point
.y
, &p
);
538 LineTo(hDC
, point
.x
- wc
, point
.y
);
539 MoveToEx(hDC
, point
.x
+ wc
, point
.y
, &p
);
540 LineTo(hDC
, point
.x
+ w
, point
.y
);
541 MoveToEx(hDC
, point
.x
, point
.y
- w
, &p
);
542 LineTo(hDC
, point
.x
, point
.y
- wc
);
543 MoveToEx(hDC
, point
.x
, point
.y
+ wc
, &p
);
544 LineTo(hDC
, point
.x
, point
.y
+ w
);
545 DeleteObject( SelectObject(hDC
, hPen
));
547 ReleaseDC(hwnd
, hDC
);
556 /***********************************************************************
557 * CC_PrepareColorGraph [internal]
559 static void CC_PrepareColorGraph(CCPRIV
*infoPtr
)
561 int sdif
, hdif
, xdif
, ydif
, hue
, sat
;
562 HWND hwnd
= GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
);
566 HCURSOR hcursor
= SetCursor( LoadCursorW(0, (LPCWSTR
)IDC_WAIT
) );
568 GetClientRect(hwnd
, &client
);
570 infoPtr
->hdcMem
= CreateCompatibleDC(hdc
);
571 infoPtr
->hbmMem
= CreateCompatibleBitmap(hdc
, client
.right
, client
.bottom
);
572 SelectObject(infoPtr
->hdcMem
, infoPtr
->hbmMem
);
574 xdif
= client
.right
/ XSTEPS
;
575 ydif
= client
.bottom
/ YSTEPS
+1;
578 for (rect
.left
= hue
= 0; hue
< 239 + hdif
; hue
+= hdif
)
580 rect
.right
= rect
.left
+ xdif
;
581 rect
.bottom
= client
.bottom
;
582 for(sat
= 0; sat
< 240 + sdif
; sat
+= sdif
)
584 rect
.top
= rect
.bottom
- ydif
;
585 hbrush
= CreateSolidBrush(CC_HSLtoRGB(hue
, sat
, 120));
586 FillRect(infoPtr
->hdcMem
, &rect
, hbrush
);
587 DeleteObject(hbrush
);
588 rect
.bottom
= rect
.top
;
590 rect
.left
= rect
.right
;
592 ReleaseDC(hwnd
, hdc
);
596 /***********************************************************************
597 * CC_PaintColorGraph [internal]
599 static void CC_PaintColorGraph(CCPRIV
*infoPtr
)
601 HWND hwnd
= GetDlgItem( infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
);
605 if (IsWindowVisible(hwnd
)) /* if full size */
607 if (!infoPtr
->hdcMem
)
608 CC_PrepareColorGraph(infoPtr
); /* should not be necessary */
611 GetClientRect(hwnd
, &rect
);
613 BitBlt(hDC
, 0, 0, rect
.right
, rect
.bottom
, infoPtr
->hdcMem
, 0, 0, SRCCOPY
);
615 WARN("choose color: hdcMem is not defined\n");
616 ReleaseDC(hwnd
, hDC
);
620 /***********************************************************************
621 * CC_PaintLumBar [internal]
623 static void CC_PaintLumBar(const CCPRIV
*infoPtr
)
625 HWND hwnd
= GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_LUMBAR
);
631 if (IsWindowVisible(hwnd
))
634 GetClientRect(hwnd
, &client
);
638 ydif
= client
.bottom
/ YSTEPS
+1;
639 for (lum
= 0; lum
< 240 + ldif
; lum
+= ldif
)
641 rect
.top
= max(0, rect
.bottom
- ydif
);
642 hbrush
= CreateSolidBrush(CC_HSLtoRGB(infoPtr
->h
, infoPtr
->s
, lum
));
643 FillRect(hDC
, &rect
, hbrush
);
644 DeleteObject(hbrush
);
645 rect
.bottom
= rect
.top
;
647 GetClientRect(hwnd
, &rect
);
648 DrawEdge(hDC
, &rect
, BDR_SUNKENOUTER
, BF_RECT
);
649 ReleaseDC(hwnd
, hDC
);
653 /***********************************************************************
654 * CC_EditSetRGB [internal]
656 static void CC_EditSetRGB( CCPRIV
*infoPtr
)
658 if (IsWindowVisible( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
) )) /* if full size */
660 COLORREF cr
= infoPtr
->lpcc
->rgbResult
;
661 int r
= GetRValue(cr
);
662 int g
= GetGValue(cr
);
663 int b
= GetBValue(cr
);
666 infoPtr
->updating
= TRUE
;
667 sprintf(buffer
, "%d", r
);
668 SetWindowTextA( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_EDIT_R
), buffer
);
669 sprintf(buffer
, "%d", g
);
670 SetWindowTextA( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_EDIT_G
), buffer
);
671 sprintf( buffer
, "%d", b
);
672 SetWindowTextA( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_EDIT_B
), buffer
);
673 infoPtr
->updating
= FALSE
;
677 /***********************************************************************
678 * CC_EditSetHSL [internal]
680 static void CC_EditSetHSL( CCPRIV
*infoPtr
)
682 if (IsWindowVisible( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
) )) /* if full size */
686 infoPtr
->updating
= TRUE
;
687 sprintf(buffer
, "%d", infoPtr
->h
);
688 SetWindowTextA( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_EDIT_H
), buffer
);
689 sprintf(buffer
, "%d", infoPtr
->s
);
690 SetWindowTextA( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_EDIT_S
), buffer
);
691 sprintf(buffer
, "%d", infoPtr
->l
);
692 SetWindowTextA( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_EDIT_L
), buffer
);
693 infoPtr
->updating
= FALSE
;
695 CC_PaintLumBar(infoPtr
);
698 /***********************************************************************
699 * CC_SwitchToFullSize [internal]
701 static void CC_SwitchToFullSize( CCPRIV
*infoPtr
, const RECT
*lprect
)
705 EnableWindow( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_DEFINE
), FALSE
);
706 CC_PrepareColorGraph(infoPtr
);
707 for (i
= IDC_COLOR_EDIT_H
; i
<= IDC_COLOR_EDIT_B
; i
++)
708 ShowWindow( GetDlgItem(infoPtr
->hwndSelf
, i
), SW_SHOW
);
709 for (i
= IDC_COLOR_HL
; i
<= IDC_COLOR_BL
; i
++)
710 ShowWindow( GetDlgItem(infoPtr
->hwndSelf
, i
), SW_SHOW
);
711 ShowWindow( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_RES
), SW_SHOW
);
712 ShowWindow( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_ADD
), SW_SHOW
);
713 ShowWindow( GetDlgItem(infoPtr
->hwndSelf
, 1090), SW_SHOW
);
716 SetWindowPos(infoPtr
->hwndSelf
, 0, 0, 0, lprect
->right
-lprect
->left
,
717 lprect
->bottom
-lprect
->top
, SWP_NOMOVE
|SWP_NOZORDER
);
719 ShowWindow( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_LUMBAR
), SW_SHOW
);
720 ShowWindow( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_RESULT
), SW_SHOW
);
722 CC_EditSetRGB(infoPtr
);
723 CC_EditSetHSL(infoPtr
);
724 ShowWindow( GetDlgItem( infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
), SW_SHOW
);
725 UpdateWindow( GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
) );
728 /***********************************************************************
729 * CC_PaintPredefColorArray [internal]
730 * Paints the default standard 48 colors
732 static void CC_PaintPredefColorArray(const CCPRIV
*infoPtr
, int rows
, int cols
)
734 HWND hwnd
= GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_PREDEF
);
735 RECT rect
, blockrect
;
740 GetClientRect(hwnd
, &rect
);
741 dx
= rect
.right
/ cols
;
742 dy
= rect
.bottom
/ rows
;
746 GetClientRect(hwnd
, &rect
);
747 hBrush
= (HBRUSH
)GetClassLongPtrW( hwnd
, GCLP_HBRBACKGROUND
);
748 if (!hBrush
) hBrush
= GetSysColorBrush(COLOR_BTNFACE
);
749 FillRect(hdc
, &rect
, hBrush
);
750 for ( j
= 0; j
< rows
; j
++ )
752 for ( i
= 0; i
< cols
; i
++ )
754 hBrush
= CreateSolidBrush(predefcolors
[j
][i
]);
757 blockrect
.left
= rect
.left
;
758 blockrect
.top
= rect
.top
;
759 blockrect
.right
= rect
.left
+ dx
- DISTANCE
;
760 blockrect
.bottom
= rect
.top
+ dy
- DISTANCE
;
761 FillRect(hdc
, &blockrect
, hBrush
);
762 DrawEdge(hdc
, &blockrect
, BDR_SUNKEN
, BF_RECT
);
763 DeleteObject(hBrush
);
770 ReleaseDC(hwnd
, hdc
);
771 if (infoPtr
->hwndFocus
== hwnd
)
772 CC_DrawCurrentFocusRect(infoPtr
);
774 /***********************************************************************
775 * CC_PaintUserColorArray [internal]
776 * Paint the 16 user-selected colors
778 static void CC_PaintUserColorArray(const CCPRIV
*infoPtr
, int rows
, int cols
)
780 HWND hwnd
= GetDlgItem(infoPtr
->hwndSelf
, IDC_COLOR_USRDEF
);
781 RECT rect
, blockrect
;
786 GetClientRect(hwnd
, &rect
);
788 dx
= rect
.right
/ cols
;
789 dy
= rect
.bottom
/ rows
;
795 hBrush
= (HBRUSH
)GetClassLongPtrW( hwnd
, GCLP_HBRBACKGROUND
);
796 if (!hBrush
) hBrush
= GetSysColorBrush(COLOR_BTNFACE
);
797 FillRect( hdc
, &rect
, hBrush
);
798 for (j
= 0; j
< rows
; j
++)
800 for (i
= 0; i
< cols
; i
++)
802 hBrush
= CreateSolidBrush(infoPtr
->lpcc
->lpCustColors
[i
+j
*cols
]);
805 blockrect
.left
= rect
.left
;
806 blockrect
.top
= rect
.top
;
807 blockrect
.right
= rect
.left
+ dx
- DISTANCE
;
808 blockrect
.bottom
= rect
.top
+ dy
- DISTANCE
;
809 FillRect(hdc
, &blockrect
, hBrush
);
810 DrawEdge(hdc
, &blockrect
, BDR_SUNKEN
, BF_RECT
);
811 DeleteObject(hBrush
);
818 ReleaseDC(hwnd
, hdc
);
820 if (infoPtr
->hwndFocus
== hwnd
)
821 CC_DrawCurrentFocusRect(infoPtr
);
825 /***********************************************************************
826 * CC_HookCallChk [internal]
828 static BOOL
CC_HookCallChk( const CHOOSECOLORW
*lpcc
)
831 if(lpcc
->Flags
& CC_ENABLEHOOK
)
837 /***********************************************************************
838 * CC_WMInitDialog [internal]
840 static LRESULT
CC_WMInitDialog( HWND hDlg
, WPARAM wParam
, LPARAM lParam
)
842 CHOOSECOLORW
*cc
= (CHOOSECOLORW
*)lParam
;
850 TRACE("WM_INITDIALOG lParam=%08lX\n", lParam
);
852 if (cc
->lStructSize
!= sizeof(CHOOSECOLORW
))
858 lpp
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(struct CCPRIVATE
) );
860 lpp
->hwndSelf
= hDlg
;
862 SetPropW( hDlg
, szColourDialogProp
, lpp
);
864 if (!(lpp
->lpcc
->Flags
& CC_SHOWHELP
))
865 ShowWindow( GetDlgItem(hDlg
,0x40e), SW_HIDE
);
866 lpp
->msetrgb
= RegisterWindowMessageA(SETRGBSTRINGA
);
869 cpos
= MAKELONG(5,7); /* init */
870 if (lpp
->lpcc
->Flags
& CC_RGBINIT
)
872 for (i
= 0; i
< 6; i
++)
873 for (j
= 0; j
< 8; j
++)
874 if (predefcolors
[i
][j
] == lpp
->lpcc
->rgbResult
)
876 cpos
= MAKELONG(i
,j
);
881 /* FIXME: Draw_a_focus_rect & set_init_values */
884 GetWindowRect(hDlg
, &lpp
->fullsize
);
885 if (lpp
->lpcc
->Flags
& CC_FULLOPEN
|| lpp
->lpcc
->Flags
& CC_PREVENTFULLOPEN
)
887 hwnd
= GetDlgItem(hDlg
, IDC_COLOR_DEFINE
);
888 EnableWindow(hwnd
, FALSE
);
890 if (!(lpp
->lpcc
->Flags
& CC_FULLOPEN
) || lpp
->lpcc
->Flags
& CC_PREVENTFULLOPEN
)
892 rect
= lpp
->fullsize
;
893 res
= rect
.bottom
- rect
.top
;
894 hwnd
= GetDlgItem(hDlg
, IDC_COLOR_GRAPH
); /* cut at left border */
895 point
.x
= point
.y
= 0;
896 ClientToScreen(hwnd
, &point
);
897 ScreenToClient(hDlg
,&point
);
898 GetClientRect(hDlg
, &rect
);
899 point
.x
+= GetSystemMetrics(SM_CXDLGFRAME
);
900 SetWindowPos(hDlg
, 0, 0, 0, point
.x
, res
, SWP_NOMOVE
|SWP_NOZORDER
);
902 for (i
= IDC_COLOR_EDIT_H
; i
<= IDC_COLOR_EDIT_B
; i
++)
903 ShowWindow( GetDlgItem(hDlg
, i
), SW_HIDE
);
904 for (i
= IDC_COLOR_HL
; i
<= IDC_COLOR_BL
; i
++)
905 ShowWindow( GetDlgItem(hDlg
, i
), SW_HIDE
);
906 ShowWindow( GetDlgItem(hDlg
, IDC_COLOR_RES
), SW_HIDE
);
907 ShowWindow( GetDlgItem(hDlg
, IDC_COLOR_ADD
), SW_HIDE
);
908 ShowWindow( GetDlgItem(hDlg
, IDC_COLOR_GRAPH
), SW_HIDE
);
909 ShowWindow( GetDlgItem(hDlg
, IDC_COLOR_RESULT
), SW_HIDE
);
910 ShowWindow( GetDlgItem(hDlg
, 1090 ), SW_HIDE
);
913 CC_SwitchToFullSize(lpp
, NULL
);
915 for (i
= IDC_COLOR_EDIT_H
; i
<= IDC_COLOR_EDIT_B
; i
++)
916 SendMessageA( GetDlgItem(hDlg
, i
), EM_LIMITTEXT
, 3, 0); /* max 3 digits: xyz */
917 if (CC_HookCallChk(lpp
->lpcc
))
919 res
= CallWindowProcA( (WNDPROC
)lpp
->lpcc
->lpfnHook
, hDlg
, WM_INITDIALOG
, wParam
, lParam
);
922 /* Set the initial values of the color chooser dialog */
923 r
= GetRValue(lpp
->lpcc
->rgbResult
);
924 g
= GetGValue(lpp
->lpcc
->rgbResult
);
925 b
= GetBValue(lpp
->lpcc
->rgbResult
);
927 CC_PaintSelectedColor(lpp
);
928 lpp
->h
= CC_RGBtoHSL('H', lpp
->lpcc
->rgbResult
);
929 lpp
->s
= CC_RGBtoHSL('S', lpp
->lpcc
->rgbResult
);
930 lpp
->l
= CC_RGBtoHSL('L', lpp
->lpcc
->rgbResult
);
932 /* Doing it the long way because CC_EditSetRGB/HSL doesn't seem to work */
933 SetDlgItemInt(hDlg
, IDC_COLOR_EDIT_H
, lpp
->h
, TRUE
);
934 SetDlgItemInt(hDlg
, IDC_COLOR_EDIT_S
, lpp
->s
, TRUE
);
935 SetDlgItemInt(hDlg
, IDC_COLOR_EDIT_L
, lpp
->l
, TRUE
);
936 SetDlgItemInt(hDlg
, IDC_COLOR_EDIT_R
, r
, TRUE
);
937 SetDlgItemInt(hDlg
, IDC_COLOR_EDIT_G
, g
, TRUE
);
938 SetDlgItemInt(hDlg
, IDC_COLOR_EDIT_B
, b
, TRUE
);
941 CC_PaintTriangle(lpp
);
947 /***********************************************************************
948 * CC_WMCommand [internal]
950 static LRESULT
CC_WMCommand(CCPRIV
*lpp
, WPARAM wParam
, LPARAM lParam
, WORD notifyCode
, HWND hwndCtl
)
957 TRACE("CC_WMCommand wParam=%lx lParam=%lx\n", wParam
, lParam
);
958 switch (LOWORD(wParam
))
960 case IDC_COLOR_EDIT_R
: /* edit notify RGB */
961 case IDC_COLOR_EDIT_G
:
962 case IDC_COLOR_EDIT_B
:
963 if (notifyCode
== EN_UPDATE
&& !lpp
->updating
)
965 i
= CC_CheckDigitsInEdit(hwndCtl
, 255);
966 r
= GetRValue(lpp
->lpcc
->rgbResult
);
967 g
= GetGValue(lpp
->lpcc
->rgbResult
);
968 b
= GetBValue(lpp
->lpcc
->rgbResult
);
970 switch (LOWORD(wParam
))
972 case IDC_COLOR_EDIT_R
: if ((xx
= (i
!= r
))) r
= i
; break;
973 case IDC_COLOR_EDIT_G
: if ((xx
= (i
!= g
))) g
= i
; break;
974 case IDC_COLOR_EDIT_B
: if ((xx
= (i
!= b
))) b
= i
; break;
976 if (xx
) /* something has changed */
978 lpp
->lpcc
->rgbResult
= RGB(r
, g
, b
);
979 CC_PaintSelectedColor(lpp
);
980 lpp
->h
= CC_RGBtoHSL('H', lpp
->lpcc
->rgbResult
);
981 lpp
->s
= CC_RGBtoHSL('S', lpp
->lpcc
->rgbResult
);
982 lpp
->l
= CC_RGBtoHSL('L', lpp
->lpcc
->rgbResult
);
985 CC_PaintTriangle(lpp
);
990 case IDC_COLOR_EDIT_H
: /* edit notify HSL */
991 case IDC_COLOR_EDIT_S
:
992 case IDC_COLOR_EDIT_L
:
993 if (notifyCode
== EN_UPDATE
&& !lpp
->updating
)
995 i
= CC_CheckDigitsInEdit(hwndCtl
, LOWORD(wParam
) == IDC_COLOR_EDIT_H
? 239 : 240);
997 switch (LOWORD(wParam
))
999 case IDC_COLOR_EDIT_H
: if ((xx
= ( i
!= lpp
->h
))) lpp
->h
= i
; break;
1000 case IDC_COLOR_EDIT_S
: if ((xx
= ( i
!= lpp
->s
))) lpp
->s
= i
; break;
1001 case IDC_COLOR_EDIT_L
: if ((xx
= ( i
!= lpp
->l
))) lpp
->l
= i
; break;
1003 if (xx
) /* something has changed */
1005 lpp
->lpcc
->rgbResult
= CC_HSLtoRGB(lpp
->h
, lpp
->s
, lpp
->l
);
1006 CC_PaintSelectedColor(lpp
);
1009 CC_PaintTriangle(lpp
);
1014 case IDC_COLOR_DEFINE
:
1015 CC_SwitchToFullSize(lpp
, &lpp
->fullsize
);
1016 SetFocus( GetDlgItem(lpp
->hwndSelf
, IDC_COLOR_EDIT_H
));
1019 case IDC_COLOR_ADD
: /* add colors ... column by column */
1020 cr
= lpp
->lpcc
->lpCustColors
;
1021 cr
[(lpp
->nextuserdef
% 2) * 8 + lpp
->nextuserdef
/ 2] = lpp
->lpcc
->rgbResult
;
1022 if (++lpp
->nextuserdef
== 16)
1023 lpp
->nextuserdef
= 0;
1024 CC_PaintUserColorArray(lpp
, 2, 8);
1027 case IDC_COLOR_RES
: /* resulting color */
1028 hdc
= GetDC(lpp
->hwndSelf
);
1029 lpp
->lpcc
->rgbResult
= GetNearestColor(hdc
, lpp
->lpcc
->rgbResult
);
1030 ReleaseDC(lpp
->hwndSelf
, hdc
);
1032 CC_PaintSelectedColor(lpp
);
1033 lpp
->h
= CC_RGBtoHSL('H', lpp
->lpcc
->rgbResult
);
1034 lpp
->s
= CC_RGBtoHSL('S', lpp
->lpcc
->rgbResult
);
1035 lpp
->l
= CC_RGBtoHSL('L', lpp
->lpcc
->rgbResult
);
1038 CC_PaintTriangle(lpp
);
1041 case 0x40e: /* Help! */ /* The Beatles, 1965 ;-) */
1042 i
= RegisterWindowMessageA(HELPMSGSTRINGA
);
1043 if (lpp
->lpcc
->hwndOwner
)
1044 SendMessageA(lpp
->lpcc
->hwndOwner
, i
, 0, (LPARAM
)lpp
->lpcc
);
1045 if ( CC_HookCallChk(lpp
->lpcc
))
1046 CallWindowProcA( (WNDPROC
) lpp
->lpcc
->lpfnHook
, lpp
->hwndSelf
,
1047 WM_COMMAND
, psh15
, (LPARAM
)lpp
->lpcc
);
1051 cokmsg
= RegisterWindowMessageA(COLOROKSTRINGA
);
1052 if (lpp
->lpcc
->hwndOwner
)
1053 if (SendMessageA(lpp
->lpcc
->hwndOwner
, cokmsg
, 0, (LPARAM
)lpp
->lpcc
))
1054 break; /* do NOT close */
1055 EndDialog(lpp
->hwndSelf
, 1) ;
1059 EndDialog(lpp
->hwndSelf
, 0) ;
1066 /***********************************************************************
1067 * CC_WMPaint [internal]
1069 static LRESULT
CC_WMPaint( CCPRIV
*lpp
)
1073 BeginPaint(lpp
->hwndSelf
, &ps
);
1074 /* we have to paint dialog children except text and buttons */
1075 CC_PaintPredefColorArray(lpp
, 6, 8);
1076 CC_PaintUserColorArray(lpp
, 2, 8);
1077 CC_PaintLumBar(lpp
);
1078 CC_PaintTriangle(lpp
);
1079 CC_PaintSelectedColor(lpp
);
1080 CC_PaintColorGraph(lpp
);
1082 EndPaint(lpp
->hwndSelf
, &ps
);
1087 /***********************************************************************
1088 * CC_WMLButtonUp [internal]
1090 static LRESULT
CC_WMLButtonUp( CCPRIV
*infoPtr
)
1092 if (infoPtr
->capturedGraph
)
1094 infoPtr
->capturedGraph
= 0;
1096 CC_PaintCross(infoPtr
);
1102 /***********************************************************************
1103 * CC_WMMouseMove [internal]
1105 static LRESULT
CC_WMMouseMove( CCPRIV
*infoPtr
, LPARAM lParam
)
1107 if (infoPtr
->capturedGraph
)
1109 int *ptrh
= NULL
, *ptrs
= &infoPtr
->l
;
1110 if (infoPtr
->capturedGraph
== IDC_COLOR_GRAPH
)
1115 if (CC_MouseCheckColorGraph( infoPtr
->hwndSelf
, infoPtr
->capturedGraph
, ptrh
, ptrs
, lParam
))
1117 infoPtr
->lpcc
->rgbResult
= CC_HSLtoRGB(infoPtr
->h
, infoPtr
->s
, infoPtr
->l
);
1118 CC_EditSetRGB(infoPtr
);
1119 CC_EditSetHSL(infoPtr
);
1120 CC_PaintCross(infoPtr
);
1121 CC_PaintTriangle(infoPtr
);
1122 CC_PaintSelectedColor(infoPtr
);
1127 infoPtr
->capturedGraph
= 0;
1134 /***********************************************************************
1135 * CC_WMLButtonDown [internal]
1137 static LRESULT
CC_WMLButtonDown( CCPRIV
*infoPtr
, LPARAM lParam
)
1141 if (CC_MouseCheckPredefColorArray(infoPtr
, 6, 8, lParam
))
1144 if (CC_MouseCheckUserColorArray(infoPtr
, 2, 8, lParam
))
1147 if (CC_MouseCheckColorGraph(infoPtr
->hwndSelf
, IDC_COLOR_GRAPH
, &infoPtr
->h
, &infoPtr
->s
, lParam
))
1150 infoPtr
->capturedGraph
= IDC_COLOR_GRAPH
;
1153 if (CC_MouseCheckColorGraph(infoPtr
->hwndSelf
, IDC_COLOR_LUMBAR
, NULL
, &infoPtr
->l
, lParam
))
1156 infoPtr
->capturedGraph
= IDC_COLOR_LUMBAR
;
1160 SetCapture(infoPtr
->hwndSelf
);
1161 infoPtr
->lpcc
->rgbResult
= CC_HSLtoRGB(infoPtr
->h
, infoPtr
->s
, infoPtr
->l
);
1165 infoPtr
->h
= CC_RGBtoHSL('H', infoPtr
->lpcc
->rgbResult
);
1166 infoPtr
->s
= CC_RGBtoHSL('S', infoPtr
->lpcc
->rgbResult
);
1167 infoPtr
->l
= CC_RGBtoHSL('L', infoPtr
->lpcc
->rgbResult
);
1171 CC_EditSetRGB(infoPtr
);
1172 CC_EditSetHSL(infoPtr
);
1173 CC_PaintCross(infoPtr
);
1174 CC_PaintTriangle(infoPtr
);
1175 CC_PaintSelectedColor(infoPtr
);
1181 /***********************************************************************
1182 * ColorDlgProc32 [internal]
1185 static INT_PTR CALLBACK
ColorDlgProc( HWND hDlg
, UINT message
,
1186 WPARAM wParam
, LPARAM lParam
)
1190 CCPRIV
*lpp
= GetPropW( hDlg
, szColourDialogProp
);
1192 if (message
!= WM_INITDIALOG
)
1197 if (CC_HookCallChk(lpp
->lpcc
))
1198 res
= CallWindowProcA( (WNDPROC
)lpp
->lpcc
->lpfnHook
, hDlg
, message
, wParam
, lParam
);
1203 /* FIXME: SetRGB message
1204 if (message && message == msetrgb)
1205 return HandleSetRGB(hDlg, lParam);
1211 return CC_WMInitDialog(hDlg
, wParam
, lParam
);
1213 DeleteDC(lpp
->hdcMem
);
1214 DeleteObject(lpp
->hbmMem
);
1215 HeapFree(GetProcessHeap(), 0, lpp
);
1216 RemovePropW( hDlg
, szColourDialogProp
);
1219 if (CC_WMCommand(lpp
, wParam
, lParam
, HIWORD(wParam
), (HWND
) lParam
))
1223 if (CC_WMPaint(lpp
))
1226 case WM_LBUTTONDBLCLK
:
1227 if (CC_MouseCheckResultWindow(hDlg
, lParam
))
1231 if (CC_WMMouseMove(lpp
, lParam
))
1234 case WM_LBUTTONUP
: /* FIXME: ClipCursor off (if in color graph)*/
1235 if (CC_WMLButtonUp(lpp
))
1238 case WM_LBUTTONDOWN
:/* FIXME: ClipCursor on (if in color graph)*/
1239 if (CC_WMLButtonDown(lpp
, lParam
))
1246 /***********************************************************************
1247 * ChooseColorW (COMDLG32.@)
1249 * Create a color dialog box.
1252 * lpChCol [I/O] in: information to initialize the dialog box.
1253 * out: User's color selection
1256 * TRUE: Ok button clicked.
1257 * FALSE: Cancel button clicked, or error.
1259 BOOL WINAPI
ChooseColorW( CHOOSECOLORW
*lpChCol
)
1261 HANDLE hDlgTmpl
= 0;
1262 const void *template;
1264 TRACE("(%p)\n", lpChCol
);
1266 if (!lpChCol
) return FALSE
;
1268 if (lpChCol
->Flags
& CC_ENABLETEMPLATEHANDLE
)
1270 if (!(template = LockResource(lpChCol
->hInstance
)))
1272 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
1276 else if (lpChCol
->Flags
& CC_ENABLETEMPLATE
)
1279 if (!(hResInfo
= FindResourceW((HINSTANCE
)lpChCol
->hInstance
,
1280 lpChCol
->lpTemplateName
,
1281 (LPWSTR
)RT_DIALOG
)))
1283 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE
);
1286 if (!(hDlgTmpl
= LoadResource((HINSTANCE
)lpChCol
->hInstance
, hResInfo
)) ||
1287 !(template = LockResource(hDlgTmpl
)))
1289 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
1297 static const WCHAR wszCHOOSE_COLOR
[] = {'C','H','O','O','S','E','_','C','O','L','O','R',0};
1298 if (!(hResInfo
= FindResourceW(COMDLG32_hInstance
, wszCHOOSE_COLOR
, (LPWSTR
)RT_DIALOG
)))
1300 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE
);
1303 if (!(hDlgTmpl
= LoadResource(COMDLG32_hInstance
, hResInfo
)) ||
1304 !(template = LockResource(hDlgTmpl
)))
1306 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE
);
1311 return DialogBoxIndirectParamW(COMDLG32_hInstance
, template, lpChCol
->hwndOwner
,
1312 ColorDlgProc
, (LPARAM
)lpChCol
);
1315 /***********************************************************************
1316 * ChooseColorA (COMDLG32.@)
1320 BOOL WINAPI
ChooseColorA( LPCHOOSECOLORA lpChCol
)
1323 LPWSTR template_name
= NULL
;
1326 LPCHOOSECOLORW lpcc
= HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY
, sizeof(CHOOSECOLORW
));
1327 lpcc
->lStructSize
= sizeof(*lpcc
);
1328 lpcc
->hwndOwner
= lpChCol
->hwndOwner
;
1329 lpcc
->hInstance
= lpChCol
->hInstance
;
1330 lpcc
->rgbResult
= lpChCol
->rgbResult
;
1331 lpcc
->lpCustColors
= lpChCol
->lpCustColors
;
1332 lpcc
->Flags
= lpChCol
->Flags
;
1333 lpcc
->lCustData
= lpChCol
->lCustData
;
1334 lpcc
->lpfnHook
= lpChCol
->lpfnHook
;
1335 if ((lpcc
->Flags
& CC_ENABLETEMPLATE
) && (lpChCol
->lpTemplateName
)) {
1336 if (!IS_INTRESOURCE(lpChCol
->lpTemplateName
)) {
1337 INT len
= MultiByteToWideChar( CP_ACP
, 0, lpChCol
->lpTemplateName
, -1, NULL
, 0);
1338 template_name
= HeapAlloc( GetProcessHeap(), 0, len
* sizeof(WCHAR
) );
1339 MultiByteToWideChar( CP_ACP
, 0, lpChCol
->lpTemplateName
, -1, template_name
, len
);
1340 lpcc
->lpTemplateName
= template_name
;
1342 lpcc
->lpTemplateName
= (LPCWSTR
)lpChCol
->lpTemplateName
;
1346 ret
= ChooseColorW(lpcc
);
1349 lpChCol
->rgbResult
= lpcc
->rgbResult
;
1350 HeapFree(GetProcessHeap(), 0, template_name
);
1351 HeapFree(GetProcessHeap(), 0, lpcc
);