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"
27 #include "debugtools.h"
31 DEFAULT_DEBUG_CHANNEL(commdlg);
35 static LRESULT WINAPI ColorDlgProc( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam );
37 #define CONV_POINTSTOPOINT( ps, p ) \
38 ((p)->x = (LONG)(ps)->x, (p)->y = (LONG)(ps)->y)
40 static const COLORREF predefcolors[6][8]=
42 { 0x008080FFL, 0x0080FFFFL, 0x0080FF80L, 0x0080FF00L,
43 0x00FFFF80L, 0x00FF8000L, 0x00C080FFL, 0x00FF80FFL },
44 { 0x000000FFL, 0x0000FFFFL, 0x0000FF80L, 0x0040FF00L,
45 0x00FFFF00L, 0x00C08000L, 0x00C08080L, 0x00FF00FFL },
47 { 0x00404080L, 0x004080FFL, 0x0000FF00L, 0x00808000L,
48 0x00804000L, 0x00FF8080L, 0x00400080L, 0x008000FFL },
49 { 0x00000080L, 0x000080FFL, 0x00008000L, 0x00408000L,
50 0x00FF0000L, 0x00A00000L, 0x00800080L, 0x00FF0080L },
52 { 0x00000040L, 0x00004080L, 0x00004000L, 0x00404000L,
53 0x00800000L, 0x00400000L, 0x00400040L, 0x00800040L },
54 { 0x00000000L, 0x00008080L, 0x00408080L, 0x00808080L,
55 0x00808040L, 0x00C0C0C0L, 0x00400040L, 0x00FFFFFFL },
60 LPCHOOSECOLORW lpcc; /* points to public known data structure */
61 LPCHOOSECOLOR16 lpcc16; /* save the 16 bits pointer */
62 int nextuserdef; /* next free place in user defined color array */
63 HDC hdcMem; /* color graph used for BitBlt() */
64 HBITMAP hbmMem; /* color graph bitmap */
65 RECT fullsize; /* original dialog window size */
66 UINT msetrgb; /* # of SETRGBSTRING message (today not used) */
67 RECT old3angle; /* last position of l-marker */
68 RECT oldcross; /* last position of color/satuation marker */
69 BOOL updating; /* to prevent recursive WM_COMMAND/EN_UPDATE processing */
72 int l; /* for temporary storing of hue,sat,lum */
73 int capturedGraph; /* control mouse captured */
74 RECT focusRect; /* rectangle last focused item */
75 HWND hwndFocus; /* handle last focused item */
78 #define LCCPRIV struct CCPRIVATE *
80 /***********************************************************************
81 * CC_HSLtoRGB [internal]
83 static int CC_HSLtoRGB(char c, int hue, int sat, int lum)
90 case 'R': if (hue > 80) hue -= 80; else hue += 160; break;
91 case 'G': if (hue > 160) hue -= 160; else hue += 80; break;
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_RGBtoHSL [internal]
128 static int CC_RGBtoHSL(char c, int r, int g, int b)
130 WORD maxi, mini, mmsum, mmdif, result = 0;
144 case 'L': mmsum *= 120; /* 0...61200=(255+255)*120 */
145 result = mmsum / 255; /* 0...240 */
148 case 'S': if (!mmsum)
151 if (!mini || maxi == 255)
155 result = mmdif * 240; /* 0...61200=255*240 */
156 result /= (mmsum > 255 ? mmsum = 510 - mmsum : mmsum); /* 0..255 */
160 case 'H': if (!mmdif)
166 iresult = 40 * (g - b); /* -10200 ... 10200 */
167 iresult /= (int) mmdif; /* -40 .. 40 */
169 iresult += 240; /* 0..40 and 200..240 */
174 iresult = 40 * (b - r);
175 iresult /= (int) mmdif;
176 iresult += 80; /* 40 .. 120 */
181 iresult = 40 * (r - g);
182 iresult /= (int) mmdif;
183 iresult += 160; /* 120 .. 200 */
189 return result; /* is this integer arithmetic precise enough ? */
193 /***********************************************************************
194 * CC_DrawCurrentFocusRect [internal]
196 void CC_DrawCurrentFocusRect( LCCPRIV lpp )
200 HDC hdc = GetDC(lpp->hwndFocus);
201 DrawFocusRect(hdc, &lpp->focusRect);
202 ReleaseDC(lpp->hwndFocus, hdc);
206 /***********************************************************************
207 * CC_DrawFocusRect [internal]
209 void CC_DrawFocusRect( LCCPRIV lpp, HWND hwnd, int x, int y, int rows, int cols)
215 CC_DrawCurrentFocusRect(lpp); /* remove current focus rect */
216 /* calculate new rect */
217 GetClientRect(hwnd, &rect);
218 dx = (rect.right - rect.left) / cols;
219 dy = (rect.bottom - rect.top) / rows;
220 rect.left += (x * dx) - 2;
221 rect.top += (y * dy) - 2;
222 rect.right = rect.left + dx;
223 rect.bottom = rect.top + dy;
226 DrawFocusRect(hdc, &rect);
227 CopyRect(&lpp->focusRect, &rect);
228 lpp->hwndFocus = hwnd;
229 ReleaseDC(hwnd, hdc);
234 /***********************************************************************
235 * CC_MouseCheckPredefColorArray [internal]
236 * returns 1 if one of the predefined colors is clicked
238 static int CC_MouseCheckPredefColorArray( LCCPRIV lpp, HWND hDlg, int dlgitem, int rows, int cols,
246 CONV_POINTSTOPOINT(&(MAKEPOINTS(lParam)) , &point);
247 ClientToScreen(hDlg, &point);
248 hwnd = GetDlgItem(hDlg, dlgitem);
249 GetWindowRect(hwnd, &rect);
250 if (PtInRect(&rect, point))
252 dx = (rect.right - rect.left) / cols;
253 dy = (rect.bottom - rect.top) / rows;
254 ScreenToClient(hwnd, &point);
256 if (point.x % dx < ( dx - DISTANCE) && point.y % dy < ( dy - DISTANCE))
260 lpp->lpcc->rgbResult = predefcolors[y][x];
261 CC_DrawFocusRect(lpp, hwnd, x, y, rows, cols);
268 /***********************************************************************
269 * CC_MouseCheckUserColorArray [internal]
270 * return 1 if the user clicked a color
272 static int CC_MouseCheckUserColorArray( LCCPRIV lpp, HWND hDlg, int dlgitem, int rows, int cols,
279 COLORREF *crarr = lpp->lpcc->lpCustColors;
281 CONV_POINTSTOPOINT(&(MAKEPOINTS(lParam)), &point);
282 ClientToScreen(hDlg, &point);
283 hwnd = GetDlgItem(hDlg, dlgitem);
284 GetWindowRect(hwnd, &rect);
285 if (PtInRect(&rect, point))
287 dx = (rect.right - rect.left) / cols;
288 dy = (rect.bottom - rect.top) / rows;
289 ScreenToClient(hwnd, &point);
291 if (point.x % dx < (dx - DISTANCE) && point.y % dy < (dy - DISTANCE))
295 lpp->lpcc->rgbResult = crarr[x + (cols * y) ];
296 CC_DrawFocusRect(lpp, hwnd, x, y, rows, cols);
306 /* 240 ^...... ^^ 240
313 /***********************************************************************
314 * CC_MouseCheckColorGraph [internal]
316 static int CC_MouseCheckColorGraph( HWND hDlg, int dlgitem, int *hori, int *vert, LPARAM lParam )
323 CONV_POINTSTOPOINT(&(MAKEPOINTS(lParam)), &point);
324 ClientToScreen(hDlg, &point);
325 hwnd = GetDlgItem( hDlg, dlgitem );
326 GetWindowRect(hwnd, &rect);
327 if (PtInRect(&rect, point))
329 GetClientRect(hwnd, &rect);
330 ScreenToClient(hwnd, &point);
332 x = (long) point.x * MAXHORI;
334 y = (long) (rect.bottom - point.y) * MAXVERT;
346 /***********************************************************************
347 * CC_MouseCheckResultWindow [internal]
348 * test if double click one of the result colors
350 static int CC_MouseCheckResultWindow( HWND hDlg, LPARAM lParam )
356 CONV_POINTSTOPOINT(&(MAKEPOINTS(lParam)), &point);
357 ClientToScreen(hDlg, &point);
358 hwnd = GetDlgItem(hDlg, 0x2c5);
359 GetWindowRect(hwnd, &rect);
360 if (PtInRect(&rect, point))
362 PostMessageA(hDlg, WM_COMMAND, 0x2c9, 0);
368 /***********************************************************************
369 * CC_CheckDigitsInEdit [internal]
371 static int CC_CheckDigitsInEdit( HWND hwnd, int maxval )
373 int i, k, m, result, value;
377 GetWindowTextA(hwnd, buffer, sizeof(buffer));
381 for (i = 0 ; i < m ; i++)
382 if (buffer[i] < '0' || buffer[i] > '9')
384 for (k = i + 1; k <= m; k++) /* delete bad character */
386 buffer[i] = buffer[k];
393 value = atoi(buffer);
394 if (value > maxval) /* build a new string */
396 sprintf(buffer, "%d", maxval);
401 editpos = SendMessageA(hwnd, EM_GETSEL, 0, 0);
402 SetWindowTextA(hwnd, buffer );
403 SendMessageA(hwnd, EM_SETSEL, 0, editpos);
410 /***********************************************************************
411 * CC_PaintSelectedColor [internal]
413 static void CC_PaintSelectedColor( HWND hDlg, COLORREF cr )
418 HWND hwnd = GetDlgItem(hDlg, 0x2c5);
419 if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6) )) /* if full size */
422 GetClientRect(hwnd, &rect) ;
423 hBrush = CreateSolidBrush(cr);
426 hBrush = SelectObject(hdc, hBrush) ;
427 Rectangle(hdc, rect.left, rect.top, rect.right/2, rect.bottom);
428 DeleteObject ( SelectObject(hdc, hBrush) ) ;
429 hBrush = CreateSolidBrush( GetNearestColor(hdc, cr) );
432 hBrush = SelectObject(hdc, hBrush) ;
433 Rectangle(hdc, rect.right/2-1, rect.top, rect.right, rect.bottom);
434 DeleteObject(SelectObject(hdc, hBrush)) ;
437 ReleaseDC(hwnd, hdc);
441 /***********************************************************************
442 * CC_PaintTriangle [internal]
444 static void CC_PaintTriangle( HWND hDlg, int y)
448 int w = LOWORD(GetDialogBaseUnits());
453 HWND hwnd = GetDlgItem(hDlg, 0x2be);
454 LCCPRIV lpp = (LCCPRIV)GetWindowLongA( hDlg, DWL_USER);
456 if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6))) /* if full size */
458 GetClientRect(hwnd, &rect);
459 height = rect.bottom;
461 points[0].y = rect.top;
462 points[0].x = rect.right; /* | /| */
463 ClientToScreen(hwnd, points); /* | / | */
464 ScreenToClient(hDlg, points); /* |< | */
465 oben = points[0].y; /* | \ | */
467 temp = (long)height * (long)y;
468 points[0].y = oben + height - temp / (long)MAXVERT;
469 points[1].y = points[0].y + w;
470 points[2].y = points[0].y - w;
471 points[2].x = points[1].x = points[0].x + w;
473 FillRect(hDC, &lpp->old3angle, GetClassLongA( hwnd, GCL_HBRBACKGROUND));
474 lpp->old3angle.left = points[0].x;
475 lpp->old3angle.right = points[1].x + 1;
476 lpp->old3angle.top = points[2].y - 1;
477 lpp->old3angle.bottom= points[1].y + 1;
478 Polygon(hDC, points, 3);
479 ReleaseDC(hDlg, hDC);
484 /***********************************************************************
485 * CC_PaintCross [internal]
487 static void CC_PaintCross( HWND hDlg, int x, int y)
490 int w = GetDialogBaseUnits();
491 HWND hwnd = GetDlgItem(hDlg, 0x2c6);
492 LCCPRIV lpp = (LCCPRIV)GetWindowLongA( hDlg, DWL_USER );
497 if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6) )) /* if full size */
499 GetClientRect(hwnd, &rect);
501 SelectClipRgn( hDC, CreateRectRgnIndirect(&rect));
502 hPen = CreatePen(PS_SOLID, 2, 0xffffff); /* -white- color */
503 hPen = SelectObject(hDC, hPen);
504 point.x = ((long)rect.right * (long)x) / (long)MAXHORI;
505 point.y = rect.bottom - ((long)rect.bottom * (long)y) / (long)MAXVERT;
506 if ( lpp->oldcross.left != lpp->oldcross.right )
507 BitBlt(hDC, lpp->oldcross.left, lpp->oldcross.top,
508 lpp->oldcross.right - lpp->oldcross.left,
509 lpp->oldcross.bottom - lpp->oldcross.top,
510 lpp->hdcMem, lpp->oldcross.left, lpp->oldcross.top, SRCCOPY);
511 lpp->oldcross.left = point.x - w - 1;
512 lpp->oldcross.right = point.x + w + 1;
513 lpp->oldcross.top = point.y - w - 1;
514 lpp->oldcross.bottom = point.y + w + 1;
516 MoveToEx(hDC, point.x - w, point.y, &p);
517 LineTo(hDC, point.x + w, point.y);
518 MoveToEx(hDC, point.x, point.y - w, &p);
519 LineTo(hDC, point.x, point.y + w);
520 DeleteObject( SelectObject(hDC, hPen)) ;
521 ReleaseDC(hwnd, hDC);
530 /***********************************************************************
531 * CC_PrepareColorGraph [internal]
533 static void CC_PrepareColorGraph( HWND hDlg )
535 int sdif, hdif, xdif, ydif, r, g, b, hue, sat;
536 HWND hwnd = GetDlgItem(hDlg, 0x2c6);
537 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
541 HCURSOR hcursor = SetCursor( LoadCursorA(0, IDC_WAITA) );
543 GetClientRect(hwnd, &client);
545 lpp->hdcMem = CreateCompatibleDC(hdc);
546 lpp->hbmMem = CreateCompatibleBitmap(hdc, client.right, client.bottom);
547 SelectObject(lpp->hdcMem, lpp->hbmMem);
549 xdif = client.right / XSTEPS;
550 ydif = client.bottom / YSTEPS+1;
553 for (rect.left = hue = 0; hue < 239 + hdif; hue += hdif)
555 rect.right = rect.left + xdif;
556 rect.bottom = client.bottom;
557 for(sat = 0; sat < 240 + sdif; sat += sdif)
559 rect.top = rect.bottom - ydif;
560 r = CC_HSLtoRGB('R', hue, sat, 120);
561 g = CC_HSLtoRGB('G', hue, sat, 120);
562 b = CC_HSLtoRGB('B', hue, sat, 120);
563 hbrush = CreateSolidBrush( RGB(r, g, b));
564 FillRect(lpp->hdcMem, &rect, hbrush);
565 DeleteObject(hbrush);
566 rect.bottom = rect.top;
568 rect.left = rect.right;
570 ReleaseDC(hwnd, hdc);
574 /***********************************************************************
575 * CC_PaintColorGraph [internal]
577 static void CC_PaintColorGraph( HWND hDlg )
579 HWND hwnd = GetDlgItem( hDlg, 0x2c6 );
580 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
583 if (IsWindowVisible(hwnd)) /* if full size */
586 CC_PrepareColorGraph(hDlg); /* should not be necessary */
589 GetClientRect(hwnd, &rect);
591 BitBlt(hDC, 0, 0, rect.right, rect.bottom, lpp->hdcMem, 0, 0, SRCCOPY);
593 WARN("choose color: hdcMem is not defined\n");
594 ReleaseDC(hwnd, hDC);
598 /***********************************************************************
599 * CC_PaintLumBar [internal]
601 static void CC_PaintLumBar( HWND hDlg, int hue, int sat )
603 HWND hwnd = GetDlgItem(hDlg, 0x2be);
605 int lum, ldif, ydif, r, g, b;
609 if (IsWindowVisible(hwnd))
612 GetClientRect(hwnd, &client);
616 ydif = client.bottom / YSTEPS+1;
617 for (lum = 0; lum < 240 + ldif; lum += ldif)
619 rect.top = max(0, rect.bottom - ydif);
620 r = CC_HSLtoRGB('R', hue, sat, lum);
621 g = CC_HSLtoRGB('G', hue, sat, lum);
622 b = CC_HSLtoRGB('B', hue, sat, lum);
623 hbrush = CreateSolidBrush( RGB(r, g, b) );
624 FillRect(hDC, &rect, hbrush);
625 DeleteObject(hbrush);
626 rect.bottom = rect.top;
628 GetClientRect(hwnd, &rect);
629 FrameRect(hDC, &rect, GetStockObject(BLACK_BRUSH) );
630 ReleaseDC(hwnd, hDC);
634 /***********************************************************************
635 * CC_EditSetRGB [internal]
637 static void CC_EditSetRGB( HWND hDlg, COLORREF cr )
640 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
641 int r = GetRValue(cr);
642 int g = GetGValue(cr);
643 int b = GetBValue(cr);
644 if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6) )) /* if full size */
646 lpp->updating = TRUE;
647 sprintf(buffer, "%d", r);
648 SetWindowTextA( GetDlgItem(hDlg, 0x2c2), buffer);
649 sprintf(buffer, "%d", g);
650 SetWindowTextA( GetDlgItem(hDlg, 0x2c3), buffer);
651 sprintf( buffer, "%d", b );
652 SetWindowTextA( GetDlgItem(hDlg, 0x2c4),buffer);
653 lpp->updating = FALSE;
657 /***********************************************************************
658 * CC_EditSetHSL [internal]
660 static void CC_EditSetHSL( HWND hDlg, int h, int s, int l )
663 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
664 lpp->updating = TRUE;
665 if (IsWindowVisible( GetDlgItem(hDlg, 0x2c6) )) /* if full size */
667 lpp->updating = TRUE;
668 sprintf(buffer, "%d", h);
669 SetWindowTextA( GetDlgItem(hDlg, 0x2bf), buffer);
670 sprintf(buffer, "%d", s);
671 SetWindowTextA( GetDlgItem(hDlg, 0x2c0), buffer);
672 sprintf(buffer, "%d", l);
673 SetWindowTextA( GetDlgItem(hDlg, 0x2c1), buffer);
674 lpp->updating = FALSE;
676 CC_PaintLumBar(hDlg, h, s);
679 /***********************************************************************
680 * CC_SwitchToFullSize [internal]
682 static void CC_SwitchToFullSize( HWND hDlg, COLORREF result, LPRECT lprect )
685 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
687 EnableWindow( GetDlgItem(hDlg, 0x2cf), FALSE);
688 CC_PrepareColorGraph(hDlg);
689 for (i = 0x2bf; i < 0x2c5; i++)
690 ShowWindow( GetDlgItem(hDlg, i), SW_SHOW);
691 for (i = 0x2d3; i < 0x2d9; i++)
692 ShowWindow( GetDlgItem(hDlg, i), SW_SHOW);
693 ShowWindow( GetDlgItem(hDlg, 0x2c9), SW_SHOW);
694 ShowWindow( GetDlgItem(hDlg, 0x2c8), SW_SHOW);
695 ShowWindow( GetDlgItem(hDlg, 1090), SW_SHOW);
698 SetWindowPos(hDlg, 0, 0, 0, lprect->right-lprect->left,
699 lprect->bottom-lprect->top, SWP_NOMOVE|SWP_NOZORDER);
701 ShowWindow( GetDlgItem(hDlg, 0x2be), SW_SHOW);
702 ShowWindow( GetDlgItem(hDlg, 0x2c5), SW_SHOW);
704 CC_EditSetRGB(hDlg, result);
705 CC_EditSetHSL(hDlg, lpp->h, lpp->s, lpp->l);
706 ShowWindow( GetDlgItem( hDlg, 0x2c6), SW_SHOW);
707 UpdateWindow( GetDlgItem(hDlg, 0x2c6) );
710 /***********************************************************************
711 * CC_PaintPredefColorArray [internal]
712 * Paints the default standard 48 colors
714 static void CC_PaintPredefColorArray( HWND hDlg, int rows, int cols)
716 HWND hwnd = GetDlgItem(hDlg, 0x2d0);
721 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
723 GetClientRect(hwnd, &rect);
724 dx = rect.right / cols;
725 dy = rect.bottom / rows;
729 GetClientRect(hwnd, &rect);
730 FillRect(hdc, &rect, GetClassLongA(hwnd, GCL_HBRBACKGROUND));
731 for ( j = 0; j < rows; j++ )
733 for ( i = 0; i < cols; i++ )
735 hBrush = CreateSolidBrush(predefcolors[j][i]);
738 hBrush = SelectObject(hdc, hBrush);
739 Rectangle(hdc, rect.left, rect.top,
740 rect.left + dx - DISTANCE, rect.top + dy - DISTANCE);
741 rect.left = rect.left + dx;
742 DeleteObject(SelectObject(hdc, hBrush)) ;
745 rect.top = rect.top + dy;
748 ReleaseDC(hwnd, hdc);
749 if (lpp->hwndFocus == hwnd)
750 CC_DrawCurrentFocusRect(lpp);
752 /***********************************************************************
753 * CC_PaintUserColorArray [internal]
754 * Paint the 16 user-selected colors
756 static void CC_PaintUserColorArray( HWND hDlg, int rows, int cols, COLORREF* lpcr )
758 HWND hwnd = GetDlgItem(hDlg, 0x2d1);
763 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
765 GetClientRect(hwnd, &rect);
767 dx = rect.right / cols;
768 dy = rect.bottom / rows;
774 FillRect(hdc, &rect, GetClassLongA(hwnd, GCL_HBRBACKGROUND) );
775 for (j = 0; j < rows; j++)
777 for (i = 0; i < cols; i++)
779 hBrush = CreateSolidBrush(lpcr[i+j*cols]);
782 hBrush = SelectObject(hdc, hBrush) ;
783 Rectangle(hdc, rect.left, rect.top,
784 rect.left + dx - DISTANCE, rect.top + dy - DISTANCE);
785 rect.left = rect.left + dx;
786 DeleteObject( SelectObject(hdc, hBrush) ) ;
789 rect.top = rect.top + dy;
792 ReleaseDC(hwnd, hdc);
794 if (lpp->hwndFocus == hwnd)
795 CC_DrawCurrentFocusRect(lpp);
800 /***********************************************************************
801 * CC_HookCallChk [internal]
803 static BOOL CC_HookCallChk( LPCHOOSECOLORW lpcc )
806 if(lpcc->Flags & CC_ENABLEHOOK)
813 /***********************************************************************
814 * CC_WMInitDialog [internal]
816 static LONG CC_WMInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam, BOOL b16 )
825 TRACE("WM_INITDIALOG lParam=%08lX\n", lParam);
826 lpp = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct CCPRIVATE) );
830 CHOOSECOLOR16 *ch16 = (CHOOSECOLOR16 *) lParam;
831 ch32 = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CHOOSECOLORW) );
834 if (lpp->lpcc16->lStructSize != sizeof(CHOOSECOLOR16) )
836 EndDialog (hDlg, 0) ;
839 ch32->lStructSize = sizeof(CHOOSECOLORW);
840 ch32->hwndOwner = ch16->hwndOwner;
841 ch32->hInstance = ch16->hInstance;
842 ch32->lpCustColors = PTR_SEG_TO_LIN(ch16->lpCustColors);
843 ch32->lpfnHook = (LPCCHOOKPROC) ch16->lpfnHook; /* only used as flag */
844 ch32->Flags = ch16->Flags;
847 lpp->lpcc = (LPCHOOSECOLORW) lParam;
849 if (lpp->lpcc->lStructSize != sizeof(CHOOSECOLORW) )
851 EndDialog (hDlg, 0) ;
854 SetWindowLongA(hDlg, DWL_USER, (LONG)lpp);
856 if (!(lpp->lpcc->Flags & CC_SHOWHELP))
857 ShowWindow( GetDlgItem(hDlg,0x40e), SW_HIDE);
858 lpp->msetrgb = RegisterWindowMessageA(SETRGBSTRING);
861 cpos = MAKELONG(5,7); /* init */
862 if (lpp->lpcc->Flags & CC_RGBINIT)
864 for (i = 0; i < 6; i++)
865 for (j = 0; j < 8; j++)
866 if (predefcolors[i][j] == lpp->lpcc->rgbResult)
868 cpos = MAKELONG(i,j);
873 /* FIXME: Draw_a_focus_rect & set_init_values */
876 GetWindowRect(hDlg, &lpp->fullsize);
877 if (lpp->lpcc->Flags & CC_FULLOPEN || lpp->lpcc->Flags & CC_PREVENTFULLOPEN)
879 hwnd = GetDlgItem(hDlg, 0x2cf);
880 EnableWindow(hwnd, FALSE);
882 if (!(lpp->lpcc->Flags & CC_FULLOPEN ) || lpp->lpcc->Flags & CC_PREVENTFULLOPEN)
884 rect = lpp->fullsize;
885 res = rect.bottom - rect.top;
886 hwnd = GetDlgItem(hDlg, 0x2c6); /* cut at left border */
887 point.x = point.y = 0;
888 ClientToScreen(hwnd, &point);
889 ScreenToClient(hDlg,&point);
890 GetClientRect(hDlg, &rect);
891 point.x += GetSystemMetrics(SM_CXDLGFRAME);
892 SetWindowPos(hDlg, 0, 0, 0, point.x, res, SWP_NOMOVE|SWP_NOZORDER);
894 for (i = 0x2bf; i < 0x2c5; i++)
895 ShowWindow( GetDlgItem(hDlg, i), SW_HIDE);
896 for (i = 0x2d3; i < 0x2d9; i++)
897 ShowWindow( GetDlgItem(hDlg, i), SW_HIDE);
898 ShowWindow( GetDlgItem(hDlg, 0x2c9), SW_HIDE);
899 ShowWindow( GetDlgItem(hDlg, 0x2c8), SW_HIDE);
900 ShowWindow( GetDlgItem(hDlg, 0x2c6), SW_HIDE);
901 ShowWindow( GetDlgItem(hDlg, 0x2c5), SW_HIDE);
902 ShowWindow( GetDlgItem(hDlg, 1090 ), SW_HIDE);
905 CC_SwitchToFullSize(hDlg, lpp->lpcc->rgbResult, NULL);
907 for (i = 0x2bf; i < 0x2c5; i++)
908 SendMessageA( GetDlgItem(hDlg, i), EM_LIMITTEXT, 3, 0); /* max 3 digits: xyz */
909 if (CC_HookCallChk(lpp->lpcc))
912 res = CallWindowProc16( (WNDPROC16)lpp->lpcc16->lpfnHook, hDlg, WM_INITDIALOG, wParam, lParam);
914 res = CallWindowProcA( (WNDPROC)lpp->lpcc->lpfnHook, hDlg, WM_INITDIALOG, wParam, lParam);
917 /* Set the initial values of the color chooser dialog */
918 r = GetRValue(lpp->lpcc->rgbResult);
919 g = GetGValue(lpp->lpcc->rgbResult);
920 b = GetBValue(lpp->lpcc->rgbResult);
922 CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
923 lpp->h = CC_RGBtoHSL('H', r, g, b);
924 lpp->s = CC_RGBtoHSL('S', r, g, b);
925 lpp->l = CC_RGBtoHSL('L', r, g, b);
927 /* Doing it the long way becaus CC_EditSetRGB/HSL doesn'nt seem to work */
928 SetDlgItemInt(hDlg, 703, lpp->h, TRUE);
929 SetDlgItemInt(hDlg, 704, lpp->s, TRUE);
930 SetDlgItemInt(hDlg, 705, lpp->l, TRUE);
931 SetDlgItemInt(hDlg, 706, r, TRUE);
932 SetDlgItemInt(hDlg, 707, g, TRUE);
933 SetDlgItemInt(hDlg, 708, b, TRUE);
935 CC_PaintCross(hDlg, lpp->h, lpp->s);
936 CC_PaintTriangle(hDlg, lpp->l);
942 /***********************************************************************
943 * CC_WMCommand [internal]
945 static LRESULT CC_WMCommand( HWND hDlg, WPARAM wParam, LPARAM lParam, WORD notifyCode, HWND hwndCtl )
951 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
952 TRACE("CC_WMCommand wParam=%x lParam=%lx\n", wParam, lParam);
955 case 0x2c2: /* edit notify RGB */
958 if (notifyCode == EN_UPDATE && !lpp->updating)
960 i = CC_CheckDigitsInEdit(hwndCtl, 255);
961 r = GetRValue(lpp->lpcc->rgbResult);
962 g = GetGValue(lpp->lpcc->rgbResult);
963 b= GetBValue(lpp->lpcc->rgbResult);
967 case 0x2c2: if ((xx = (i != r))) r = i; break;
968 case 0x2c3: if ((xx = (i != g))) g = i; break;
969 case 0x2c4: if ((xx = (i != b))) b = i; break;
971 if (xx) /* something has changed */
973 lpp->lpcc->rgbResult = RGB(r, g, b);
974 CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
975 lpp->h = CC_RGBtoHSL('H', r, g, b);
976 lpp->s = CC_RGBtoHSL('S', r, g, b);
977 lpp->l = CC_RGBtoHSL('L', r, g, b);
978 CC_EditSetHSL(hDlg, lpp->h, lpp->s, lpp->l);
979 CC_PaintCross(hDlg, lpp->h, lpp->s);
980 CC_PaintTriangle(hDlg, lpp->l);
985 case 0x2bf: /* edit notify HSL */
988 if (notifyCode == EN_UPDATE && !lpp->updating)
990 i = CC_CheckDigitsInEdit(hwndCtl , wParam == 0x2bf ? 239:240);
994 case 0x2bf: if ((xx = ( i != lpp->h))) lpp->h = i; break;
995 case 0x2c0: if ((xx = ( i != lpp->s))) lpp->s = i; break;
996 case 0x2c1: if ((xx = ( i != lpp->l))) lpp->l = i; break;
998 if (xx) /* something has changed */
1000 r = CC_HSLtoRGB('R', lpp->h, lpp->s, lpp->l);
1001 g = CC_HSLtoRGB('G', lpp->h, lpp->s, lpp->l);
1002 b = CC_HSLtoRGB('B', lpp->h, lpp->s, lpp->l);
1003 lpp->lpcc->rgbResult = RGB(r, g, b);
1004 CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
1005 CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
1006 CC_PaintCross(hDlg, lpp->h, lpp->s);
1007 CC_PaintTriangle(hDlg, lpp->l);
1013 CC_SwitchToFullSize(hDlg, lpp->lpcc->rgbResult, &lpp->fullsize);
1014 SetFocus( GetDlgItem(hDlg, 0x2bf));
1017 case 0x2c8: /* add colors ... column by column */
1018 cr = lpp->lpcc->lpCustColors;
1019 cr[(lpp->nextuserdef % 2) * 8 + lpp->nextuserdef / 2] = lpp->lpcc->rgbResult;
1020 if (++lpp->nextuserdef == 16)
1021 lpp->nextuserdef = 0;
1022 CC_PaintUserColorArray(hDlg, 2, 8, lpp->lpcc->lpCustColors);
1025 case 0x2c9: /* resulting color */
1027 lpp->lpcc->rgbResult = GetNearestColor(hdc, lpp->lpcc->rgbResult);
1028 ReleaseDC(hDlg, hdc);
1029 CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
1030 CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
1031 r = GetRValue(lpp->lpcc->rgbResult);
1032 g = GetGValue(lpp->lpcc->rgbResult);
1033 b = GetBValue(lpp->lpcc->rgbResult);
1034 lpp->h = CC_RGBtoHSL('H', r, g, b);
1035 lpp->s = CC_RGBtoHSL('S', r, g, b);
1036 lpp->l = CC_RGBtoHSL('L', r, g, b);
1037 CC_EditSetHSL(hDlg, lpp->h, lpp->s, lpp->l);
1038 CC_PaintCross(hDlg, lpp->h, lpp->s);
1039 CC_PaintTriangle(hDlg, lpp->l);
1042 case 0x40e: /* Help! */ /* The Beatles, 1965 ;-) */
1043 i = RegisterWindowMessageA(HELPMSGSTRING);
1046 if (lpp->lpcc->hwndOwner)
1047 SendMessage16(lpp->lpcc->hwndOwner, i, 0, (LPARAM)lpp->lpcc16);
1048 if ( CC_HookCallChk(lpp->lpcc))
1049 CallWindowProc16( (WNDPROC16) lpp->lpcc16->lpfnHook, hDlg,
1050 WM_COMMAND, psh15, (LPARAM)lpp->lpcc16);
1054 if (lpp->lpcc->hwndOwner)
1055 SendMessageA(lpp->lpcc->hwndOwner, i, 0, (LPARAM)lpp->lpcc);
1056 if ( CC_HookCallChk(lpp->lpcc))
1057 CallWindowProcA( (WNDPROC) lpp->lpcc->lpfnHook, hDlg,
1058 WM_COMMAND, psh15, (LPARAM)lpp->lpcc);
1063 cokmsg = RegisterWindowMessageA(COLOROKSTRING);
1066 if (lpp->lpcc->hwndOwner)
1067 if (SendMessage16(lpp->lpcc->hwndOwner, cokmsg, 0, (LPARAM)lpp->lpcc16))
1068 break; /* do NOT close */
1072 if (lpp->lpcc->hwndOwner)
1073 if (SendMessageA(lpp->lpcc->hwndOwner, cokmsg, 0, (LPARAM)lpp->lpcc))
1074 break; /* do NOT close */
1078 BYTE *ptr = PTR_SEG_TO_LIN(lpp->lpcc16->lpCustColors);
1079 memcpy(ptr, lpp->lpcc->lpCustColors, sizeof(COLORREF)*16);
1080 lpp->lpcc16->rgbResult = lpp->lpcc->rgbResult;
1082 EndDialog(hDlg, 1) ;
1086 EndDialog(hDlg, 0) ;
1093 /***********************************************************************
1094 * CC_WMPaint [internal]
1096 static LRESULT CC_WMPaint( HWND hDlg, WPARAM wParam, LPARAM lParam )
1100 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
1102 hdc = BeginPaint(hDlg, &ps);
1103 /* we have to paint dialog children except text and buttons */
1104 CC_PaintPredefColorArray(hDlg, 6, 8);
1105 CC_PaintUserColorArray(hDlg, 2, 8, lpp->lpcc->lpCustColors);
1106 CC_PaintLumBar(hDlg, lpp->h, lpp->s);
1107 CC_PaintCross(hDlg, lpp->h, lpp->s);
1108 CC_PaintTriangle(hDlg, lpp->l);
1109 CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
1110 CC_PaintColorGraph(hDlg);
1111 EndPaint(hDlg, &ps);
1117 /***********************************************************************
1118 * CC_WMLButtonUp [internal]
1120 static LRESULT CC_WMLButtonUp( HWND hDlg, WPARAM wParam, LPARAM lParam )
1122 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
1123 if (lpp->capturedGraph)
1125 lpp->capturedGraph = 0;
1127 CC_PaintCross(hDlg, lpp->h, lpp->s);
1134 /***********************************************************************
1135 * CC_WMMouseMove [internal]
1137 static LRESULT CC_WMMouseMove( HWND hDlg, LPARAM lParam )
1139 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
1142 if (lpp->capturedGraph)
1144 int *ptrh = NULL, *ptrs = &lpp->l;
1145 if (lpp->capturedGraph == 0x2c6)
1150 if (CC_MouseCheckColorGraph( hDlg, lpp->capturedGraph, ptrh, ptrs, lParam))
1152 r = CC_HSLtoRGB('R', lpp->h, lpp->s, lpp->l);
1153 g = CC_HSLtoRGB('G', lpp->h, lpp->s, lpp->l);
1154 b = CC_HSLtoRGB('B', lpp->h, lpp->s, lpp->l);
1155 lpp->lpcc->rgbResult = RGB(r, g, b);
1156 CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
1157 CC_EditSetHSL(hDlg,lpp->h, lpp->s, lpp->l);
1158 CC_PaintCross(hDlg, lpp->h, lpp->s);
1159 CC_PaintTriangle(hDlg, lpp->l);
1160 CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
1165 lpp->capturedGraph = 0;
1171 /***********************************************************************
1172 * CC_WMLButtonDown [internal]
1174 static LRESULT CC_WMLButtonDown( HWND hDlg, WPARAM wParam, LPARAM lParam )
1176 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
1180 if (CC_MouseCheckPredefColorArray(lpp, hDlg, 0x2d0, 6, 8, lParam))
1183 if (CC_MouseCheckUserColorArray(lpp, hDlg, 0x2d1, 2, 8, lParam))
1186 if (CC_MouseCheckColorGraph(hDlg, 0x2c6, &lpp->h, &lpp->s, lParam))
1189 lpp->capturedGraph = 0x2c6;
1192 if (CC_MouseCheckColorGraph(hDlg, 0x2be, NULL, &lpp->l, lParam))
1195 lpp->capturedGraph = 0x2be;
1200 r = CC_HSLtoRGB('R', lpp->h, lpp->s, lpp->l);
1201 g = CC_HSLtoRGB('G', lpp->h, lpp->s, lpp->l);
1202 b = CC_HSLtoRGB('B', lpp->h, lpp->s, lpp->l);
1203 lpp->lpcc->rgbResult = RGB(r, g, b);
1207 r = GetRValue(lpp->lpcc->rgbResult);
1208 g = GetGValue(lpp->lpcc->rgbResult);
1209 b = GetBValue(lpp->lpcc->rgbResult);
1210 lpp->h = CC_RGBtoHSL('H', r, g, b);
1211 lpp->s = CC_RGBtoHSL('S', r, g, b);
1212 lpp->l = CC_RGBtoHSL('L', r, g, b);
1216 CC_EditSetRGB(hDlg, lpp->lpcc->rgbResult);
1217 CC_EditSetHSL(hDlg,lpp->h, lpp->s, lpp->l);
1218 CC_PaintCross(hDlg, lpp->h, lpp->s);
1219 CC_PaintTriangle(hDlg, lpp->l);
1220 CC_PaintSelectedColor(hDlg, lpp->lpcc->rgbResult);
1227 /***********************************************************************
1228 * ColorDlgProc32 [internal]
1231 static LRESULT WINAPI ColorDlgProc( HWND hDlg, UINT message,
1232 WPARAM wParam, LPARAM lParam )
1236 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
1237 if (message != WM_INITDIALOG)
1242 if (CC_HookCallChk(lpp->lpcc))
1243 res = CallWindowProcA( (WNDPROC)lpp->lpcc->lpfnHook, hDlg, message, wParam, lParam);
1248 /* FIXME: SetRGB message
1249 if (message && message == msetrgb)
1250 return HandleSetRGB(hDlg, lParam);
1256 return CC_WMInitDialog(hDlg, wParam, lParam, FALSE);
1258 DeleteDC(lpp->hdcMem);
1259 DeleteObject(lpp->hbmMem);
1260 HeapFree(GetProcessHeap(), 0, lpp);
1261 SetWindowLongA(hDlg, DWL_USER, 0L); /* we don't need it anymore */
1264 if (CC_WMCommand( hDlg, wParam, lParam, HIWORD(wParam), (HWND) lParam))
1268 if ( CC_WMPaint(hDlg, wParam, lParam))
1271 case WM_LBUTTONDBLCLK:
1272 if (CC_MouseCheckResultWindow(hDlg, lParam))
1276 if (CC_WMMouseMove(hDlg, lParam))
1279 case WM_LBUTTONUP: /* FIXME: ClipCursor off (if in color graph)*/
1280 if (CC_WMLButtonUp(hDlg, wParam, lParam))
1283 case WM_LBUTTONDOWN:/* FIXME: ClipCursor on (if in color graph)*/
1284 if (CC_WMLButtonDown(hDlg, wParam, lParam))
1291 /***********************************************************************
1292 * ColorDlgProc16 (COMMDLG.8)
1294 LRESULT WINAPI ColorDlgProc16( HWND16 hDlg, UINT16 message,
1295 WPARAM16 wParam, LONG lParam )
1298 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
1299 if (message != WM_INITDIALOG)
1304 if (CC_HookCallChk(lpp->lpcc))
1305 res = CallWindowProc16( (WNDPROC16)lpp->lpcc16->lpfnHook, hDlg, message, wParam, lParam);
1310 /* FIXME: SetRGB message
1311 if (message && message == msetrgb)
1312 return HandleSetRGB(hDlg, lParam);
1318 return CC_WMInitDialog(hDlg, wParam, lParam, TRUE);
1320 DeleteDC(lpp->hdcMem);
1321 DeleteObject(lpp->hbmMem);
1322 HeapFree(GetProcessHeap(), 0, lpp->lpcc);
1323 HeapFree(GetProcessHeap(), 0, lpp);
1324 SetWindowLongA(hDlg, DWL_USER, 0L); /* we don't need it anymore */
1327 if (CC_WMCommand(hDlg, wParam, lParam, HIWORD(lParam), (HWND)LOWORD(lParam)))
1331 if (CC_WMPaint(hDlg, wParam, lParam))
1334 case WM_LBUTTONDBLCLK:
1335 if (CC_MouseCheckResultWindow(hDlg,lParam))
1339 if (CC_WMMouseMove(hDlg, lParam))
1342 case WM_LBUTTONUP: /* FIXME: ClipCursor off (if in color graph)*/
1343 if (CC_WMLButtonUp(hDlg, wParam, lParam))
1346 case WM_LBUTTONDOWN:/* FIXME: ClipCursor on (if in color graph)*/
1347 if (CC_WMLButtonDown(hDlg, wParam, lParam))
1356 /***********************************************************************
1357 * ChooseColor16 (COMMDLG.5)
1359 BOOL16 WINAPI ChooseColor16( LPCHOOSECOLOR16 lpChCol )
1362 HANDLE16 hDlgTmpl16 = 0, hResource16 = 0;
1363 HGLOBAL16 hGlobal16 = 0;
1364 BOOL16 bRet = FALSE;
1368 TRACE("ChooseColor\n");
1369 if (!lpChCol) return FALSE;
1371 if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE)
1372 hDlgTmpl16 = lpChCol->hInstance;
1373 else if (lpChCol->Flags & CC_ENABLETEMPLATE)
1376 if (!(hResInfo = FindResource16(lpChCol->hInstance,
1377 lpChCol->lpTemplateName,
1380 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
1383 if (!(hDlgTmpl16 = LoadResource16(lpChCol->hInstance, hResInfo)))
1385 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
1388 hResource16 = hDlgTmpl16;
1392 HANDLE hResInfo, hDlgTmpl32;
1395 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_COLOR", RT_DIALOGA)))
1397 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
1400 if (!(hDlgTmpl32 = LoadResource(COMMDLG_hInstance32, hResInfo)) ||
1401 !(template32 = LockResource(hDlgTmpl32)))
1403 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
1406 size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo);
1407 hGlobal16 = GlobalAlloc16(0, size);
1410 COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
1411 ERR("alloc failure for %ld bytes\n", size);
1414 template = GlobalLock16(hGlobal16);
1417 COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE);
1418 ERR("global lock failure for %x handle\n", hDlgTmpl16);
1419 GlobalFree16(hGlobal16);
1422 ConvertDialog32To16((LPVOID)template32, size, (LPVOID)template);
1423 hDlgTmpl16 = hGlobal16;
1426 ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (SEGPTR) 8);
1427 hInst = GetWindowLongA(lpChCol->hwndOwner, GWL_HINSTANCE);
1428 bRet = DialogBoxIndirectParam16(hInst, hDlgTmpl16, lpChCol->hwndOwner,
1429 (DLGPROC16) ptr, (DWORD)lpChCol);
1430 if (hResource16) FreeResource16(hDlgTmpl16);
1433 GlobalUnlock16(hGlobal16);
1434 GlobalFree16(hGlobal16);
1439 /***********************************************************************
1440 * ChooseColorW (COMDLG32.2)
1442 BOOL WINAPI ChooseColorW( LPCHOOSECOLORW lpChCol )
1446 HANDLE hDlgTmpl = 0;
1450 TRACE("ChooseColor\n");
1451 if (!lpChCol) return FALSE;
1453 if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE)
1455 if (!(template = LockResource(lpChCol->hInstance)))
1457 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
1461 else if (lpChCol->Flags & CC_ENABLETEMPLATE)
1464 if (!(hResInfo = FindResourceW(lpChCol->hInstance,
1465 lpChCol->lpTemplateName,
1468 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
1471 if (!(hDlgTmpl = LoadResource(lpChCol->hInstance, hResInfo)) ||
1472 !(template = LockResource(hDlgTmpl)))
1474 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
1480 HANDLE hResInfo, hDlgTmpl;
1481 if (!(hResInfo = FindResourceA(COMMDLG_hInstance32, "CHOOSE_COLOR", RT_DIALOGA)))
1483 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
1486 if (!(hDlgTmpl = LoadResource(COMMDLG_hInstance32, hResInfo )) ||
1487 !(template = LockResource(hDlgTmpl)))
1489 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
1494 bRet = DialogBoxIndirectParamW(COMMDLG_hInstance32, template, lpChCol->hwndOwner,
1495 (DLGPROC)ColorDlgProc, (DWORD)lpChCol);
1499 /***********************************************************************
1500 * ChooseColorA (COMDLG32.1)
1502 BOOL WINAPI ChooseColorA( LPCHOOSECOLORA lpChCol )
1506 LPCHOOSECOLORW lpcc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CHOOSECOLORW));
1507 lpcc->lStructSize = sizeof(*lpcc);
1508 lpcc->hwndOwner = lpChCol->hwndOwner;
1509 lpcc->hInstance = lpChCol->hInstance;
1510 lpcc->rgbResult = lpChCol->rgbResult;
1511 lpcc->lpCustColors = lpChCol->lpCustColors;
1512 lpcc->Flags = lpChCol->Flags;
1513 lpcc->lCustData = lpChCol->lCustData;
1514 lpcc->lpfnHook = (LPCCHOOKPROC) lpChCol->lpfnHook;
1515 if ((lpcc->Flags & CC_ENABLETEMPLATE) && (lpChCol->lpTemplateName)) {
1516 if (HIWORD(lpChCol->lpTemplateName))
1517 lpcc->lpTemplateName = HEAP_strdupAtoW(GetProcessHeap(), 0, lpChCol->lpTemplateName);
1519 lpcc->lpTemplateName = (LPWSTR)lpChCol->lpTemplateName;
1522 ret = ChooseColorW(lpcc);
1525 lpChCol->rgbResult = lpcc->rgbResult;
1526 if (HIWORD(lpcc->lpTemplateName)) HeapFree(GetProcessHeap(), 0, (LPSTR)lpcc->lpTemplateName);
1527 HeapFree(GetProcessHeap(), 0, lpcc);