1999-02-28 21:05:11 +01:00
|
|
|
/*
|
2000-04-24 19:35:11 +02:00
|
|
|
* COMMDLG - Color Dialog
|
1999-02-28 21:05:11 +01:00
|
|
|
*
|
|
|
|
* Copyright 1994 Martin Ayotte
|
|
|
|
* Copyright 1996 Albrecht Kleine
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
|
|
|
|
2000-07-23 16:21:38 +02:00
|
|
|
/* BUGS : still seems to not refresh correctly
|
|
|
|
sometimes, especially when 2 instances of the
|
|
|
|
dialog are loaded at the same time */
|
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.h>
|
2000-02-10 20:03:02 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "windef.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
#include "winbase.h"
|
2000-02-10 20:03:02 +01:00
|
|
|
#include "wingdi.h"
|
2003-09-06 01:08:26 +02:00
|
|
|
#include "winuser.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
#include "commdlg.h"
|
|
|
|
#include "dlgs.h"
|
2002-03-10 00:29:33 +01:00
|
|
|
#include "wine/debug.h"
|
1999-03-13 18:07:56 +01:00
|
|
|
#include "cderr.h"
|
2003-12-12 07:09:13 +01:00
|
|
|
#include "cdlg.h"
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2002-03-10 00:29:33 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
|
1999-04-19 16:56:29 +02:00
|
|
|
|
2002-10-31 02:04:39 +01:00
|
|
|
static INT_PTR CALLBACK ColorDlgProc( HWND hWnd, UINT wMsg, WPARAM wParam, LPARAM lParam );
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2003-09-17 06:28:28 +02:00
|
|
|
#define CONV_LPARAMTOPOINT(lp,p) do { (p)->x = (short)LOWORD(lp); (p)->y = (short)HIWORD(lp); } while(0)
|
2000-09-27 00:20:14 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
static const COLORREF predefcolors[6][8]=
|
|
|
|
{
|
|
|
|
{ 0x008080FFL, 0x0080FFFFL, 0x0080FF80L, 0x0080FF00L,
|
|
|
|
0x00FFFF80L, 0x00FF8000L, 0x00C080FFL, 0x00FF80FFL },
|
|
|
|
{ 0x000000FFL, 0x0000FFFFL, 0x0000FF80L, 0x0040FF00L,
|
|
|
|
0x00FFFF00L, 0x00C08000L, 0x00C08080L, 0x00FF00FFL },
|
|
|
|
|
|
|
|
{ 0x00404080L, 0x004080FFL, 0x0000FF00L, 0x00808000L,
|
|
|
|
0x00804000L, 0x00FF8080L, 0x00400080L, 0x008000FFL },
|
|
|
|
{ 0x00000080L, 0x000080FFL, 0x00008000L, 0x00408000L,
|
|
|
|
0x00FF0000L, 0x00A00000L, 0x00800080L, 0x00FF0080L },
|
|
|
|
|
|
|
|
{ 0x00000040L, 0x00004080L, 0x00004000L, 0x00404000L,
|
|
|
|
0x00800000L, 0x00400000L, 0x00400040L, 0x00800040L },
|
|
|
|
{ 0x00000000L, 0x00008080L, 0x00408080L, 0x00808080L,
|
|
|
|
0x00808040L, 0x00C0C0C0L, 0x00400040L, 0x00FFFFFFL },
|
|
|
|
};
|
|
|
|
|
2006-03-09 16:45:16 +01:00
|
|
|
static const WCHAR szColourDialogProp[] = {
|
|
|
|
'c','o','l','o','u','r','d','i','a','l','o','g','p','r','o','p',0 };
|
|
|
|
|
2003-12-12 07:09:13 +01:00
|
|
|
/* Chose Color PRIVATE Structure:
|
|
|
|
*
|
|
|
|
* This structure is duplicated in the 16 bit code with
|
2005-03-23 14:15:18 +01:00
|
|
|
* an extra member
|
2003-12-12 07:09:13 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
typedef struct CCPRIVATE
|
|
|
|
{
|
|
|
|
LPCHOOSECOLORW lpcc; /* points to public known data structure */
|
2013-05-13 07:38:09 +02:00
|
|
|
HWND hwndSelf; /* dialog window */
|
2003-12-12 07:09:13 +01:00
|
|
|
int nextuserdef; /* next free place in user defined color array */
|
|
|
|
HDC hdcMem; /* color graph used for BitBlt() */
|
|
|
|
HBITMAP hbmMem; /* color graph bitmap */
|
|
|
|
RECT fullsize; /* original dialog window size */
|
|
|
|
UINT msetrgb; /* # of SETRGBSTRING message (today not used) */
|
|
|
|
RECT old3angle; /* last position of l-marker */
|
2008-02-13 22:11:01 +01:00
|
|
|
RECT oldcross; /* last position of color/saturation marker */
|
2003-12-12 07:09:13 +01:00
|
|
|
BOOL updating; /* to prevent recursive WM_COMMAND/EN_UPDATE processing */
|
|
|
|
int h;
|
|
|
|
int s;
|
|
|
|
int l; /* for temporary storing of hue,sat,lum */
|
|
|
|
int capturedGraph; /* control mouse captured */
|
|
|
|
RECT focusRect; /* rectangle last focused item */
|
|
|
|
HWND hwndFocus; /* handle last focused item */
|
2013-05-14 11:33:25 +02:00
|
|
|
} CCPRIV;
|
2003-12-12 07:09:13 +01:00
|
|
|
|
2013-05-13 06:48:28 +02:00
|
|
|
static int hsl_to_x(int hue, int sat, int lum)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
int res = 0, maxrgb;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
/* l below 120 */
|
2000-04-24 19:35:11 +02:00
|
|
|
maxrgb = (256 * min(120,lum)) / 120; /* 0 .. 256 */
|
|
|
|
if (hue < 80)
|
|
|
|
res = 0;
|
1999-02-28 21:05:11 +01:00
|
|
|
else
|
2000-04-24 19:35:11 +02:00
|
|
|
if (hue < 120)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
res = (hue - 80) * maxrgb; /* 0...10240 */
|
|
|
|
res /= 40; /* 0...256 */
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
else
|
2000-04-24 19:35:11 +02:00
|
|
|
if (hue < 200)
|
|
|
|
res = maxrgb;
|
1999-02-28 21:05:11 +01:00
|
|
|
else
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
res= (240 - hue) * maxrgb;
|
|
|
|
res /= 40;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
res = res - maxrgb / 2; /* -128...128 */
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
/* saturation */
|
2000-04-24 19:35:11 +02:00
|
|
|
res = maxrgb / 2 + (sat * res) / 240; /* 0..256 */
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
/* lum above 120 */
|
2000-04-24 19:35:11 +02:00
|
|
|
if (lum > 120 && res < 256)
|
|
|
|
res += ((lum - 120) * (256 - res)) / 120;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
return min(res, 255);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
2013-05-13 06:48:28 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* CC_HSLtoRGB [internal]
|
|
|
|
*/
|
|
|
|
static COLORREF CC_HSLtoRGB(int hue, int sat, int lum)
|
|
|
|
{
|
|
|
|
int h, r, g, b;
|
|
|
|
|
|
|
|
/* r */
|
|
|
|
h = hue > 80 ? hue-80 : hue+160;
|
|
|
|
r = hsl_to_x(h, sat, lum);
|
|
|
|
/* g */
|
|
|
|
h = hue > 160 ? hue-160 : hue+80;
|
|
|
|
g = hsl_to_x(h, sat, lum);
|
|
|
|
/* b */
|
|
|
|
b = hsl_to_x(hue, sat, lum);
|
|
|
|
|
|
|
|
return RGB(r, g, b);
|
|
|
|
}
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* CC_RGBtoHSL [internal]
|
|
|
|
*/
|
2013-05-13 07:03:22 +02:00
|
|
|
static int CC_RGBtoHSL(char c, COLORREF rgb)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
WORD maxi, mini, mmsum, mmdif, result = 0;
|
2013-05-13 07:03:22 +02:00
|
|
|
int iresult = 0, r, g, b;
|
|
|
|
|
|
|
|
r = GetRValue(rgb);
|
|
|
|
g = GetGValue(rgb);
|
|
|
|
b = GetBValue(rgb);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
maxi = max(r, b);
|
|
|
|
maxi = max(maxi, g);
|
|
|
|
mini = min(r, b);
|
|
|
|
mini = min(mini, g);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
mmsum = maxi + mini;
|
|
|
|
mmdif = maxi - mini;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
switch(c)
|
|
|
|
{
|
|
|
|
/* lum */
|
2000-04-24 19:35:11 +02:00
|
|
|
case 'L': mmsum *= 120; /* 0...61200=(255+255)*120 */
|
|
|
|
result = mmsum / 255; /* 0...240 */
|
1999-02-28 21:05:11 +01:00
|
|
|
break;
|
|
|
|
/* saturation */
|
2000-04-24 19:35:11 +02:00
|
|
|
case 'S': if (!mmsum)
|
|
|
|
result = 0;
|
1999-02-28 21:05:11 +01:00
|
|
|
else
|
2000-04-24 19:35:11 +02:00
|
|
|
if (!mini || maxi == 255)
|
|
|
|
result = 240;
|
1999-02-28 21:05:11 +01:00
|
|
|
else
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
result = mmdif * 240; /* 0...61200=255*240 */
|
2008-11-25 00:19:52 +01:00
|
|
|
result /= (mmsum > 255 ? 510 - mmsum : mmsum); /* 0..255 */
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
/* hue */
|
2000-04-24 19:35:11 +02:00
|
|
|
case 'H': if (!mmdif)
|
|
|
|
result = 160;
|
1999-02-28 21:05:11 +01:00
|
|
|
else
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
if (maxi == r)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
iresult = 40 * (g - b); /* -10200 ... 10200 */
|
|
|
|
iresult /= (int) mmdif; /* -40 .. 40 */
|
|
|
|
if (iresult < 0)
|
|
|
|
iresult += 240; /* 0..40 and 200..240 */
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
else
|
2000-04-24 19:35:11 +02:00
|
|
|
if (maxi == g)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
iresult = 40 * (b - r);
|
|
|
|
iresult /= (int) mmdif;
|
|
|
|
iresult += 80; /* 40 .. 120 */
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
else
|
2000-04-24 19:35:11 +02:00
|
|
|
if (maxi == b)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
iresult = 40 * (r - g);
|
|
|
|
iresult /= (int) mmdif;
|
|
|
|
iresult += 160; /* 120 .. 200 */
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
result = iresult;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return result; /* is this integer arithmetic precise enough ? */
|
|
|
|
}
|
|
|
|
|
2000-07-23 16:21:38 +02:00
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_DrawCurrentFocusRect [internal]
|
|
|
|
*/
|
2007-04-04 23:22:20 +02:00
|
|
|
static void CC_DrawCurrentFocusRect( const CCPRIV *lpp )
|
2000-07-23 16:21:38 +02:00
|
|
|
{
|
|
|
|
if (lpp->hwndFocus)
|
|
|
|
{
|
|
|
|
HDC hdc = GetDC(lpp->hwndFocus);
|
|
|
|
DrawFocusRect(hdc, &lpp->focusRect);
|
|
|
|
ReleaseDC(lpp->hwndFocus, hdc);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_DrawFocusRect [internal]
|
|
|
|
*/
|
2013-05-14 11:33:25 +02:00
|
|
|
static void CC_DrawFocusRect(CCPRIV *lpp, HWND hwnd, int x, int y, int rows, int cols)
|
2000-07-23 16:21:38 +02:00
|
|
|
{
|
|
|
|
RECT rect;
|
|
|
|
int dx, dy;
|
|
|
|
HDC hdc;
|
|
|
|
|
|
|
|
CC_DrawCurrentFocusRect(lpp); /* remove current focus rect */
|
|
|
|
/* calculate new rect */
|
|
|
|
GetClientRect(hwnd, &rect);
|
|
|
|
dx = (rect.right - rect.left) / cols;
|
|
|
|
dy = (rect.bottom - rect.top) / rows;
|
|
|
|
rect.left += (x * dx) - 2;
|
|
|
|
rect.top += (y * dy) - 2;
|
|
|
|
rect.right = rect.left + dx;
|
|
|
|
rect.bottom = rect.top + dy;
|
|
|
|
/* draw it */
|
|
|
|
hdc = GetDC(hwnd);
|
|
|
|
DrawFocusRect(hdc, &rect);
|
2016-06-22 11:52:30 +02:00
|
|
|
lpp->focusRect = rect;
|
2000-07-23 16:21:38 +02:00
|
|
|
lpp->hwndFocus = hwnd;
|
|
|
|
ReleaseDC(hwnd, hdc);
|
|
|
|
}
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
#define DISTANCE 4
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_MouseCheckPredefColorArray [internal]
|
2013-10-22 22:21:49 +02:00
|
|
|
* returns TRUE if one of the predefined colors is clicked
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2013-10-22 22:21:49 +02:00
|
|
|
static BOOL CC_MouseCheckPredefColorArray(CCPRIV *lpp, int rows, int cols, LPARAM lParam)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
HWND hwnd;
|
|
|
|
POINT point;
|
|
|
|
RECT rect;
|
|
|
|
int dx, dy, x, y;
|
|
|
|
|
2000-09-27 00:20:14 +02:00
|
|
|
CONV_LPARAMTOPOINT(lParam, &point);
|
2013-05-14 11:33:25 +02:00
|
|
|
ClientToScreen(lpp->hwndSelf, &point);
|
|
|
|
hwnd = GetDlgItem(lpp->hwndSelf, IDC_COLOR_PREDEF);
|
2000-04-24 19:35:11 +02:00
|
|
|
GetWindowRect(hwnd, &rect);
|
|
|
|
if (PtInRect(&rect, point))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
dx = (rect.right - rect.left) / cols;
|
|
|
|
dy = (rect.bottom - rect.top) / rows;
|
|
|
|
ScreenToClient(hwnd, &point);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
if (point.x % dx < ( dx - DISTANCE) && point.y % dy < ( dy - DISTANCE))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
x = point.x / dx;
|
|
|
|
y = point.y / dy;
|
2000-07-23 16:21:38 +02:00
|
|
|
lpp->lpcc->rgbResult = predefcolors[y][x];
|
|
|
|
CC_DrawFocusRect(lpp, hwnd, x, y, rows, cols);
|
2013-10-22 22:21:49 +02:00
|
|
|
return TRUE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
2013-10-22 22:21:49 +02:00
|
|
|
return FALSE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_MouseCheckUserColorArray [internal]
|
2013-10-22 22:21:49 +02:00
|
|
|
* return TRUE if the user clicked a color
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2013-10-22 22:21:49 +02:00
|
|
|
static BOOL CC_MouseCheckUserColorArray(CCPRIV *lpp, int rows, int cols, LPARAM lParam)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
HWND hwnd;
|
|
|
|
POINT point;
|
|
|
|
RECT rect;
|
|
|
|
int dx, dy, x, y;
|
2000-07-23 16:21:38 +02:00
|
|
|
COLORREF *crarr = lpp->lpcc->lpCustColors;
|
2000-04-24 19:35:11 +02:00
|
|
|
|
2000-09-27 00:20:14 +02:00
|
|
|
CONV_LPARAMTOPOINT(lParam, &point);
|
2013-05-14 11:33:25 +02:00
|
|
|
ClientToScreen(lpp->hwndSelf, &point);
|
|
|
|
hwnd = GetDlgItem(lpp->hwndSelf, IDC_COLOR_USRDEF);
|
2000-04-24 19:35:11 +02:00
|
|
|
GetWindowRect(hwnd, &rect);
|
|
|
|
if (PtInRect(&rect, point))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
dx = (rect.right - rect.left) / cols;
|
|
|
|
dy = (rect.bottom - rect.top) / rows;
|
|
|
|
ScreenToClient(hwnd, &point);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
if (point.x % dx < (dx - DISTANCE) && point.y % dy < (dy - DISTANCE))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
x = point.x / dx;
|
|
|
|
y = point.y / dy;
|
2000-07-23 16:21:38 +02:00
|
|
|
lpp->lpcc->rgbResult = crarr[x + (cols * y) ];
|
|
|
|
CC_DrawFocusRect(lpp, hwnd, x, y, rows, cols);
|
2013-10-22 22:21:49 +02:00
|
|
|
return TRUE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
2013-10-22 22:21:49 +02:00
|
|
|
return FALSE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#define MAXVERT 240
|
|
|
|
#define MAXHORI 239
|
|
|
|
|
|
|
|
/* 240 ^...... ^^ 240
|
|
|
|
| . ||
|
|
|
|
SAT | . || LUM
|
|
|
|
| . ||
|
|
|
|
+-----> 239 ----
|
|
|
|
HUE
|
|
|
|
*/
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_MouseCheckColorGraph [internal]
|
|
|
|
*/
|
2013-10-22 22:21:49 +02:00
|
|
|
static BOOL CC_MouseCheckColorGraph( HWND hDlg, int dlgitem, int *hori, int *vert, LPARAM lParam )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
HWND hwnd;
|
2000-04-24 19:35:11 +02:00
|
|
|
POINT point;
|
|
|
|
RECT rect;
|
1999-02-28 21:05:11 +01:00
|
|
|
long x,y;
|
|
|
|
|
2000-09-27 00:20:14 +02:00
|
|
|
CONV_LPARAMTOPOINT(lParam, &point);
|
2000-04-24 19:35:11 +02:00
|
|
|
ClientToScreen(hDlg, &point);
|
|
|
|
hwnd = GetDlgItem( hDlg, dlgitem );
|
|
|
|
GetWindowRect(hwnd, &rect);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2008-01-07 17:44:10 +01:00
|
|
|
if (!PtInRect(&rect, point))
|
2013-10-22 22:21:49 +02:00
|
|
|
return FALSE;
|
2008-01-07 17:44:10 +01:00
|
|
|
|
|
|
|
GetClientRect(hwnd, &rect);
|
|
|
|
ScreenToClient(hwnd, &point);
|
|
|
|
|
|
|
|
x = (long) point.x * MAXHORI;
|
|
|
|
x /= rect.right;
|
|
|
|
y = (long) (rect.bottom - point.y) * MAXVERT;
|
|
|
|
y /= rect.bottom;
|
|
|
|
|
|
|
|
if (x < 0) x = 0;
|
|
|
|
if (y < 0) y = 0;
|
|
|
|
if (x > MAXHORI) x = MAXHORI;
|
|
|
|
if (y > MAXVERT) y = MAXVERT;
|
|
|
|
|
|
|
|
if (hori)
|
|
|
|
*hori = x;
|
|
|
|
if (vert)
|
|
|
|
*vert = y;
|
|
|
|
|
2013-10-22 22:21:49 +02:00
|
|
|
return TRUE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_MouseCheckResultWindow [internal]
|
2000-04-24 19:35:11 +02:00
|
|
|
* test if double click one of the result colors
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2013-10-22 22:21:49 +02:00
|
|
|
static BOOL CC_MouseCheckResultWindow( HWND hDlg, LPARAM lParam )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
HWND hwnd;
|
|
|
|
POINT point;
|
|
|
|
RECT rect;
|
|
|
|
|
2000-09-27 00:20:14 +02:00
|
|
|
CONV_LPARAMTOPOINT(lParam, &point);
|
2000-04-24 19:35:11 +02:00
|
|
|
ClientToScreen(hDlg, &point);
|
2013-05-13 06:24:29 +02:00
|
|
|
hwnd = GetDlgItem(hDlg, IDC_COLOR_RESULT);
|
2000-04-24 19:35:11 +02:00
|
|
|
GetWindowRect(hwnd, &rect);
|
|
|
|
if (PtInRect(&rect, point))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-13 06:24:29 +02:00
|
|
|
PostMessageA(hDlg, WM_COMMAND, IDC_COLOR_RES, 0);
|
2013-10-22 22:21:49 +02:00
|
|
|
return TRUE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2013-10-22 22:21:49 +02:00
|
|
|
return FALSE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_CheckDigitsInEdit [internal]
|
|
|
|
*/
|
2009-11-12 20:33:49 +01:00
|
|
|
static int CC_CheckDigitsInEdit( HWND hwnd, int maxval )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
int i, k, m, result, value;
|
1999-02-28 21:05:11 +01:00
|
|
|
long editpos;
|
|
|
|
char buffer[30];
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
GetWindowTextA(hwnd, buffer, sizeof(buffer));
|
|
|
|
m = strlen(buffer);
|
|
|
|
result = 0;
|
|
|
|
|
|
|
|
for (i = 0 ; i < m ; i++)
|
|
|
|
if (buffer[i] < '0' || buffer[i] > '9')
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
for (k = i + 1; k <= m; k++) /* delete bad character */
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
buffer[i] = buffer[k];
|
1999-02-28 21:05:11 +01:00
|
|
|
m--;
|
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
buffer[m] = 0;
|
|
|
|
result = 1;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
value = atoi(buffer);
|
|
|
|
if (value > maxval) /* build a new string */
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
sprintf(buffer, "%d", maxval);
|
|
|
|
result = 2;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
if (result)
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
editpos = SendMessageA(hwnd, EM_GETSEL, 0, 0);
|
|
|
|
SetWindowTextA(hwnd, buffer );
|
|
|
|
SendMessageA(hwnd, EM_SETSEL, 0, editpos);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
return value;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_PaintSelectedColor [internal]
|
|
|
|
*/
|
2013-05-13 07:38:09 +02:00
|
|
|
static void CC_PaintSelectedColor(const CCPRIV *infoPtr)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-13 07:38:09 +02:00
|
|
|
if (IsWindowVisible( GetDlgItem(infoPtr->hwndSelf, IDC_COLOR_GRAPH) )) /* if full size */
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-13 07:38:09 +02:00
|
|
|
RECT rect;
|
|
|
|
HDC hdc;
|
|
|
|
HBRUSH hBrush;
|
|
|
|
HWND hwnd = GetDlgItem(infoPtr->hwndSelf, IDC_COLOR_RESULT);
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
hdc = GetDC(hwnd);
|
|
|
|
GetClientRect(hwnd, &rect) ;
|
2013-05-13 07:38:09 +02:00
|
|
|
hBrush = CreateSolidBrush(infoPtr->lpcc->rgbResult);
|
1999-02-28 21:05:11 +01:00
|
|
|
if (hBrush)
|
|
|
|
{
|
2008-01-07 18:16:42 +01:00
|
|
|
FillRect(hdc, &rect, hBrush);
|
|
|
|
DrawEdge(hdc, &rect, BDR_SUNKENOUTER, BF_RECT);
|
2008-02-13 16:19:24 +01:00
|
|
|
DeleteObject(hBrush);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
ReleaseDC(hwnd, hdc);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_PaintTriangle [internal]
|
|
|
|
*/
|
2013-05-13 07:38:09 +02:00
|
|
|
static void CC_PaintTriangle(CCPRIV *infoPtr)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
HDC hDC;
|
|
|
|
long temp;
|
2008-01-07 17:54:07 +01:00
|
|
|
int w = LOWORD(GetDialogBaseUnits()) / 2;
|
2000-04-24 19:35:11 +02:00
|
|
|
POINT points[3];
|
1999-02-28 21:05:11 +01:00
|
|
|
int height;
|
|
|
|
int oben;
|
2000-04-24 19:35:11 +02:00
|
|
|
RECT rect;
|
2007-02-12 09:42:19 +01:00
|
|
|
HBRUSH hbr;
|
2013-05-13 07:38:09 +02:00
|
|
|
HWND hwnd = GetDlgItem(infoPtr->hwndSelf, IDC_COLOR_LUMBAR);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2013-05-13 07:38:09 +02:00
|
|
|
if (IsWindowVisible( GetDlgItem(infoPtr->hwndSelf, IDC_COLOR_GRAPH))) /* if full size */
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
GetClientRect(hwnd, &rect);
|
|
|
|
height = rect.bottom;
|
2013-05-13 07:38:09 +02:00
|
|
|
hDC = GetDC(infoPtr->hwndSelf);
|
2000-04-24 19:35:11 +02:00
|
|
|
points[0].y = rect.top;
|
2013-05-13 07:38:09 +02:00
|
|
|
points[0].x = rect.right; /* | /| */
|
|
|
|
ClientToScreen(hwnd, points); /* | / | */
|
|
|
|
ScreenToClient(infoPtr->hwndSelf, points); /* |< | */
|
|
|
|
oben = points[0].y; /* | \ | */
|
|
|
|
/* | \| */
|
|
|
|
temp = (long)height * (long)infoPtr->l;
|
2008-01-07 17:54:07 +01:00
|
|
|
points[0].x += 1;
|
2000-04-24 19:35:11 +02:00
|
|
|
points[0].y = oben + height - temp / (long)MAXVERT;
|
|
|
|
points[1].y = points[0].y + w;
|
|
|
|
points[2].y = points[0].y - w;
|
|
|
|
points[2].x = points[1].x = points[0].x + w;
|
|
|
|
|
2007-02-12 09:42:19 +01:00
|
|
|
hbr = (HBRUSH)GetClassLongPtrW( hwnd, GCLP_HBRBACKGROUND);
|
|
|
|
if (!hbr) hbr = GetSysColorBrush(COLOR_BTNFACE);
|
2013-05-13 07:38:09 +02:00
|
|
|
FillRect(hDC, &infoPtr->old3angle, hbr);
|
|
|
|
infoPtr->old3angle.left = points[0].x;
|
|
|
|
infoPtr->old3angle.right = points[1].x + 1;
|
|
|
|
infoPtr->old3angle.top = points[2].y - 1;
|
|
|
|
infoPtr->old3angle.bottom= points[1].y + 1;
|
2008-01-07 17:54:07 +01:00
|
|
|
|
|
|
|
hbr = SelectObject(hDC, GetStockObject(BLACK_BRUSH));
|
2000-04-24 19:35:11 +02:00
|
|
|
Polygon(hDC, points, 3);
|
2008-01-07 17:54:07 +01:00
|
|
|
SelectObject(hDC, hbr);
|
|
|
|
|
2013-05-13 07:38:09 +02:00
|
|
|
ReleaseDC(infoPtr->hwndSelf, hDC);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_PaintCross [internal]
|
|
|
|
*/
|
2013-05-13 07:38:09 +02:00
|
|
|
static void CC_PaintCross(CCPRIV *infoPtr)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-14 11:33:25 +02:00
|
|
|
HWND hwnd = GetDlgItem(infoPtr->hwndSelf, IDC_COLOR_GRAPH);
|
|
|
|
|
|
|
|
if (IsWindowVisible(hwnd)) /* if full size */
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-13 07:38:09 +02:00
|
|
|
HDC hDC;
|
|
|
|
int w = GetDialogBaseUnits() - 1;
|
|
|
|
int wc = GetDialogBaseUnits() * 3 / 4;
|
|
|
|
RECT rect;
|
|
|
|
POINT point, p;
|
|
|
|
HPEN hPen;
|
|
|
|
int x, y;
|
|
|
|
|
|
|
|
x = infoPtr->h;
|
|
|
|
y = infoPtr->s;
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
GetClientRect(hwnd, &rect);
|
|
|
|
hDC = GetDC(hwnd);
|
|
|
|
SelectClipRgn( hDC, CreateRectRgnIndirect(&rect));
|
2008-01-07 18:10:44 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
point.x = ((long)rect.right * (long)x) / (long)MAXHORI;
|
|
|
|
point.y = rect.bottom - ((long)rect.bottom * (long)y) / (long)MAXVERT;
|
2013-05-13 07:38:09 +02:00
|
|
|
if ( infoPtr->oldcross.left != infoPtr->oldcross.right )
|
|
|
|
BitBlt(hDC, infoPtr->oldcross.left, infoPtr->oldcross.top,
|
|
|
|
infoPtr->oldcross.right - infoPtr->oldcross.left,
|
|
|
|
infoPtr->oldcross.bottom - infoPtr->oldcross.top,
|
|
|
|
infoPtr->hdcMem, infoPtr->oldcross.left, infoPtr->oldcross.top, SRCCOPY);
|
|
|
|
infoPtr->oldcross.left = point.x - w - 1;
|
|
|
|
infoPtr->oldcross.right = point.x + w + 1;
|
|
|
|
infoPtr->oldcross.top = point.y - w - 1;
|
|
|
|
infoPtr->oldcross.bottom = point.y + w + 1;
|
2000-04-24 19:35:11 +02:00
|
|
|
|
2013-05-13 06:24:29 +02:00
|
|
|
hPen = CreatePen(PS_SOLID, 3, RGB(0, 0, 0)); /* -black- color */
|
2008-01-07 18:10:44 +01:00
|
|
|
hPen = SelectObject(hDC, hPen);
|
2002-06-01 01:06:46 +02:00
|
|
|
MoveToEx(hDC, point.x - w, point.y, &p);
|
2008-01-07 18:10:44 +01:00
|
|
|
LineTo(hDC, point.x - wc, point.y);
|
|
|
|
MoveToEx(hDC, point.x + wc, point.y, &p);
|
2000-04-24 19:35:11 +02:00
|
|
|
LineTo(hDC, point.x + w, point.y);
|
2002-06-01 01:06:46 +02:00
|
|
|
MoveToEx(hDC, point.x, point.y - w, &p);
|
2008-01-07 18:10:44 +01:00
|
|
|
LineTo(hDC, point.x, point.y - wc);
|
|
|
|
MoveToEx(hDC, point.x, point.y + wc, &p);
|
2000-04-24 19:35:11 +02:00
|
|
|
LineTo(hDC, point.x, point.y + w);
|
2008-01-07 18:10:44 +01:00
|
|
|
DeleteObject( SelectObject(hDC, hPen));
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
ReleaseDC(hwnd, hDC);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
#define XSTEPS 48
|
|
|
|
#define YSTEPS 24
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_PrepareColorGraph [internal]
|
|
|
|
*/
|
2013-05-14 11:33:25 +02:00
|
|
|
static void CC_PrepareColorGraph(CCPRIV *infoPtr)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-13 06:48:28 +02:00
|
|
|
int sdif, hdif, xdif, ydif, hue, sat;
|
2013-05-14 11:33:25 +02:00
|
|
|
HWND hwnd = GetDlgItem(infoPtr->hwndSelf, IDC_COLOR_GRAPH);
|
1999-02-28 21:05:11 +01:00
|
|
|
HBRUSH hbrush;
|
|
|
|
HDC hdc ;
|
2000-04-24 19:35:11 +02:00
|
|
|
RECT rect, client;
|
2005-02-15 22:51:06 +01:00
|
|
|
HCURSOR hcursor = SetCursor( LoadCursorW(0, (LPCWSTR)IDC_WAIT) );
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
GetClientRect(hwnd, &client);
|
|
|
|
hdc = GetDC(hwnd);
|
2013-05-14 11:33:25 +02:00
|
|
|
infoPtr->hdcMem = CreateCompatibleDC(hdc);
|
|
|
|
infoPtr->hbmMem = CreateCompatibleBitmap(hdc, client.right, client.bottom);
|
|
|
|
SelectObject(infoPtr->hdcMem, infoPtr->hbmMem);
|
2000-04-24 19:35:11 +02:00
|
|
|
|
|
|
|
xdif = client.right / XSTEPS;
|
|
|
|
ydif = client.bottom / YSTEPS+1;
|
|
|
|
hdif = 239 / XSTEPS;
|
|
|
|
sdif = 240 / YSTEPS;
|
|
|
|
for (rect.left = hue = 0; hue < 239 + hdif; hue += hdif)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
rect.right = rect.left + xdif;
|
|
|
|
rect.bottom = client.bottom;
|
|
|
|
for(sat = 0; sat < 240 + sdif; sat += sdif)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
rect.top = rect.bottom - ydif;
|
2013-05-13 06:48:28 +02:00
|
|
|
hbrush = CreateSolidBrush(CC_HSLtoRGB(hue, sat, 120));
|
2013-05-14 11:33:25 +02:00
|
|
|
FillRect(infoPtr->hdcMem, &rect, hbrush);
|
1999-02-28 21:05:11 +01:00
|
|
|
DeleteObject(hbrush);
|
2000-04-24 19:35:11 +02:00
|
|
|
rect.bottom = rect.top;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
rect.left = rect.right;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
ReleaseDC(hwnd, hdc);
|
|
|
|
SetCursor(hcursor);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_PaintColorGraph [internal]
|
|
|
|
*/
|
2013-05-14 11:33:25 +02:00
|
|
|
static void CC_PaintColorGraph(CCPRIV *infoPtr)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-13 07:38:09 +02:00
|
|
|
HWND hwnd = GetDlgItem( infoPtr->hwndSelf, IDC_COLOR_GRAPH );
|
1999-02-28 21:05:11 +01:00
|
|
|
HDC hDC;
|
2000-04-24 19:35:11 +02:00
|
|
|
RECT rect;
|
2013-05-13 07:38:09 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
if (IsWindowVisible(hwnd)) /* if full size */
|
|
|
|
{
|
2013-05-13 07:38:09 +02:00
|
|
|
if (!infoPtr->hdcMem)
|
2013-05-14 11:33:25 +02:00
|
|
|
CC_PrepareColorGraph(infoPtr); /* should not be necessary */
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
hDC = GetDC(hwnd);
|
|
|
|
GetClientRect(hwnd, &rect);
|
2013-05-13 07:38:09 +02:00
|
|
|
if (infoPtr->hdcMem)
|
|
|
|
BitBlt(hDC, 0, 0, rect.right, rect.bottom, infoPtr->hdcMem, 0, 0, SRCCOPY);
|
1999-02-28 21:05:11 +01:00
|
|
|
else
|
2000-04-24 19:35:11 +02:00
|
|
|
WARN("choose color: hdcMem is not defined\n");
|
|
|
|
ReleaseDC(hwnd, hDC);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* CC_PaintLumBar [internal]
|
|
|
|
*/
|
2013-05-13 07:38:09 +02:00
|
|
|
static void CC_PaintLumBar(const CCPRIV *infoPtr)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-13 07:38:09 +02:00
|
|
|
HWND hwnd = GetDlgItem(infoPtr->hwndSelf, IDC_COLOR_LUMBAR);
|
2000-04-24 19:35:11 +02:00
|
|
|
RECT rect, client;
|
2013-05-13 06:48:28 +02:00
|
|
|
int lum, ldif, ydif;
|
1999-02-28 21:05:11 +01:00
|
|
|
HBRUSH hbrush;
|
|
|
|
HDC hDC;
|
|
|
|
|
|
|
|
if (IsWindowVisible(hwnd))
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
hDC = GetDC(hwnd);
|
|
|
|
GetClientRect(hwnd, &client);
|
|
|
|
rect = client;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
ldif = 240 / YSTEPS;
|
|
|
|
ydif = client.bottom / YSTEPS+1;
|
|
|
|
for (lum = 0; lum < 240 + ldif; lum += ldif)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
rect.top = max(0, rect.bottom - ydif);
|
2013-05-13 07:38:09 +02:00
|
|
|
hbrush = CreateSolidBrush(CC_HSLtoRGB(infoPtr->h, infoPtr->s, lum));
|
2000-04-24 19:35:11 +02:00
|
|
|
FillRect(hDC, &rect, hbrush);
|
1999-02-28 21:05:11 +01:00
|
|
|
DeleteObject(hbrush);
|
2000-04-24 19:35:11 +02:00
|
|
|
rect.bottom = rect.top;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
GetClientRect(hwnd, &rect);
|
2008-01-07 17:54:07 +01:00
|
|
|
DrawEdge(hDC, &rect, BDR_SUNKENOUTER, BF_RECT);
|
2000-04-24 19:35:11 +02:00
|
|
|
ReleaseDC(hwnd, hDC);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_EditSetRGB [internal]
|
|
|
|
*/
|
2013-05-14 11:33:25 +02:00
|
|
|
static void CC_EditSetRGB( CCPRIV *infoPtr )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-14 11:33:25 +02:00
|
|
|
if (IsWindowVisible( GetDlgItem(infoPtr->hwndSelf, IDC_COLOR_GRAPH) )) /* if full size */
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-14 11:33:25 +02:00
|
|
|
COLORREF cr = infoPtr->lpcc->rgbResult;
|
|
|
|
int r = GetRValue(cr);
|
|
|
|
int g = GetGValue(cr);
|
|
|
|
int b = GetBValue(cr);
|
|
|
|
|
|
|
|
infoPtr->updating = TRUE;
|
2016-10-15 13:39:31 +02:00
|
|
|
SetDlgItemInt(infoPtr->hwndSelf, IDC_COLOR_EDIT_R, r, TRUE);
|
|
|
|
SetDlgItemInt(infoPtr->hwndSelf, IDC_COLOR_EDIT_G, g, TRUE);
|
|
|
|
SetDlgItemInt(infoPtr->hwndSelf, IDC_COLOR_EDIT_B, b, TRUE);
|
2013-05-14 11:33:25 +02:00
|
|
|
infoPtr->updating = FALSE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_EditSetHSL [internal]
|
|
|
|
*/
|
2013-05-14 11:33:25 +02:00
|
|
|
static void CC_EditSetHSL( CCPRIV *infoPtr )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-14 11:33:25 +02:00
|
|
|
if (IsWindowVisible( GetDlgItem(infoPtr->hwndSelf, IDC_COLOR_GRAPH) )) /* if full size */
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-14 11:33:25 +02:00
|
|
|
infoPtr->updating = TRUE;
|
2016-10-15 13:39:31 +02:00
|
|
|
SetDlgItemInt(infoPtr->hwndSelf, IDC_COLOR_EDIT_H, infoPtr->h, TRUE);
|
|
|
|
SetDlgItemInt(infoPtr->hwndSelf, IDC_COLOR_EDIT_S, infoPtr->s, TRUE);
|
|
|
|
SetDlgItemInt(infoPtr->hwndSelf, IDC_COLOR_EDIT_L, infoPtr->l, TRUE);
|
2013-05-14 11:33:25 +02:00
|
|
|
infoPtr->updating = FALSE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2013-05-14 11:33:25 +02:00
|
|
|
CC_PaintLumBar(infoPtr);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_SwitchToFullSize [internal]
|
|
|
|
*/
|
2013-05-14 11:33:25 +02:00
|
|
|
static void CC_SwitchToFullSize( CCPRIV *infoPtr, const RECT *lprect )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
int i;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2013-05-14 11:33:25 +02:00
|
|
|
EnableWindow( GetDlgItem(infoPtr->hwndSelf, IDC_COLOR_DEFINE), FALSE);
|
|
|
|
CC_PrepareColorGraph(infoPtr);
|
2013-05-13 06:24:29 +02:00
|
|
|
for (i = IDC_COLOR_EDIT_H; i <= IDC_COLOR_EDIT_B; i++)
|
2013-05-14 11:33:25 +02:00
|
|
|
ShowWindow( GetDlgItem(infoPtr->hwndSelf, i), SW_SHOW);
|
2013-05-13 06:24:29 +02:00
|
|
|
for (i = IDC_COLOR_HL; i <= IDC_COLOR_BL; i++)
|
2013-05-14 11:33:25 +02:00
|
|
|
ShowWindow( GetDlgItem(infoPtr->hwndSelf, i), SW_SHOW);
|
|
|
|
ShowWindow( GetDlgItem(infoPtr->hwndSelf, IDC_COLOR_RES), SW_SHOW);
|
|
|
|
ShowWindow( GetDlgItem(infoPtr->hwndSelf, IDC_COLOR_ADD), SW_SHOW);
|
|
|
|
ShowWindow( GetDlgItem(infoPtr->hwndSelf, 1090), SW_SHOW);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
if (lprect)
|
2013-05-14 11:33:25 +02:00
|
|
|
SetWindowPos(infoPtr->hwndSelf, 0, 0, 0, lprect->right-lprect->left,
|
1999-02-28 21:05:11 +01:00
|
|
|
lprect->bottom-lprect->top, SWP_NOMOVE|SWP_NOZORDER);
|
|
|
|
|
2013-05-14 11:33:25 +02:00
|
|
|
ShowWindow( GetDlgItem(infoPtr->hwndSelf, IDC_COLOR_LUMBAR), SW_SHOW);
|
|
|
|
ShowWindow( GetDlgItem(infoPtr->hwndSelf, IDC_COLOR_RESULT), SW_SHOW);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2013-05-14 11:33:25 +02:00
|
|
|
CC_EditSetRGB(infoPtr);
|
|
|
|
CC_EditSetHSL(infoPtr);
|
|
|
|
ShowWindow( GetDlgItem( infoPtr->hwndSelf, IDC_COLOR_GRAPH), SW_SHOW);
|
|
|
|
UpdateWindow( GetDlgItem(infoPtr->hwndSelf, IDC_COLOR_GRAPH) );
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_PaintPredefColorArray [internal]
|
2000-04-24 19:35:11 +02:00
|
|
|
* Paints the default standard 48 colors
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2013-05-14 11:33:25 +02:00
|
|
|
static void CC_PaintPredefColorArray(const CCPRIV *infoPtr, int rows, int cols)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-14 11:33:25 +02:00
|
|
|
HWND hwnd = GetDlgItem(infoPtr->hwndSelf, IDC_COLOR_PREDEF);
|
2008-01-07 18:46:54 +01:00
|
|
|
RECT rect, blockrect;
|
1999-02-28 21:05:11 +01:00
|
|
|
HDC hdc;
|
|
|
|
HBRUSH hBrush;
|
2000-04-24 19:35:11 +02:00
|
|
|
int dx, dy, i, j, k;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
GetClientRect(hwnd, &rect);
|
|
|
|
dx = rect.right / cols;
|
|
|
|
dy = rect.bottom / rows;
|
|
|
|
k = rect.left;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
hdc = GetDC(hwnd);
|
|
|
|
GetClientRect(hwnd, &rect);
|
2007-02-12 09:42:19 +01:00
|
|
|
hBrush = (HBRUSH)GetClassLongPtrW( hwnd, GCLP_HBRBACKGROUND);
|
|
|
|
if (!hBrush) hBrush = GetSysColorBrush(COLOR_BTNFACE);
|
|
|
|
FillRect(hdc, &rect, hBrush);
|
2000-04-24 19:35:11 +02:00
|
|
|
for ( j = 0; j < rows; j++ )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
for ( i = 0; i < cols; i++ )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
hBrush = CreateSolidBrush(predefcolors[j][i]);
|
|
|
|
if (hBrush)
|
|
|
|
{
|
2008-01-07 18:46:54 +01:00
|
|
|
blockrect.left = rect.left;
|
|
|
|
blockrect.top = rect.top;
|
|
|
|
blockrect.right = rect.left + dx - DISTANCE;
|
|
|
|
blockrect.bottom = rect.top + dy - DISTANCE;
|
|
|
|
FillRect(hdc, &blockrect, hBrush);
|
|
|
|
DrawEdge(hdc, &blockrect, BDR_SUNKEN, BF_RECT);
|
|
|
|
DeleteObject(hBrush);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2008-01-07 18:46:54 +01:00
|
|
|
rect.left += dx;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2008-01-07 18:46:54 +01:00
|
|
|
rect.top += dy;
|
2000-04-24 19:35:11 +02:00
|
|
|
rect.left = k;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
ReleaseDC(hwnd, hdc);
|
2013-05-14 11:33:25 +02:00
|
|
|
if (infoPtr->hwndFocus == hwnd)
|
|
|
|
CC_DrawCurrentFocusRect(infoPtr);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_PaintUserColorArray [internal]
|
2002-06-01 01:06:46 +02:00
|
|
|
* Paint the 16 user-selected colors
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2013-05-14 11:33:25 +02:00
|
|
|
static void CC_PaintUserColorArray(const CCPRIV *infoPtr, int rows, int cols)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-14 11:33:25 +02:00
|
|
|
HWND hwnd = GetDlgItem(infoPtr->hwndSelf, IDC_COLOR_USRDEF);
|
2008-01-07 18:46:54 +01:00
|
|
|
RECT rect, blockrect;
|
1999-02-28 21:05:11 +01:00
|
|
|
HDC hdc;
|
|
|
|
HBRUSH hBrush;
|
2000-04-24 19:35:11 +02:00
|
|
|
int dx, dy, i, j, k;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
GetClientRect(hwnd, &rect);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
dx = rect.right / cols;
|
|
|
|
dy = rect.bottom / rows;
|
|
|
|
k = rect.left;
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
hdc = GetDC(hwnd);
|
2002-06-01 01:06:46 +02:00
|
|
|
if (hdc)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2007-02-12 09:42:19 +01:00
|
|
|
hBrush = (HBRUSH)GetClassLongPtrW( hwnd, GCLP_HBRBACKGROUND);
|
|
|
|
if (!hBrush) hBrush = GetSysColorBrush(COLOR_BTNFACE);
|
|
|
|
FillRect( hdc, &rect, hBrush );
|
2000-04-24 19:35:11 +02:00
|
|
|
for (j = 0; j < rows; j++)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
for (i = 0; i < cols; i++)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-14 11:33:25 +02:00
|
|
|
hBrush = CreateSolidBrush(infoPtr->lpcc->lpCustColors[i+j*cols]);
|
1999-02-28 21:05:11 +01:00
|
|
|
if (hBrush)
|
2002-06-01 01:06:46 +02:00
|
|
|
{
|
2008-01-07 18:46:54 +01:00
|
|
|
blockrect.left = rect.left;
|
|
|
|
blockrect.top = rect.top;
|
|
|
|
blockrect.right = rect.left + dx - DISTANCE;
|
|
|
|
blockrect.bottom = rect.top + dy - DISTANCE;
|
|
|
|
FillRect(hdc, &blockrect, hBrush);
|
|
|
|
DrawEdge(hdc, &blockrect, BDR_SUNKEN, BF_RECT);
|
|
|
|
DeleteObject(hBrush);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2008-01-07 18:46:54 +01:00
|
|
|
rect.left += dx;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2008-01-07 18:46:54 +01:00
|
|
|
rect.top += dy;
|
2000-04-24 19:35:11 +02:00
|
|
|
rect.left = k;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
ReleaseDC(hwnd, hdc);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2013-05-14 11:33:25 +02:00
|
|
|
if (infoPtr->hwndFocus == hwnd)
|
|
|
|
CC_DrawCurrentFocusRect(infoPtr);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_HookCallChk [internal]
|
|
|
|
*/
|
2009-11-12 20:33:49 +01:00
|
|
|
static BOOL CC_HookCallChk( const CHOOSECOLORW *lpcc )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
if (lpcc)
|
|
|
|
if(lpcc->Flags & CC_ENABLEHOOK)
|
|
|
|
if (lpcc->lpfnHook)
|
|
|
|
return TRUE;
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2000-04-24 19:35:11 +02:00
|
|
|
* CC_WMInitDialog [internal]
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2009-11-12 20:33:49 +01:00
|
|
|
static LRESULT CC_WMInitDialog( HWND hDlg, WPARAM wParam, LPARAM lParam )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-13 07:38:09 +02:00
|
|
|
CHOOSECOLORW *cc = (CHOOSECOLORW*)lParam;
|
2000-04-24 19:35:11 +02:00
|
|
|
int i, res;
|
1999-02-28 21:05:11 +01:00
|
|
|
int r, g, b;
|
2000-04-24 19:35:11 +02:00
|
|
|
HWND hwnd;
|
|
|
|
RECT rect;
|
|
|
|
POINT point;
|
2013-05-13 07:38:09 +02:00
|
|
|
CCPRIV *lpp;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-06-12 17:45:58 +02:00
|
|
|
TRACE("WM_INITDIALOG lParam=%08lX\n", lParam);
|
2003-12-01 23:45:30 +01:00
|
|
|
|
2013-05-13 07:38:09 +02:00
|
|
|
if (cc->lStructSize != sizeof(CHOOSECOLORW))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-13 07:38:09 +02:00
|
|
|
EndDialog(hDlg, 0);
|
2003-12-01 23:45:30 +01:00
|
|
|
return FALSE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2003-12-01 23:45:30 +01:00
|
|
|
|
2013-05-13 07:38:09 +02:00
|
|
|
lpp = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(struct CCPRIVATE) );
|
|
|
|
lpp->lpcc = cc;
|
|
|
|
lpp->hwndSelf = hDlg;
|
|
|
|
|
2006-03-09 16:45:16 +01:00
|
|
|
SetPropW( hDlg, szColourDialogProp, lpp );
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
if (!(lpp->lpcc->Flags & CC_SHOWHELP))
|
2017-05-11 11:13:05 +02:00
|
|
|
ShowWindow(GetDlgItem(hDlg, pshHelp), SW_HIDE);
|
2001-01-22 03:13:58 +01:00
|
|
|
lpp->msetrgb = RegisterWindowMessageA(SETRGBSTRINGA);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
#if 0
|
2000-04-24 19:35:11 +02:00
|
|
|
cpos = MAKELONG(5,7); /* init */
|
1999-02-28 21:05:11 +01:00
|
|
|
if (lpp->lpcc->Flags & CC_RGBINIT)
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
for (i = 0; i < 6; i++)
|
2000-04-24 19:35:11 +02:00
|
|
|
for (j = 0; j < 8; j++)
|
|
|
|
if (predefcolors[i][j] == lpp->lpcc->rgbResult)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
cpos = MAKELONG(i,j);
|
1999-02-28 21:05:11 +01:00
|
|
|
goto found;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
found:
|
|
|
|
/* FIXME: Draw_a_focus_rect & set_init_values */
|
|
|
|
#endif
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
GetWindowRect(hDlg, &lpp->fullsize);
|
1999-02-28 21:05:11 +01:00
|
|
|
if (lpp->lpcc->Flags & CC_FULLOPEN || lpp->lpcc->Flags & CC_PREVENTFULLOPEN)
|
|
|
|
{
|
2013-05-13 06:24:29 +02:00
|
|
|
hwnd = GetDlgItem(hDlg, IDC_COLOR_DEFINE);
|
2000-04-24 19:35:11 +02:00
|
|
|
EnableWindow(hwnd, FALSE);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
if (!(lpp->lpcc->Flags & CC_FULLOPEN ) || lpp->lpcc->Flags & CC_PREVENTFULLOPEN)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
rect = lpp->fullsize;
|
|
|
|
res = rect.bottom - rect.top;
|
2013-05-13 06:24:29 +02:00
|
|
|
hwnd = GetDlgItem(hDlg, IDC_COLOR_GRAPH); /* cut at left border */
|
2000-04-24 19:35:11 +02:00
|
|
|
point.x = point.y = 0;
|
|
|
|
ClientToScreen(hwnd, &point);
|
|
|
|
ScreenToClient(hDlg,&point);
|
|
|
|
GetClientRect(hDlg, &rect);
|
|
|
|
point.x += GetSystemMetrics(SM_CXDLGFRAME);
|
|
|
|
SetWindowPos(hDlg, 0, 0, 0, point.x, res, SWP_NOMOVE|SWP_NOZORDER);
|
|
|
|
|
2013-05-13 06:24:29 +02:00
|
|
|
for (i = IDC_COLOR_EDIT_H; i <= IDC_COLOR_EDIT_B; i++)
|
2000-04-24 19:35:11 +02:00
|
|
|
ShowWindow( GetDlgItem(hDlg, i), SW_HIDE);
|
2013-05-13 06:24:29 +02:00
|
|
|
for (i = IDC_COLOR_HL; i <= IDC_COLOR_BL; i++)
|
2000-04-24 19:35:11 +02:00
|
|
|
ShowWindow( GetDlgItem(hDlg, i), SW_HIDE);
|
2013-05-13 06:24:29 +02:00
|
|
|
ShowWindow( GetDlgItem(hDlg, IDC_COLOR_RES), SW_HIDE);
|
|
|
|
ShowWindow( GetDlgItem(hDlg, IDC_COLOR_ADD), SW_HIDE);
|
|
|
|
ShowWindow( GetDlgItem(hDlg, IDC_COLOR_GRAPH), SW_HIDE);
|
|
|
|
ShowWindow( GetDlgItem(hDlg, IDC_COLOR_RESULT), SW_HIDE);
|
2000-04-24 19:35:11 +02:00
|
|
|
ShowWindow( GetDlgItem(hDlg, 1090 ), SW_HIDE);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
else
|
2013-05-14 11:33:25 +02:00
|
|
|
CC_SwitchToFullSize(lpp, NULL);
|
2000-07-23 16:21:38 +02:00
|
|
|
res = TRUE;
|
2013-05-13 06:24:29 +02:00
|
|
|
for (i = IDC_COLOR_EDIT_H; i <= IDC_COLOR_EDIT_B; i++)
|
2000-04-24 19:35:11 +02:00
|
|
|
SendMessageA( GetDlgItem(hDlg, i), EM_LIMITTEXT, 3, 0); /* max 3 digits: xyz */
|
1999-02-28 21:05:11 +01:00
|
|
|
if (CC_HookCallChk(lpp->lpcc))
|
2000-04-24 19:35:11 +02:00
|
|
|
{
|
|
|
|
res = CallWindowProcA( (WNDPROC)lpp->lpcc->lpfnHook, hDlg, WM_INITDIALOG, wParam, lParam);
|
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/* Set the initial values of the color chooser dialog */
|
|
|
|
r = GetRValue(lpp->lpcc->rgbResult);
|
|
|
|
g = GetGValue(lpp->lpcc->rgbResult);
|
|
|
|
b = GetBValue(lpp->lpcc->rgbResult);
|
|
|
|
|
2013-05-13 07:38:09 +02:00
|
|
|
CC_PaintSelectedColor(lpp);
|
2013-05-13 07:03:22 +02:00
|
|
|
lpp->h = CC_RGBtoHSL('H', lpp->lpcc->rgbResult);
|
|
|
|
lpp->s = CC_RGBtoHSL('S', lpp->lpcc->rgbResult);
|
|
|
|
lpp->l = CC_RGBtoHSL('L', lpp->lpcc->rgbResult);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2003-04-02 03:23:43 +02:00
|
|
|
/* Doing it the long way because CC_EditSetRGB/HSL doesn't seem to work */
|
2013-05-13 06:24:29 +02:00
|
|
|
SetDlgItemInt(hDlg, IDC_COLOR_EDIT_H, lpp->h, TRUE);
|
|
|
|
SetDlgItemInt(hDlg, IDC_COLOR_EDIT_S, lpp->s, TRUE);
|
|
|
|
SetDlgItemInt(hDlg, IDC_COLOR_EDIT_L, lpp->l, TRUE);
|
|
|
|
SetDlgItemInt(hDlg, IDC_COLOR_EDIT_R, r, TRUE);
|
|
|
|
SetDlgItemInt(hDlg, IDC_COLOR_EDIT_G, g, TRUE);
|
|
|
|
SetDlgItemInt(hDlg, IDC_COLOR_EDIT_B, b, TRUE);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2013-05-13 07:38:09 +02:00
|
|
|
CC_PaintCross(lpp);
|
|
|
|
CC_PaintTriangle(lpp);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* CC_WMCommand [internal]
|
|
|
|
*/
|
2013-05-14 11:33:25 +02:00
|
|
|
static LRESULT CC_WMCommand(CCPRIV *lpp, WPARAM wParam, LPARAM lParam, WORD notifyCode, HWND hwndCtl)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
int r, g, b, i, xx;
|
|
|
|
UINT cokmsg;
|
1999-02-28 21:05:11 +01:00
|
|
|
HDC hdc;
|
|
|
|
COLORREF *cr;
|
2008-10-30 22:31:35 +01:00
|
|
|
|
2007-05-24 16:41:17 +02:00
|
|
|
TRACE("CC_WMCommand wParam=%lx lParam=%lx\n", wParam, lParam);
|
2005-12-31 13:23:30 +01:00
|
|
|
switch (LOWORD(wParam))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-13 06:24:29 +02:00
|
|
|
case IDC_COLOR_EDIT_R: /* edit notify RGB */
|
|
|
|
case IDC_COLOR_EDIT_G:
|
|
|
|
case IDC_COLOR_EDIT_B:
|
2000-04-24 19:35:11 +02:00
|
|
|
if (notifyCode == EN_UPDATE && !lpp->updating)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
i = CC_CheckDigitsInEdit(hwndCtl, 255);
|
|
|
|
r = GetRValue(lpp->lpcc->rgbResult);
|
|
|
|
g = GetGValue(lpp->lpcc->rgbResult);
|
|
|
|
b= GetBValue(lpp->lpcc->rgbResult);
|
|
|
|
xx = 0;
|
2005-12-31 13:23:30 +01:00
|
|
|
switch (LOWORD(wParam))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-13 06:24:29 +02:00
|
|
|
case IDC_COLOR_EDIT_R: if ((xx = (i != r))) r = i; break;
|
|
|
|
case IDC_COLOR_EDIT_G: if ((xx = (i != g))) g = i; break;
|
|
|
|
case IDC_COLOR_EDIT_B: if ((xx = (i != b))) b = i; break;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
if (xx) /* something has changed */
|
|
|
|
{
|
2000-04-24 19:35:11 +02:00
|
|
|
lpp->lpcc->rgbResult = RGB(r, g, b);
|
2013-05-13 07:38:09 +02:00
|
|
|
CC_PaintSelectedColor(lpp);
|
2013-05-13 07:03:22 +02:00
|
|
|
lpp->h = CC_RGBtoHSL('H', lpp->lpcc->rgbResult);
|
|
|
|
lpp->s = CC_RGBtoHSL('S', lpp->lpcc->rgbResult);
|
|
|
|
lpp->l = CC_RGBtoHSL('L', lpp->lpcc->rgbResult);
|
2013-05-14 11:33:25 +02:00
|
|
|
CC_EditSetHSL(lpp);
|
2013-05-13 07:38:09 +02:00
|
|
|
CC_PaintCross(lpp);
|
|
|
|
CC_PaintTriangle(lpp);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2013-05-13 06:24:29 +02:00
|
|
|
case IDC_COLOR_EDIT_H: /* edit notify HSL */
|
|
|
|
case IDC_COLOR_EDIT_S:
|
|
|
|
case IDC_COLOR_EDIT_L:
|
2000-04-24 19:35:11 +02:00
|
|
|
if (notifyCode == EN_UPDATE && !lpp->updating)
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-13 06:24:29 +02:00
|
|
|
i = CC_CheckDigitsInEdit(hwndCtl , LOWORD(wParam) == IDC_COLOR_EDIT_H ? 239 : 240);
|
2000-04-24 19:35:11 +02:00
|
|
|
xx = 0;
|
2005-12-31 13:23:30 +01:00
|
|
|
switch (LOWORD(wParam))
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-13 06:24:29 +02:00
|
|
|
case IDC_COLOR_EDIT_H: if ((xx = ( i != lpp->h))) lpp->h = i; break;
|
|
|
|
case IDC_COLOR_EDIT_S: if ((xx = ( i != lpp->s))) lpp->s = i; break;
|
|
|
|
case IDC_COLOR_EDIT_L: if ((xx = ( i != lpp->l))) lpp->l = i; break;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
if (xx) /* something has changed */
|
|
|
|
{
|
2013-05-13 06:48:28 +02:00
|
|
|
lpp->lpcc->rgbResult = CC_HSLtoRGB(lpp->h, lpp->s, lpp->l);
|
2013-05-13 07:38:09 +02:00
|
|
|
CC_PaintSelectedColor(lpp);
|
2013-05-14 11:33:25 +02:00
|
|
|
CC_EditSetRGB(lpp);
|
2013-05-13 07:38:09 +02:00
|
|
|
CC_PaintCross(lpp);
|
|
|
|
CC_PaintTriangle(lpp);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
break;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2013-05-13 06:24:29 +02:00
|
|
|
case IDC_COLOR_DEFINE:
|
2013-05-14 11:33:25 +02:00
|
|
|
CC_SwitchToFullSize(lpp, &lpp->fullsize);
|
|
|
|
SetFocus( GetDlgItem(lpp->hwndSelf, IDC_COLOR_EDIT_H));
|
1999-02-28 21:05:11 +01:00
|
|
|
break;
|
|
|
|
|
2013-05-13 06:24:29 +02:00
|
|
|
case IDC_COLOR_ADD: /* add colors ... column by column */
|
2000-04-24 19:35:11 +02:00
|
|
|
cr = lpp->lpcc->lpCustColors;
|
|
|
|
cr[(lpp->nextuserdef % 2) * 8 + lpp->nextuserdef / 2] = lpp->lpcc->rgbResult;
|
|
|
|
if (++lpp->nextuserdef == 16)
|
|
|
|
lpp->nextuserdef = 0;
|
2013-05-14 11:33:25 +02:00
|
|
|
CC_PaintUserColorArray(lpp, 2, 8);
|
1999-02-28 21:05:11 +01:00
|
|
|
break;
|
|
|
|
|
2013-05-13 06:24:29 +02:00
|
|
|
case IDC_COLOR_RES: /* resulting color */
|
2013-05-14 11:33:25 +02:00
|
|
|
hdc = GetDC(lpp->hwndSelf);
|
2000-04-24 19:35:11 +02:00
|
|
|
lpp->lpcc->rgbResult = GetNearestColor(hdc, lpp->lpcc->rgbResult);
|
2013-05-14 11:33:25 +02:00
|
|
|
ReleaseDC(lpp->hwndSelf, hdc);
|
|
|
|
CC_EditSetRGB(lpp);
|
2013-05-13 07:38:09 +02:00
|
|
|
CC_PaintSelectedColor(lpp);
|
2013-05-13 07:03:22 +02:00
|
|
|
lpp->h = CC_RGBtoHSL('H', lpp->lpcc->rgbResult);
|
|
|
|
lpp->s = CC_RGBtoHSL('S', lpp->lpcc->rgbResult);
|
|
|
|
lpp->l = CC_RGBtoHSL('L', lpp->lpcc->rgbResult);
|
2013-05-14 11:33:25 +02:00
|
|
|
CC_EditSetHSL(lpp);
|
2013-05-13 07:38:09 +02:00
|
|
|
CC_PaintCross(lpp);
|
|
|
|
CC_PaintTriangle(lpp);
|
1999-02-28 21:05:11 +01:00
|
|
|
break;
|
|
|
|
|
2017-05-11 11:13:05 +02:00
|
|
|
case pshHelp: /* Help! */ /* The Beatles, 1965 ;-) */
|
2001-01-22 03:13:58 +01:00
|
|
|
i = RegisterWindowMessageA(HELPMSGSTRINGA);
|
2000-04-24 19:35:11 +02:00
|
|
|
if (lpp->lpcc->hwndOwner)
|
|
|
|
SendMessageA(lpp->lpcc->hwndOwner, i, 0, (LPARAM)lpp->lpcc);
|
|
|
|
if ( CC_HookCallChk(lpp->lpcc))
|
2013-05-14 11:33:25 +02:00
|
|
|
CallWindowProcA( (WNDPROC) lpp->lpcc->lpfnHook, lpp->hwndSelf,
|
2000-04-24 19:35:11 +02:00
|
|
|
WM_COMMAND, psh15, (LPARAM)lpp->lpcc);
|
1999-02-28 21:05:11 +01:00
|
|
|
break;
|
|
|
|
|
|
|
|
case IDOK :
|
2001-01-22 03:13:58 +01:00
|
|
|
cokmsg = RegisterWindowMessageA(COLOROKSTRINGA);
|
2000-04-24 19:35:11 +02:00
|
|
|
if (lpp->lpcc->hwndOwner)
|
|
|
|
if (SendMessageA(lpp->lpcc->hwndOwner, cokmsg, 0, (LPARAM)lpp->lpcc))
|
2003-12-01 23:45:30 +01:00
|
|
|
break; /* do NOT close */
|
2013-05-14 11:33:25 +02:00
|
|
|
EndDialog(lpp->hwndSelf, 1) ;
|
1999-02-28 21:05:11 +01:00
|
|
|
return TRUE ;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
case IDCANCEL :
|
2013-05-14 11:33:25 +02:00
|
|
|
EndDialog(lpp->hwndSelf, 0) ;
|
1999-02-28 21:05:11 +01:00
|
|
|
return TRUE ;
|
|
|
|
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_WMPaint [internal]
|
|
|
|
*/
|
2013-05-14 11:33:25 +02:00
|
|
|
static LRESULT CC_WMPaint( CCPRIV *lpp )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
|
|
|
PAINTSTRUCT ps;
|
|
|
|
|
2013-05-14 11:33:25 +02:00
|
|
|
BeginPaint(lpp->hwndSelf, &ps);
|
1999-02-28 21:05:11 +01:00
|
|
|
/* we have to paint dialog children except text and buttons */
|
2013-05-14 11:33:25 +02:00
|
|
|
CC_PaintPredefColorArray(lpp, 6, 8);
|
|
|
|
CC_PaintUserColorArray(lpp, 2, 8);
|
2013-05-13 07:38:09 +02:00
|
|
|
CC_PaintLumBar(lpp);
|
|
|
|
CC_PaintTriangle(lpp);
|
|
|
|
CC_PaintSelectedColor(lpp);
|
|
|
|
CC_PaintColorGraph(lpp);
|
|
|
|
CC_PaintCross(lpp);
|
2013-05-14 11:33:25 +02:00
|
|
|
EndPaint(lpp->hwndSelf, &ps);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2005-01-09 17:42:53 +01:00
|
|
|
return TRUE;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* CC_WMLButtonUp [internal]
|
|
|
|
*/
|
2013-05-14 11:33:25 +02:00
|
|
|
static LRESULT CC_WMLButtonUp( CCPRIV *infoPtr )
|
2000-04-24 19:35:11 +02:00
|
|
|
{
|
2013-05-14 11:33:25 +02:00
|
|
|
if (infoPtr->capturedGraph)
|
2000-04-24 19:35:11 +02:00
|
|
|
{
|
2013-05-14 11:33:25 +02:00
|
|
|
infoPtr->capturedGraph = 0;
|
2000-04-24 19:35:11 +02:00
|
|
|
ReleaseCapture();
|
2013-05-14 11:33:25 +02:00
|
|
|
CC_PaintCross(infoPtr);
|
2000-04-24 19:35:11 +02:00
|
|
|
return 1;
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* CC_WMMouseMove [internal]
|
|
|
|
*/
|
2013-05-14 11:33:25 +02:00
|
|
|
static LRESULT CC_WMMouseMove( CCPRIV *infoPtr, LPARAM lParam )
|
2000-04-24 19:35:11 +02:00
|
|
|
{
|
2013-05-14 11:33:25 +02:00
|
|
|
if (infoPtr->capturedGraph)
|
2000-04-24 19:35:11 +02:00
|
|
|
{
|
2013-05-14 11:33:25 +02:00
|
|
|
int *ptrh = NULL, *ptrs = &infoPtr->l;
|
|
|
|
if (infoPtr->capturedGraph == IDC_COLOR_GRAPH)
|
2000-04-24 19:35:11 +02:00
|
|
|
{
|
2013-05-14 11:33:25 +02:00
|
|
|
ptrh = &infoPtr->h;
|
|
|
|
ptrs = &infoPtr->s;
|
2000-04-24 19:35:11 +02:00
|
|
|
}
|
2013-05-14 11:33:25 +02:00
|
|
|
if (CC_MouseCheckColorGraph( infoPtr->hwndSelf, infoPtr->capturedGraph, ptrh, ptrs, lParam))
|
2000-04-24 19:35:11 +02:00
|
|
|
{
|
2013-05-14 11:33:25 +02:00
|
|
|
infoPtr->lpcc->rgbResult = CC_HSLtoRGB(infoPtr->h, infoPtr->s, infoPtr->l);
|
|
|
|
CC_EditSetRGB(infoPtr);
|
|
|
|
CC_EditSetHSL(infoPtr);
|
|
|
|
CC_PaintCross(infoPtr);
|
|
|
|
CC_PaintTriangle(infoPtr);
|
|
|
|
CC_PaintSelectedColor(infoPtr);
|
2000-04-24 19:35:11 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
ReleaseCapture();
|
2013-05-14 11:33:25 +02:00
|
|
|
infoPtr->capturedGraph = 0;
|
2000-04-24 19:35:11 +02:00
|
|
|
}
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
2003-06-13 20:07:45 +02:00
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* CC_WMLButtonDown [internal]
|
|
|
|
*/
|
2013-05-14 11:33:25 +02:00
|
|
|
static LRESULT CC_WMLButtonDown( CCPRIV *infoPtr, LPARAM lParam )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-13 07:03:22 +02:00
|
|
|
int i = 0;
|
2000-04-24 19:35:11 +02:00
|
|
|
|
2013-05-14 11:33:25 +02:00
|
|
|
if (CC_MouseCheckPredefColorArray(infoPtr, 6, 8, lParam))
|
2000-04-24 19:35:11 +02:00
|
|
|
i = 1;
|
1999-02-28 21:05:11 +01:00
|
|
|
else
|
2013-05-14 11:33:25 +02:00
|
|
|
if (CC_MouseCheckUserColorArray(infoPtr, 2, 8, lParam))
|
2000-04-24 19:35:11 +02:00
|
|
|
i = 1;
|
1999-02-28 21:05:11 +01:00
|
|
|
else
|
2013-05-14 11:33:25 +02:00
|
|
|
if (CC_MouseCheckColorGraph(infoPtr->hwndSelf, IDC_COLOR_GRAPH, &infoPtr->h, &infoPtr->s, lParam))
|
2000-04-24 19:35:11 +02:00
|
|
|
{
|
|
|
|
i = 2;
|
2013-05-14 11:33:25 +02:00
|
|
|
infoPtr->capturedGraph = IDC_COLOR_GRAPH;
|
2000-04-24 19:35:11 +02:00
|
|
|
}
|
1999-02-28 21:05:11 +01:00
|
|
|
else
|
2013-05-14 11:33:25 +02:00
|
|
|
if (CC_MouseCheckColorGraph(infoPtr->hwndSelf, IDC_COLOR_LUMBAR, NULL, &infoPtr->l, lParam))
|
2000-04-24 19:35:11 +02:00
|
|
|
{
|
|
|
|
i = 2;
|
2013-05-14 11:33:25 +02:00
|
|
|
infoPtr->capturedGraph = IDC_COLOR_LUMBAR;
|
2000-04-24 19:35:11 +02:00
|
|
|
}
|
|
|
|
if ( i == 2 )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-14 11:33:25 +02:00
|
|
|
SetCapture(infoPtr->hwndSelf);
|
|
|
|
infoPtr->lpcc->rgbResult = CC_HSLtoRGB(infoPtr->h, infoPtr->s, infoPtr->l);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
2000-04-24 19:35:11 +02:00
|
|
|
if ( i == 1 )
|
1999-02-28 21:05:11 +01:00
|
|
|
{
|
2013-05-14 11:33:25 +02:00
|
|
|
infoPtr->h = CC_RGBtoHSL('H', infoPtr->lpcc->rgbResult);
|
|
|
|
infoPtr->s = CC_RGBtoHSL('S', infoPtr->lpcc->rgbResult);
|
|
|
|
infoPtr->l = CC_RGBtoHSL('L', infoPtr->lpcc->rgbResult);
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|
|
|
|
if (i)
|
|
|
|
{
|
2013-05-14 11:33:25 +02:00
|
|
|
CC_EditSetRGB(infoPtr);
|
|
|
|
CC_EditSetHSL(infoPtr);
|
|
|
|
CC_PaintCross(infoPtr);
|
|
|
|
CC_PaintTriangle(infoPtr);
|
|
|
|
CC_PaintSelectedColor(infoPtr);
|
1999-02-28 21:05:11 +01:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* ColorDlgProc32 [internal]
|
|
|
|
*
|
|
|
|
*/
|
2002-10-31 02:04:39 +01:00
|
|
|
static INT_PTR CALLBACK ColorDlgProc( HWND hDlg, UINT message,
|
2000-04-24 19:35:11 +02:00
|
|
|
WPARAM wParam, LPARAM lParam )
|
|
|
|
{
|
|
|
|
|
|
|
|
int res;
|
2013-05-14 11:33:25 +02:00
|
|
|
CCPRIV *lpp = GetPropW( hDlg, szColourDialogProp );
|
2008-10-30 22:31:35 +01:00
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
if (message != WM_INITDIALOG)
|
|
|
|
{
|
|
|
|
if (!lpp)
|
|
|
|
return FALSE;
|
|
|
|
res = 0;
|
|
|
|
if (CC_HookCallChk(lpp->lpcc))
|
|
|
|
res = CallWindowProcA( (WNDPROC)lpp->lpcc->lpfnHook, hDlg, message, wParam, lParam);
|
|
|
|
if ( res )
|
|
|
|
return res;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* FIXME: SetRGB message
|
|
|
|
if (message && message == msetrgb)
|
|
|
|
return HandleSetRGB(hDlg, lParam);
|
|
|
|
*/
|
|
|
|
|
|
|
|
switch (message)
|
|
|
|
{
|
|
|
|
case WM_INITDIALOG:
|
2003-12-01 23:45:30 +01:00
|
|
|
return CC_WMInitDialog(hDlg, wParam, lParam);
|
2000-04-24 19:35:11 +02:00
|
|
|
case WM_NCDESTROY:
|
2002-06-01 01:06:46 +02:00
|
|
|
DeleteDC(lpp->hdcMem);
|
|
|
|
DeleteObject(lpp->hbmMem);
|
2000-04-24 19:35:11 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, lpp);
|
2006-03-10 04:26:50 +01:00
|
|
|
RemovePropW( hDlg, szColourDialogProp );
|
2000-04-24 19:35:11 +02:00
|
|
|
break;
|
|
|
|
case WM_COMMAND:
|
2013-05-14 11:33:25 +02:00
|
|
|
if (CC_WMCommand(lpp, wParam, lParam, HIWORD(wParam), (HWND) lParam))
|
2000-04-24 19:35:11 +02:00
|
|
|
return TRUE;
|
2002-06-01 01:06:46 +02:00
|
|
|
break;
|
2000-04-24 19:35:11 +02:00
|
|
|
case WM_PAINT:
|
2013-05-14 11:33:25 +02:00
|
|
|
if (CC_WMPaint(lpp))
|
2000-04-24 19:35:11 +02:00
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case WM_LBUTTONDBLCLK:
|
|
|
|
if (CC_MouseCheckResultWindow(hDlg, lParam))
|
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case WM_MOUSEMOVE:
|
2013-05-14 11:33:25 +02:00
|
|
|
if (CC_WMMouseMove(lpp, lParam))
|
2000-04-24 19:35:11 +02:00
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case WM_LBUTTONUP: /* FIXME: ClipCursor off (if in color graph)*/
|
2013-05-14 11:33:25 +02:00
|
|
|
if (CC_WMLButtonUp(lpp))
|
2000-04-24 19:35:11 +02:00
|
|
|
return TRUE;
|
|
|
|
break;
|
|
|
|
case WM_LBUTTONDOWN:/* FIXME: ClipCursor on (if in color graph)*/
|
2013-05-14 11:33:25 +02:00
|
|
|
if (CC_WMLButtonDown(lpp, lParam))
|
2000-04-24 19:35:11 +02:00
|
|
|
return TRUE;
|
2002-06-01 01:06:46 +02:00
|
|
|
break;
|
2000-04-24 19:35:11 +02:00
|
|
|
}
|
|
|
|
return FALSE ;
|
|
|
|
}
|
|
|
|
|
1999-02-28 21:05:11 +01:00
|
|
|
/***********************************************************************
|
2001-06-19 05:34:07 +02:00
|
|
|
* ChooseColorW (COMDLG32.@)
|
2005-11-12 20:12:25 +01:00
|
|
|
*
|
|
|
|
* Create a color dialog box.
|
|
|
|
*
|
|
|
|
* PARAMS
|
|
|
|
* lpChCol [I/O] in: information to initialize the dialog box.
|
|
|
|
* out: User's color selection
|
|
|
|
*
|
|
|
|
* RETURNS
|
|
|
|
* TRUE: Ok button clicked.
|
|
|
|
* FALSE: Cancel button clicked, or error.
|
1999-02-28 21:05:11 +01:00
|
|
|
*/
|
2013-05-13 07:38:09 +02:00
|
|
|
BOOL WINAPI ChooseColorW( CHOOSECOLORW *lpChCol )
|
2000-04-24 19:35:11 +02:00
|
|
|
{
|
|
|
|
HANDLE hDlgTmpl = 0;
|
2013-05-13 07:38:09 +02:00
|
|
|
const void *template;
|
|
|
|
|
|
|
|
TRACE("(%p)\n", lpChCol);
|
2000-04-24 19:35:11 +02:00
|
|
|
|
2002-06-01 01:06:46 +02:00
|
|
|
if (!lpChCol) return FALSE;
|
2000-04-24 19:35:11 +02:00
|
|
|
|
|
|
|
if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE)
|
|
|
|
{
|
|
|
|
if (!(template = LockResource(lpChCol->hInstance)))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (lpChCol->Flags & CC_ENABLETEMPLATE)
|
|
|
|
{
|
2002-09-17 00:47:05 +02:00
|
|
|
HRSRC hResInfo;
|
2002-11-22 00:55:10 +01:00
|
|
|
if (!(hResInfo = FindResourceW((HINSTANCE)lpChCol->hInstance,
|
2000-04-24 19:35:11 +02:00
|
|
|
lpChCol->lpTemplateName,
|
2003-09-10 05:56:47 +02:00
|
|
|
(LPWSTR)RT_DIALOG)))
|
2000-04-24 19:35:11 +02:00
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2002-11-22 00:55:10 +01:00
|
|
|
if (!(hDlgTmpl = LoadResource((HINSTANCE)lpChCol->hInstance, hResInfo)) ||
|
2000-04-24 19:35:11 +02:00
|
|
|
!(template = LockResource(hDlgTmpl)))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-09-17 00:47:05 +02:00
|
|
|
HRSRC hResInfo;
|
|
|
|
HGLOBAL hDlgTmpl;
|
2005-01-10 14:22:35 +01:00
|
|
|
static const WCHAR wszCHOOSE_COLOR[] = {'C','H','O','O','S','E','_','C','O','L','O','R',0};
|
|
|
|
if (!(hResInfo = FindResourceW(COMDLG32_hInstance, wszCHOOSE_COLOR, (LPWSTR)RT_DIALOG)))
|
2000-04-24 19:35:11 +02:00
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
2003-04-30 00:52:02 +02:00
|
|
|
if (!(hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo )) ||
|
2000-04-24 19:35:11 +02:00
|
|
|
!(template = LockResource(hDlgTmpl)))
|
|
|
|
{
|
|
|
|
COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-13 07:38:09 +02:00
|
|
|
return DialogBoxIndirectParamW(COMDLG32_hInstance, template, lpChCol->hwndOwner,
|
2005-09-02 13:32:17 +02:00
|
|
|
ColorDlgProc, (LPARAM)lpChCol);
|
2000-04-24 19:35:11 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
2001-06-19 05:34:07 +02:00
|
|
|
* ChooseColorA (COMDLG32.@)
|
2005-11-12 20:12:25 +01:00
|
|
|
*
|
|
|
|
* See ChooseColorW.
|
2000-04-24 19:35:11 +02:00
|
|
|
*/
|
|
|
|
BOOL WINAPI ChooseColorA( LPCHOOSECOLORA lpChCol )
|
1999-02-28 21:05:11 +01:00
|
|
|
|
|
|
|
{
|
2006-10-22 14:32:29 +02:00
|
|
|
LPWSTR template_name = NULL;
|
2000-04-24 19:35:11 +02:00
|
|
|
BOOL ret;
|
2006-10-22 14:32:29 +02:00
|
|
|
|
2000-04-25 21:53:04 +02:00
|
|
|
LPCHOOSECOLORW lpcc = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(CHOOSECOLORW));
|
2000-04-24 19:35:11 +02:00
|
|
|
lpcc->lStructSize = sizeof(*lpcc);
|
|
|
|
lpcc->hwndOwner = lpChCol->hwndOwner;
|
|
|
|
lpcc->hInstance = lpChCol->hInstance;
|
|
|
|
lpcc->rgbResult = lpChCol->rgbResult;
|
|
|
|
lpcc->lpCustColors = lpChCol->lpCustColors;
|
|
|
|
lpcc->Flags = lpChCol->Flags;
|
|
|
|
lpcc->lCustData = lpChCol->lCustData;
|
2007-12-03 23:40:42 +01:00
|
|
|
lpcc->lpfnHook = lpChCol->lpfnHook;
|
2000-06-25 14:51:14 +02:00
|
|
|
if ((lpcc->Flags & CC_ENABLETEMPLATE) && (lpChCol->lpTemplateName)) {
|
2010-01-27 12:07:28 +01:00
|
|
|
if (!IS_INTRESOURCE(lpChCol->lpTemplateName)) {
|
2002-01-04 19:23:46 +01:00
|
|
|
INT len = MultiByteToWideChar( CP_ACP, 0, lpChCol->lpTemplateName, -1, NULL, 0);
|
2006-10-22 14:32:29 +02:00
|
|
|
template_name = HeapAlloc( GetProcessHeap(), 0, len * sizeof(WCHAR) );
|
|
|
|
MultiByteToWideChar( CP_ACP, 0, lpChCol->lpTemplateName, -1, template_name, len );
|
|
|
|
lpcc->lpTemplateName = template_name;
|
2002-01-04 19:23:46 +01:00
|
|
|
} else {
|
2006-09-02 17:33:45 +02:00
|
|
|
lpcc->lpTemplateName = (LPCWSTR)lpChCol->lpTemplateName;
|
2002-01-04 19:23:46 +01:00
|
|
|
}
|
2000-06-25 14:51:14 +02:00
|
|
|
}
|
|
|
|
|
2000-04-24 19:35:11 +02:00
|
|
|
ret = ChooseColorW(lpcc);
|
1999-02-28 21:05:11 +01:00
|
|
|
|
2000-04-25 21:53:04 +02:00
|
|
|
if (ret)
|
2000-04-24 19:35:11 +02:00
|
|
|
lpChCol->rgbResult = lpcc->rgbResult;
|
2006-10-22 14:32:29 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, template_name);
|
2000-04-25 21:53:04 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, lpcc);
|
2000-04-24 19:35:11 +02:00
|
|
|
return ret;
|
1999-02-28 21:05:11 +01:00
|
|
|
}
|