2 * COMMDLG - Color Dialog
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
7 * This library is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU Lesser General Public
9 * License as published by the Free Software Foundation; either
10 * version 2.1 of the License, or (at your option) any later version.
12 * This library is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this library; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
22 /* BUGS : still seems to not refresh correctly
23 sometimes, especially when 2 instances of the
24 dialog are loaded at the same time */
34 #include "wine/winbase16.h"
35 #include "wine/winuser16.h"
39 #include "wine/debug.h"
42 WINE_DEFAULT_DEBUG_CHANNEL(commdlg);
47 /***********************************************************************
48 * ColorDlgProc (COMMDLG.8)
50 BOOL16 CALLBACK ColorDlgProc16( HWND16 hDlg16, UINT16 message,
51 WPARAM16 wParam, LONG lParam )
54 HWND hDlg = HWND_32(hDlg16);
56 LCCPRIV lpp = (LCCPRIV)GetWindowLongA(hDlg, DWL_USER);
57 if (message != WM_INITDIALOG)
62 if (CC_HookCallChk(lpp->lpcc))
63 res = CallWindowProc16( (WNDPROC16)lpp->lpcc16->lpfnHook, hDlg16, message, wParam, lParam);
68 /* FIXME: SetRGB message
69 if (message && message == msetrgb)
70 return HandleSetRGB(hDlg, lParam);
76 return CC_WMInitDialog(hDlg, wParam, lParam, TRUE);
78 DeleteDC(lpp->hdcMem);
79 DeleteObject(lpp->hbmMem);
80 HeapFree(GetProcessHeap(), 0, lpp->lpcc);
81 HeapFree(GetProcessHeap(), 0, lpp);
82 SetWindowLongA(hDlg, DWL_USER, 0L); /* we don't need it anymore */
85 if (CC_WMCommand(hDlg, wParam, lParam,
86 HIWORD(lParam), HWND_32(LOWORD(lParam))))
90 if (CC_WMPaint(hDlg, wParam, lParam))
93 case WM_LBUTTONDBLCLK:
94 if (CC_MouseCheckResultWindow(hDlg,lParam))
98 if (CC_WMMouseMove(hDlg, lParam))
101 case WM_LBUTTONUP: /* FIXME: ClipCursor off (if in color graph)*/
102 if (CC_WMLButtonUp(hDlg, wParam, lParam))
105 case WM_LBUTTONDOWN:/* FIXME: ClipCursor on (if in color graph)*/
106 if (CC_WMLButtonDown(hDlg, wParam, lParam))
115 /***********************************************************************
116 * ChooseColor (COMMDLG.5)
118 BOOL16 WINAPI ChooseColor16( LPCHOOSECOLOR16 lpChCol )
121 HANDLE16 hDlgTmpl16 = 0, hResource16 = 0;
122 HGLOBAL16 hGlobal16 = 0;
127 TRACE("ChooseColor\n");
128 if (!lpChCol) return FALSE;
130 if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE)
131 hDlgTmpl16 = lpChCol->hInstance;
132 else if (lpChCol->Flags & CC_ENABLETEMPLATE)
135 if (!(hResInfo = FindResource16(lpChCol->hInstance,
136 MapSL(lpChCol->lpTemplateName),
139 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
142 if (!(hDlgTmpl16 = LoadResource16(lpChCol->hInstance, hResInfo)))
144 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
147 hResource16 = hDlgTmpl16;
155 if (!(hResInfo = FindResourceA(COMDLG32_hInstance, "CHOOSE_COLOR", (LPSTR)RT_DIALOG)))
157 COMDLG32_SetCommDlgExtendedError(CDERR_FINDRESFAILURE);
160 if (!(hDlgTmpl32 = LoadResource(COMDLG32_hInstance, hResInfo)) ||
161 !(template32 = LockResource(hDlgTmpl32)))
163 COMDLG32_SetCommDlgExtendedError(CDERR_LOADRESFAILURE);
166 size = SizeofResource(GetModuleHandleA("COMDLG32"), hResInfo);
167 hGlobal16 = GlobalAlloc16(0, size);
170 COMDLG32_SetCommDlgExtendedError(CDERR_MEMALLOCFAILURE);
171 ERR("alloc failure for %ld bytes\n", size);
174 template = GlobalLock16(hGlobal16);
177 COMDLG32_SetCommDlgExtendedError(CDERR_MEMLOCKFAILURE);
178 ERR("global lock failure for %x handle\n", hDlgTmpl16);
179 GlobalFree16(hGlobal16);
182 ConvertDialog32To16((LPVOID)template32, size, (LPVOID)template);
183 hDlgTmpl16 = hGlobal16;
186 ptr = GetProcAddress16(GetModuleHandle16("COMMDLG"), (LPCSTR) 8);
187 hInst = GetWindowLongA(HWND_32(lpChCol->hwndOwner), GWL_HINSTANCE);
188 bRet = DialogBoxIndirectParam16(hInst, hDlgTmpl16, lpChCol->hwndOwner,
189 (DLGPROC16) ptr, (DWORD)lpChCol);
190 if (hResource16) FreeResource16(hDlgTmpl16);
193 GlobalUnlock16(hGlobal16);
194 GlobalFree16(hGlobal16);