2 * COMMDLG - Color Dialog
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
8 /* BUGS : still seems to not refresh correctly
9 sometimes, especially when 2 instances of the
10 dialog are loaded at the same time */
19 #include "wine/winbase16.h"
20 #include "wine/winuser16.h"
24 #include "debugtools.h"
27 DEFAULT_DEBUG_CHANNEL(commdlg);
31 static LRESULT WINAPI ColorDlgProc( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam );
33 #define CONV_LPARAMTOPOINT(lp,p) do { (p)->x = SLOWORD(lp); (p)->y = SHIWORD(lp); } while(0)
35 static const COLORREF predefcolors[6][8]=
37 { 0x008080FFL, 0x0080FFFFL, 0x0080FF80L, 0x0080FF00L,
38 0x00FFFF80L, 0x00FF8000L, 0x00C080FFL, 0x00FF80FFL },
39 { 0x000000FFL, 0x0000FFFFL, 0x0000FF80L, 0x0040FF00L,
40 0x00FFFF00L, 0x00C08000L, 0x00C08080L, 0x00FF00FFL },
42 { 0x00404080L, 0x004080FFL, 0x0000FF00L, 0x00808000L,
43 0x00804000L, 0x00FF8080L, 0x00400080L, 0x008000FFL },
44 { 0x00000080L, 0x000080FFL, 0x00008000L, 0x00408000L,
45 0x00FF0000L, 0x00A00000L, 0x00800080L, 0x00FF0080L },
47 { 0x00000040L, 0x00004080L, 0x00004000L, 0x00404000L,
48 0x00800000L, 0x00400000L, 0x00400040L, 0x00800040L },
49 { 0x00000000L, 0x00008080L, 0x00408080L, 0x00808080L,
50 0x00808040L, 0x00C0C0C0L, 0x00400040L, 0x00FFFFFFL },
55 LPCHOOSECOLORW lpcc; /* points to public known data structure */
56 LPCHOOSECOLOR16 lpcc16; /* save the 16 bits pointer */
57 int nextuserdef; /* next free place in user defined color array */
58 HDC hdcMem; /* color graph used for BitBlt() */
59 HBITMAP hbmMem; /* color graph bitmap */
60 RECT fullsize; /* original dialog window size */
61 UINT msetrgb; /* # of SETRGBSTRING message (today not used) */
62 RECT old3angle; /* last position of l-marker */
63 RECT oldcross; /* last position of color/satuation marker */
64 BOOL updating; /* to prevent recursive WM_COMMAND/EN_UPDATE processing */
67 int l; /* for temporary storing of hue,sat,lum */
68 int capturedGraph; /* control mouse captured */
69 RECT focusRect; /* rectangle last focused item */
70 HWND hwndFocus; /* handle last focused item */
73 #define LCCPRIV struct CCPRIVATE *
75 /***********************************************************************
76 * CC_HSLtoRGB [internal]
78 static int CC_HSLtoRGB(char c, int hue, int sat, int lum)
85 case 'R': if (hue > 80) hue -= 80; else hue += 160; break;
86 case 'G': if (hue > 160) hue -= 160; else hue += 80; break;
91 maxrgb = (256 * min(120,lum)) / 120; /* 0 .. 256 */
97 res = (hue - 80) * maxrgb; /* 0...10240 */
98 res /= 40; /* 0...256 */
105 res= (240 - hue) * maxrgb;
108 res = res - maxrgb / 2; /* -128...128 */
111 res = maxrgb / 2 + (sat * res) / 240; /* 0..256 */
114 if (lum > 120 && res < 256)
115 res += ((lum - 120) * (256 - res)) / 120;
117 return min(res, 255);
120 /***********************************************************************
121 * CC_RGBtoHSL [internal]
123 static int CC_RGBtoHSL(char c, int r, int g, int b)
125 WORD maxi, mini, mmsum, mmdif, result = 0;
139 case 'L': mmsum *= 120; /* 0...61200=(255+255)*120 */
140 result = mmsum / 255; /* 0...240 */
143 case 'S': if (!mmsum)
146 if (!mini || maxi == 255)
150 result = mmdif * 240; /* 0...61200=255*240 */
151 result /= (mmsum > 255 ? mmsum = 510 - mmsum : mmsum); /* 0..255 */
155 case 'H': if (!mmdif)
161 iresult = 40 * (g - b); /* -10200 ... 10200 */
162 iresult /= (int) mmdif; /* -40 .. 40 */
164 iresult += 240; /* 0..40 and 200..240 */
169 iresult = 40 * (b - r);
170 iresult /= (int) mmdif;
171 iresult += 80; /* 40 .. 120 */
176 iresult = 40 * (r - g);
177 iresult /= (int) mmdif;
178 iresult += 160; /* 120 .. 200 */
184 return result; /* is this integer arithmetic precise enough ? */
188 /***********************************************************************
189 * CC_DrawCurrentFocusRect [internal]
191 void CC_DrawCurrentFocusRect( LCCPRIV lpp )
195 HDC hdc = GetDC(lpp->hwndFocus);
196 DrawFocusRect(hdc, &lpp->focusRect);
197 ReleaseDC(lpp->hwndFocus, hdc);
201 /***********************************************************************
202 * CC_DrawFocusRect [internal]
204 void CC_DrawFocusRect( LCCPRIV lpp, HWND hwnd, int x, int y, int rows, int cols)
210 CC_DrawCurrentFocusRect(lpp); /* remove current focus rect */
211 /* calculate new rect */
212 GetClientRect(hwnd, &rect);
213 dx = (rect.right - rect.left) / cols;
214 dy = (rect.bottom - rect.top) / rows;
215 rect.left += (x * dx) - 2;
216 rect.top += (y * dy) - 2;
217 rect.right = rect.left + dx;
218 rect.bottom = rect.top + dy;
221 DrawFocusRect(hdc, &rect);
222 CopyRect(&lpp->focusRect, &rect);
223 lpp->hwndFocus = hwnd;
224 ReleaseDC(hwnd, hdc);
229 /***********************************************************************
230 * CC_MouseCheckPredefColorArray [internal]
231 * returns 1 if one of the predefined colors is clicked
233 static int CC_MouseCheckPredefColorArray( LCCPRIV lpp, HWND hDlg, int dlgitem, int rows, int cols,
241 CONV_LPARAMTOPOINT(lParam, &point);
242 ClientToScreen(hDlg, &point);
243 hwnd = GetDlgItem(hDlg, dlgitem);
244 GetWindowRect(hwnd, &rect);
245 if (PtInRect(&rect, point))
247 dx = (rect.right - rect.left) / cols;
248 dy = (rect.bottom - rect.top) / rows;
249 ScreenToClient(hwnd, &point);
251 if (point.x % dx < ( dx - DISTANCE) && point.y % dy < ( dy - DISTANCE))
255 lpp->lpcc->rgbResult = predefcolors[y][x];
256 CC_DrawFocusRect(lpp, hwnd, x, y, rows, cols);
263 /***********************************************************************
264 * CC_MouseCheckUserColorArray [internal]
265 * return 1 if the user clicked a color
267 static int CC_MouseCheckUserColorArray( LCCPRIV lpp, HWND hDlg, int dlgitem, int rows, int cols,
274 COLORREF *crarr = lpp->lpcc->lpCustColors;
276 CONV_LPARAMTOPOINT(lParam, &point);
277 ClientToScreen(hDlg, &point);
278 hwnd = GetDlgItem(hDlg, dlgitem);
279 GetWindowRect(hwnd, &rect);
280 if (PtInRect(&rect, point))
282 dx = (rect.right - rect.left) / cols;
283 dy = (rect.bottom - rect.top) / rows;
284 ScreenToClient(hwnd, &point);
286 if (point.x % dx < (dx - DISTANCE) && point.y % dy < (dy - DISTANCE))
290 lpp->lpcc->rgbResult = crarr[x + (cols * y) ];
291 CC_DrawFocusRect(lpp, hwnd, x, y, rows, cols);
301 /* 240 ^...... ^^ 240
308 /***********************************************************************
309 * CC_MouseCheckColorGraph [internal]
311 static int CC_MouseCheckColorGraph( HWND hDlg, int dlgitem, int *hori, int *vert, LPARAM lParam )
318 CONV_LPARAMTOPOINT(lParam, &point);
319 ClientToScreen(hDlg, &point);
320 hwnd = GetDlgItem( hDlg, dlgitem );
321 GetWindowRect(hwnd, &rect);
322 if (PtInRect(&rect, point))
324 GetClientRect(hwnd, &rect);
325 ScreenToClient(hwnd, &point);
327 x = (long) point.x * MAXHORI;
329 y = (long) (rect.bottom - point.y) * MAXVERT;
341 /***********************************************************************
342 * CC_MouseCheckResultWindow [internal]
343 * test if double click one of the result colors
345 static int CC_MouseCheckResultWindow( HWND hDlg, LPARAM lParam )
351 CONV_LPARAMTOPOINT(lParam, &point);
352 ClientToScreen(hDlg, &point);
353 hwnd = GetDlgItem(hDlg, 0x2c5);
354 GetWindowRect(hwnd, &rect);
355 if (PtInRect(&rect, point))
357 PostMessageA(hDlg, WM_COMMAND, 0x2c9, 0);
363 /***********************************************************************
364 * CC_CheckDigitsInEdit [internal]
366 static int CC_CheckDigitsInEdit( HWND hwnd, int maxval )
368 int i, k, m, result, value;
372 GetWindowTextA(hwnd, buffer, sizeof(buffer));
376 for (i = 0 ; i < m ; i++)
377 if (buffer[i] < '0' || buffer[i] > '9')
379 for (k = i + 1; k <= m; k++) /* delete bad character */
381 buffer[i] = buffer[k];
388 value = atoi(buffer);
389 if (value > maxval) /* build a new string */
391 sprintf(buffer, "%d", maxval);
396 editpos = SendMessageA(hwnd, EM_GETSEL, 0, 0);
397 SetWindowTextA(hwnd, buffer );
398 SendMessageA(hwnd, EM_SETSEL, 0, editpos);
405 /***********************************************************************
406 * CC_PaintSelectedColor [internal]
408 static void CC_PaintSelectedColor( HWND hDlg, COLORREF cr )
413 HWND hwnd = GetDlgItem(hDlg, 0x2c5);
414 if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6) )) /* if full size */
417 GetClientRect(hwnd, &rect) ;
418 hBrush = CreateSolidBrush(cr);
421 hBrush = SelectObject(hdc, hBrush) ;
422 Rectangle(hdc, rect.left, rect.top, rect.right/2, rect.bottom);
423 DeleteObject ( SelectObject(hdc, hBrush) ) ;
424 hBrush = CreateSolidBrush( GetNearestColor(hdc, cr) );
427 hBrush = SelectObject(hdc, hBrush) ;
428 Rectangle(hdc, rect.right/2-1, rect.top, rect.right, rect.bottom);
429 DeleteObject(SelectObject(hdc, hBrush)) ;
432 ReleaseDC(hwnd, hdc);
436 /***********************************************************************
437 * CC_PaintTriangle [internal]
439 static void CC_PaintTriangle( HWND hDlg, int y)
443 int w = LOWORD(GetDialogBaseUnits());
448 HWND hwnd = GetDlgItem(hDlg, 0x2be);
449 LCCPRIV lpp = (LCCPRIV)GetWindowLongA( hDlg, DWL_USER);
451 if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6))) /* if full size */
453 GetClientRect(hwnd, &rect);
454 height = rect.bottom;
456 points[0].y = rect.top;
457 points[0].x = rect.right; /* | /| */
458 ClientToScreen(hwnd, points); /* | / | */
459 ScreenToClient(hDlg, points); /* |< | */
460 oben = points[0].y; /* | \ | */
462 temp = (long)height * (long)y;
463 points[0].y = oben + height - temp / (long)MAXVERT;
464 points[1].y = points[0].y + w;
465 points[2].y = points[0].y - w;
466 points[2].x = points[1].x = points[0].x + w;
468 FillRect(hDC, &lpp->old3angle, GetClassLongA( hwnd, GCL_HBRBACKGROUND));
469 lpp->old3angle.left = points[0].x;
470 lpp->old3angle.right = points[1].x + 1;
471 lpp->old3angle.top = points[2].y - 1;
472 lpp->old3angle.bottom= points[1].y + 1;
473 Polygon(hDC, points, 3);
474 ReleaseDC(hDlg, hDC);
479 /***********************************************************************
480 * CC_PaintCross [internal]
482 static void CC_PaintCross( HWND hDlg, int x, int y)
485 int w = GetDialogBaseUnits();
486 HWND hwnd = GetDlgItem(hDlg, 0x2c6);
487 LCCPRIV lpp = (LCCPRIV)GetWindowLongA( hDlg, DWL_USER );
492 if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6) )) /* if full size */
494 GetClientRect(hwnd, &rect);
496 SelectClipRgn( hDC, CreateRectRgnIndirect(&rect));
497 hPen = CreatePen(PS_SOLID, 2, 0xffffff); /* -white- color */
498 hPen = SelectObject(hDC, hPen);
499 point.x = ((long)rect.right * (long)x) / (long)MAXHORI;
500 point.y = rect.bottom - ((long)rect.bottom * (long)y) / (long)MAXVERT;
501 if ( lpp->oldcross.left != lpp->oldcross.right )
502 BitBlt(hDC, lpp->oldcross.left, lpp->oldcross.top,
503 lpp->oldcross.right - lpp->oldcross.left,
504 lpp->oldcross.bottom - lpp->oldcross.top,
505 lpp->hdcMem, lpp->oldcross.left, lpp->oldcross.top, SRCCOPY);
506 lpp->oldcross.left = point.x - w - 1;
507 lpp->oldcross.right = point.x + w + 1;
508 lpp->oldcross.top = point.y - w - 1;
509 lpp->oldcross.bottom = point.y + w + 1;
511 MoveToEx(hDC, point.x - w, point.y, &p);
512 LineTo(hDC, point.x + w, point.y);
513 MoveToEx(hDC, point.x, point.y - w, &p);
514 LineTo(hDC, point.x, point.y + w);
515 DeleteObject( SelectObject(hDC, hPen)) ;
516 ReleaseDC(hwnd, hDC);
525 /***********************************************************************
526 * CC_PrepareColorGraph [internal]
528 static void CC_PrepareColorGraph( HWND hDlg )
530 int sdif, hdif, xdif, ydif, r, g, b, hue, sat;
531 HWND hwnd = GetDlgItem(hDlg, 0x2c6);
532 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
536 HCURSOR hcursor = SetCursor( LoadCursorA(0, IDC_WAITA) );
538 GetClientRect(hwnd, &client);
540 lpp->hdcMem = CreateCompatibleDC(hdc);
541 lpp->hbmMem = CreateCompatibleBitmap(hdc, client.right, client.bottom);
542 SelectObject(lpp->hdcMem, lpp->hbmMem);
544 xdif = client.right / XSTEPS;
545 ydif = client.bottom / YSTEPS+1;
548 for (rect.left = hue = 0; hue < 239 + hdif; hue += hdif)
550 rect.right = rect.left + xdif;
551 rect.bottom = client.bottom;
552 for(sat = 0; sat < 240 + sdif; sat += sdif)
554 rect.top = rect.bottom - ydif;
555 r = CC_HSLtoRGB('R', hue, sat, 120);
556 g = CC_HSLtoRGB('G', hue, sat, 120);
557 b = CC_HSLtoRGB('B', hue, sat, 120);
558 hbrush = CreateSolidBrush( RGB(r, g, b));
559 FillRect(lpp->hdcMem, &rect, hbrush);
560 DeleteObject(hbrush);
561 rect.bottom = rect.top;
563 rect.left = rect.right;
565 ReleaseDC(hwnd, hdc);
569 /***********************************************************************
570 * CC_PaintColorGraph [internal]
572 static void CC_PaintColorGraph( HWND hDlg )
574 HWND hwnd = GetDlgItem( hDlg, 0x2c6 );
575 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
578 if (IsWindowVisible(hwnd)) /* if full size */
581 CC_PrepareColorGraph(hDlg); /* should not be necessary */
584 GetClientRect(hwnd, &rect);
586 BitBlt(hDC, 0, 0, rect.right, rect.bottom, lpp->hdcMem, 0, 0, SRCCOPY);
588 WARN("choose color: hdcMem is not defined\n");
589 ReleaseDC(hwnd, hDC);
593 /***********************************************************************
594 * CC_PaintLumBar [internal]
596 static void CC_PaintLumBar( HWND hDlg, int hue, int sat )
598 HWND hwnd = GetDlgItem(hDlg, 0x2be);
600 int lum, ldif, ydif, r, g, b;
604 if (IsWindowVisible(hwnd))
607 GetClientRect(hwnd, &client);
611 ydif = client.bottom / YSTEPS+1;
612 for (lum = 0; lum < 240 + ldif; lum += ldif)
614 rect.top = max(0, rect.bottom - ydif);
615 r = CC_HSLtoRGB('R', hue, sat, lum);
616 g = CC_HSLtoRGB('G', hue, sat, lum);
617 b = CC_HSLtoRGB('B', hue, sat, lum);
618 hbrush = CreateSolidBrush( RGB(r, g, b) );
619 FillRect(hDC, &rect, hbrush);
620 DeleteObject(hbrush);
621 rect.bottom = rect.top;
623 GetClientRect(hwnd, &rect);
624 FrameRect(hDC, &rect, GetStockObject(BLACK_BRUSH) );
625 ReleaseDC(hwnd, hDC);
629 /***********************************************************************
630 * CC_EditSetRGB [internal]
632 static void CC_EditSetRGB( HWND hDlg, COLORREF cr )
635 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
636 int r = GetRValue(cr);
637 int g = GetGValue(cr);
638 int b = GetBValue(cr);
639 if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6) )) /* if full size */
641 lpp->updating = TRUE;
642 sprintf(buffer, "%d", r);
643 SetWindowTextA( GetDlgItem(hDlg, 0x2c2), buffer);
644 sprintf(buffer, "%d", g);
645 SetWindowTextA( GetDlgItem(hDlg, 0x2c3), buffer);
646 sprintf( buffer, "%d", b );
647 SetWindowTextA( GetDlgItem(hDlg, 0x2c4),buffer);
648 lpp->updating = FALSE;
652 /***********************************************************************
653 * CC_EditSetHSL [internal]
655 static void CC_EditSetHSL( HWND hDlg, int h, int s, int l )
658 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
659 lpp->updating = TRUE;
660 if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6) )) /* if full size */
662 lpp->updating = TRUE;
663 sprintf(buffer, "%d", h);
664 SetWindowTextA( GetDlgItem(hDlg, 0x2bf), buffer);
665 sprintf(buffer, "%d", s);
666 SetWindowTextA( GetDlgItem(hDlg, 0x2c0), buffer);
667 sprintf(buffer, "%d", l);
668 SetWindowTextA( GetDlgItem(hDlg, 0x2c1), buffer);
669 lpp->updating = FALSE;
671 CC_PaintLumBar(hDlg, h, s);
674 /***********************************************************************
675 * CC_SwitchToFullSize [internal]
677 static void CC_SwitchToFullSize( HWND hDlg, COLORREF result, LPRECT lprect )
680 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
682 EnableWindow( GetDlgItem(hDlg, 0x2cf), FALSE);
683 CC_PrepareColorGraph(hDlg);
684 for (i = 0x2bf; i < 0x2c5; i++)
685 ShowWindow( GetDlgItem(hDlg, i), SW_SHOW);
686 for (i = 0x2d3; i < 0x2d9; i++)
687 ShowWindow( GetDlgItem(hDlg, i), SW_SHOW);
688 ShowWindow( GetDlgItem(hDlg, 0x2c9), SW_SHOW);
689 ShowWindow( GetDlgItem(hDlg, 0x2c8), SW_SHOW);
690 ShowWindow( GetDlgItem(hDlg, 1090), SW_SHOW);
693 SetWindowPos(hDlg, 0, 0, 0, lprect->right-lprect->left,
694 lprect->bottom-lprect->top, SWP_NOMOVE|SWP_NOZORDER);
696 ShowWindow( GetDlgItem(hDlg, 0x2be), SW_SHOW);
697 ShowWindow( GetDlgItem(hDlg, 0x2c5), SW_SHOW);
699 CC_EditSetRGB(hDlg, result);
700 CC_EditSetHSL(hDlg, lpp->h, lpp->s, lpp->l);
701 ShowWindow( GetDlgItem( hDlg, 0x2c6), SW_SHOW);
702 UpdateWindow( GetDlgItem(hDlg, 0x2c6) );
705 /***********************************************************************
706 * CC_PaintPredefColorArray [internal]
707 * Paints the default standard 48 colors
709 static void CC_PaintPredefColorArray( HWND hDlg, int rows, int cols)
711 HWND hwnd = GetDlgItem(hDlg, 0x2d0);
716 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
718 GetClientRect(hwnd, &rect);
719 dx = rect.right / cols;
720 dy = rect.bottom / rows;
724 GetClientRect(hwnd, &rect);
725 FillRect(hdc, &rect, GetClassLongA(hwnd, GCL_HBRBACKGROUND));
726 for ( j = 0; j < rows; j++ )
728 for ( i = 0; i < cols; i++ )
730 hBrush = CreateSolidBrush(predefcolors[j][i]);
733 hBrush = SelectObject(hdc, hBrush);
734 Rectangle(hdc, rect.left, rect.top,
735 rect.left + dx - DISTANCE, rect.top + dy - DISTANCE);
736 rect.left = rect.left + dx;
737 DeleteObject(SelectObject(hdc, hBrush)) ;
740 rect.top = rect.top + dy;
743 ReleaseDC(hwnd, hdc);
744 if (lpp->hwndFocus == hwnd)
745 CC_DrawCurrentFocusRect(lpp);
747 /***********************************************************************
748 * CC_PaintUserColorArray [internal]
749 * Paint the 16 user-selected colors
751 static void CC_PaintUserColorArray( HWND hDlg, int rows, int cols, COLORREF* lpcr )
753 HWND hwnd = GetDlgItem(hDlg, 0x2d1);
758 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
760 GetClientRect(hwnd, &rect);
762 dx = rect.right / cols;
763 dy = rect.bottom / rows;
769 FillRect(hdc, &rect, GetClassLongA(hwnd, GCL_HBRBACKGROUND) );
770 for (j = 0; j < rows; j++)
772 for (i = 0; i < cols; i++)
774 hBrush = CreateSolidBrush(lpcr[i+j*cols]);
777 hBrush = SelectObject(hdc, hBrush) ;
778 Rectangle(hdc, rect.left, rect.top,
779 rect.left + dx - DISTANCE, rect.top + dy - DISTANCE);
780 rect.left = rect.left + dx;
781 DeleteObject( SelectObject(hdc, hBrush) ) ;
784 rect.top = rect.top + dy;
787 ReleaseDC(hwnd, hdc);
789 if (lpp->hwndFocus == hwnd)
790 CC_DrawCurrentFocusRect(lpp);
795 /***********************************************************************
796 * CC_HookCallChk [internal]
798 static BOOL CC_HookCallChk( LPCHOOSECOLORW lpcc )
801 if(lpcc->Flags & CC_ENABLEHOOK)
808 /***********************************************************************
809 * CC_WMInitDialog [internal]
811 static LONG CC_WMInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam, BOOL b16 )
820 TRACE("WM_INITDIALOG lParam=%08lX\n", lParam);
821 lpp = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct CCPRIVATE) );
825 CHOOSECOLOR16 *ch16 = (CHOOSECOLOR16 *) lParam;
826 ch32 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CHOOSECOLORW) );
829 if (lpp->lpcc16->lStructSize != sizeof(CHOOSECOLOR16) )
831 EndDialog (hDlg, 0) ;
834 ch32->lStructSize = sizeof(CHOOSECOLORW);
835 ch32->hwndOwner = ch16->hwndOwner;
836 ch32->hInstance = ch16->hInstance;
837 ch32->lpCustColors = MapSL(ch16->lpCustColors);
838 ch32->lpfnHook = (LPCCHOOKPROC) ch16->lpfnHook; /* only used as flag */
839 ch32->Flags = ch16->Flags;
842 lpp->lpcc = (LPCHOOSECOLORW) lParam;
844 if (lpp->lpcc->lStructSize != sizeof(CHOOSECOLORW) )
846 EndDialog (hDlg, 0) ;
849 SetWindowLongA(hDlg, DWL_USER, (LONG)lpp);
851 if (!(lpp->lpcc->Flags & CC_SHOWHELP))
852 ShowWindow( GetDlgItem(hDlg,0x40e), SW_HIDE);
853 lpp->msetrgb = RegisterWindowMessageA(SETRGBSTRINGA);
856 cpos = MAKELONG(5,7); /* init */
857 if (lpp->lpcc->Flags & CC_RGBINIT)
859 for (i = 0; i < 6; i++)
860 for (j = 0; j < 8; j++)
861 if (predefcolors[i][j] == lpp->lpcc->rgbResult)
863 cpos = MAKELONG(i,j);
868 /* FIXME: Draw_a_focus_rect & set_init_values */
871 GetWindowRect(hDlg, &lpp->fullsize);
872 if (lpp->lpcc->Flags & CC_FULLOPEN || lpp->lpcc->Flags & CC_PREVENTFULLOPEN)
874 hwnd = GetDlgItem(hDlg, 0x2cf);
875 EnableWindow(hwnd, FALSE);
877 if (!(lpp->lpcc->Flags & CC_FULLOPEN ) || lpp->lpcc->Flags & CC_PREVENTFULLOPEN)
879 rect = lpp->fullsize;
880 res = rect.bottom - rect.top;
881 hwnd = GetDlgItem(hDlg, 0x2c6); /* cut at left border */
882 point.x = point.y = 0;
883 ClientToScreen(hwnd, &point);
884 ScreenToClient(hDlg,&point);
885 GetClientRect(hDlg, &rect);
886 point.x += GetSystemMetrics(SM_CXDLGFRAME);
887 SetWindowPos(hDlg, 0, 0, 0, point.x, res, SWP_NOMOVE|SWP_NOZORDER);
889 for (i = 0x2bf; i < 0x2c5; i++)
890 ShowWindow( GetDlgItem(hDlg, i), SW_HIDE);
891 for (i = 0x2d3; i < 0x2d9; i++)
892 ShowWindow( GetDlgItem(hDlg, i), SW_HIDE);
893 ShowWindow( GetDlgItem(hDlg, 0x2c9), SW_HIDE);
894 ShowWindow( GetDlgItem(hDlg, 0x2c8), SW_HIDE);
895 ShowWindow( GetDlgItem(hDlg, 0x2c6), SW_HIDE);
896 ShowWindow( GetDlgItem(hDlg, 0x2c5), SW_HIDE);
897 ShowWindow( GetDlgItem(hDlg, 1090 ), SW_HIDE);
900 CC_SwitchToFullSize(hDlg, lpp->lpcc->rgbResult, NULL);
902 for (i = 0x2bf; i < 0x2c5; i++)
903 SendMessageA( GetDlgItem(hDlg, i), EM_LIMITTEXT, 3, 0); /* max 3 digits: xyz */
904 if (CC_HookCallChk(lpp->lpcc))
907 res = CallWindowProc16( (WNDPROC16)lpp->lpcc16->lpfnHook, hDlg, WM_INITDIALOG, wParam, lParam);
909 res = CallWindowProcA( (WNDPROC)lpp->lpcc->lpfnHook, hDlg, WM_INITDIALOG, wParam, lParam);
912 /* Set the initial values of the color chooser dialog */
913 r = GetRValue(lpp->lpcc->rgbResult);
914 g = GetGValue(lpp->lpcc->rgbResult);
915 b = GetBValue(lpp->lpcc->rgbResult);
917 CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
918 lpp->h = CC_RGBtoHSL('H', r, g, b);
919 lpp->s = CC_RGBtoHSL('S', r, g, b);
920 lpp->l = CC_RGBtoHSL('L', r, g, b);
922 /* Doing it the long way becaus CC_EditSetRGB/HSL doesn'nt seem to work */
923 SetDlgItemInt(hDlg, 703, lpp->h, TRUE);
924 SetDlgItemInt(hDlg, 704, lpp->s, TRUE);
925 SetDlgItemInt(hDlg, 705, lpp->l, TRUE);
926 SetDlgItemInt(hDlg, 706, r, TRUE);
927 SetDlgItemInt(hDlg, 707, g, TRUE);
928 SetDlgItemInt(hDlg, 708, b, TRUE);
930 CC_PaintCross(hDlg, lpp->h, lpp->s);
931 CC_PaintTriangle(hDlg, lpp->l);
937 /***********************************************************************
938 * CC_WMCommand [internal]
940 static LRESULT CC_WMCommand( HWND hDlg, WPARAM wParam, LPARAM lParam, WORD notifyCode, HWND hwndCtl )
946 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
947 TRACE("CC_WMCommand wParam=%x lParam=%lx\n", wParam, lParam);
950 case 0x2c2: /* edit notify RGB */
953 if (notifyCode == EN_UPDATE && !lpp->updating)
955 i = CC_CheckDigitsInEdit(hwndCtl, 255);
956 r = GetRValue(lpp->lpcc->rgbResult);
957 g = GetGValue(lpp->lpcc->rgbResult);
958 b= GetBValue(lpp->lpcc->rgbResult);
962 case 0x2c2: if ((xx = (i != r))) r = i; break;
963 case 0x2c3: if ((xx = (i != g))) g = i; break;
964 case 0x2c4: if ((xx = (i != b))) b = i; break;
966 if (xx) /* something has changed */
968 lpp->lpcc->rgbResult = RGB(r, g, b);
969 CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
970 lpp->h = CC_RGBtoHSL('H', r, g, b);
971 lpp->s = CC_RGBtoHSL('S', r, g, b);
972 lpp->l = CC_RGBtoHSL('L', r, g, b);
973 CC_EditSetHSL(hDlg, lpp->h, lpp->s, lpp->l);
974 CC_PaintCross(hDlg, lpp->h, lpp->s);
975 CC_PaintTriangle(hDlg, lpp->l);
980 case 0x2bf: /* edit notify HSL */
983 if (notifyCode == EN_UPDATE && !lpp->updating)
985 i = CC_CheckDigitsInEdit(hwndCtl , wParam == 0x2bf ? 239:240);
989 case 0x2bf: if ((xx = ( i != lpp->h))) lpp->h = i; break;
990 case 0x2c0: if ((xx = ( i != lpp->s))) lpp->s = i; break;
991 case 0x2c1: if ((xx = ( i != lpp->l))) lpp->l = i; break;
993 if (xx) /* something has changed */
995 r = CC_HSLtoRGB('R', lpp->h, lpp->s, lpp->l);
996 g = CC_HSLtoRGB('G', lpp->h, lpp->s, lpp->l);
997 b = CC_HSLtoRGB('B', lpp->h, lpp->s, lpp->l);
998 lpp->lpcc->rgbResult = RGB(r, g, b);
999 CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
1000 CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
1001 CC_PaintCross(hDlg, lpp->h, lpp->s);
1002 CC_PaintTriangle(hDlg, lpp->l);
1008 CC_SwitchToFullSize(hDlg, lpp->lpcc->rgbResult, &lpp->fullsize);
1009 SetFocus( GetDlgItem(hDlg, 0x2bf));
1012 case 0x2c8: /* add colors ... column by column */
1013 cr = lpp->lpcc->lpCustColors;
1014 cr[(lpp->nextuserdef % 2) * 8 + lpp->nextuserdef / 2] = lpp->lpcc->rgbResult;
1015 if (++lpp->nextuserdef == 16)
1016 lpp->nextuserdef = 0;
1017 CC_PaintUserColorArray(hDlg, 2, 8, lpp->lpcc->lpCustColors);
1020 case 0x2c9: /* resulting color */
1022 lpp->lpcc->rgbResult = GetNearestColor(hdc, lpp->lpcc->rgbResult);
1023 ReleaseDC(hDlg, hdc);
1024 CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
1025 CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
1026 r = GetRValue(lpp->lpcc->rgbResult);
1027 g = GetGValue(lpp->lpcc->rgbResult);
1028 b = GetBValue(lpp->lpcc->rgbResult);
1029 lpp->h = CC_RGBtoHSL('H', r, g, b);
1030 lpp->s = CC_RGBtoHSL('S', r, g, b);
1031 lpp->l = CC_RGBtoHSL('L', r, g, b);
1032 CC_EditSetHSL(hDlg, lpp->h, lpp->s, lpp->l);
1033 CC_PaintCross(hDlg, lpp->h, lpp->s);
1034 CC_PaintTriangle(hDlg, lpp->l);
1037 case 0x40e: /* Help! */ /* The Beatles, 1965 ;-) */
1038 i = RegisterWindowMessageA(HELPMSGSTRINGA);
1041 if (lpp->lpcc->hwndOwner)
1042 SendMessageA(lpp->lpcc->hwndOwner, i, 0, (LPARAM)lpp->lpcc16);
1043 if ( CC_HookCallChk(lpp->lpcc))
1044 CallWindowProc16( (WNDPROC16) lpp->lpcc16->lpfnHook, hDlg,
1045 WM_COMMAND, psh15, (LPARAM)lpp->lpcc16);
1049 if (lpp->lpcc->hwndOwner)
1050 SendMessageA(lpp->lpcc->hwndOwner, i, 0, (LPARAM)lpp->lpcc);
1051 if ( CC_HookCallChk(lpp->lpcc))
1052 CallWindowProcA( (WNDPROC) lpp->lpcc->lpfnHook, hDlg,
1053 WM_COMMAND, psh15, (LPARAM)lpp->lpcc);
1058 cokmsg = RegisterWindowMessageA(COLOROKSTRINGA);
1061 if (lpp->lpcc->hwndOwner)
1062 if (SendMessageA(lpp->lpcc->hwndOwner, cokmsg, 0, (LPARAM)lpp->lpcc16))
1063 break; /* do NOT close */
1067 if (lpp->lpcc->hwndOwner)
1068 if (SendMessageA(lpp->lpcc->hwndOwner, cokmsg, 0, (LPARAM)lpp->lpcc))
1069 break; /* do NOT close */
1073 BYTE *ptr = MapSL(lpp->lpcc16->lpCustColors);
1074 memcpy(ptr, lpp->lpcc->lpCustColors, sizeof(COLORREF)*16);
1075 lpp->lpcc16->rgbResult = lpp->lpcc->rgbResult;
1077 EndDialog(hDlg, 1) ;
1081 EndDialog(hDlg, 0) ;
1088 /***********************************************************************
1089 * CC_WMPaint [internal]
1091 static LRESULT CC_WMPaint( HWND hDlg, WPARAM wParam, LPARAM lParam )
1095 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
1097 hdc = BeginPaint(hDlg, &ps);
1098 /* we have to paint dialog children except text and buttons */
1099 CC_PaintPredefColorArray(hDlg, 6, 8);
1100 CC_PaintUserColorArray(hDlg, 2, 8, lpp->lpcc->lpCustColors);
1101 CC_PaintLumBar(hDlg, lpp->h, lpp->s);
1102 CC_PaintCross(hDlg, lpp->h, lpp->s);
1103 CC_PaintTriangle(hDlg, lpp->l);
1104 CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
1105 CC_PaintColorGraph(hDlg);
1106 EndPaint(hDlg, &ps);
1112 /***********************************************************************
1113 * CC_WMLButtonUp [internal]
1115 static LRESULT CC_WMLButtonUp( HWND hDlg, WPARAM wParam, LPARAM lParam )
1117 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
1118 if (lpp->capturedGraph)
1120 lpp->capturedGraph = 0;
1122 CC_PaintCross(hDlg, lpp->h, lpp->s);
1129 /***********************************************************************
1130 * CC_WMMouseMove [internal]
1132 static LRESULT CC_WMMouseMove( HWND hDlg, LPARAM lParam )
1134 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
1137 if (lpp->capturedGraph)
1139 int *ptrh = NULL, *ptrs = &lpp->l;
1140 if (lpp->capturedGraph == 0x2c6)
1145 if (CC_MouseCheckColorGraph( hDlg, lpp->capturedGraph, ptrh, ptrs, lParam))
1147 r = CC_HSLtoRGB('R', lpp->h, lpp->s, lpp->l);
1148 g = CC_HSLtoRGB('G', lpp->h, lpp->s, lpp->l);
1149 b = CC_HSLtoRGB('B', lpp->h, lpp->s, lpp->l);
1150 lpp->lpcc->rgbResult = RGB(r, g, b);
1151 CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
1152 CC_EditSetHSL(hDlg,lpp->h, lpp->s, lpp->l);
1153 CC_PaintCross(hDlg, lpp->h, lpp->s);
1154 CC_PaintTriangle(hDlg, lpp->l);
1155 CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
1160 lpp->capturedGraph = 0;
1166 /***********************************************************************
1167 * CC_WMLButtonDown [internal]
1169 static LRESULT CC_WMLButtonDown( HWND hDlg, WPARAM wParam, LPARAM lParam )
1171 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
1175 if (CC_MouseCheckPredefColorArray(lpp, hDlg, 0x2d0, 6, 8, lParam))
1178 if (CC_MouseCheckUserColorArray(lpp, hDlg, 0x2d1, 2, 8, lParam))
1181 if (CC_MouseCheckColorGraph(hDlg, 0x2c6, &lpp->h, &lpp->s, lParam))
1184 lpp->capturedGraph = 0x2c6;
1187 if (CC_MouseCheckColorGraph(hDlg, 0x2be, NULL, &lpp->l, lParam))
1190 lpp->capturedGraph = 0x2be;
1195 r = CC_HSLtoRGB('R', lpp->h, lpp->s, lpp->l);
1196 g = CC_HSLtoRGB('G', lpp->h, lpp->s, lpp->l);
1197 b = CC_HSLtoRGB('B', lpp->h, lpp->s, lpp->l);
1198 lpp->lpcc->rgbResult = RGB(r, g, b);
1202 r = GetRValue(lpp->lpcc->rgbResult);
1203 g = GetGValue(lpp->lpcc->rgbResult);
1204 b = GetBValue(lpp->lpcc->rgbResult);
1205 lpp->h = CC_RGBtoHSL('H', r, g, b);
1206 lpp->s = CC_RGBtoHSL('S', r, g, b);
1207 lpp->l = CC_RGBtoHSL('L', r, g, b);
1211 CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
1212 CC_EditSetHSL(hDlg,lpp->h, lpp->s, lpp->l);
1213 CC_PaintCross(hDlg, lpp->h, lpp->s);
1214 CC_PaintTriangle(hDlg, lpp->l);
1215 CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
1222 /***********************************************************************
1223 * ColorDlgProc32 [internal]
1226 static LRESULT WINAPI ColorDlgProc( HWND hDlg, UINT message,
1227 WPARAM wParam, LPARAM lParam )
1231 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
1232 if (message != WM_INITDIALOG)
1237 if (CC_HookCallChk(lpp->lpcc))
1238 res = CallWindowProcA( (WNDPROC)lpp->lpcc->lpfnHook, hDlg, message, wParam, lParam);
1243 /* FIXME: SetRGB message
1244 if (message && message == msetrgb)
1245 return HandleSetRGB(hDlg, lParam);
1251 return CC_WMInitDialog(hDlg, wParam, lParam, FALSE);
1253 DeleteDC(lpp->hdcMem);
1254 DeleteObject(lpp->hbmMem);
1255 HeapFree(GetProcessHeap(), 0, lpp);
1256 SetWindowLongA(hDlg, DWL_USER, 0L); /* we don't need it anymore */
1259 if (CC_WMCommand( hDlg, wParam, lParam, HIWORD(wParam), (HWND) lParam))
1263 if ( CC_WMPaint(hDlg, wParam, lParam))
1266 case WM_LBUTTONDBLCLK:
1267 if (CC_MouseCheckResultWindow(hDlg, lParam))
1271 if (CC_WMMouseMove(hDlg, lParam))
1274 case WM_LBUTTONUP: /* FIXME: ClipCursor off (if in color graph)*/
1275 if (CC_WMLButtonUp(hDlg, wParam, lParam))
1278 case WM_LBUTTONDOWN:/* FIXME: ClipCursor on (if in color graph)*/
1279 if (CC_WMLButtonDown(hDlg, wParam, lParam))
1286 /***********************************************************************
1287 * ColorDlgProc16 (COMMDLG.8)
1289 LRESULT WINAPI ColorDlgProc16( HWND16 hDlg, UINT16 message,
1290 WPARAM16 wParam, LONG lParam )
1293 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
1294 if (message != WM_INITDIALOG)
1299 if (CC_HookCallChk(lpp->lpcc))
1300 res = CallWindowProc16( (WNDPROC16)lpp->lpcc16->lpfnHook, hDlg, message, wParam, lParam);
1305 /* FIXME: SetRGB message
1306 if (message && message == msetrgb)
1307 return HandleSetRGB(hDlg, lParam);
1313 return CC_WMInitDialog(hDlg, wParam, lParam, TRUE);
1315 DeleteDC(lpp->hdcMem);
1316 DeleteObject(lpp->hbmMem);
1317 HeapFree(GetProcessHeap(), 0, lpp->lpcc);
1318 HeapFree(GetProcessHeap(), 0, lpp);
1319 SetWindowLongA(hDlg, DWL_USER, 0L); /* we don't need it anymore */
1322 if (CC_WMCommand(hDlg, wParam, lParam, HIWORD(lParam), (HWND)LOWORD(lParam)))
1326 if (CC_WMPaint(hDlg, wParam, lParam))
1329 case WM_LBUTTONDBLCLK:
1330 if (CC_MouseCheckResultWindow(hDlg,lParam))
1334 if (CC_WMMouseMove(hDlg, lParam))
1337 case WM_LBUTTONUP: /* FIXME: ClipCursor off (if in color graph)*/
1338 if (CC_WMLButtonUp(hDlg, wParam, lParam))
1341 case WM_LBUTTONDOWN:/* FIXME: ClipCursor on (if in color graph)*/
1342 if (CC_WMLButtonDown(hDlg, wParam, lParam))
1351 /***********************************************************************
1352 * ChooseColor16 (COMMDLG.5)
1354 BOOL16 WINAPI ChooseColor16( LPCHOOSECOLOR16 lpChCol )
1357 HANDLE16 hDlgTmpl16 = 0, hResource16 = 0;
1358 HGLOBAL16 hGlobal16 = 0;
1359 BOOL16 bRet = FALSE;
1363 TRACE("ChooseColor\n");
1364 if (!lpChCol) return FALSE;
1366 if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE)
1367 hDlgTmpl16 = lpChCol->hInstance;
1368 else if (lpChCol->Flags & CC_ENABLETEMPLATE)
1371 if (!(hResInfo = FindResource16(lpChCol->hInstance,
1372 MapSL(lpChCol->lpTemplateName),
1375 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
1378 if (!(hDlgTmpl16 = LoadResource16(lpChCol->hInstance, hResInfo)))
1380 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
1383 hResource16 = hDlgTmpl16;
1387 HANDLE hResInfo, hDlgTmpl32;
1390 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_COLOR", RT_DIALOGA)))
1392 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
1395 if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo)) ||
1396 !(template32 = LockResource(hDlgTmpl32)))
1398 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
1401 size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo);
1402 hGlobal16 = GlobalAlloc16(0, size);
1405 COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
1406 ERR("alloc failure for %ld bytes\n", size);
1409 template = GlobalLock16(hGlobal16);
1412 COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE);
1413 ERR("global lock failure for %x handle\n", hDlgTmpl16);
1414 GlobalFree16(hGlobal16);
1417 ConvertDialog32To16((LPVOID)template32, size, (LPVOID)template);
1418 hDlgTmpl16 = hGlobal16;
1421 ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 8);
1422 hInst = GetWindowLongA(lpChCol->hwndOwner, GWL_HINSTANCE);
1423 bRet = DialogBoxIndirectParam16(hInst, hDlgTmpl16, lpChCol->hwndOwner,
1424 (DLGPROC16) ptr, (DWORD)lpChCol);
1425 if (hResource16) FreeResource16(hDlgTmpl16);
1428 GlobalUnlock16(hGlobal16);
1429 GlobalFree16(hGlobal16);
1434 /***********************************************************************
1435 * ChooseColorW (COMDLG32.@)
1437 BOOL WINAPI ChooseColorW( LPCHOOSECOLORW lpChCol )
1441 HANDLE hDlgTmpl = 0;
1445 TRACE("ChooseColor\n");
1446 if (!lpChCol) return FALSE;
1448 if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE)
1450 if (!(template = LockResource(lpChCol->hInstance)))
1452 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
1456 else if (lpChCol->Flags & CC_ENABLETEMPLATE)
1459 if (!(hResInfo = FindResourceW(lpChCol->hInstance,
1460 lpChCol->lpTemplateName,
1463 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
1466 if (!(hDlgTmpl = LoadResource(lpChCol->hInstance, hResInfo)) ||
1467 !(template = LockResource(hDlgTmpl)))
1469 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
1475 HANDLE hResInfo, hDlgTmpl;
1476 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_COLOR", RT_DIALOGA)))
1478 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
1481 if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
1482 !(template = LockResource(hDlgTmpl)))
1484 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
1489 bRet = DialogBoxIndirectParamW(COMMDLG_hInstance32, template, lpChCol->hwndOwner,
1490 (DLGPROC)ColorDlgProc, (DWORD)lpChCol);
1494 /***********************************************************************
1495 * ChooseColorA (COMDLG32.@)
1497 BOOL WINAPI ChooseColorA( LPCHOOSECOLORA lpChCol )
1501 LPCHOOSECOLORW lpcc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CHOOSECOLORW));
1502 lpcc->lStructSize = sizeof(*lpcc);
1503 lpcc->hwndOwner = lpChCol->hwndOwner;
1504 lpcc->hInstance = lpChCol->hInstance;
1505 lpcc->rgbResult = lpChCol->rgbResult;
1506 lpcc->lpCustColors = lpChCol->lpCustColors;
1507 lpcc->Flags = lpChCol->Flags;
1508 lpcc->lCustData = lpChCol->lCustData;
1509 lpcc->lpfnHook = (LPCCHOOKPROC) lpChCol->lpfnHook;
1510 if ((lpcc->Flags & CC_ENABLETEMPLATE) && (lpChCol->lpTemplateName)) {
1511 if (HIWORD(lpChCol->lpTemplateName))
1512 lpcc->lpTemplateName = HEAP_strdupAtoW(GetProcessHeap(), 0, lpChCol->lpTemplateName);
1514 lpcc->lpTemplateName = (LPWSTR)lpChCol->lpTemplateName;
1517 ret = ChooseColorW(lpcc);
1520 lpChCol->rgbResult = lpcc->rgbResult;
1521 if (HIWORD(lpcc->lpTemplateName)) HeapFree(GetProcessHeap(), 0, (LPSTR)lpcc->lpTemplateName);
1522 HeapFree(GetProcessHeap(), 0, lpcc);