Release 961222
[wine/multimedia.git] / misc / commdlg.c
blob42845d529ce181deda82656c9b8393d9bdf5ca67
1 /*
2 * COMMDLG functions
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
6 */
8 #include <stdio.h>
9 #include <stdlib.h>
10 #include <string.h>
11 #include "win.h"
12 #include "heap.h"
13 #include "message.h"
14 #include "commdlg.h"
15 #include "dlgs.h"
16 #include "module.h"
17 #include "resource.h"
18 #include "dos_fs.h"
19 #include "drive.h"
20 #include "stddebug.h"
21 #include "debug.h"
23 static DWORD CommDlgLastError = 0;
25 static HBITMAP16 hFolder = 0;
26 static HBITMAP16 hFolder2 = 0;
27 static HBITMAP16 hFloppy = 0;
28 static HBITMAP16 hHDisk = 0;
29 static HBITMAP16 hCDRom = 0;
30 static HBITMAP16 hBitmapTT = 0;
32 /***********************************************************************
33 * FileDlg_Init [internal]
35 static BOOL FileDlg_Init()
37 static BOOL initialized = 0;
39 if (!initialized) {
40 if (!hFolder) hFolder = LoadBitmap16(0, MAKEINTRESOURCE(OBM_FOLDER));
41 if (!hFolder2) hFolder2 = LoadBitmap16(0, MAKEINTRESOURCE(OBM_FOLDER2));
42 if (!hFloppy) hFloppy = LoadBitmap16(0, MAKEINTRESOURCE(OBM_FLOPPY));
43 if (!hHDisk) hHDisk = LoadBitmap16(0, MAKEINTRESOURCE(OBM_HDISK));
44 if (!hCDRom) hCDRom = LoadBitmap16(0, MAKEINTRESOURCE(OBM_CDROM));
45 if (hFolder == 0 || hFolder2 == 0 || hFloppy == 0 ||
46 hHDisk == 0 || hCDRom == 0)
48 fprintf(stderr, "FileDlg_Init // Error loading bitmaps !");
49 return FALSE;
51 initialized = TRUE;
53 return TRUE;
56 /***********************************************************************
57 * GetOpenFileName (COMMDLG.1)
59 BOOL GetOpenFileName( SEGPTR ofn )
61 HINSTANCE16 hInst;
62 HANDLE16 hDlgTmpl, hResInfo;
63 BOOL bRet;
64 LPOPENFILENAME lpofn = (LPOPENFILENAME)PTR_SEG_TO_LIN(ofn);
66 if (!lpofn || !FileDlg_Init()) return FALSE;
68 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE) hDlgTmpl = lpofn->hInstance;
69 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
71 if (!(hResInfo = FindResource16(lpofn->hInstance,
72 lpofn->lpTemplateName, RT_DIALOG)))
74 CommDlgLastError = CDERR_FINDRESFAILURE;
75 return FALSE;
77 hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo );
79 else hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_OPEN_FILE );
80 if (!hDlgTmpl)
82 CommDlgLastError = CDERR_LOADRESFAILURE;
83 return FALSE;
86 hInst = WIN_GetWindowInstance( lpofn->hwndOwner );
87 bRet = DialogBoxIndirectParam16( hInst, hDlgTmpl, lpofn->hwndOwner,
88 (DLGPROC16)MODULE_GetWndProcEntry16("FileOpenDlgProc"),
89 ofn );
91 if (!(lpofn->Flags & OFN_ENABLETEMPLATEHANDLE))
93 if (lpofn->Flags & OFN_ENABLETEMPLATE) FreeResource16( hDlgTmpl );
94 else SYSRES_FreeResource( hDlgTmpl );
97 dprintf_commdlg(stddeb,"GetOpenFileName // return lpstrFile='%s' !\n",
98 (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
99 return bRet;
103 /***********************************************************************
104 * GetSaveFileName (COMMDLG.2)
106 BOOL GetSaveFileName( SEGPTR ofn)
108 HINSTANCE16 hInst;
109 HANDLE16 hDlgTmpl, hResInfo;
110 BOOL bRet;
111 LPOPENFILENAME lpofn = (LPOPENFILENAME)PTR_SEG_TO_LIN(ofn);
113 if (!lpofn || !FileDlg_Init()) return FALSE;
115 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE) hDlgTmpl = lpofn->hInstance;
116 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
118 hInst = lpofn->hInstance;
119 if (!(hResInfo = FindResource16(lpofn->hInstance,
120 lpofn->lpTemplateName, RT_DIALOG )))
122 CommDlgLastError = CDERR_FINDRESFAILURE;
123 return FALSE;
125 hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo );
127 else hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_SAVE_FILE );
129 hInst = WIN_GetWindowInstance( lpofn->hwndOwner );
130 bRet = DialogBoxIndirectParam16( hInst, hDlgTmpl, lpofn->hwndOwner,
131 (DLGPROC16)MODULE_GetWndProcEntry16("FileSaveDlgProc"),
132 ofn );
133 if (!(lpofn->Flags & OFN_ENABLETEMPLATEHANDLE))
135 if (lpofn->Flags & OFN_ENABLETEMPLATE) FreeResource16( hDlgTmpl );
136 else SYSRES_FreeResource( hDlgTmpl );
139 dprintf_commdlg(stddeb, "GetSaveFileName // return lpstrFile='%s' !\n",
140 (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
141 return bRet;
144 /***********************************************************************
145 * FILEDLG_StripEditControl [internal]
146 * Strip pathnames off the contents of the edit control.
148 static void FILEDLG_StripEditControl(HWND hwnd)
150 char temp[512], *cp;
152 GetDlgItemText32A( hwnd, edt1, temp, sizeof(temp) );
153 cp = strrchr(temp, '\\');
154 if (cp != NULL) {
155 strcpy(temp, cp+1);
157 cp = strrchr(temp, ':');
158 if (cp != NULL) {
159 strcpy(temp, cp+1);
161 /* FIXME: shouldn't we do something with the result here? ;-) */
164 /***********************************************************************
165 * FILEDLG_ScanDir [internal]
167 static BOOL FILEDLG_ScanDir(HWND hWnd, LPSTR newPath)
169 int len;
170 char str[512];
172 lstrcpyn32A( str, newPath, 512 );
173 len = strlen(str);
174 GetDlgItemText32A( hWnd, edt1, str + len, sizeof(str) - len );
175 if (!DlgDirList32A( hWnd, str, lst1, 0, 0x0000 )) return FALSE;
176 return DlgDirList32A( hWnd, "*.*", lst2, stc1, 0x8010 );
179 /***********************************************************************
180 * FILEDLG_GetFileType [internal]
183 static LPSTR FILEDLG_GetFileType(LPSTR cfptr, LPSTR fptr, WORD index)
185 int n, i;
186 i = 0;
187 if (cfptr)
188 for ( ;(n = strlen(cfptr)) != 0; i++)
190 cfptr += n + 1;
191 if (i == index)
192 return cfptr;
193 cfptr += strlen(cfptr) + 1;
195 if (fptr)
196 for ( ;(n = strlen(fptr)) != 0; i++)
198 fptr += n + 1;
199 if (i == index)
200 return fptr;
201 fptr += strlen(fptr) + 1;
203 return NULL;
206 /***********************************************************************
207 * FILEDLG_WMDrawItem [internal]
209 static LONG FILEDLG_WMDrawItem(HWND hWnd, WPARAM16 wParam, LPARAM lParam,int savedlg)
211 LPDRAWITEMSTRUCT16 lpdis = (LPDRAWITEMSTRUCT16)PTR_SEG_TO_LIN(lParam);
212 char *str;
213 HBRUSH32 hBrush;
214 HBITMAP16 hBitmap, hPrevBitmap;
215 BITMAP16 bm;
216 HDC32 hMemDC;
218 if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst1)
220 if (!(str = SEGPTR_ALLOC(512))) return FALSE;
221 hBrush = SelectObject32(lpdis->hDC, GetStockObject32(LTGRAY_BRUSH));
222 SelectObject32(lpdis->hDC, hBrush);
223 FillRect16(lpdis->hDC, &lpdis->rcItem, hBrush);
224 SendMessage16(lpdis->hwndItem, LB_GETTEXT16, lpdis->itemID,
225 (LPARAM)SEGPTR_GET(str));
227 if (savedlg) /* use _gray_ text in FileSaveDlg */
228 if (!lpdis->itemState)
229 SetTextColor(lpdis->hDC,GetSysColor(COLOR_GRAYTEXT) );
230 else
231 SetTextColor(lpdis->hDC,GetSysColor(COLOR_WINDOWTEXT) );
232 /* inversion of gray would be bad readable */
234 TextOut16(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
235 str, strlen(str));
236 if (lpdis->itemState != 0) {
237 InvertRect16(lpdis->hDC, &lpdis->rcItem);
239 SEGPTR_FREE(str);
240 return TRUE;
243 if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst2)
245 if (!(str = SEGPTR_ALLOC(512))) return FALSE;
246 hBrush = SelectObject32(lpdis->hDC, GetStockObject32(LTGRAY_BRUSH));
247 SelectObject32(lpdis->hDC, hBrush);
248 FillRect16(lpdis->hDC, &lpdis->rcItem, hBrush);
249 SendMessage16(lpdis->hwndItem, LB_GETTEXT16, lpdis->itemID,
250 (LPARAM)SEGPTR_GET(str));
252 hBitmap = hFolder;
253 GetObject16( hBitmap, sizeof(bm), &bm );
254 TextOut16(lpdis->hDC, lpdis->rcItem.left + bm.bmWidth,
255 lpdis->rcItem.top, str, strlen(str));
256 hMemDC = CreateCompatibleDC32(lpdis->hDC);
257 hPrevBitmap = SelectObject32(hMemDC, hBitmap);
258 BitBlt32(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
259 bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
260 SelectObject32(hMemDC, hPrevBitmap);
261 DeleteDC32(hMemDC);
262 if (lpdis->itemState != 0) InvertRect16(lpdis->hDC, &lpdis->rcItem);
263 SEGPTR_FREE(str);
264 return TRUE;
266 if (lpdis->CtlType == ODT_COMBOBOX && lpdis->CtlID == cmb2)
268 if (!(str = SEGPTR_ALLOC(512))) return FALSE;
269 hBrush = SelectObject32(lpdis->hDC, GetStockObject32(LTGRAY_BRUSH));
270 SelectObject32(lpdis->hDC, hBrush);
271 FillRect16(lpdis->hDC, &lpdis->rcItem, hBrush);
272 SendMessage16(lpdis->hwndItem, CB_GETLBTEXT16, lpdis->itemID,
273 (LPARAM)SEGPTR_GET(str));
274 switch(DRIVE_GetType( str[2] - 'a' ))
276 case TYPE_FLOPPY: hBitmap = hFloppy; break;
277 case TYPE_CDROM: hBitmap = hCDRom; break;
278 case TYPE_HD:
279 case TYPE_NETWORK:
280 default: hBitmap = hHDisk; break;
282 GetObject16( hBitmap, sizeof(bm), &bm );
283 TextOut16(lpdis->hDC, lpdis->rcItem.left + bm.bmWidth,
284 lpdis->rcItem.top, str, strlen(str));
285 hMemDC = CreateCompatibleDC32(lpdis->hDC);
286 hPrevBitmap = SelectObject32(hMemDC, hBitmap);
287 BitBlt32( lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
288 bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY );
289 SelectObject32(hMemDC, hPrevBitmap);
290 DeleteDC32(hMemDC);
291 if (lpdis->itemState != 0) InvertRect16(lpdis->hDC, &lpdis->rcItem);
292 SEGPTR_FREE(str);
293 return TRUE;
295 return FALSE;
298 /***********************************************************************
299 * FILEDLG_WMMeasureItem [internal]
301 static LONG FILEDLG_WMMeasureItem(HWND hWnd, WPARAM16 wParam, LPARAM lParam)
303 BITMAP16 bm;
304 LPMEASUREITEMSTRUCT16 lpmeasure;
306 GetObject16( hFolder2, sizeof(bm), &bm );
307 lpmeasure = (LPMEASUREITEMSTRUCT16)PTR_SEG_TO_LIN(lParam);
308 lpmeasure->itemHeight = bm.bmHeight;
309 return TRUE;
312 /***********************************************************************
313 * FILEDLG_HookCallChk [internal]
315 static int FILEDLG_HookCallChk(LPOPENFILENAME lpofn)
317 if (lpofn)
318 if (lpofn->Flags & OFN_ENABLEHOOK)
319 if (lpofn->lpfnHook)
320 return 1;
321 return 0;
324 /***********************************************************************
325 * FILEDLG_WMInitDialog [internal]
328 static LONG FILEDLG_WMInitDialog(HWND hWnd, WPARAM16 wParam, LPARAM lParam)
330 int i, n;
331 LPOPENFILENAME lpofn;
332 char tmpstr[512];
333 LPSTR pstr;
334 SetWindowLong32A(hWnd, DWL_USER, lParam);
335 lpofn = (LPOPENFILENAME)PTR_SEG_TO_LIN(lParam);
336 if (lpofn->lpstrTitle) SetWindowText16( hWnd, lpofn->lpstrTitle );
337 /* read custom filter information */
338 if (lpofn->lpstrCustomFilter)
340 pstr = (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter);
341 n = 0;
342 dprintf_commdlg(stddeb,"lpstrCustomFilter = %p\n", pstr);
343 while(*pstr)
345 dprintf_commdlg(stddeb,"lpstrCustomFilter // add str='%s' ",pstr);
346 i = SendDlgItemMessage16(hWnd, cmb1, CB_ADDSTRING16, 0,
347 (LPARAM)lpofn->lpstrCustomFilter + n );
348 n += strlen(pstr) + 1;
349 pstr += strlen(pstr) + 1;
350 dprintf_commdlg(stddeb,"associated to '%s'\n", pstr);
351 SendDlgItemMessage16(hWnd, cmb1, CB_SETITEMDATA16, i, (LPARAM)pstr);
352 n += strlen(pstr) + 1;
353 pstr += strlen(pstr) + 1;
356 /* read filter information */
357 if (lpofn->lpstrFilter) {
358 pstr = (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFilter);
359 n = 0;
360 while(*pstr) {
361 dprintf_commdlg(stddeb,"lpstrFilter // add str='%s' ", pstr);
362 i = SendDlgItemMessage16(hWnd, cmb1, CB_ADDSTRING16, 0,
363 (LPARAM)lpofn->lpstrFilter + n );
364 n += strlen(pstr) + 1;
365 pstr += strlen(pstr) + 1;
366 dprintf_commdlg(stddeb,"associated to '%s'\n", pstr);
367 SendDlgItemMessage16(hWnd, cmb1, CB_SETITEMDATA16, i, (LPARAM)pstr);
368 n += strlen(pstr) + 1;
369 pstr += strlen(pstr) + 1;
372 /* set default filter */
373 if (lpofn->nFilterIndex == 0 && lpofn->lpstrCustomFilter == (SEGPTR)NULL)
374 lpofn->nFilterIndex = 1;
375 SendDlgItemMessage16(hWnd, cmb1, CB_SETCURSEL16, lpofn->nFilterIndex - 1, 0);
376 strncpy(tmpstr, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter),
377 PTR_SEG_TO_LIN(lpofn->lpstrFilter), lpofn->nFilterIndex - 1),511);
378 tmpstr[511]=0;
379 dprintf_commdlg(stddeb,"nFilterIndex = %ld // SetText of edt1 to '%s'\n",
380 lpofn->nFilterIndex, tmpstr);
381 SetDlgItemText32A( hWnd, edt1, tmpstr );
382 /* get drive list */
383 DlgDirListComboBox32A(hWnd, "", cmb2, 0, 0xC000);
384 /* read initial directory */
385 if (PTR_SEG_TO_LIN(lpofn->lpstrInitialDir) != NULL)
387 strncpy(tmpstr, PTR_SEG_TO_LIN(lpofn->lpstrInitialDir), 510);
388 tmpstr[510]=0;
389 if (strlen(tmpstr) > 0 && tmpstr[strlen(tmpstr)-1] != '\\'
390 && tmpstr[strlen(tmpstr)-1] != ':')
391 strcat(tmpstr,"\\");
393 else
394 *tmpstr = 0;
395 if (!FILEDLG_ScanDir(hWnd, tmpstr))
396 fprintf(stderr, "FileDlg: couldn't read initial directory %s!\n", tmpstr);
397 /* select current drive in combo 2 */
398 n = DRIVE_GetCurrentDrive();
399 SendDlgItemMessage16(hWnd, cmb2, CB_SETCURSEL16, n, 0);
400 if (!(lpofn->Flags & OFN_SHOWHELP))
401 ShowWindow(GetDlgItem(hWnd, pshHelp), SW_HIDE);
402 if (lpofn->Flags & OFN_HIDEREADONLY)
403 ShowWindow(GetDlgItem(hWnd, chx1), SW_HIDE);
404 if (FILEDLG_HookCallChk(lpofn))
405 return (BOOL)CallWindowProc16(lpofn->lpfnHook,
406 hWnd, WM_INITDIALOG, wParam, lParam );
407 else
408 return TRUE;
411 /***********************************************************************
412 * FILEDLG_WMCommand [internal]
414 static LRESULT FILEDLG_WMCommand(HWND hWnd, WPARAM16 wParam, LPARAM lParam)
416 LONG lRet;
417 LPOPENFILENAME lpofn;
418 OPENFILENAME ofn2;
419 char tmpstr[512], tmpstr2[512];
420 LPSTR pstr, pstr2;
421 UINT control,notification;
423 /* Notifications are packaged differently in Win32 */
424 control = wParam;
425 notification = HIWORD(lParam);
427 lpofn = (LPOPENFILENAME)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
428 switch (control)
430 case lst1: /* file list */
431 FILEDLG_StripEditControl(hWnd);
432 if (notification == LBN_DBLCLK)
433 goto almost_ok;
434 lRet = SendDlgItemMessage16(hWnd, lst1, LB_GETCURSEL16, 0, 0);
435 if (lRet == LB_ERR) return TRUE;
436 if ((pstr = SEGPTR_ALLOC(512)))
438 SendDlgItemMessage16(hWnd, lst1, LB_GETTEXT16, lRet,
439 (LPARAM)SEGPTR_GET(pstr));
440 SetDlgItemText32A( hWnd, edt1, pstr );
441 SEGPTR_FREE(pstr);
443 if (FILEDLG_HookCallChk(lpofn))
444 CallWindowProc16(lpofn->lpfnHook, hWnd,
445 RegisterWindowMessage32A( LBSELCHSTRING ),
446 control, MAKELONG(lRet,CD_LBSELCHANGE));
447 /* FIXME: for OFN_ALLOWMULTISELECT we need CD_LBSELSUB, CD_SELADD, CD_LBSELNOITEMS */
448 return TRUE;
449 case lst2: /* directory list */
450 FILEDLG_StripEditControl(hWnd);
451 if (notification == LBN_DBLCLK)
453 lRet = SendDlgItemMessage16(hWnd, lst2, LB_GETCURSEL16, 0, 0);
454 if (lRet == LB_ERR) return TRUE;
455 pstr = SEGPTR_ALLOC(512);
456 SendDlgItemMessage16(hWnd, lst2, LB_GETTEXT16, lRet,
457 (LPARAM)SEGPTR_GET(pstr));
458 strcpy( tmpstr, pstr );
459 SEGPTR_FREE(pstr);
460 if (tmpstr[0] == '[')
462 tmpstr[strlen(tmpstr) - 1] = 0;
463 strcpy(tmpstr,tmpstr+1);
465 strcat(tmpstr, "\\");
466 goto reset_scan;
468 return TRUE;
469 case cmb1: /* file type drop list */
470 if (notification == CBN_SELCHANGE)
472 *tmpstr = 0;
473 goto reset_scan;
475 return TRUE;
476 case cmb2: /* disk drop list */
477 FILEDLG_StripEditControl(hWnd);
478 lRet = SendDlgItemMessage16(hWnd, cmb2, CB_GETCURSEL16, 0, 0L);
479 if (lRet == LB_ERR) return 0;
480 pstr = SEGPTR_ALLOC(512);
481 SendDlgItemMessage16(hWnd, cmb2, CB_GETLBTEXT16, lRet,
482 (LPARAM)SEGPTR_GET(pstr));
483 sprintf(tmpstr, "%c:", pstr[2]);
484 SEGPTR_FREE(pstr);
485 reset_scan:
486 lRet = SendDlgItemMessage16(hWnd, cmb1, CB_GETCURSEL16, 0, 0);
487 if (lRet == LB_ERR)
488 return TRUE;
489 pstr = (LPSTR)SendDlgItemMessage16(hWnd, cmb1, CB_GETITEMDATA16, lRet, 0);
490 dprintf_commdlg(stddeb,"Selected filter : %s\n", pstr);
491 SetDlgItemText32A( hWnd, edt1, pstr );
492 FILEDLG_ScanDir(hWnd, tmpstr);
493 return TRUE;
494 case chx1:
495 return TRUE;
496 case pshHelp:
497 return TRUE;
498 case IDOK:
499 almost_ok:
500 ofn2=*lpofn; /* for later restoring */
501 GetDlgItemText32A( hWnd, edt1, tmpstr, sizeof(tmpstr) );
502 pstr = strrchr(tmpstr, '\\');
503 if (pstr == NULL)
504 pstr = strrchr(tmpstr, ':');
505 if (strchr(tmpstr,'*') != NULL || strchr(tmpstr,'?') != NULL)
507 /* edit control contains wildcards */
508 if (pstr != NULL)
510 strncpy(tmpstr2, pstr+1, 511); tmpstr2[511]=0;
511 *(pstr+1) = 0;
513 else
515 strcpy(tmpstr2, tmpstr);
516 *tmpstr=0;
518 dprintf_commdlg(stddeb,"commdlg: %s, %s\n", tmpstr, tmpstr2);
519 SetDlgItemText32A( hWnd, edt1, tmpstr2 );
520 FILEDLG_ScanDir(hWnd, tmpstr);
521 return TRUE;
523 /* no wildcards, we might have a directory or a filename */
524 /* try appending a wildcard and reading the directory */
525 pstr2 = tmpstr + strlen(tmpstr);
526 if (pstr == NULL || *(pstr+1) != 0)
527 strcat(tmpstr, "\\");
528 lRet = SendDlgItemMessage16(hWnd, cmb1, CB_GETCURSEL16, 0, 0);
529 if (lRet == LB_ERR) return TRUE;
530 lpofn->nFilterIndex = lRet + 1;
531 dprintf_commdlg(stddeb,"commdlg: lpofn->nFilterIndex=%ld\n", lpofn->nFilterIndex);
532 lstrcpyn32A(tmpstr2,
533 FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter),
534 PTR_SEG_TO_LIN(lpofn->lpstrFilter),
535 lRet), sizeof(tmpstr2));
536 SetDlgItemText32A( hWnd, edt1, tmpstr2 );
537 /* if ScanDir succeeds, we have changed the directory */
538 if (FILEDLG_ScanDir(hWnd, tmpstr)) return TRUE;
539 /* if not, this must be a filename */
540 *pstr2 = 0;
541 if (pstr != NULL)
543 /* strip off the pathname */
544 *pstr = 0;
545 SetDlgItemText32A( hWnd, edt1, pstr + 1 );
546 lstrcpyn32A(tmpstr2, pstr+1, sizeof(tmpstr2) );
547 /* Should we MessageBox() if this fails? */
548 if (!FILEDLG_ScanDir(hWnd, tmpstr)) return TRUE;
549 strcpy(tmpstr, tmpstr2);
551 else SetDlgItemText32A( hWnd, edt1, tmpstr );
552 #if 0
553 ShowWindow(hWnd, SW_HIDE); /* this should not be necessary ?! (%%%) */
554 #endif
556 int drive = DRIVE_GetCurrentDrive();
557 tmpstr2[0] = 'A'+ drive;
558 tmpstr2[1] = ':';
559 tmpstr2[2] = '\\';
560 strncpy(tmpstr2 + 3, DRIVE_GetDosCwd(drive), 507); tmpstr2[510]=0;
561 if (strlen(tmpstr2) > 3)
562 strcat(tmpstr2, "\\");
563 strncat(tmpstr2, tmpstr, 511-strlen(tmpstr2)); tmpstr2[511]=0;
564 strcpy(PTR_SEG_TO_LIN(lpofn->lpstrFile), tmpstr2);
566 lpofn->nFileOffset = 0;
567 lpofn->nFileExtension = 0;
568 while(tmpstr2[lpofn->nFileExtension] != '.' && tmpstr2[lpofn->nFileExtension] != '\0')
569 lpofn->nFileExtension++;
570 if (lpofn->nFileExtension == '\0')
571 lpofn->nFileExtension = 0;
572 else
573 lpofn->nFileExtension++;
574 if (PTR_SEG_TO_LIN(lpofn->lpstrFileTitle) != NULL)
576 lRet = SendDlgItemMessage16(hWnd, lst1, LB_GETCURSEL16, 0, 0);
577 SendDlgItemMessage16(hWnd, lst1, LB_GETTEXT16, lRet,
578 lpofn->lpstrFileTitle );
580 if (FILEDLG_HookCallChk(lpofn))
582 lRet= (BOOL)CallWindowProc16(lpofn->lpfnHook,
583 hWnd, RegisterWindowMessage32A( FILEOKSTRING ), 0, lParam );
584 if (lRet)
586 *lpofn=ofn2; /* restore old state */
587 #if 0
588 ShowWindow(hWnd, SW_SHOW); /* only if above (%%%) SW_HIDE used */
589 #endif
590 break;
593 EndDialog(hWnd, TRUE);
594 return TRUE;
595 case IDCANCEL:
596 EndDialog(hWnd, FALSE);
597 return TRUE;
599 return FALSE;
603 /***********************************************************************
604 * FileOpenDlgProc (COMMDLG.6)
606 LRESULT FileOpenDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam)
608 LPOPENFILENAME lpofn = (LPOPENFILENAME)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
610 if (wMsg!=WM_INITDIALOG)
611 if (FILEDLG_HookCallChk(lpofn))
613 LRESULT lRet=(BOOL)CallWindowProc16(lpofn->lpfnHook, hWnd, wMsg, wParam, lParam);
614 if (lRet)
615 return lRet; /* else continue message processing */
617 switch (wMsg)
619 case WM_INITDIALOG:
620 return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
621 case WM_MEASUREITEM:
622 return FILEDLG_WMMeasureItem(hWnd, wParam, lParam);
623 case WM_DRAWITEM:
624 return FILEDLG_WMDrawItem(hWnd, wParam, lParam, FALSE);
625 case WM_COMMAND:
626 return FILEDLG_WMCommand(hWnd, wParam, lParam);
627 #if 0
628 case WM_CTLCOLOR:
629 SetBkColor((HDC16)wParam, 0x00C0C0C0);
630 switch (HIWORD(lParam))
632 case CTLCOLOR_BTN:
633 SetTextColor((HDC16)wParam, 0x00000000);
634 return hGRAYBrush;
635 case CTLCOLOR_STATIC:
636 SetTextColor((HDC16)wParam, 0x00000000);
637 return hGRAYBrush;
639 break;
640 #endif
642 return FALSE;
646 /***********************************************************************
647 * FileSaveDlgProc (COMMDLG.7)
649 LRESULT FileSaveDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam)
651 LPOPENFILENAME lpofn = (LPOPENFILENAME)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
653 if (wMsg!=WM_INITDIALOG)
654 if (FILEDLG_HookCallChk(lpofn))
656 LRESULT lRet=(BOOL)CallWindowProc16(lpofn->lpfnHook, hWnd, wMsg, wParam, lParam);
657 if (lRet)
658 return lRet; /* else continue message processing */
660 switch (wMsg) {
661 case WM_INITDIALOG:
662 return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
664 case WM_MEASUREITEM:
665 return FILEDLG_WMMeasureItem(hWnd, wParam, lParam);
667 case WM_DRAWITEM:
668 return FILEDLG_WMDrawItem(hWnd, wParam, lParam, TRUE);
670 case WM_COMMAND:
671 return FILEDLG_WMCommand(hWnd, wParam, lParam);
675 case WM_CTLCOLOR:
676 SetBkColor((HDC16)wParam, 0x00C0C0C0);
677 switch (HIWORD(lParam))
679 case CTLCOLOR_BTN:
680 SetTextColor((HDC16)wParam, 0x00000000);
681 return hGRAYBrush;
682 case CTLCOLOR_STATIC:
683 SetTextColor((HDC16)wParam, 0x00000000);
684 return hGRAYBrush;
686 return FALSE;
689 return FALSE;
693 /***********************************************************************
694 * FindTextDlg (COMMDLG.11)
696 BOOL FindText( SEGPTR find )
698 HANDLE16 hInst, hDlgTmpl;
699 BOOL bRet;
700 LPCVOID ptr;
701 LPFINDREPLACE lpFind = (LPFINDREPLACE)PTR_SEG_TO_LIN(find);
704 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
705 * For now, only the standard dialog works.
708 * FIXME : We should do error checking on the lpFind structure here
709 * and make CommDlgExtendedError() return the error condition.
711 hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_FIND_TEXT );
712 hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
713 if (!(ptr = GlobalLock16( hDlgTmpl ))) return -1;
714 bRet = CreateDialogIndirectParam16( hInst, ptr, lpFind->hwndOwner,
715 (DLGPROC16)MODULE_GetWndProcEntry16("FindTextDlgProc"),
716 find );
717 GlobalUnlock16( hDlgTmpl );
718 SYSRES_FreeResource( hDlgTmpl );
719 return bRet;
723 /***********************************************************************
724 * ReplaceTextDlg (COMMDLG.12)
726 BOOL ReplaceText( SEGPTR find )
728 HANDLE16 hInst, hDlgTmpl;
729 BOOL bRet;
730 LPCVOID ptr;
731 LPFINDREPLACE lpFind = (LPFINDREPLACE)PTR_SEG_TO_LIN(find);
734 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
735 * For now, only the standard dialog works.
738 * FIXME : We should do error checking on the lpFind structure here
739 * and make CommDlgExtendedError() return the error condition.
741 hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_REPLACE_TEXT );
742 hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
743 if (!(ptr = GlobalLock16( hDlgTmpl ))) return -1;
744 bRet = CreateDialogIndirectParam16( hInst, ptr, lpFind->hwndOwner,
745 (DLGPROC16)MODULE_GetWndProcEntry16("ReplaceTextDlgProc"),
746 find );
747 GlobalUnlock16( hDlgTmpl );
748 SYSRES_FreeResource( hDlgTmpl );
749 return bRet;
753 /***********************************************************************
754 * FINDDLG_WMInitDialog [internal]
756 static LRESULT FINDDLG_WMInitDialog(HWND hWnd, WPARAM16 wParam, LPARAM lParam)
758 LPFINDREPLACE lpfr;
760 SetWindowLong32A(hWnd, DWL_USER, lParam);
761 lpfr = (LPFINDREPLACE)PTR_SEG_TO_LIN(lParam);
762 lpfr->Flags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
764 * FIXME : If the initial FindWhat string is empty, we should disable the
765 * FindNext (IDOK) button. Only after typing some text, the button should be
766 * enabled.
768 SetDlgItemText16(hWnd, edt1, lpfr->lpstrFindWhat);
769 CheckRadioButton(hWnd, rad1, rad2, (lpfr->Flags & FR_DOWN) ? rad2 : rad1);
770 if (lpfr->Flags & (FR_HIDEUPDOWN | FR_NOUPDOWN)) {
771 EnableWindow(GetDlgItem(hWnd, rad1), FALSE);
772 EnableWindow(GetDlgItem(hWnd, rad2), FALSE);
774 if (lpfr->Flags & FR_HIDEUPDOWN) {
775 ShowWindow(GetDlgItem(hWnd, rad1), SW_HIDE);
776 ShowWindow(GetDlgItem(hWnd, rad2), SW_HIDE);
777 ShowWindow(GetDlgItem(hWnd, grp1), SW_HIDE);
779 CheckDlgButton(hWnd, chx1, (lpfr->Flags & FR_WHOLEWORD) ? 1 : 0);
780 if (lpfr->Flags & (FR_HIDEWHOLEWORD | FR_NOWHOLEWORD))
781 EnableWindow(GetDlgItem(hWnd, chx1), FALSE);
782 if (lpfr->Flags & FR_HIDEWHOLEWORD)
783 ShowWindow(GetDlgItem(hWnd, chx1), SW_HIDE);
784 CheckDlgButton(hWnd, chx2, (lpfr->Flags & FR_MATCHCASE) ? 1 : 0);
785 if (lpfr->Flags & (FR_HIDEMATCHCASE | FR_NOMATCHCASE))
786 EnableWindow(GetDlgItem(hWnd, chx2), FALSE);
787 if (lpfr->Flags & FR_HIDEMATCHCASE)
788 ShowWindow(GetDlgItem(hWnd, chx2), SW_HIDE);
789 if (!(lpfr->Flags & FR_SHOWHELP)) {
790 EnableWindow(GetDlgItem(hWnd, pshHelp), FALSE);
791 ShowWindow(GetDlgItem(hWnd, pshHelp), SW_HIDE);
793 ShowWindow(hWnd, SW_SHOWNORMAL);
794 return TRUE;
798 /***********************************************************************
799 * FINDDLG_WMCommand [internal]
801 static LRESULT FINDDLG_WMCommand(HWND hWnd, WPARAM16 wParam, LPARAM lParam)
803 LPFINDREPLACE lpfr;
804 int uFindReplaceMessage = RegisterWindowMessage32A( FINDMSGSTRING );
805 int uHelpMessage = RegisterWindowMessage32A( HELPMSGSTRING );
807 lpfr = (LPFINDREPLACE)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
808 switch (wParam) {
809 case IDOK:
810 GetDlgItemText16(hWnd, edt1, lpfr->lpstrFindWhat, lpfr->wFindWhatLen);
811 if (IsDlgButtonChecked(hWnd, rad2))
812 lpfr->Flags |= FR_DOWN;
813 else lpfr->Flags &= ~FR_DOWN;
814 if (IsDlgButtonChecked(hWnd, chx1))
815 lpfr->Flags |= FR_WHOLEWORD;
816 else lpfr->Flags &= ~FR_WHOLEWORD;
817 if (IsDlgButtonChecked(hWnd, chx2))
818 lpfr->Flags |= FR_MATCHCASE;
819 else lpfr->Flags &= ~FR_MATCHCASE;
820 lpfr->Flags &= ~(FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
821 lpfr->Flags |= FR_FINDNEXT;
822 SendMessage16(lpfr->hwndOwner, uFindReplaceMessage, 0,
823 GetWindowLong32A(hWnd, DWL_USER) );
824 return TRUE;
825 case IDCANCEL:
826 lpfr->Flags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL);
827 lpfr->Flags |= FR_DIALOGTERM;
828 SendMessage16(lpfr->hwndOwner, uFindReplaceMessage, 0,
829 GetWindowLong32A(hWnd, DWL_USER) );
830 DestroyWindow(hWnd);
831 return TRUE;
832 case pshHelp:
833 /* FIXME : should lpfr structure be passed as an argument ??? */
834 SendMessage16(lpfr->hwndOwner, uHelpMessage, 0, 0);
835 return TRUE;
837 return FALSE;
841 /***********************************************************************
842 * FindTextDlgProc (COMMDLG.13)
844 LRESULT FindTextDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam)
846 switch (wMsg) {
847 case WM_INITDIALOG:
848 return FINDDLG_WMInitDialog(hWnd, wParam, lParam);
849 case WM_COMMAND:
850 return FINDDLG_WMCommand(hWnd, wParam, lParam);
852 return FALSE;
856 /***********************************************************************
857 * REPLACEDLG_WMInitDialog [internal]
859 static LRESULT REPLACEDLG_WMInitDialog(HWND hWnd, WPARAM16 wParam, LPARAM lParam)
861 LPFINDREPLACE lpfr;
863 SetWindowLong32A(hWnd, DWL_USER, lParam);
864 lpfr = (LPFINDREPLACE)PTR_SEG_TO_LIN(lParam);
865 lpfr->Flags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
867 * FIXME : If the initial FindWhat string is empty, we should disable the FinNext /
868 * Replace / ReplaceAll buttons. Only after typing some text, the buttons should be
869 * enabled.
871 SetDlgItemText16(hWnd, edt1, lpfr->lpstrFindWhat);
872 SetDlgItemText16(hWnd, edt2, lpfr->lpstrReplaceWith);
873 CheckDlgButton(hWnd, chx1, (lpfr->Flags & FR_WHOLEWORD) ? 1 : 0);
874 if (lpfr->Flags & (FR_HIDEWHOLEWORD | FR_NOWHOLEWORD))
875 EnableWindow(GetDlgItem(hWnd, chx1), FALSE);
876 if (lpfr->Flags & FR_HIDEWHOLEWORD)
877 ShowWindow(GetDlgItem(hWnd, chx1), SW_HIDE);
878 CheckDlgButton(hWnd, chx2, (lpfr->Flags & FR_MATCHCASE) ? 1 : 0);
879 if (lpfr->Flags & (FR_HIDEMATCHCASE | FR_NOMATCHCASE))
880 EnableWindow(GetDlgItem(hWnd, chx2), FALSE);
881 if (lpfr->Flags & FR_HIDEMATCHCASE)
882 ShowWindow(GetDlgItem(hWnd, chx2), SW_HIDE);
883 if (!(lpfr->Flags & FR_SHOWHELP)) {
884 EnableWindow(GetDlgItem(hWnd, pshHelp), FALSE);
885 ShowWindow(GetDlgItem(hWnd, pshHelp), SW_HIDE);
887 ShowWindow(hWnd, SW_SHOWNORMAL);
888 return TRUE;
892 /***********************************************************************
893 * REPLACEDLG_WMCommand [internal]
895 static LRESULT REPLACEDLG_WMCommand(HWND hWnd, WPARAM16 wParam, LPARAM lParam)
897 LPFINDREPLACE lpfr;
898 int uFindReplaceMessage = RegisterWindowMessage32A( FINDMSGSTRING );
899 int uHelpMessage = RegisterWindowMessage32A( HELPMSGSTRING );
901 lpfr = (LPFINDREPLACE)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
902 switch (wParam) {
903 case IDOK:
904 GetDlgItemText16(hWnd, edt1, lpfr->lpstrFindWhat, lpfr->wFindWhatLen);
905 GetDlgItemText16(hWnd, edt2, lpfr->lpstrReplaceWith, lpfr->wReplaceWithLen);
906 if (IsDlgButtonChecked(hWnd, chx1))
907 lpfr->Flags |= FR_WHOLEWORD;
908 else lpfr->Flags &= ~FR_WHOLEWORD;
909 if (IsDlgButtonChecked(hWnd, chx2))
910 lpfr->Flags |= FR_MATCHCASE;
911 else lpfr->Flags &= ~FR_MATCHCASE;
912 lpfr->Flags &= ~(FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
913 lpfr->Flags |= FR_FINDNEXT;
914 SendMessage16(lpfr->hwndOwner, uFindReplaceMessage, 0,
915 GetWindowLong32A(hWnd, DWL_USER) );
916 return TRUE;
917 case IDCANCEL:
918 lpfr->Flags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL);
919 lpfr->Flags |= FR_DIALOGTERM;
920 SendMessage16(lpfr->hwndOwner, uFindReplaceMessage, 0,
921 GetWindowLong32A(hWnd, DWL_USER) );
922 DestroyWindow(hWnd);
923 return TRUE;
924 case psh1:
925 GetDlgItemText16(hWnd, edt1, lpfr->lpstrFindWhat, lpfr->wFindWhatLen);
926 GetDlgItemText16(hWnd, edt2, lpfr->lpstrReplaceWith, lpfr->wReplaceWithLen);
927 if (IsDlgButtonChecked(hWnd, chx1))
928 lpfr->Flags |= FR_WHOLEWORD;
929 else lpfr->Flags &= ~FR_WHOLEWORD;
930 if (IsDlgButtonChecked(hWnd, chx2))
931 lpfr->Flags |= FR_MATCHCASE;
932 else lpfr->Flags &= ~FR_MATCHCASE;
933 lpfr->Flags &= ~(FR_FINDNEXT | FR_REPLACEALL | FR_DIALOGTERM);
934 lpfr->Flags |= FR_REPLACE;
935 SendMessage16(lpfr->hwndOwner, uFindReplaceMessage, 0,
936 GetWindowLong32A(hWnd, DWL_USER) );
937 return TRUE;
938 case psh2:
939 GetDlgItemText16(hWnd, edt1, lpfr->lpstrFindWhat, lpfr->wFindWhatLen);
940 GetDlgItemText16(hWnd, edt2, lpfr->lpstrReplaceWith, lpfr->wReplaceWithLen);
941 if (IsDlgButtonChecked(hWnd, chx1))
942 lpfr->Flags |= FR_WHOLEWORD;
943 else lpfr->Flags &= ~FR_WHOLEWORD;
944 if (IsDlgButtonChecked(hWnd, chx2))
945 lpfr->Flags |= FR_MATCHCASE;
946 else lpfr->Flags &= ~FR_MATCHCASE;
947 lpfr->Flags &= ~(FR_FINDNEXT | FR_REPLACE | FR_DIALOGTERM);
948 lpfr->Flags |= FR_REPLACEALL;
949 SendMessage16(lpfr->hwndOwner, uFindReplaceMessage, 0,
950 GetWindowLong32A(hWnd, DWL_USER) );
951 return TRUE;
952 case pshHelp:
953 /* FIXME : should lpfr structure be passed as an argument ??? */
954 SendMessage16(lpfr->hwndOwner, uHelpMessage, 0, 0);
955 return TRUE;
957 return FALSE;
961 /***********************************************************************
962 * ReplaceTextDlgProc (COMMDLG.14)
964 LRESULT ReplaceTextDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam)
966 switch (wMsg) {
967 case WM_INITDIALOG:
968 return REPLACEDLG_WMInitDialog(hWnd, wParam, lParam);
969 case WM_COMMAND:
970 return REPLACEDLG_WMCommand(hWnd, wParam, lParam);
972 return FALSE;
976 /***********************************************************************
977 * PrintDlg (COMMDLG.20)
979 BOOL PrintDlg( SEGPTR printdlg )
981 HANDLE16 hInst, hDlgTmpl;
982 BOOL bRet;
983 LPPRINTDLG lpPrint = (LPPRINTDLG)PTR_SEG_TO_LIN(printdlg);
985 dprintf_commdlg(stddeb,"PrintDlg(%p) // Flags=%08lX\n", lpPrint, lpPrint->Flags );
987 if (lpPrint->Flags & PD_RETURNDEFAULT)
988 /* FIXME: should fill lpPrint->hDevMode and lpPrint->hDevNames here */
989 return TRUE;
991 if (lpPrint->Flags & PD_PRINTSETUP)
992 hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_PRINT_SETUP );
993 else
994 hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_PRINT );
996 hInst = WIN_GetWindowInstance( lpPrint->hwndOwner );
997 bRet = DialogBoxIndirectParam16( hInst, hDlgTmpl, lpPrint->hwndOwner,
998 (DLGPROC16)((lpPrint->Flags & PD_PRINTSETUP) ?
999 MODULE_GetWndProcEntry16("PrintSetupDlgProc") :
1000 MODULE_GetWndProcEntry16("PrintDlgProc")),
1001 printdlg );
1002 SYSRES_FreeResource( hDlgTmpl );
1003 return bRet;
1007 /***********************************************************************
1008 * PrintDlgProc (COMMDLG.21)
1010 LRESULT PrintDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam)
1012 switch (wMsg)
1014 case WM_INITDIALOG:
1015 dprintf_commdlg(stddeb,"PrintDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
1016 ShowWindow(hWnd, SW_SHOWNORMAL);
1017 return (TRUE);
1018 case WM_COMMAND:
1019 switch (wParam)
1021 case IDOK:
1022 EndDialog(hWnd, TRUE);
1023 return(TRUE);
1024 case IDCANCEL:
1025 EndDialog(hWnd, FALSE);
1026 return(TRUE);
1028 return(FALSE);
1030 return FALSE;
1034 /***********************************************************************
1035 * PrintSetupDlgProc (COMMDLG.22)
1037 LRESULT PrintSetupDlgProc(HWND hWnd, UINT wMsg, WPARAM16 wParam, LPARAM lParam)
1039 switch (wMsg)
1041 case WM_INITDIALOG:
1042 dprintf_commdlg(stddeb,"PrintSetupDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
1043 ShowWindow(hWnd, SW_SHOWNORMAL);
1044 return (TRUE);
1045 case WM_COMMAND:
1046 switch (wParam) {
1047 case IDOK:
1048 EndDialog(hWnd, TRUE);
1049 return(TRUE);
1050 case IDCANCEL:
1051 EndDialog(hWnd, FALSE);
1052 return(TRUE);
1054 return(FALSE);
1056 return FALSE;
1060 /***********************************************************************
1061 * CommDlgExtendedError (COMMDLG.26)
1063 DWORD CommDlgExtendedError(void)
1065 return CommDlgLastError;
1069 /***********************************************************************
1070 * GetFileTitle (COMMDLG.27)
1072 short GetFileTitle(LPCSTR lpFile, LPSTR lpTitle, UINT cbBuf)
1074 int i, len;
1075 dprintf_commdlg(stddeb,"GetFileTitle(%p %p %d); \n", lpFile, lpTitle, cbBuf);
1076 if (lpFile == NULL || lpTitle == NULL)
1077 return -1;
1078 len = strlen(lpFile);
1079 if (len == 0)
1080 return -1;
1081 if (strpbrk(lpFile, "*[]"))
1082 return -1;
1083 len--;
1084 if (lpFile[len] == '/' || lpFile[len] == '\\' || lpFile[len] == ':')
1085 return -1;
1086 for (i = len; i >= 0; i--)
1087 if (lpFile[i] == '/' || lpFile[i] == '\\' || lpFile[i] == ':')
1089 i++;
1090 break;
1092 dprintf_commdlg(stddeb,"\n---> '%s' ", &lpFile[i]);
1094 len = strlen(lpFile+i)+1;
1095 if (cbBuf < len)
1096 return len;
1098 strncpy(lpTitle, &lpFile[i], len);
1099 return 0;
1103 /* ------------------------ Choose Color Dialog --------------------------- */
1105 /***********************************************************************
1106 * ChooseColor (COMMDLG.5)
1108 BOOL ChooseColor(LPCHOOSECOLOR lpChCol)
1110 HINSTANCE16 hInst;
1111 HANDLE16 hDlgTmpl, hResInfo;
1112 BOOL bRet;
1114 dprintf_commdlg(stddeb,"ChooseColor\n");
1115 if (!lpChCol) return FALSE;
1116 if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE) hDlgTmpl = lpChCol->hInstance;
1117 else if (lpChCol->Flags & CC_ENABLETEMPLATE)
1119 if (!(hResInfo = FindResource16(lpChCol->hInstance,
1120 lpChCol->lpTemplateName, RT_DIALOG)))
1122 CommDlgLastError = CDERR_FINDRESFAILURE;
1123 return FALSE;
1125 hDlgTmpl = LoadResource16( lpChCol->hInstance, hResInfo );
1127 else hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_CHOOSE_COLOR );
1128 if (!hDlgTmpl)
1130 CommDlgLastError = CDERR_LOADRESFAILURE;
1131 return FALSE;
1133 hInst = WIN_GetWindowInstance( lpChCol->hwndOwner );
1134 bRet = DialogBoxIndirectParam16( hInst, hDlgTmpl, lpChCol->hwndOwner,
1135 (DLGPROC16)MODULE_GetWndProcEntry16("ColorDlgProc"),
1136 (DWORD)lpChCol);
1137 if (!(lpChCol->Flags & CC_ENABLETEMPLATEHANDLE))
1139 if (lpChCol->Flags & CC_ENABLETEMPLATE) FreeResource16( hDlgTmpl );
1140 else SYSRES_FreeResource( hDlgTmpl );
1142 return bRet;
1146 static const COLORREF predefcolors[6][8]=
1148 { 0x008080FFL, 0x0080FFFFL, 0x0080FF80L, 0x0080FF00L,
1149 0x00FFFF80L, 0x00FF8000L, 0x00C080FFL, 0x00FF80FFL },
1150 { 0x000000FFL, 0x0000FFFFL, 0x0000FF80L, 0x0040FF00L,
1151 0x00FFFF00L, 0x00C08000L, 0x00C08080L, 0x00FF00FFL },
1153 { 0x00404080L, 0x004080FFL, 0x0000FF00L, 0x00808000L,
1154 0x00804000L, 0x00FF8080L, 0x00400080L, 0x008000FFL },
1155 { 0x00000080L, 0x000080FFL, 0x00008000L, 0x00408000L,
1156 0x00FF0000L, 0x00A00000L, 0x00800080L, 0x00FF0080L },
1158 { 0x00000040L, 0x00004080L, 0x00004000L, 0x00404000L,
1159 0x00800000L, 0x00400000L, 0x00400040L, 0x00800040L },
1160 { 0x00000000L, 0x00008080L, 0x00408080L, 0x00808080L,
1161 0x00808040L, 0x00C0C0C0L, 0x00400040L, 0x00FFFFFFL },
1164 struct CCPRIVATE
1166 LPCHOOSECOLOR lpcc; /* points to public known data structure */
1167 int nextuserdef; /* next free place in user defined color array */
1168 HDC16 hdcMem; /* color graph used for BitBlt() */
1169 HBITMAP16 hbmMem; /* color graph bitmap */
1170 RECT16 fullsize; /* original dialog window size */
1171 UINT msetrgb; /* # of SETRGBSTRING message (today not used) */
1172 RECT16 old3angle; /* last position of l-marker */
1173 RECT16 oldcross; /* last position of color/satuation marker */
1174 BOOL updating; /* to prevent recursive WM_COMMAND/EN_UPDATE procesing */
1175 int h;
1176 int s;
1177 int l; /* for temporary storing of hue,sat,lum */
1180 /***********************************************************************
1181 * CC_HSLtoRGB [internal]
1183 static int CC_HSLtoRGB(char c,int hue,int sat,int lum)
1185 int res=0,maxrgb;
1187 /* hue */
1188 switch(c)
1190 case 'R':if (hue>80) hue-=80; else hue+=160; break;
1191 case 'G':if (hue>160) hue-=160; else hue+=80; break;
1192 case 'B':break;
1195 /* l below 120 */
1196 maxrgb=(256*MIN(120,lum))/120; /* 0 .. 256 */
1197 if (hue< 80)
1198 res=0;
1199 else
1200 if (hue< 120)
1202 res=(hue-80)* maxrgb; /* 0...10240 */
1203 res/=40; /* 0...256 */
1205 else
1206 if (hue< 200)
1207 res=maxrgb;
1208 else
1210 res=(240-hue)* maxrgb;
1211 res/=40;
1213 res=res-maxrgb/2; /* -128...128 */
1215 /* saturation */
1216 res=maxrgb/2 + (sat*res) /240; /* 0..256 */
1218 /* lum above 120 */
1219 if (lum>120 && res<256)
1220 res+=((lum-120) * (256-res))/120;
1222 return MIN(res,255);
1225 /***********************************************************************
1226 * CC_RGBtoHSL [internal]
1228 static int CC_RGBtoHSL(char c,int r,int g,int b)
1230 WORD maxi,mini,mmsum,mmdif,result=0;
1231 int iresult=0;
1233 maxi=MAX(r,b);
1234 maxi=MAX(maxi,g);
1235 mini=MIN(r,b);
1236 mini=MIN(mini,g);
1238 mmsum=maxi+mini;
1239 mmdif=maxi-mini;
1241 switch(c)
1243 /* lum */
1244 case 'L':mmsum*=120; /* 0...61200=(255+255)*120 */
1245 result=mmsum/255; /* 0...240 */
1246 break;
1247 /* saturation */
1248 case 'S':if (!mmsum)
1249 result=0;
1250 else
1251 if (!mini || maxi==255)
1252 result=240;
1253 else
1255 result=mmdif*240; /* 0...61200=255*240 */
1256 result/= (mmsum>255 ? mmsum=510-mmsum : mmsum); /* 0..255 */
1258 break;
1259 /* hue */
1260 case 'H':if (!mmdif)
1261 result=160;
1262 else
1264 if (maxi==r)
1266 iresult=40*(g-b); /* -10200 ... 10200 */
1267 iresult/=(int)mmdif; /* -40 .. 40 */
1268 if (iresult<0)
1269 iresult+=240; /* 0..40 and 200..240 */
1271 else
1272 if (maxi==g)
1274 iresult=40*(b-r);
1275 iresult/=(int)mmdif;
1276 iresult+=80; /* 40 .. 120 */
1278 else
1279 if (maxi==b)
1281 iresult=40*(r-g);
1282 iresult/=(int)mmdif;
1283 iresult+=160; /* 120 .. 200 */
1285 result=iresult;
1287 break;
1289 return result; /* is this integer arithmetic precise enough ? */
1292 #define DISTANCE 4
1294 /***********************************************************************
1295 * CC_MouseCheckPredefColorArray [internal]
1297 static int CC_MouseCheckPredefColorArray(HWND hDlg,int dlgitem,int rows,int cols,
1298 LPARAM lParam,COLORREF *cr)
1300 HWND hwnd;
1301 POINT16 point = MAKEPOINT16(lParam);
1302 RECT16 rect;
1303 int dx,dy,x,y;
1305 ClientToScreen16(hDlg,&point);
1306 hwnd=GetDlgItem(hDlg,dlgitem);
1307 GetWindowRect16(hwnd,&rect);
1308 if (PtInRect16(&rect,point))
1310 dx=(rect.right-rect.left)/cols;
1311 dy=(rect.bottom-rect.top)/rows;
1312 ScreenToClient16(hwnd,&point);
1314 if (point.x % dx < (dx-DISTANCE) && point.y % dy < (dy-DISTANCE))
1316 x=point.x/dx;
1317 y=point.y/dy;
1318 *cr=predefcolors[y][x];
1319 /* FIXME: Draw_a_Focus_Rect() */
1320 return 1;
1323 return 0;
1326 /***********************************************************************
1327 * CC_MouseCheckUserColorArray [internal]
1329 static int CC_MouseCheckUserColorArray(HWND hDlg,int dlgitem,int rows,int cols,
1330 LPARAM lParam,COLORREF *cr,COLORREF*crarr)
1332 HWND hwnd;
1333 POINT16 point = MAKEPOINT16(lParam);
1334 RECT16 rect;
1335 int dx,dy,x,y;
1337 ClientToScreen16(hDlg,&point);
1338 hwnd=GetDlgItem(hDlg,dlgitem);
1339 GetWindowRect16(hwnd,&rect);
1340 if (PtInRect16(&rect,point))
1342 dx=(rect.right-rect.left)/cols;
1343 dy=(rect.bottom-rect.top)/rows;
1344 ScreenToClient16(hwnd,&point);
1346 if (point.x % dx < (dx-DISTANCE) && point.y % dy < (dy-DISTANCE))
1348 x=point.x/dx;
1349 y=point.y/dy;
1350 *cr=crarr[x+cols*y];
1351 /* FIXME: Draw_a_Focus_Rect() */
1352 return 1;
1355 return 0;
1358 #define MAXVERT 240
1359 #define MAXHORI 239
1361 /* 240 ^...... ^^ 240
1362 | . ||
1363 SAT | . || LUM
1364 | . ||
1365 +-----> 239 ----
1368 /***********************************************************************
1369 * CC_MouseCheckColorGraph [internal]
1371 static int CC_MouseCheckColorGraph(HWND hDlg,int dlgitem,int *hori,int *vert,LPARAM lParam)
1373 HWND hwnd;
1374 POINT16 point = MAKEPOINT16(lParam);
1375 RECT16 rect;
1376 long x,y;
1378 ClientToScreen16(hDlg,&point);
1379 hwnd=GetDlgItem(hDlg,dlgitem);
1380 GetWindowRect16(hwnd,&rect);
1381 if (PtInRect16(&rect,point))
1383 GetClientRect16(hwnd,&rect);
1384 ScreenToClient16(hwnd,&point);
1386 x=(long)point.x*MAXHORI;
1387 x/=rect.right;
1388 y=(long)(rect.bottom-point.y)*MAXVERT;
1389 y/=rect.bottom;
1391 if (hori)
1392 *hori=x;
1393 if (vert)
1394 *vert=y;
1395 return 1;
1397 else
1398 return 0;
1400 /***********************************************************************
1401 * CC_MouseCheckResultWindow [internal]
1403 static int CC_MouseCheckResultWindow(HWND hDlg,LPARAM lParam)
1405 HWND hwnd;
1406 POINT16 point = MAKEPOINT16(lParam);
1407 RECT16 rect;
1409 ClientToScreen16(hDlg,&point);
1410 hwnd=GetDlgItem(hDlg,0x2c5);
1411 GetWindowRect16(hwnd,&rect);
1412 if (PtInRect16(&rect,point))
1414 PostMessage(hDlg,WM_COMMAND,0x2c9,0);
1415 return 1;
1417 return 0;
1420 /***********************************************************************
1421 * CC_CheckDigitsInEdit [internal]
1423 static int CC_CheckDigitsInEdit(HWND hwnd,int maxval)
1425 int i,k,m,result,value;
1426 long editpos;
1427 char buffer[30];
1428 GetWindowText32A(hwnd,buffer,sizeof(buffer));
1429 m=strlen(buffer);
1430 result=0;
1432 for (i=0;i<m;i++)
1433 if (buffer[i]<'0' || buffer[i]>'9')
1435 for (k=i+1;k<=m;k++) /* delete bad character */
1437 buffer[i]=buffer[k];
1438 m--;
1440 buffer[m]=0;
1441 result=1;
1444 value=atoi(buffer);
1445 if (value>maxval) /* build a new string */
1447 sprintf(buffer,"%d",maxval);
1448 result=2;
1450 if (result)
1452 editpos=SendMessage16(hwnd,EM_GETSEL,0,0);
1453 SetWindowText32A(hwnd,buffer);
1454 SendMessage16(hwnd,EM_SETSEL,0,editpos);
1456 return value;
1461 /***********************************************************************
1462 * CC_PaintSelectedColor [internal]
1464 static void CC_PaintSelectedColor(HWND hDlg,COLORREF cr)
1466 RECT16 rect;
1467 HDC32 hdc;
1468 HBRUSH32 hBrush;
1469 HWND hwnd=GetDlgItem(hDlg,0x2c5);
1470 if (IsWindowVisible(GetDlgItem(hDlg,0x2c6))) /* if full size */
1472 hdc=GetDC32(hwnd);
1473 GetClientRect16 (hwnd, &rect) ;
1474 hBrush = CreateSolidBrush32(cr);
1475 if (hBrush)
1477 hBrush = SelectObject32 (hdc, hBrush) ;
1478 Rectangle32(hdc, rect.left,rect.top,rect.right/2,rect.bottom);
1479 DeleteObject32 (SelectObject32 (hdc,hBrush)) ;
1480 hBrush=CreateSolidBrush32(GetNearestColor(hdc,cr));
1481 if (hBrush)
1483 hBrush= SelectObject32 (hdc, hBrush) ;
1484 Rectangle32( hdc, rect.right/2-1,rect.top,rect.right,rect.bottom);
1485 DeleteObject32( SelectObject32 (hdc, hBrush)) ;
1488 ReleaseDC32(hwnd,hdc);
1492 /***********************************************************************
1493 * CC_PaintTriangle [internal]
1495 static void CC_PaintTriangle(HWND hDlg,int y)
1497 HDC32 hDC;
1498 long temp;
1499 int w=GetDialogBaseUnits();
1500 POINT16 points[3];
1501 int height;
1502 int oben;
1503 RECT16 rect;
1504 HWND hwnd=GetDlgItem(hDlg,0x2be);
1505 struct CCPRIVATE *lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
1507 if (IsWindowVisible(GetDlgItem(hDlg,0x2c6))) /* if full size */
1509 GetClientRect16(hwnd,&rect);
1510 height=rect.bottom;
1511 hDC=GetDC32(hDlg);
1513 points[0].y=rect.top;
1514 points[0].x=rect.right; /* | /| */
1515 ClientToScreen16(hwnd,points); /* | / | */
1516 ScreenToClient16(hDlg,points); /* |< | */
1517 oben=points[0].y; /* | \ | */
1518 /* | \| */
1519 temp=(long)height*(long)y;
1520 points[0].y=oben+height -temp/(long)MAXVERT;
1521 points[1].y=points[0].y+w;
1522 points[2].y=points[0].y-w;
1523 points[2].x=points[1].x=points[0].x + w;
1525 if (lpp->old3angle.left)
1526 FillRect16(hDC,&lpp->old3angle,GetStockObject32(WHITE_BRUSH));
1527 lpp->old3angle.left =points[0].x;
1528 lpp->old3angle.right =points[1].x+1;
1529 lpp->old3angle.top =points[2].y-1;
1530 lpp->old3angle.bottom=points[1].y+1;
1531 Polygon16(hDC,points,3);
1532 ReleaseDC32(hDlg,hDC);
1537 /***********************************************************************
1538 * CC_PaintCross [internal]
1540 static void CC_PaintCross(HWND hDlg,int x,int y)
1542 HDC32 hDC;
1543 int w=GetDialogBaseUnits();
1544 HWND hwnd=GetDlgItem(hDlg,0x2c6);
1545 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
1546 RECT16 rect;
1547 POINT16 point;
1548 HPEN32 hPen;
1550 if (IsWindowVisible(GetDlgItem(hDlg,0x2c6))) /* if full size */
1552 GetClientRect16(hwnd,&rect);
1553 hDC=GetDC32(hwnd);
1554 SelectClipRgn32(hDC,CreateRectRgnIndirect16(&rect));
1555 hPen=CreatePen32(PS_SOLID,2,0);
1556 hPen=SelectObject32(hDC,hPen);
1557 point.x=((long)rect.right*(long)x)/(long)MAXHORI;
1558 point.y=rect.bottom-((long)rect.bottom*(long)y)/(long)MAXVERT;
1559 if (lpp->oldcross.left!=lpp->oldcross.right)
1560 BitBlt32(hDC,lpp->oldcross.left,lpp->oldcross.top,
1561 lpp->oldcross.right-lpp->oldcross.left,
1562 lpp->oldcross.bottom-lpp->oldcross.top,
1563 lpp->hdcMem,lpp->oldcross.left,lpp->oldcross.top,SRCCOPY);
1564 lpp->oldcross.left =point.x-w-1;
1565 lpp->oldcross.right =point.x+w+1;
1566 lpp->oldcross.top =point.y-w-1;
1567 lpp->oldcross.bottom=point.y+w+1;
1569 MoveTo(hDC,point.x-w,point.y);
1570 LineTo32(hDC,point.x+w,point.y);
1571 MoveTo(hDC,point.x,point.y-w);
1572 LineTo32(hDC,point.x,point.y+w);
1573 DeleteObject32(SelectObject32(hDC,hPen));
1574 ReleaseDC32(hwnd,hDC);
1579 #define XSTEPS 48
1580 #define YSTEPS 24
1583 /***********************************************************************
1584 * CC_PrepareColorGraph [internal]
1586 static void CC_PrepareColorGraph(HWND hDlg)
1588 int sdif,hdif,xdif,ydif,r,g,b,hue,sat;
1589 HWND hwnd=GetDlgItem(hDlg,0x2c6);
1590 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
1591 HBRUSH32 hbrush;
1592 HDC32 hdc ;
1593 RECT16 rect,client;
1594 HCURSOR16 hcursor=SetCursor(LoadCursor16(0,IDC_WAIT));
1596 GetClientRect16(hwnd,&client);
1597 hdc=GetDC32(hwnd);
1598 lpp->hdcMem = CreateCompatibleDC32(hdc);
1599 lpp->hbmMem = CreateCompatibleBitmap(hdc,client.right,client.bottom);
1600 SelectObject32(lpp->hdcMem,lpp->hbmMem);
1602 xdif=client.right /XSTEPS;
1603 ydif=client.bottom/YSTEPS+1;
1604 hdif=239/XSTEPS;
1605 sdif=240/YSTEPS;
1606 for(rect.left=hue=0;hue<239+hdif;hue+=hdif)
1608 rect.right=rect.left+xdif;
1609 rect.bottom=client.bottom;
1610 for(sat=0;sat<240+sdif;sat+=sdif)
1612 rect.top=rect.bottom-ydif;
1613 r=CC_HSLtoRGB('R',hue,sat,120);
1614 g=CC_HSLtoRGB('G',hue,sat,120);
1615 b=CC_HSLtoRGB('B',hue,sat,120);
1616 hbrush=CreateSolidBrush32(RGB(r,g,b));
1617 FillRect16(lpp->hdcMem,&rect,hbrush);
1618 DeleteObject32(hbrush);
1619 rect.bottom=rect.top;
1621 rect.left=rect.right;
1623 ReleaseDC32(hwnd,hdc);
1624 SetCursor(hcursor);
1627 /***********************************************************************
1628 * CC_PaintColorGraph [internal]
1630 static void CC_PaintColorGraph(HWND hDlg)
1632 HWND hwnd=GetDlgItem(hDlg,0x2c6);
1633 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
1634 HDC32 hDC;
1635 RECT16 rect;
1636 if (IsWindowVisible(hwnd)) /* if full size */
1638 if (!lpp->hdcMem)
1639 CC_PrepareColorGraph(hDlg); /* should not be necessary */
1641 hDC=GetDC32(hwnd);
1642 GetClientRect16(hwnd,&rect);
1643 if (lpp->hdcMem)
1644 BitBlt32(hDC,0,0,rect.right,rect.bottom,lpp->hdcMem,0,0,SRCCOPY);
1645 else
1646 fprintf(stderr,"choose color: hdcMem is not defined\n");
1647 ReleaseDC32(hwnd,hDC);
1650 /***********************************************************************
1651 * CC_PaintLumBar [internal]
1653 static void CC_PaintLumBar(HWND hDlg,int hue,int sat)
1655 HWND hwnd=GetDlgItem(hDlg,0x2be);
1656 RECT16 rect,client;
1657 int lum,ldif,ydif,r,g,b;
1658 HBRUSH32 hbrush;
1659 HDC32 hDC;
1661 if (IsWindowVisible(hwnd))
1663 hDC=GetDC32(hwnd);
1664 GetClientRect16(hwnd,&client);
1665 rect=client;
1667 ldif=240/YSTEPS;
1668 ydif=client.bottom/YSTEPS+1;
1669 for(lum=0;lum<240+ldif;lum+=ldif)
1671 rect.top=MAX(0,rect.bottom-ydif);
1672 r=CC_HSLtoRGB('R',hue,sat,lum);
1673 g=CC_HSLtoRGB('G',hue,sat,lum);
1674 b=CC_HSLtoRGB('B',hue,sat,lum);
1675 hbrush=CreateSolidBrush32(RGB(r,g,b));
1676 FillRect16(hDC,&rect,hbrush);
1677 DeleteObject32(hbrush);
1678 rect.bottom=rect.top;
1680 GetClientRect16(hwnd,&rect);
1681 FrameRect16(hDC,&rect,GetStockObject32(BLACK_BRUSH));
1682 ReleaseDC32(hwnd,hDC);
1686 /***********************************************************************
1687 * CC_EditSetRGB [internal]
1689 static void CC_EditSetRGB(HWND hDlg,COLORREF cr)
1691 char buffer[10];
1692 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
1693 int r=GetRValue(cr);
1694 int g=GetGValue(cr);
1695 int b=GetBValue(cr);
1696 if (IsWindowVisible(GetDlgItem(hDlg,0x2c6))) /* if full size */
1698 lpp->updating=TRUE;
1699 sprintf(buffer,"%d",r);
1700 SetWindowText32A(GetDlgItem(hDlg,0x2c2),buffer);
1701 sprintf(buffer,"%d",g);
1702 SetWindowText32A(GetDlgItem(hDlg,0x2c3),buffer);
1703 sprintf(buffer,"%d",b);
1704 SetWindowText32A(GetDlgItem(hDlg,0x2c4),buffer);
1705 lpp->updating=FALSE;
1709 /***********************************************************************
1710 * CC_EditSetHSL [internal]
1712 static void CC_EditSetHSL(HWND hDlg,int h,int s,int l)
1714 char buffer[10];
1715 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
1716 lpp->updating=TRUE;
1717 if (IsWindowVisible(GetDlgItem(hDlg,0x2c6))) /* if full size */
1719 lpp->updating=TRUE;
1720 sprintf(buffer,"%d",h);
1721 SetWindowText32A(GetDlgItem(hDlg,0x2bf),buffer);
1722 sprintf(buffer,"%d",s);
1723 SetWindowText32A(GetDlgItem(hDlg,0x2c0),buffer);
1724 sprintf(buffer,"%d",l);
1725 SetWindowText32A(GetDlgItem(hDlg,0x2c1),buffer);
1726 lpp->updating=FALSE;
1728 CC_PaintLumBar(hDlg,h,s);
1731 /***********************************************************************
1732 * CC_SwitchToFullSize [internal]
1734 static void CC_SwitchToFullSize(HWND hDlg,COLORREF result,LPRECT16 lprect)
1736 int i;
1737 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
1739 EnableWindow(GetDlgItem(hDlg,0x2cf),FALSE);
1740 CC_PrepareColorGraph(hDlg);
1741 for (i=0x2bf;i<0x2c5;i++)
1742 EnableWindow(GetDlgItem(hDlg,i),TRUE);
1743 for (i=0x2d3;i<0x2d9;i++)
1744 EnableWindow(GetDlgItem(hDlg,i),TRUE);
1745 EnableWindow(GetDlgItem(hDlg,0x2c9),TRUE);
1746 EnableWindow(GetDlgItem(hDlg,0x2c8),TRUE);
1748 if (lprect)
1749 SetWindowPos(hDlg,NULL,0,0,lprect->right-lprect->left,
1750 lprect->bottom-lprect->top, SWP_NOMOVE|SWP_NOZORDER);
1752 ShowWindow(GetDlgItem(hDlg,0x2c6),SW_SHOW);
1753 ShowWindow(GetDlgItem(hDlg,0x2be),SW_SHOW);
1754 ShowWindow(GetDlgItem(hDlg,0x2c5),SW_SHOW);
1756 CC_EditSetRGB(hDlg,result);
1757 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
1760 /***********************************************************************
1761 * CC_PaintPredefColorArray [internal]
1763 static void CC_PaintPredefColorArray(HWND hDlg,int rows,int cols)
1765 HWND hwnd=GetDlgItem(hDlg,0x2d0);
1766 RECT16 rect;
1767 HDC32 hdc;
1768 HBRUSH32 hBrush;
1769 int dx,dy,i,j,k;
1771 GetClientRect16(hwnd,&rect);
1772 dx=rect.right/cols;
1773 dy=rect.bottom/rows;
1774 k=rect.left;
1776 hdc=GetDC32(hwnd);
1777 GetClientRect16 (hwnd, &rect) ;
1779 for (j=0;j<rows;j++)
1781 for (i=0;i<cols;i++)
1783 hBrush = CreateSolidBrush32(predefcolors[j][i]);
1784 if (hBrush)
1786 hBrush = SelectObject32 (hdc, hBrush) ;
1787 Rectangle32(hdc, rect.left, rect.top,
1788 rect.left+dx-DISTANCE, rect.top+dy-DISTANCE);
1789 rect.left=rect.left+dx;
1790 DeleteObject32( SelectObject32 (hdc, hBrush)) ;
1793 rect.top=rect.top+dy;
1794 rect.left=k;
1796 ReleaseDC32(hwnd,hdc);
1797 /* FIXME: draw_a_focus_rect */
1799 /***********************************************************************
1800 * CC_PaintUserColorArray [internal]
1802 static void CC_PaintUserColorArray(HWND hDlg,int rows,int cols,COLORREF* lpcr)
1804 HWND hwnd=GetDlgItem(hDlg,0x2d1);
1805 RECT16 rect;
1806 HDC32 hdc;
1807 HBRUSH32 hBrush;
1808 int dx,dy,i,j,k;
1810 GetClientRect16(hwnd,&rect);
1812 dx=rect.right/cols;
1813 dy=rect.bottom/rows;
1814 k=rect.left;
1816 hdc=GetDC32(hwnd);
1817 if (hdc)
1819 for (j=0;j<rows;j++)
1821 for (i=0;i<cols;i++)
1823 hBrush = CreateSolidBrush32(lpcr[i+j*cols]);
1824 if (hBrush)
1826 hBrush = SelectObject32 (hdc, hBrush) ;
1827 Rectangle32( hdc, rect.left, rect.top,
1828 rect.left+dx-DISTANCE, rect.top+dy-DISTANCE);
1829 rect.left=rect.left+dx;
1830 DeleteObject32( SelectObject32 (hdc, hBrush)) ;
1833 rect.top=rect.top+dy;
1834 rect.left=k;
1836 ReleaseDC32(hwnd,hdc);
1838 /* FIXME: draw_a_focus_rect */
1843 /***********************************************************************
1844 * CC_HookCallChk [internal]
1846 static BOOL CC_HookCallChk(LPCHOOSECOLOR lpcc)
1848 if (lpcc)
1849 if(lpcc->Flags & CC_ENABLEHOOK)
1850 if (lpcc->lpfnHook)
1851 return TRUE;
1852 return FALSE;
1855 /***********************************************************************
1856 * CC_WMInitDialog [internal]
1858 static LONG CC_WMInitDialog(HWND hDlg, WPARAM16 wParam, LPARAM lParam)
1860 int i,res;
1861 HWND hwnd;
1862 RECT16 rect;
1863 POINT16 point;
1864 struct CCPRIVATE * lpp;
1866 dprintf_commdlg(stddeb,"ColorDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
1867 lpp=calloc(1,sizeof(struct CCPRIVATE));
1868 lpp->lpcc=(LPCHOOSECOLOR)lParam;
1869 if (lpp->lpcc->lStructSize != sizeof(CHOOSECOLOR))
1871 EndDialog (hDlg, 0) ;
1872 return FALSE;
1874 SetWindowLong32A(hDlg, DWL_USER, (LONG)lpp);
1876 if (!(lpp->lpcc->Flags & CC_SHOWHELP))
1877 ShowWindow(GetDlgItem(hDlg,0x40e),SW_HIDE);
1878 lpp->msetrgb=RegisterWindowMessage32A( SETRGBSTRING );
1879 #if 0
1880 cpos=MAKELONG(5,7); /* init */
1881 if (lpp->lpcc->Flags & CC_RGBINIT)
1883 for (i=0;i<6;i++)
1884 for (j=0;j<8;j++)
1885 if (predefcolors[i][j]==lpp->lpcc->rgbResult)
1887 cpos=MAKELONG(i,j);
1888 goto found;
1891 found:
1892 /* FIXME: Draw_a_focus_rect & set_init_values */
1893 #endif
1894 GetWindowRect16(hDlg,&lpp->fullsize);
1895 if (lpp->lpcc->Flags & CC_FULLOPEN || lpp->lpcc->Flags & CC_PREVENTFULLOPEN)
1897 hwnd=GetDlgItem(hDlg,0x2cf);
1898 EnableWindow(hwnd,FALSE);
1900 if (!(lpp->lpcc->Flags & CC_FULLOPEN) || lpp->lpcc->Flags & CC_PREVENTFULLOPEN)
1902 rect=lpp->fullsize;
1903 res=rect.bottom-rect.top;
1904 hwnd=GetDlgItem(hDlg,0x2c6); /* cut at left border */
1905 point.x=point.y=0;
1906 ClientToScreen16(hwnd,&point);
1907 ScreenToClient16(hDlg,&point);
1908 GetClientRect16(hDlg,&rect);
1909 point.x+=GetSystemMetrics(SM_CXDLGFRAME);
1910 SetWindowPos(hDlg,NULL,0,0,point.x,res,SWP_NOMOVE|SWP_NOZORDER);
1912 ShowWindow(GetDlgItem(hDlg,0x2c6),SW_HIDE);
1913 ShowWindow(GetDlgItem(hDlg,0x2c5),SW_HIDE);
1915 else
1916 CC_SwitchToFullSize(hDlg,lpp->lpcc->rgbResult,NULL);
1917 res=TRUE;
1918 for (i=0x2bf;i<0x2c5;i++)
1919 SendMessage16(GetDlgItem(hDlg,i),EM_LIMITTEXT,3,0); /* max 3 digits: xyz */
1920 if (CC_HookCallChk(lpp->lpcc))
1921 res=CallWindowProc16(lpp->lpcc->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
1922 return res;
1925 /***********************************************************************
1926 * CC_WMCommand [internal]
1928 static LRESULT CC_WMCommand(HWND hDlg, WPARAM16 wParam, LPARAM lParam)
1930 int r,g,b,i,xx;
1931 UINT cokmsg;
1932 HDC32 hdc;
1933 COLORREF *cr;
1934 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
1935 dprintf_commdlg(stddeb,"CC_WMCommand wParam=%x lParam=%lx\n",wParam,lParam);
1936 switch (wParam)
1938 case 0x2c2: /* edit notify RGB */
1939 case 0x2c3:
1940 case 0x2c4:
1941 if (HIWORD(lParam)==EN_UPDATE && !lpp->updating)
1943 i=CC_CheckDigitsInEdit(LOWORD(lParam),255);
1944 r=GetRValue(lpp->lpcc->rgbResult);
1945 g=GetGValue(lpp->lpcc->rgbResult);
1946 b=GetBValue(lpp->lpcc->rgbResult);
1947 xx=0;
1948 switch (wParam)
1950 case 0x2c2:if ((xx=(i!=r))) r=i;break;
1951 case 0x2c3:if ((xx=(i!=g))) g=i;break;
1952 case 0x2c4:if ((xx=(i!=b))) b=i;break;
1954 if (xx) /* something has changed */
1956 lpp->lpcc->rgbResult=RGB(r,g,b);
1957 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
1958 lpp->h=CC_RGBtoHSL('H',r,g,b);
1959 lpp->s=CC_RGBtoHSL('S',r,g,b);
1960 lpp->l=CC_RGBtoHSL('L',r,g,b);
1961 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
1962 CC_PaintCross(hDlg,lpp->h,lpp->s);
1963 CC_PaintTriangle(hDlg,lpp->l);
1966 break;
1968 case 0x2bf: /* edit notify HSL */
1969 case 0x2c0:
1970 case 0x2c1:
1971 if (HIWORD(lParam)==EN_UPDATE && !lpp->updating)
1973 i=CC_CheckDigitsInEdit(LOWORD(lParam),wParam==0x2bf?239:240);
1974 xx=0;
1975 switch (wParam)
1977 case 0x2bf:if ((xx=(i!=lpp->h))) lpp->h=i;break;
1978 case 0x2c0:if ((xx=(i!=lpp->s))) lpp->s=i;break;
1979 case 0x2c1:if ((xx=(i!=lpp->l))) lpp->l=i;break;
1981 if (xx) /* something has changed */
1983 r=CC_HSLtoRGB('R',lpp->h,lpp->s,lpp->l);
1984 g=CC_HSLtoRGB('G',lpp->h,lpp->s,lpp->l);
1985 b=CC_HSLtoRGB('B',lpp->h,lpp->s,lpp->l);
1986 lpp->lpcc->rgbResult=RGB(r,g,b);
1987 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
1988 CC_EditSetRGB(hDlg,lpp->lpcc->rgbResult);
1989 CC_PaintCross(hDlg,lpp->h,lpp->s);
1990 CC_PaintTriangle(hDlg,lpp->l);
1993 break;
1995 case 0x2cf:
1996 CC_SwitchToFullSize(hDlg,lpp->lpcc->rgbResult,&lpp->fullsize);
1997 InvalidateRect32( hDlg, NULL, TRUE );
1998 SetFocus32(GetDlgItem(hDlg,0x2bf));
1999 break;
2001 case 0x2c8: /* add colors ... column by column */
2002 cr=PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors);
2003 cr[(lpp->nextuserdef%2)*8 + lpp->nextuserdef/2]=lpp->lpcc->rgbResult;
2004 if (++lpp->nextuserdef==16)
2005 lpp->nextuserdef=0;
2006 CC_PaintUserColorArray(hDlg,2,8,PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors));
2007 break;
2009 case 0x2c9: /* resulting color */
2010 hdc=GetDC32(hDlg);
2011 lpp->lpcc->rgbResult=GetNearestColor(hdc,lpp->lpcc->rgbResult);
2012 ReleaseDC32(hDlg,hdc);
2013 CC_EditSetRGB(hDlg,lpp->lpcc->rgbResult);
2014 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2015 r=GetRValue(lpp->lpcc->rgbResult);
2016 g=GetGValue(lpp->lpcc->rgbResult);
2017 b=GetBValue(lpp->lpcc->rgbResult);
2018 lpp->h=CC_RGBtoHSL('H',r,g,b);
2019 lpp->s=CC_RGBtoHSL('S',r,g,b);
2020 lpp->l=CC_RGBtoHSL('L',r,g,b);
2021 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
2022 CC_PaintCross(hDlg,lpp->h,lpp->s);
2023 CC_PaintTriangle(hDlg,lpp->l);
2024 break;
2026 case 0x40e: /* Help! */ /* The Beatles, 1965 ;-) */
2027 i=RegisterWindowMessage32A( HELPMSGSTRING );
2028 if (lpp->lpcc->hwndOwner)
2029 SendMessage16(lpp->lpcc->hwndOwner,i,0,(LPARAM)lpp->lpcc);
2030 if (CC_HookCallChk(lpp->lpcc))
2031 CallWindowProc16(lpp->lpcc->lpfnHook,hDlg,
2032 WM_COMMAND,psh15,(LPARAM)lpp->lpcc);
2033 break;
2035 case IDOK :
2036 cokmsg=RegisterWindowMessage32A( COLOROKSTRING );
2037 if (lpp->lpcc->hwndOwner)
2038 if (SendMessage16(lpp->lpcc->hwndOwner,cokmsg,0,(LPARAM)lpp->lpcc))
2039 break; /* do NOT close */
2041 EndDialog (hDlg, 1) ;
2042 return TRUE ;
2044 case IDCANCEL :
2045 EndDialog (hDlg, 0) ;
2046 return TRUE ;
2049 return FALSE;
2052 /***********************************************************************
2053 * CC_WMPaint [internal]
2055 static LRESULT CC_WMPaint(HWND hDlg, WPARAM16 wParam, LPARAM lParam)
2057 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2058 /* we have to paint dialog children except text and buttons */
2060 CC_PaintPredefColorArray(hDlg,6,8);
2061 CC_PaintUserColorArray(hDlg,2,8,PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors));
2062 CC_PaintColorGraph(hDlg);
2063 CC_PaintLumBar(hDlg,lpp->h,lpp->s);
2064 CC_PaintCross(hDlg,lpp->h,lpp->s);
2065 CC_PaintTriangle(hDlg,lpp->l);
2066 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2068 /* special necessary for Wine */
2069 ValidateRect32(GetDlgItem(hDlg,0x2d0),NULL);
2070 ValidateRect32(GetDlgItem(hDlg,0x2d1),NULL);
2071 ValidateRect32(GetDlgItem(hDlg,0x2c6),NULL);
2072 ValidateRect32(GetDlgItem(hDlg,0x2be),NULL);
2073 ValidateRect32(GetDlgItem(hDlg,0x2c5),NULL);
2074 /* hope we can remove it later -->FIXME */
2075 return 0;
2079 /***********************************************************************
2080 * CC_WMLButtonDown [internal]
2082 static LRESULT CC_WMLButtonDown(HWND hDlg, WPARAM16 wParam, LPARAM lParam)
2084 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2085 int r,g,b,i;
2086 i=0;
2087 if (CC_MouseCheckPredefColorArray(hDlg,0x2d0,6,8,lParam,&lpp->lpcc->rgbResult))
2088 i=1;
2089 else
2090 if (CC_MouseCheckUserColorArray(hDlg,0x2d1,2,8,lParam,&lpp->lpcc->rgbResult,
2091 PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors)))
2092 i=1;
2093 else
2094 if (CC_MouseCheckColorGraph(hDlg,0x2c6,&lpp->h,&lpp->s,lParam))
2095 i=2;
2096 else
2097 if (CC_MouseCheckColorGraph(hDlg,0x2be,NULL,&lpp->l,lParam))
2098 i=2;
2099 if (i==2)
2101 r=CC_HSLtoRGB('R',lpp->h,lpp->s,lpp->l);
2102 g=CC_HSLtoRGB('G',lpp->h,lpp->s,lpp->l);
2103 b=CC_HSLtoRGB('B',lpp->h,lpp->s,lpp->l);
2104 lpp->lpcc->rgbResult=RGB(r,g,b);
2106 if (i==1)
2108 r=GetRValue(lpp->lpcc->rgbResult);
2109 g=GetGValue(lpp->lpcc->rgbResult);
2110 b=GetBValue(lpp->lpcc->rgbResult);
2111 lpp->h=CC_RGBtoHSL('H',r,g,b);
2112 lpp->s=CC_RGBtoHSL('S',r,g,b);
2113 lpp->l=CC_RGBtoHSL('L',r,g,b);
2115 if (i)
2117 CC_EditSetRGB(hDlg,lpp->lpcc->rgbResult);
2118 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
2119 CC_PaintCross(hDlg,lpp->h,lpp->s);
2120 CC_PaintTriangle(hDlg,lpp->l);
2121 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2122 return TRUE;
2124 return FALSE;
2127 /***********************************************************************
2128 * ColorDlgProc (COMMDLG.8)
2130 LRESULT ColorDlgProc(HWND hDlg, UINT message,
2131 WPARAM16 wParam, LONG lParam)
2133 int res;
2134 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2135 if (message!=WM_INITDIALOG)
2137 if (!lpp)
2138 return FALSE;
2139 res=0;
2140 if (CC_HookCallChk(lpp->lpcc))
2141 res=CallWindowProc16(lpp->lpcc->lpfnHook,hDlg,message,wParam,lParam);
2142 if (res)
2143 return res;
2146 /* FIXME: SetRGB message
2147 if (message && message==msetrgb)
2148 return HandleSetRGB(hDlg,lParam);
2151 switch (message)
2153 case WM_INITDIALOG:
2154 return CC_WMInitDialog(hDlg,wParam,lParam);
2155 case WM_NCDESTROY:
2156 DeleteDC32(lpp->hdcMem);
2157 DeleteObject32(lpp->hbmMem);
2158 free(lpp);
2159 SetWindowLong32A(hDlg, DWL_USER, 0L); /* we don't need it anymore */
2160 break;
2161 case WM_COMMAND:
2162 if (CC_WMCommand(hDlg, wParam, lParam))
2163 return TRUE;
2164 break;
2165 case WM_PAINT:
2166 CC_WMPaint(hDlg, wParam, lParam);
2167 break;
2168 case WM_LBUTTONDBLCLK:
2169 if (CC_MouseCheckResultWindow(hDlg,lParam))
2170 return TRUE;
2171 break;
2172 case WM_MOUSEMOVE: /* FIXME: calculate new hue,sat,lum (if in color graph) */
2173 break;
2174 case WM_LBUTTONUP: /* FIXME: ClipCursor off (if in color graph)*/
2175 break;
2176 case WM_LBUTTONDOWN:/* FIXME: ClipCursor on (if in color graph)*/
2177 if (CC_WMLButtonDown(hDlg, wParam, lParam))
2178 return TRUE;
2179 break;
2181 return FALSE ;
2186 /***********************************************************************
2187 * ChooseFont (COMMDLG.15)
2189 BOOL ChooseFont(LPCHOOSEFONT lpChFont)
2191 HINSTANCE16 hInst;
2192 HANDLE16 hDlgTmpl, hResInfo;
2193 BOOL bRet;
2195 dprintf_commdlg(stddeb,"ChooseFont\n");
2196 if (!lpChFont) return FALSE;
2197 if (lpChFont->Flags & CF_ENABLETEMPLATEHANDLE) hDlgTmpl = lpChFont->hInstance;
2198 else if (lpChFont->Flags & CF_ENABLETEMPLATE)
2200 if (!(hResInfo = FindResource16(lpChFont->hInstance,
2201 lpChFont->lpTemplateName, RT_DIALOG)))
2203 CommDlgLastError = CDERR_FINDRESFAILURE;
2204 return FALSE;
2206 hDlgTmpl = LoadResource16( lpChFont->hInstance, hResInfo );
2208 else hDlgTmpl = SYSRES_LoadResource( SYSRES_DIALOG_CHOOSE_FONT );
2209 if (!hDlgTmpl)
2211 CommDlgLastError = CDERR_LOADRESFAILURE;
2212 return FALSE;
2214 hInst = WIN_GetWindowInstance( lpChFont->hwndOwner );
2215 bRet = DialogBoxIndirectParam16( hInst, hDlgTmpl, lpChFont->hwndOwner,
2216 (DLGPROC16)MODULE_GetWndProcEntry16("FormatCharDlgProc"),
2217 (DWORD)lpChFont);
2218 if (!(lpChFont->Flags & CF_ENABLETEMPLATEHANDLE))
2220 if (lpChFont->Flags & CF_ENABLETEMPLATE) FreeResource16( hDlgTmpl );
2221 else SYSRES_FreeResource( hDlgTmpl );
2223 return bRet;
2227 #define TEXT_EXTRAS 4
2228 #define TEXT_COLORS 16
2230 static const COLORREF textcolors[TEXT_COLORS]=
2232 0x00000000L,0x00000080L,0x00008000L,0x00008080L,
2233 0x00800000L,0x00800080L,0x00808000L,0x00808080L,
2234 0x00c0c0c0L,0x000000ffL,0x0000ff00L,0x0000ffffL,
2235 0x00ff0000L,0x00ff00ffL,0x00ffff00L,0x00FFFFFFL
2238 /***********************************************************************
2239 * CFn_HookCallChk [internal]
2241 static BOOL CFn_HookCallChk(LPCHOOSEFONT lpcf)
2243 if (lpcf)
2244 if(lpcf->Flags & CF_ENABLEHOOK)
2245 if (lpcf->lpfnHook)
2246 return TRUE;
2247 return FALSE;
2251 /***********************************************************************
2252 * FontFamilyEnumProc (COMMDLG.19)
2254 INT16 FontFamilyEnumProc( SEGPTR logfont, SEGPTR metrics,
2255 UINT16 nFontType, LPARAM lParam )
2257 int i;
2258 WORD w;
2259 HWND hwnd=LOWORD(lParam);
2260 HWND hDlg=GetParent16(hwnd);
2261 LPCHOOSEFONT lpcf=(LPCHOOSEFONT)GetWindowLong32A(hDlg, DWL_USER);
2262 LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN( logfont );
2264 dprintf_commdlg(stddeb,"FontFamilyEnumProc: font=%s (nFontType=%d)\n",
2265 lplf->lfFaceName,nFontType);
2267 if (lpcf->Flags & CF_FIXEDPITCHONLY)
2268 if (!(lplf->lfPitchAndFamily & FIXED_PITCH))
2269 return 1;
2270 if (lpcf->Flags & CF_ANSIONLY)
2271 if (lplf->lfCharSet != ANSI_CHARSET)
2272 return 1;
2273 if (lpcf->Flags & CF_TTONLY)
2274 if (!(nFontType & 0x0004)) /* this means 'TRUETYPE_FONTTYPE' */
2275 return 1;
2277 i=SendMessage16(hwnd,CB_ADDSTRING16,0,
2278 (LPARAM)logfont + ((char *)lplf->lfFaceName - (char *)lplf));
2279 if (i!=CB_ERR)
2281 w=(lplf->lfCharSet << 8) | lplf->lfPitchAndFamily;
2282 SendMessage16(hwnd, CB_SETITEMDATA16,i,MAKELONG(nFontType,w));
2283 return 1 ; /* store some important font information */
2285 else
2286 return 0;
2289 /*************************************************************************
2290 * SetFontStylesToCombo2 [internal]
2292 * Fill font style information into combobox (without using font.c directly)
2294 static int SetFontStylesToCombo2(HWND hwnd, HDC16 hdc, LPLOGFONT16 lplf,
2295 LPTEXTMETRIC16 lptm)
2297 #define FSTYLES 4
2298 struct FONTSTYLE
2299 { int italic;
2300 int weight;
2301 char stname[20]; };
2302 static struct FONTSTYLE fontstyles[FSTYLES]={
2303 { 0,FW_NORMAL,"Regular"},{0,FW_BOLD,"Bold"},
2304 { 1,FW_NORMAL,"Italic"}, {1,FW_BOLD,"Bold Italic"}};
2305 HFONT16 hf;
2306 int i,j;
2308 for (i=0;i<FSTYLES;i++)
2310 lplf->lfItalic=fontstyles[i].italic;
2311 lplf->lfWeight=fontstyles[i].weight;
2312 hf=CreateFontIndirect16(lplf);
2313 hf=SelectObject32(hdc,hf);
2314 GetTextMetrics16(hdc,lptm);
2315 hf=SelectObject32(hdc,hf);
2316 DeleteObject32(hf);
2318 if (lptm->tmWeight==fontstyles[i].weight &&
2319 lptm->tmItalic==fontstyles[i].italic) /* font successful created ? */
2321 char *str = SEGPTR_STRDUP(fontstyles[i].stname);
2322 j=SendMessage16(hwnd,CB_ADDSTRING16,0,(LPARAM)SEGPTR_GET(str) );
2323 SEGPTR_FREE(str);
2324 if (j==CB_ERR) return 1;
2325 j=SendMessage16(hwnd, CB_SETITEMDATA16, j,
2326 MAKELONG(fontstyles[i].weight,fontstyles[i].italic));
2327 if (j==CB_ERR) return 1;
2330 return 0;
2333 /*************************************************************************
2334 * SetFontSizesToCombo3 [internal]
2336 static int SetFontSizesToCombo3(HWND hwnd, LPLOGFONT16 lplf, LPCHOOSEFONT lpcf)
2338 static const int sizes[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72,0};
2339 int h,i,j;
2340 char *buffer;
2342 if (!(buffer = SEGPTR_ALLOC(20))) return 1;
2343 for (i=0;sizes[i] && !lplf->lfHeight;i++)
2345 h=lplf->lfHeight ? lplf->lfHeight : sizes[i];
2347 if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
2348 ((lpcf->Flags & CF_LIMITSIZE) && (h >= lpcf->nSizeMin) && (h <= lpcf->nSizeMax)))
2350 sprintf(buffer,"%2d",h);
2351 j=SendMessage16(hwnd,CB_FINDSTRING16,-1,(LPARAM)SEGPTR_GET(buffer));
2352 if (j==CB_ERR)
2354 j=SendMessage16(hwnd,CB_ADDSTRING16,0,(LPARAM)SEGPTR_GET(buffer));
2355 if (j!=CB_ERR) j = SendMessage16(hwnd, CB_SETITEMDATA16, j, h);
2356 if (j==CB_ERR)
2358 SEGPTR_FREE(buffer);
2359 return 1;
2364 SEGPTR_FREE(buffer);
2365 return 0;
2369 /***********************************************************************
2370 * FontStyleEnumProc (COMMDLG.18)
2372 INT16 FontStyleEnumProc( SEGPTR logfont, SEGPTR metrics,
2373 UINT16 nFontType, LPARAM lParam )
2375 HWND hcmb2=LOWORD(lParam);
2376 HWND hcmb3=HIWORD(lParam);
2377 HWND hDlg=GetParent16(hcmb3);
2378 LPCHOOSEFONT lpcf=(LPCHOOSEFONT)GetWindowLong32A(hDlg, DWL_USER);
2379 LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN(logfont);
2380 TEXTMETRIC16 *lptm = (TEXTMETRIC16 *)PTR_SEG_TO_LIN(metrics);
2381 int i;
2383 dprintf_commdlg(stddeb,"FontStyleEnumProc: (nFontType=%d)\n",nFontType);
2384 dprintf_commdlg(stddeb," %s h=%d w=%d e=%d o=%d wg=%d i=%d u=%d s=%d ch=%d op=%d cp=%d q=%d pf=%xh\n",
2385 lplf->lfFaceName,lplf->lfHeight,lplf->lfWidth,lplf->lfEscapement,lplf->lfOrientation,
2386 lplf->lfWeight,lplf->lfItalic,lplf->lfUnderline,lplf->lfStrikeOut,lplf->lfCharSet,
2387 lplf->lfOutPrecision,lplf->lfClipPrecision,lplf->lfQuality,lplf->lfPitchAndFamily);
2389 if (SetFontSizesToCombo3(hcmb3, lplf ,lpcf))
2390 return 0;
2392 if (!SendMessage16(hcmb2,CB_GETCOUNT16,0,0))
2394 HDC32 hdc= (lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC32(hDlg);
2395 i=SetFontStylesToCombo2(hcmb2,hdc,lplf,lptm);
2396 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
2397 ReleaseDC32(hDlg,hdc);
2398 if (i)
2399 return 0;
2401 return 1 ;
2405 /***********************************************************************
2406 * CFn_WMInitDialog [internal]
2408 LRESULT CFn_WMInitDialog(HWND hDlg, WPARAM16 wParam, LPARAM lParam)
2410 HDC32 hdc;
2411 int i,j,res,init=0;
2412 long l;
2413 LPLOGFONT16 lpxx;
2414 HCURSOR16 hcursor=SetCursor(LoadCursor16(0,IDC_WAIT));
2415 LPCHOOSEFONT lpcf;
2417 SetWindowLong32A(hDlg, DWL_USER, lParam);
2418 lpcf=(LPCHOOSEFONT)lParam;
2419 lpxx=PTR_SEG_TO_LIN(lpcf->lpLogFont);
2420 dprintf_commdlg(stddeb,"FormatCharDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
2422 if (lpcf->lStructSize != sizeof(CHOOSEFONT))
2424 dprintf_commdlg(stddeb,"WM_INITDIALOG: structure size failure !!!\n");
2425 EndDialog (hDlg, 0);
2426 return FALSE;
2428 if (!hBitmapTT)
2429 hBitmapTT = LoadBitmap16(0, MAKEINTRESOURCE(OBM_TRTYPE));
2431 if (!(lpcf->Flags & CF_SHOWHELP) || !IsWindow(lpcf->hwndOwner))
2432 ShowWindow(GetDlgItem(hDlg,pshHelp),SW_HIDE);
2433 if (!(lpcf->Flags & CF_APPLY))
2434 ShowWindow(GetDlgItem(hDlg,psh3),SW_HIDE);
2435 if (lpcf->Flags & CF_EFFECTS)
2437 for (res=1,i=0;res && i<TEXT_COLORS;i++)
2439 /* FIXME: load color name from resource: res=LoadString(...,i+....,buffer,.....); */
2440 char *name = SEGPTR_ALLOC(20);
2441 strcpy( name, "[color name]" );
2442 j=SendDlgItemMessage16(hDlg,cmb4,CB_ADDSTRING16,0,(LPARAM)SEGPTR_GET(name));
2443 SEGPTR_FREE(name);
2444 SendDlgItemMessage16(hDlg,cmb4, CB_SETITEMDATA16,j,textcolors[j]);
2445 /* look for a fitting value in color combobox */
2446 if (textcolors[j]==lpcf->rgbColors)
2447 SendDlgItemMessage16(hDlg,cmb4, CB_SETCURSEL16,j,0);
2450 else
2452 ShowWindow(GetDlgItem(hDlg,cmb4),SW_HIDE);
2453 ShowWindow(GetDlgItem(hDlg,chx1),SW_HIDE);
2454 ShowWindow(GetDlgItem(hDlg,chx2),SW_HIDE);
2455 ShowWindow(GetDlgItem(hDlg,grp1),SW_HIDE);
2456 ShowWindow(GetDlgItem(hDlg,stc4),SW_HIDE);
2458 hdc= (lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC32(hDlg);
2459 if (hdc)
2461 if (!EnumFontFamilies16(hdc, NULL,FontFamilyEnumProc,(LPARAM)GetDlgItem(hDlg,cmb1)))
2462 dprintf_commdlg(stddeb,"WM_INITDIALOG: EnumFontFamilies returns 0\n");
2463 if (lpcf->Flags & CF_INITTOLOGFONTSTRUCT)
2465 /* look for fitting font name in combobox1 */
2466 j=SendDlgItemMessage16(hDlg,cmb1,CB_FINDSTRING16,-1,(LONG)lpxx->lfFaceName);
2467 if (j!=CB_ERR)
2469 SendDlgItemMessage16(hDlg,cmb1,CB_SETCURSEL16,j,0);
2470 SendMessage16(hDlg,WM_COMMAND,cmb1,MAKELONG(GetDlgItem(hDlg,cmb1),CBN_SELCHANGE));
2471 init=1;
2472 /* look for fitting font style in combobox2 */
2473 l=MAKELONG(lpxx->lfWeight > FW_MEDIUM ? FW_BOLD:FW_NORMAL,lpxx->lfItalic !=0);
2474 for (i=0;i<TEXT_EXTRAS;i++)
2476 if (l==SendDlgItemMessage16(hDlg,cmb2, CB_GETITEMDATA16,i,0))
2477 SendDlgItemMessage16(hDlg,cmb2,CB_SETCURSEL16,i,0);
2480 /* look for fitting font size in combobox3 */
2481 j=SendDlgItemMessage16(hDlg,cmb3,CB_GETCOUNT16,0,0);
2482 for (i=0;i<j;i++)
2484 if (lpxx->lfHeight==(int)SendDlgItemMessage16(hDlg,cmb3, CB_GETITEMDATA16,i,0))
2485 SendDlgItemMessage16(hDlg,cmb3,CB_SETCURSEL16,i,0);
2488 if (!init)
2490 SendDlgItemMessage16(hDlg,cmb1,CB_SETCURSEL16,0,0);
2491 SendMessage16(hDlg,WM_COMMAND,cmb1,MAKELONG(GetDlgItem(hDlg,cmb1),CBN_SELCHANGE));
2494 if (lpcf->Flags & CF_USESTYLE && lpcf->lpszStyle)
2496 j=SendDlgItemMessage16(hDlg,cmb2,CB_FINDSTRING16,-1,(LONG)lpcf->lpszStyle);
2497 if (j!=CB_ERR)
2499 j=SendDlgItemMessage16(hDlg,cmb2,CB_SETCURSEL16,j,0);
2500 SendMessage16(hDlg,WM_COMMAND,cmb2,MAKELONG(GetDlgItem(hDlg,cmb2),CBN_SELCHANGE));
2504 else
2506 dprintf_commdlg(stddeb,"WM_INITDIALOG: HDC failure !!!\n");
2507 EndDialog (hDlg, 0);
2508 return FALSE;
2511 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
2512 ReleaseDC32(hDlg,hdc);
2513 res=TRUE;
2514 if (CFn_HookCallChk(lpcf))
2515 res=CallWindowProc16(lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
2516 SetCursor(hcursor);
2517 return res;
2521 /***********************************************************************
2522 * CFn_WMMeasureItem [internal]
2524 LRESULT CFn_WMMeasureItem(HWND hDlg, WPARAM16 wParam, LPARAM lParam)
2526 BITMAP16 bm;
2527 LPMEASUREITEMSTRUCT16 lpmi=PTR_SEG_TO_LIN((LPMEASUREITEMSTRUCT16)lParam);
2528 if (!hBitmapTT)
2529 hBitmapTT = LoadBitmap16(0, MAKEINTRESOURCE(OBM_TRTYPE));
2530 GetObject16( hBitmapTT, sizeof(bm), &bm );
2531 lpmi->itemHeight=bm.bmHeight;
2532 /* FIXME: use MAX of bm.bmHeight and tm.tmHeight .*/
2533 return 0;
2537 /***********************************************************************
2538 * CFn_WMDrawItem [internal]
2540 LRESULT CFn_WMDrawItem(HWND hDlg, WPARAM16 wParam, LPARAM lParam)
2542 HBRUSH16 hBrush;
2543 char *buffer;
2544 BITMAP16 bm;
2545 COLORREF cr;
2546 RECT16 rect;
2547 #if 0
2548 HDC16 hMemDC;
2549 int nFontType;
2550 HBITMAP16 hBitmap; /* for later TT usage */
2551 #endif
2552 LPDRAWITEMSTRUCT16 lpdi = (LPDRAWITEMSTRUCT16)PTR_SEG_TO_LIN(lParam);
2554 if (lpdi->itemID == 0xFFFF) /* got no items */
2555 DrawFocusRect16(lpdi->hDC, &lpdi->rcItem);
2556 else
2558 if (lpdi->CtlType == ODT_COMBOBOX)
2560 hBrush = SelectObject32(lpdi->hDC, GetStockObject32(LTGRAY_BRUSH));
2561 SelectObject32(lpdi->hDC, hBrush);
2562 FillRect16(lpdi->hDC, &lpdi->rcItem, hBrush);
2564 else
2565 return TRUE; /* this should never happen */
2567 rect=lpdi->rcItem;
2568 buffer = SEGPTR_ALLOC(40);
2569 switch (lpdi->CtlID)
2571 case cmb1: /* dprintf_commdlg(stddeb,"WM_Drawitem cmb1\n"); */
2572 SendMessage16(lpdi->hwndItem, CB_GETLBTEXT16, lpdi->itemID,
2573 (LPARAM)SEGPTR_GET(buffer));
2574 GetObject16( hBitmapTT, sizeof(bm), &bm );
2575 TextOut16(lpdi->hDC, lpdi->rcItem.left + bm.bmWidth + 10,
2576 lpdi->rcItem.top, buffer, lstrlen16(buffer));
2577 #if 0
2578 nFontType = SendMessage16(lpdi->hwndItem, CB_GETITEMDATA16, lpdi->itemID,0L);
2579 /* FIXME: draw bitmap if truetype usage */
2580 if (nFontType&TRUETYPE_FONTTYPE)
2582 hMemDC = CreateCompatibleDC32(lpdi->hDC);
2583 hBitmap = SelectObject32(hMemDC, hBitmapTT);
2584 BitBlt32(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top,
2585 bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
2586 SelectObject32(hMemDC, hBitmap);
2587 DeleteDC32(hMemDC);
2589 #endif
2590 break;
2591 case cmb2:
2592 case cmb3: /* dprintf_commdlg(stddeb,"WM_DRAWITEN cmb2,cmb3\n"); */
2593 SendMessage16(lpdi->hwndItem, CB_GETLBTEXT16, lpdi->itemID,
2594 (LPARAM)SEGPTR_GET(buffer));
2595 TextOut16(lpdi->hDC, lpdi->rcItem.left,
2596 lpdi->rcItem.top, buffer, lstrlen16(buffer));
2597 break;
2599 case cmb4: /* dprintf_commdlg(stddeb,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
2600 SendMessage16(lpdi->hwndItem, CB_GETLBTEXT16, lpdi->itemID,
2601 (LPARAM)SEGPTR_GET(buffer));
2602 TextOut16(lpdi->hDC, lpdi->rcItem.left + 25+5,
2603 lpdi->rcItem.top, buffer, lstrlen16(buffer));
2604 cr = SendMessage16(lpdi->hwndItem, CB_GETITEMDATA16, lpdi->itemID,0L);
2605 hBrush = CreateSolidBrush32(cr);
2606 if (hBrush)
2608 hBrush = SelectObject32 (lpdi->hDC, hBrush) ;
2609 rect.right=rect.left+25;
2610 rect.top++;
2611 rect.left+=5;
2612 rect.bottom--;
2613 Rectangle32( lpdi->hDC, rect.left, rect.top,
2614 rect.right, rect.bottom );
2615 DeleteObject32( SelectObject32 (lpdi->hDC, hBrush)) ;
2617 rect=lpdi->rcItem;
2618 rect.left+=25+5;
2619 break;
2621 default: return TRUE; /* this should never happen */
2623 SEGPTR_FREE(buffer);
2624 if (lpdi->itemState ==ODS_SELECTED)
2625 InvertRect16(lpdi->hDC, &rect);
2627 return TRUE;
2630 /***********************************************************************
2631 * CFn_WMCtlColor [internal]
2633 LRESULT CFn_WMCtlColor(HWND hDlg, WPARAM16 wParam, LPARAM lParam)
2635 LPCHOOSEFONT lpcf=(LPCHOOSEFONT)GetWindowLong32A(hDlg, DWL_USER);
2637 if (lpcf->Flags & CF_EFFECTS)
2638 if (HIWORD(lParam)==CTLCOLOR_STATIC && GetDlgCtrlID(LOWORD(lParam))==stc6)
2640 SetTextColor(wParam,lpcf->rgbColors);
2641 return GetStockObject32(WHITE_BRUSH);
2643 return 0;
2646 /***********************************************************************
2647 * CFn_WMCommand [internal]
2649 LRESULT CFn_WMCommand(HWND hDlg, WPARAM16 wParam, LPARAM lParam)
2651 HFONT16 hFont;
2652 int i,j;
2653 long l;
2654 HDC16 hdc;
2655 LPCHOOSEFONT lpcf=(LPCHOOSEFONT)GetWindowLong32A(hDlg, DWL_USER);
2656 LPLOGFONT16 lpxx=PTR_SEG_TO_LIN(lpcf->lpLogFont);
2658 dprintf_commdlg(stddeb,"FormatCharDlgProc // WM_COMMAND lParam=%08lX\n", lParam);
2659 switch (wParam)
2661 case cmb1:if (HIWORD(lParam)==CBN_SELCHANGE)
2663 hdc=(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC32(hDlg);
2664 if (hdc)
2666 SendDlgItemMessage16(hDlg,cmb2,CB_RESETCONTENT16,0,0);
2667 SendDlgItemMessage16(hDlg,cmb3,CB_RESETCONTENT16,0,0);
2668 i=SendDlgItemMessage16(hDlg,cmb1,CB_GETCURSEL16,0,0);
2669 if (i!=CB_ERR)
2671 HCURSOR16 hcursor=SetCursor(LoadCursor16(0,IDC_WAIT));
2672 char *str = SEGPTR_ALLOC(256);
2673 SendDlgItemMessage16(hDlg,cmb1,CB_GETLBTEXT16,i,
2674 (LPARAM)SEGPTR_GET(str));
2675 dprintf_commdlg(stddeb,"WM_COMMAND/cmb1 =>%s\n",str);
2676 EnumFontFamilies16(hdc,str,FontStyleEnumProc,
2677 MAKELONG(GetDlgItem(hDlg,cmb2),GetDlgItem(hDlg,cmb3)));
2678 SetCursor(hcursor);
2679 SEGPTR_FREE(str);
2681 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
2682 ReleaseDC32(hDlg,hdc);
2684 else
2686 dprintf_commdlg(stddeb,"WM_COMMAND: HDC failure !!!\n");
2687 EndDialog (hDlg, 0);
2688 return TRUE;
2691 case chx1:
2692 case chx2:
2693 case cmb2:
2694 case cmb3:if (HIWORD(lParam)==CBN_SELCHANGE || HIWORD(lParam)== BN_CLICKED )
2696 char *str = SEGPTR_ALLOC(256);
2697 dprintf_commdlg(stddeb,"WM_COMMAND/cmb2,3 =%08lX\n", lParam);
2698 i=SendDlgItemMessage16(hDlg,cmb1,CB_GETCURSEL16,0,0);
2699 if (i==CB_ERR)
2700 i=GetDlgItemText32A( hDlg, cmb1, str, 256 );
2701 else
2703 SendDlgItemMessage16(hDlg,cmb1,CB_GETLBTEXT16,i,
2704 (LPARAM)SEGPTR_GET(str));
2705 l=SendDlgItemMessage16(hDlg,cmb1,CB_GETITEMDATA16,i,0);
2706 j=HIWORD(l);
2707 lpcf->nFontType = LOWORD(l);
2708 /* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */
2709 /* same value reported to the EnumFonts
2710 call back with the extra FONTTYPE_... bits added */
2711 lpxx->lfPitchAndFamily=j&0xff;
2712 lpxx->lfCharSet=j>>8;
2714 strcpy(lpxx->lfFaceName,str);
2715 SEGPTR_FREE(str);
2716 i=SendDlgItemMessage16(hDlg,cmb2,CB_GETCURSEL16,0,0);
2717 if (i!=CB_ERR)
2719 l=SendDlgItemMessage16(hDlg,cmb2,CB_GETITEMDATA16,i,0);
2720 if (0!=(lpxx->lfItalic=HIWORD(l)))
2721 lpcf->nFontType |= ITALIC_FONTTYPE;
2722 if ((lpxx->lfWeight=LOWORD(l)) > FW_MEDIUM)
2723 lpcf->nFontType |= BOLD_FONTTYPE;
2725 i=SendDlgItemMessage16(hDlg,cmb3,CB_GETCURSEL16,0,0);
2726 if (i!=CB_ERR)
2727 lpxx->lfHeight=-LOWORD(SendDlgItemMessage16(hDlg,cmb3,CB_GETITEMDATA16,i,0));
2728 else
2729 lpxx->lfHeight=0;
2730 lpxx->lfStrikeOut=IsDlgButtonChecked(hDlg,chx1);
2731 lpxx->lfUnderline=IsDlgButtonChecked(hDlg,chx2);
2732 lpxx->lfWidth=lpxx->lfOrientation=lpxx->lfEscapement=0;
2733 lpxx->lfOutPrecision=OUT_DEFAULT_PRECIS;
2734 lpxx->lfClipPrecision=CLIP_DEFAULT_PRECIS;
2735 lpxx->lfQuality=DEFAULT_QUALITY;
2736 lpcf->iPointSize= -10*lpxx->lfHeight;
2738 hFont=CreateFontIndirect16(lpxx);
2739 if (hFont)
2740 SendDlgItemMessage16(hDlg,stc6,WM_SETFONT,hFont,TRUE);
2741 /* FIXME: Delete old font ...? */
2743 break;
2745 case cmb4:i=SendDlgItemMessage16(hDlg,cmb4,CB_GETCURSEL16,0,0);
2746 if (i!=CB_ERR)
2748 lpcf->rgbColors=textcolors[i];
2749 InvalidateRect32( GetDlgItem(hDlg,stc6), NULL, 0 );
2751 break;
2753 case psh15:i=RegisterWindowMessage32A( HELPMSGSTRING );
2754 if (lpcf->hwndOwner)
2755 SendMessage16(lpcf->hwndOwner,i,0,(LPARAM)lpcf);
2756 if (CFn_HookCallChk(lpcf))
2757 CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);
2758 break;
2760 case IDOK:if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
2761 ( (lpcf->Flags & CF_LIMITSIZE) &&
2762 (-lpxx->lfHeight >= lpcf->nSizeMin) &&
2763 (-lpxx->lfHeight <= lpcf->nSizeMax)))
2764 EndDialog(hDlg, TRUE);
2765 else
2767 char buffer[80];
2768 sprintf(buffer,"Select a font size between %d and %d points.",
2769 lpcf->nSizeMin,lpcf->nSizeMax);
2770 MessageBox16(hDlg,buffer,NULL,MB_OK);
2772 return(TRUE);
2773 case IDCANCEL:EndDialog(hDlg, FALSE);
2774 return(TRUE);
2776 return(FALSE);
2780 /***********************************************************************
2781 * FormatCharDlgProc (COMMDLG.16)
2782 FIXME: 1. some strings are "hardcoded", but it's better load from sysres
2783 2. some CF_.. flags are not supported
2784 3. some TType extensions
2786 LRESULT FormatCharDlgProc(HWND hDlg, UINT message, WPARAM16 wParam, LPARAM lParam)
2788 LPCHOOSEFONT lpcf=(LPCHOOSEFONT)GetWindowLong32A(hDlg, DWL_USER);
2789 if (message!=WM_INITDIALOG)
2791 int res=0;
2792 if (!lpcf)
2793 return FALSE;
2794 if (CFn_HookCallChk(lpcf))
2795 res=CallWindowProc16(lpcf->lpfnHook,hDlg,message,wParam,lParam);
2796 if (res)
2797 return res;
2799 else
2800 return CFn_WMInitDialog(hDlg,wParam,lParam);
2801 switch (message)
2803 case WM_MEASUREITEM:
2804 return CFn_WMMeasureItem(hDlg,wParam,lParam);
2805 case WM_DRAWITEM:
2806 return CFn_WMDrawItem(hDlg,wParam,lParam);
2807 case WM_CTLCOLOR:
2808 return CFn_WMCtlColor(hDlg,wParam,lParam);
2809 case WM_COMMAND:
2810 return CFn_WMCommand(hDlg,wParam,lParam);
2811 case WM_CHOOSEFONT_GETLOGFONT:
2812 dprintf_commdlg(stddeb,
2813 "FormatCharDlgProc // WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n", lParam);
2814 /* FIXME: current logfont back to caller */
2815 break;
2817 return FALSE;