4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
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 BOOL32 FileDlg_Init()
37 static BOOL32 initialized = 0;
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 !");
56 /***********************************************************************
57 * GetOpenFileName (COMMDLG.1)
59 BOOL16 WINAPI GetOpenFileName16( SEGPTR ofn )
62 HANDLE32 hDlgTmpl = 0, hResInfo;
63 BOOL32 bRet = FALSE, win32Format = FALSE;
65 LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(ofn);
68 if (!lpofn || !FileDlg_Init()) return FALSE;
70 if (lpofn->Flags & OFN_WINE32) {
71 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
73 if (!(template = LockResource32( lpofn->hInstance )))
75 CommDlgLastError = CDERR_LOADRESFAILURE;
79 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
81 if (!(hResInfo = FindResource32A(lpofn->hInstance,
82 PTR_SEG_TO_LIN(lpofn->lpTemplateName), (LPSTR)RT_DIALOG)))
84 CommDlgLastError = CDERR_FINDRESFAILURE;
87 if (!(hDlgTmpl = LoadResource32( lpofn->hInstance, hResInfo )) ||
88 !(template = LockResource32( hDlgTmpl )))
90 CommDlgLastError = CDERR_LOADRESFAILURE;
94 template = SYSRES_GetResPtr( SYSRES_DIALOG_OPEN_FILE );
98 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
100 if (!(template = LockResource16( lpofn->hInstance )))
102 CommDlgLastError = CDERR_LOADRESFAILURE;
106 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
108 if (!(hResInfo = FindResource16(lpofn->hInstance,
109 lpofn->lpTemplateName, RT_DIALOG)))
111 CommDlgLastError = CDERR_FINDRESFAILURE;
114 if (!(hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo )) ||
115 !(template = LockResource16( hDlgTmpl )))
117 CommDlgLastError = CDERR_LOADRESFAILURE;
121 template = SYSRES_GetResPtr( SYSRES_DIALOG_OPEN_FILE );
126 hInst = WIN_GetWindowInstance( lpofn->hwndOwner );
127 /* FIXME: doesn't handle win32 format correctly yet */
128 hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
130 (DLGPROC16)MODULE_GetWndProcEntry16("FileOpenDlgProc"),
132 if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpofn->hwndOwner );
135 if (lpofn->Flags & OFN_WINE32)
136 FreeResource32( hDlgTmpl );
138 FreeResource16( hDlgTmpl );
141 dprintf_commdlg(stddeb,"GetOpenFileName // return lpstrFile='%s' !\n",
142 (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
147 /***********************************************************************
148 * GetSaveFileName (COMMDLG.2)
150 BOOL16 WINAPI GetSaveFileName16( SEGPTR ofn)
153 HANDLE32 hDlgTmpl = 0;
154 BOOL32 bRet = FALSE, win32Format = FALSE;
155 LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(ofn);
159 if (!lpofn || !FileDlg_Init()) return FALSE;
161 if (lpofn->Flags & OFN_WINE32) {
162 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
164 if (!(template = LockResource32( lpofn->hInstance )))
166 CommDlgLastError = CDERR_LOADRESFAILURE;
170 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
173 if (!(hResInfo = FindResource32A(lpofn->hInstance,
174 PTR_SEG_TO_LIN(lpofn->lpTemplateName), (LPSTR)RT_DIALOG)))
176 CommDlgLastError = CDERR_FINDRESFAILURE;
179 if (!(hDlgTmpl = LoadResource32(lpofn->hInstance,hResInfo)) ||
180 !(template = LockResource32(hDlgTmpl)))
182 CommDlgLastError = CDERR_LOADRESFAILURE;
187 template = SYSRES_GetResPtr( SYSRES_DIALOG_SAVE_FILE );
191 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
193 if (!(template = LockResource16( lpofn->hInstance )))
195 CommDlgLastError = CDERR_LOADRESFAILURE;
199 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
202 if (!(hResInfo = FindResource16(lpofn->hInstance,
203 lpofn->lpTemplateName, RT_DIALOG)))
205 CommDlgLastError = CDERR_FINDRESFAILURE;
208 if (!(hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo )) ||
209 !(template = LockResource16( hDlgTmpl )))
211 CommDlgLastError = CDERR_LOADRESFAILURE;
215 template = SYSRES_GetResPtr( SYSRES_DIALOG_SAVE_FILE );
220 hInst = WIN_GetWindowInstance( lpofn->hwndOwner );
222 hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
224 (DLGPROC16)MODULE_GetWndProcEntry16("FileSaveDlgProc"),
226 if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpofn->hwndOwner );
229 if (lpofn->Flags & OFN_WINE32)
230 FreeResource32( hDlgTmpl );
232 FreeResource16( hDlgTmpl );
235 dprintf_commdlg(stddeb, "GetSaveFileName // return lpstrFile='%s' !\n",
236 (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
240 /***********************************************************************
241 * FILEDLG_StripEditControl [internal]
242 * Strip pathnames off the contents of the edit control.
244 static void FILEDLG_StripEditControl(HWND16 hwnd)
248 GetDlgItemText32A( hwnd, edt1, temp, sizeof(temp) );
249 cp = strrchr(temp, '\\');
253 cp = strrchr(temp, ':');
257 /* FIXME: shouldn't we do something with the result here? ;-) */
260 /***********************************************************************
261 * FILEDLG_ScanDir [internal]
263 static BOOL32 FILEDLG_ScanDir(HWND16 hWnd, LPSTR newPath)
268 lstrcpyn32A( str, newPath, 512 );
270 GetDlgItemText32A( hWnd, edt1, str + len, sizeof(str) - len );
271 if (!DlgDirList32A( hWnd, str, lst1, 0, 0x0000 )) return FALSE;
272 strcpy( str, "*.*" );
273 return DlgDirList32A( hWnd, str, lst2, stc1, 0x8010 );
276 /***********************************************************************
277 * FILEDLG_GetFileType [internal]
280 static LPSTR FILEDLG_GetFileType(LPSTR cfptr, LPSTR fptr, WORD index)
285 for ( ;(n = strlen(cfptr)) != 0; i++)
290 cfptr += strlen(cfptr) + 1;
293 for ( ;(n = strlen(fptr)) != 0; i++)
298 fptr += strlen(fptr) + 1;
300 return "*.*"; /* FIXME */
303 /***********************************************************************
304 * FILEDLG_WMDrawItem [internal]
306 static LONG FILEDLG_WMDrawItem(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam,int savedlg)
308 LPDRAWITEMSTRUCT16 lpdis = (LPDRAWITEMSTRUCT16)PTR_SEG_TO_LIN(lParam);
311 HBITMAP16 hBitmap, hPrevBitmap;
315 if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst1)
317 if (!(str = SEGPTR_ALLOC(512))) return FALSE;
318 hBrush = SelectObject32(lpdis->hDC, GetStockObject32(LTGRAY_BRUSH));
319 SelectObject32(lpdis->hDC, hBrush);
320 FillRect16(lpdis->hDC, &lpdis->rcItem, hBrush);
321 SendMessage16(lpdis->hwndItem, LB_GETTEXT16, lpdis->itemID,
322 (LPARAM)SEGPTR_GET(str));
324 if (savedlg) /* use _gray_ text in FileSaveDlg */
325 if (!lpdis->itemState)
326 SetTextColor32(lpdis->hDC,GetSysColor32(COLOR_GRAYTEXT) );
328 SetTextColor32(lpdis->hDC,GetSysColor32(COLOR_WINDOWTEXT) );
329 /* inversion of gray would be bad readable */
331 TextOut16(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
333 if (lpdis->itemState != 0) {
334 InvertRect16(lpdis->hDC, &lpdis->rcItem);
340 if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst2)
342 if (!(str = SEGPTR_ALLOC(512))) return FALSE;
343 hBrush = SelectObject32(lpdis->hDC, GetStockObject32(LTGRAY_BRUSH));
344 SelectObject32(lpdis->hDC, hBrush);
345 FillRect16(lpdis->hDC, &lpdis->rcItem, hBrush);
346 SendMessage16(lpdis->hwndItem, LB_GETTEXT16, lpdis->itemID,
347 (LPARAM)SEGPTR_GET(str));
350 GetObject16( hBitmap, sizeof(bm), &bm );
351 TextOut16(lpdis->hDC, lpdis->rcItem.left + bm.bmWidth,
352 lpdis->rcItem.top, str, strlen(str));
353 hMemDC = CreateCompatibleDC32(lpdis->hDC);
354 hPrevBitmap = SelectObject32(hMemDC, hBitmap);
355 BitBlt32(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
356 bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
357 SelectObject32(hMemDC, hPrevBitmap);
359 if (lpdis->itemState != 0) InvertRect16(lpdis->hDC, &lpdis->rcItem);
363 if (lpdis->CtlType == ODT_COMBOBOX && lpdis->CtlID == cmb2)
365 if (!(str = SEGPTR_ALLOC(512))) return FALSE;
366 hBrush = SelectObject32(lpdis->hDC, GetStockObject32(LTGRAY_BRUSH));
367 SelectObject32(lpdis->hDC, hBrush);
368 FillRect16(lpdis->hDC, &lpdis->rcItem, hBrush);
369 SendMessage16(lpdis->hwndItem, CB_GETLBTEXT16, lpdis->itemID,
370 (LPARAM)SEGPTR_GET(str));
371 switch(DRIVE_GetType( str[2] - 'a' ))
373 case TYPE_FLOPPY: hBitmap = hFloppy; break;
374 case TYPE_CDROM: hBitmap = hCDRom; break;
377 default: hBitmap = hHDisk; break;
379 GetObject16( hBitmap, sizeof(bm), &bm );
380 TextOut16(lpdis->hDC, lpdis->rcItem.left + bm.bmWidth,
381 lpdis->rcItem.top, str, strlen(str));
382 hMemDC = CreateCompatibleDC32(lpdis->hDC);
383 hPrevBitmap = SelectObject32(hMemDC, hBitmap);
384 BitBlt32( lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
385 bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY );
386 SelectObject32(hMemDC, hPrevBitmap);
388 if (lpdis->itemState != 0) InvertRect16(lpdis->hDC, &lpdis->rcItem);
395 /***********************************************************************
396 * FILEDLG_WMMeasureItem [internal]
398 static LONG FILEDLG_WMMeasureItem(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
401 LPMEASUREITEMSTRUCT16 lpmeasure;
403 GetObject16( hFolder2, sizeof(bm), &bm );
404 lpmeasure = (LPMEASUREITEMSTRUCT16)PTR_SEG_TO_LIN(lParam);
405 lpmeasure->itemHeight = bm.bmHeight;
409 /***********************************************************************
410 * FILEDLG_HookCallChk [internal]
412 static int FILEDLG_HookCallChk(LPOPENFILENAME16 lpofn)
415 if (lpofn->Flags & OFN_ENABLEHOOK)
421 /***********************************************************************
422 * FILEDLG_CallWindowProc [internal]
424 * Adapt the structures back for win32 calls so the callee can read lpCustData
426 static BOOL32 FILEDLG_CallWindowProc(LPOPENFILENAME16 lpofn,HWND32 hwnd,
427 UINT32 wMsg,WPARAM32 wParam,LPARAM lParam
432 needstruct = (PTR_SEG_TO_LIN(lParam) == lpofn);
434 if (!(lpofn->Flags & OFN_WINE32))
435 return (BOOL32)CallWindowProc16(
436 lpofn->lpfnHook,hwnd,(UINT16)wMsg,(WPARAM16)wParam,lParam
439 if (lpofn->Flags & OFN_UNICODE) {
441 OPENFILENAME32W ofnw;
443 /* FIXME: probably needs more converted */
444 ofnw.lCustData = lpofn->lCustData;
445 return (BOOL32)CallWindowProc32W(
446 (WNDPROC32)lpofn->lpfnHook,hwnd,wMsg,wParam,(LPARAM)&ofnw
449 return (BOOL32)CallWindowProc32W(
450 (WNDPROC32)lpofn->lpfnHook,hwnd,wMsg,wParam,lParam
455 OPENFILENAME32A ofna;
457 /* FIXME: probably needs more converted */
458 ofna.lCustData = lpofn->lCustData;
459 return (BOOL32)CallWindowProc32A(
460 (WNDPROC32)lpofn->lpfnHook,hwnd,wMsg,wParam,(LPARAM)&ofna
463 return (BOOL32)CallWindowProc32A(
464 (WNDPROC32)lpofn->lpfnHook,hwnd,wMsg,wParam,lParam
469 /***********************************************************************
470 * FILEDLG_WMInitDialog [internal]
473 static LONG FILEDLG_WMInitDialog(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
476 LPOPENFILENAME16 lpofn;
479 SetWindowLong32A(hWnd, DWL_USER, lParam);
480 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(lParam);
481 if (lpofn->lpstrTitle) SetWindowText16( hWnd, lpofn->lpstrTitle );
482 /* read custom filter information */
483 if (lpofn->lpstrCustomFilter)
485 pstr = (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter);
487 dprintf_commdlg(stddeb,"lpstrCustomFilter = %p\n", pstr);
490 dprintf_commdlg(stddeb,"lpstrCustomFilter // add str='%s' ",pstr);
491 i = SendDlgItemMessage16(hWnd, cmb1, CB_ADDSTRING16, 0,
492 (LPARAM)lpofn->lpstrCustomFilter + n );
493 n += strlen(pstr) + 1;
494 pstr += strlen(pstr) + 1;
495 dprintf_commdlg(stddeb,"associated to '%s'\n", pstr);
496 SendDlgItemMessage16(hWnd, cmb1, CB_SETITEMDATA16, i, (LPARAM)pstr);
497 n += strlen(pstr) + 1;
498 pstr += strlen(pstr) + 1;
501 /* read filter information */
502 if (lpofn->lpstrFilter) {
503 pstr = (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFilter);
506 dprintf_commdlg(stddeb,"lpstrFilter // add str='%s' ", pstr);
507 i = SendDlgItemMessage16(hWnd, cmb1, CB_ADDSTRING16, 0,
508 (LPARAM)lpofn->lpstrFilter + n );
509 n += strlen(pstr) + 1;
510 pstr += strlen(pstr) + 1;
511 dprintf_commdlg(stddeb,"associated to '%s'\n", pstr);
512 SendDlgItemMessage16(hWnd, cmb1, CB_SETITEMDATA16, i, (LPARAM)pstr);
513 n += strlen(pstr) + 1;
514 pstr += strlen(pstr) + 1;
517 /* set default filter */
518 if (lpofn->nFilterIndex == 0 && lpofn->lpstrCustomFilter == (SEGPTR)NULL)
519 lpofn->nFilterIndex = 1;
520 SendDlgItemMessage16(hWnd, cmb1, CB_SETCURSEL16, lpofn->nFilterIndex - 1, 0);
521 strncpy(tmpstr, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter),
522 PTR_SEG_TO_LIN(lpofn->lpstrFilter), lpofn->nFilterIndex - 1),511);
524 dprintf_commdlg(stddeb,"nFilterIndex = %ld // SetText of edt1 to '%s'\n",
525 lpofn->nFilterIndex, tmpstr);
526 SetDlgItemText32A( hWnd, edt1, tmpstr );
529 DlgDirListComboBox32A(hWnd, tmpstr, cmb2, 0, 0xC000);
530 /* read initial directory */
531 if (PTR_SEG_TO_LIN(lpofn->lpstrInitialDir) != NULL)
533 strncpy(tmpstr, PTR_SEG_TO_LIN(lpofn->lpstrInitialDir), 510);
535 if (strlen(tmpstr) > 0 && tmpstr[strlen(tmpstr)-1] != '\\'
536 && tmpstr[strlen(tmpstr)-1] != ':')
541 if (!FILEDLG_ScanDir(hWnd, tmpstr)) {
543 if (!FILEDLG_ScanDir(hWnd, tmpstr))
544 fprintf(stderr, "FileDlg: couldn't read initial directory %s!\n",tmpstr);
546 /* select current drive in combo 2, omit missing drives */
547 for(i=0, n=-1; i<=DRIVE_GetCurrentDrive(); i++)
548 if (DRIVE_IsValid(i)) n++;
549 SendDlgItemMessage16(hWnd, cmb2, CB_SETCURSEL16, n, 0);
550 if (!(lpofn->Flags & OFN_SHOWHELP))
551 ShowWindow32(GetDlgItem32(hWnd, pshHelp), SW_HIDE);
552 if (lpofn->Flags & OFN_HIDEREADONLY)
553 ShowWindow32(GetDlgItem32(hWnd, chx1), SW_HIDE);
554 if (FILEDLG_HookCallChk(lpofn))
555 return (BOOL16)FILEDLG_CallWindowProc(lpofn,hWnd,WM_INITDIALOG,wParam,lParam );
560 /***********************************************************************
561 * FILEDLG_WMCommand [internal]
563 static LRESULT FILEDLG_WMCommand(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
566 LPOPENFILENAME16 lpofn;
568 char tmpstr[512], tmpstr2[512];
570 UINT16 control,notification;
572 /* Notifications are packaged differently in Win32 */
574 notification = HIWORD(lParam);
576 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
579 case lst1: /* file list */
580 FILEDLG_StripEditControl(hWnd);
581 if (notification == LBN_DBLCLK)
583 lRet = SendDlgItemMessage16(hWnd, lst1, LB_GETCURSEL16, 0, 0);
584 if (lRet == LB_ERR) return TRUE;
585 if ((pstr = SEGPTR_ALLOC(512)))
587 SendDlgItemMessage16(hWnd, lst1, LB_GETTEXT16, lRet,
588 (LPARAM)SEGPTR_GET(pstr));
589 SetDlgItemText32A( hWnd, edt1, pstr );
592 if (FILEDLG_HookCallChk(lpofn))
593 FILEDLG_CallWindowProc(lpofn,hWnd,
594 RegisterWindowMessage32A( LBSELCHSTRING ),
595 control, MAKELONG(lRet,CD_LBSELCHANGE));
596 /* FIXME: for OFN_ALLOWMULTISELECT we need CD_LBSELSUB, CD_SELADD, CD_LBSELNOITEMS */
598 case lst2: /* directory list */
599 FILEDLG_StripEditControl(hWnd);
600 if (notification == LBN_DBLCLK)
602 lRet = SendDlgItemMessage16(hWnd, lst2, LB_GETCURSEL16, 0, 0);
603 if (lRet == LB_ERR) return TRUE;
604 pstr = SEGPTR_ALLOC(512);
605 SendDlgItemMessage16(hWnd, lst2, LB_GETTEXT16, lRet,
606 (LPARAM)SEGPTR_GET(pstr));
607 strcpy( tmpstr, pstr );
609 if (tmpstr[0] == '[')
611 tmpstr[strlen(tmpstr) - 1] = 0;
612 strcpy(tmpstr,tmpstr+1);
614 strcat(tmpstr, "\\");
618 case cmb1: /* file type drop list */
619 if (notification == CBN_SELCHANGE)
625 case cmb2: /* disk drop list */
626 FILEDLG_StripEditControl(hWnd);
627 lRet = SendDlgItemMessage16(hWnd, cmb2, CB_GETCURSEL16, 0, 0L);
628 if (lRet == LB_ERR) return 0;
629 pstr = SEGPTR_ALLOC(512);
630 SendDlgItemMessage16(hWnd, cmb2, CB_GETLBTEXT16, lRet,
631 (LPARAM)SEGPTR_GET(pstr));
632 sprintf(tmpstr, "%c:", pstr[2]);
635 lRet = SendDlgItemMessage16(hWnd, cmb1, CB_GETCURSEL16, 0, 0);
638 pstr = (LPSTR)SendDlgItemMessage16(hWnd, cmb1, CB_GETITEMDATA16, lRet, 0);
639 dprintf_commdlg(stddeb,"Selected filter : %s\n", pstr);
640 SetDlgItemText32A( hWnd, edt1, pstr );
641 FILEDLG_ScanDir(hWnd, tmpstr);
649 ofn2=*lpofn; /* for later restoring */
650 GetDlgItemText32A( hWnd, edt1, tmpstr, sizeof(tmpstr) );
651 pstr = strrchr(tmpstr, '\\');
653 pstr = strrchr(tmpstr, ':');
654 if (strchr(tmpstr,'*') != NULL || strchr(tmpstr,'?') != NULL)
656 /* edit control contains wildcards */
659 strncpy(tmpstr2, pstr+1, 511); tmpstr2[511]=0;
664 strcpy(tmpstr2, tmpstr);
667 dprintf_commdlg(stddeb,"commdlg: %s, %s\n", tmpstr, tmpstr2);
668 SetDlgItemText32A( hWnd, edt1, tmpstr2 );
669 FILEDLG_ScanDir(hWnd, tmpstr);
672 /* no wildcards, we might have a directory or a filename */
673 /* try appending a wildcard and reading the directory */
674 pstr2 = tmpstr + strlen(tmpstr);
675 if (pstr == NULL || *(pstr+1) != 0)
676 strcat(tmpstr, "\\");
677 lRet = SendDlgItemMessage16(hWnd, cmb1, CB_GETCURSEL16, 0, 0);
678 if (lRet == LB_ERR) return TRUE;
679 lpofn->nFilterIndex = lRet + 1;
680 dprintf_commdlg(stddeb,"commdlg: lpofn->nFilterIndex=%ld\n", lpofn->nFilterIndex);
682 FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter),
683 PTR_SEG_TO_LIN(lpofn->lpstrFilter),
684 lRet), sizeof(tmpstr2));
685 SetDlgItemText32A( hWnd, edt1, tmpstr2 );
686 /* if ScanDir succeeds, we have changed the directory */
687 if (FILEDLG_ScanDir(hWnd, tmpstr)) return TRUE;
688 /* if not, this must be a filename */
692 /* strip off the pathname */
694 SetDlgItemText32A( hWnd, edt1, pstr + 1 );
695 lstrcpyn32A(tmpstr2, pstr+1, sizeof(tmpstr2) );
696 /* Should we MessageBox() if this fails? */
697 if (!FILEDLG_ScanDir(hWnd, tmpstr)) return TRUE;
698 strcpy(tmpstr, tmpstr2);
700 else SetDlgItemText32A( hWnd, edt1, tmpstr );
702 ShowWindow16(hWnd, SW_HIDE); /* this should not be necessary ?! (%%%) */
705 int drive = DRIVE_GetCurrentDrive();
706 tmpstr2[0] = 'A'+ drive;
709 strncpy(tmpstr2 + 3, DRIVE_GetDosCwd(drive), 507); tmpstr2[510]=0;
710 if (strlen(tmpstr2) > 3)
711 strcat(tmpstr2, "\\");
712 strncat(tmpstr2, tmpstr, 511-strlen(tmpstr2)); tmpstr2[511]=0;
713 strcpy(PTR_SEG_TO_LIN(lpofn->lpstrFile), tmpstr2);
715 lpofn->nFileOffset = 0;
716 lpofn->nFileExtension = 0;
717 while(tmpstr2[lpofn->nFileExtension] != '.' && tmpstr2[lpofn->nFileExtension] != '\0')
718 lpofn->nFileExtension++;
719 if (lpofn->nFileExtension == '\0')
720 lpofn->nFileExtension = 0;
722 lpofn->nFileExtension++;
723 if (PTR_SEG_TO_LIN(lpofn->lpstrFileTitle) != NULL)
725 lRet = SendDlgItemMessage16(hWnd, lst1, LB_GETCURSEL16, 0, 0);
726 SendDlgItemMessage16(hWnd, lst1, LB_GETTEXT16, lRet,
727 lpofn->lpstrFileTitle );
729 if (FILEDLG_HookCallChk(lpofn))
731 lRet= (BOOL16)FILEDLG_CallWindowProc(lpofn,
732 hWnd, RegisterWindowMessage32A( FILEOKSTRING ), 0, lParam );
735 *lpofn=ofn2; /* restore old state */
737 ShowWindow16(hWnd, SW_SHOW); /* only if above (%%%) SW_HIDE used */
742 EndDialog32(hWnd, TRUE);
745 EndDialog32(hWnd, FALSE);
752 /***********************************************************************
753 * FileOpenDlgProc (COMMDLG.6)
755 LRESULT WINAPI FileOpenDlgProc(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
758 LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
760 if (wMsg!=WM_INITDIALOG)
761 if (FILEDLG_HookCallChk(lpofn))
763 LRESULT lRet=(BOOL16)FILEDLG_CallWindowProc(lpofn,hWnd,wMsg,wParam,lParam);
765 return lRet; /* else continue message processing */
770 return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
772 return FILEDLG_WMMeasureItem(hWnd, wParam, lParam);
774 return FILEDLG_WMDrawItem(hWnd, wParam, lParam, FALSE);
776 return FILEDLG_WMCommand(hWnd, wParam, lParam);
779 SetBkColor((HDC16)wParam, 0x00C0C0C0);
780 switch (HIWORD(lParam))
783 SetTextColor((HDC16)wParam, 0x00000000);
785 case CTLCOLOR_STATIC:
786 SetTextColor((HDC16)wParam, 0x00000000);
796 /***********************************************************************
797 * FileSaveDlgProc (COMMDLG.7)
799 LRESULT WINAPI FileSaveDlgProc(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
802 LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
804 if (wMsg!=WM_INITDIALOG)
805 if (FILEDLG_HookCallChk(lpofn))
807 LRESULT lRet=(BOOL16)FILEDLG_CallWindowProc(lpofn,hWnd,wMsg,wParam,lParam);
809 return lRet; /* else continue message processing */
813 return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
816 return FILEDLG_WMMeasureItem(hWnd, wParam, lParam);
819 return FILEDLG_WMDrawItem(hWnd, wParam, lParam, TRUE);
822 return FILEDLG_WMCommand(hWnd, wParam, lParam);
827 SetBkColor((HDC16)wParam, 0x00C0C0C0);
828 switch (HIWORD(lParam))
831 SetTextColor((HDC16)wParam, 0x00000000);
833 case CTLCOLOR_STATIC:
834 SetTextColor((HDC16)wParam, 0x00000000);
844 /***********************************************************************
845 * FindTextDlg (COMMDLG.11)
847 HWND16 WINAPI FindText( SEGPTR find )
851 LPFINDREPLACE lpFind = (LPFINDREPLACE)PTR_SEG_TO_LIN(find);
854 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
855 * For now, only the standard dialog works.
858 * FIXME : We should do error checking on the lpFind structure here
859 * and make CommDlgExtendedError() return the error condition.
861 ptr = SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT );
862 hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
863 return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
864 (DLGPROC16)MODULE_GetWndProcEntry16("FindTextDlgProc"),
869 /***********************************************************************
870 * ReplaceText (COMMDLG.12)
872 HWND16 WINAPI ReplaceText( SEGPTR find )
876 LPFINDREPLACE lpFind = (LPFINDREPLACE)PTR_SEG_TO_LIN(find);
879 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
880 * For now, only the standard dialog works.
883 * FIXME : We should do error checking on the lpFind structure here
884 * and make CommDlgExtendedError() return the error condition.
886 ptr = SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT );
887 hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
888 return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
889 (DLGPROC16)MODULE_GetWndProcEntry16("ReplaceTextDlgProc"),
894 /***********************************************************************
895 * FINDDLG_WMInitDialog [internal]
897 static LRESULT FINDDLG_WMInitDialog(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
901 SetWindowLong32A(hWnd, DWL_USER, lParam);
902 lpfr = (LPFINDREPLACE)PTR_SEG_TO_LIN(lParam);
903 lpfr->Flags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
905 * FIXME : If the initial FindWhat string is empty, we should disable the
906 * FindNext (IDOK) button. Only after typing some text, the button should be
909 SetDlgItemText16(hWnd, edt1, lpfr->lpstrFindWhat);
910 CheckRadioButton32(hWnd, rad1, rad2, (lpfr->Flags & FR_DOWN) ? rad2 : rad1);
911 if (lpfr->Flags & (FR_HIDEUPDOWN | FR_NOUPDOWN)) {
912 EnableWindow32(GetDlgItem32(hWnd, rad1), FALSE);
913 EnableWindow32(GetDlgItem32(hWnd, rad2), FALSE);
915 if (lpfr->Flags & FR_HIDEUPDOWN) {
916 ShowWindow32(GetDlgItem32(hWnd, rad1), SW_HIDE);
917 ShowWindow32(GetDlgItem32(hWnd, rad2), SW_HIDE);
918 ShowWindow32(GetDlgItem32(hWnd, grp1), SW_HIDE);
920 CheckDlgButton32(hWnd, chx1, (lpfr->Flags & FR_WHOLEWORD) ? 1 : 0);
921 if (lpfr->Flags & (FR_HIDEWHOLEWORD | FR_NOWHOLEWORD))
922 EnableWindow32(GetDlgItem32(hWnd, chx1), FALSE);
923 if (lpfr->Flags & FR_HIDEWHOLEWORD)
924 ShowWindow32(GetDlgItem32(hWnd, chx1), SW_HIDE);
925 CheckDlgButton32(hWnd, chx2, (lpfr->Flags & FR_MATCHCASE) ? 1 : 0);
926 if (lpfr->Flags & (FR_HIDEMATCHCASE | FR_NOMATCHCASE))
927 EnableWindow32(GetDlgItem32(hWnd, chx2), FALSE);
928 if (lpfr->Flags & FR_HIDEMATCHCASE)
929 ShowWindow32(GetDlgItem32(hWnd, chx2), SW_HIDE);
930 if (!(lpfr->Flags & FR_SHOWHELP)) {
931 EnableWindow32(GetDlgItem32(hWnd, pshHelp), FALSE);
932 ShowWindow32(GetDlgItem32(hWnd, pshHelp), SW_HIDE);
934 ShowWindow32(hWnd, SW_SHOWNORMAL);
939 /***********************************************************************
940 * FINDDLG_WMCommand [internal]
942 static LRESULT FINDDLG_WMCommand(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
945 int uFindReplaceMessage = RegisterWindowMessage32A( FINDMSGSTRING );
946 int uHelpMessage = RegisterWindowMessage32A( HELPMSGSTRING );
948 lpfr = (LPFINDREPLACE)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
951 GetDlgItemText16(hWnd, edt1, lpfr->lpstrFindWhat, lpfr->wFindWhatLen);
952 if (IsDlgButtonChecked32(hWnd, rad2))
953 lpfr->Flags |= FR_DOWN;
954 else lpfr->Flags &= ~FR_DOWN;
955 if (IsDlgButtonChecked32(hWnd, chx1))
956 lpfr->Flags |= FR_WHOLEWORD;
957 else lpfr->Flags &= ~FR_WHOLEWORD;
958 if (IsDlgButtonChecked32(hWnd, chx2))
959 lpfr->Flags |= FR_MATCHCASE;
960 else lpfr->Flags &= ~FR_MATCHCASE;
961 lpfr->Flags &= ~(FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
962 lpfr->Flags |= FR_FINDNEXT;
963 SendMessage16(lpfr->hwndOwner, uFindReplaceMessage, 0,
964 GetWindowLong32A(hWnd, DWL_USER) );
967 lpfr->Flags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL);
968 lpfr->Flags |= FR_DIALOGTERM;
969 SendMessage16(lpfr->hwndOwner, uFindReplaceMessage, 0,
970 GetWindowLong32A(hWnd, DWL_USER) );
971 DestroyWindow16(hWnd);
974 /* FIXME : should lpfr structure be passed as an argument ??? */
975 SendMessage16(lpfr->hwndOwner, uHelpMessage, 0, 0);
982 /***********************************************************************
983 * FindTextDlgProc (COMMDLG.13)
985 LRESULT WINAPI FindTextDlgProc(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
990 return FINDDLG_WMInitDialog(hWnd, wParam, lParam);
992 return FINDDLG_WMCommand(hWnd, wParam, lParam);
998 /***********************************************************************
999 * REPLACEDLG_WMInitDialog [internal]
1001 static LRESULT REPLACEDLG_WMInitDialog(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
1005 SetWindowLong32A(hWnd, DWL_USER, lParam);
1006 lpfr = (LPFINDREPLACE)PTR_SEG_TO_LIN(lParam);
1007 lpfr->Flags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
1009 * FIXME : If the initial FindWhat string is empty, we should disable the FinNext /
1010 * Replace / ReplaceAll buttons. Only after typing some text, the buttons should be
1013 SetDlgItemText16(hWnd, edt1, lpfr->lpstrFindWhat);
1014 SetDlgItemText16(hWnd, edt2, lpfr->lpstrReplaceWith);
1015 CheckDlgButton32(hWnd, chx1, (lpfr->Flags & FR_WHOLEWORD) ? 1 : 0);
1016 if (lpfr->Flags & (FR_HIDEWHOLEWORD | FR_NOWHOLEWORD))
1017 EnableWindow32(GetDlgItem32(hWnd, chx1), FALSE);
1018 if (lpfr->Flags & FR_HIDEWHOLEWORD)
1019 ShowWindow32(GetDlgItem32(hWnd, chx1), SW_HIDE);
1020 CheckDlgButton32(hWnd, chx2, (lpfr->Flags & FR_MATCHCASE) ? 1 : 0);
1021 if (lpfr->Flags & (FR_HIDEMATCHCASE | FR_NOMATCHCASE))
1022 EnableWindow32(GetDlgItem32(hWnd, chx2), FALSE);
1023 if (lpfr->Flags & FR_HIDEMATCHCASE)
1024 ShowWindow32(GetDlgItem32(hWnd, chx2), SW_HIDE);
1025 if (!(lpfr->Flags & FR_SHOWHELP)) {
1026 EnableWindow32(GetDlgItem32(hWnd, pshHelp), FALSE);
1027 ShowWindow32(GetDlgItem32(hWnd, pshHelp), SW_HIDE);
1029 ShowWindow32(hWnd, SW_SHOWNORMAL);
1034 /***********************************************************************
1035 * REPLACEDLG_WMCommand [internal]
1037 static LRESULT REPLACEDLG_WMCommand(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
1040 int uFindReplaceMessage = RegisterWindowMessage32A( FINDMSGSTRING );
1041 int uHelpMessage = RegisterWindowMessage32A( HELPMSGSTRING );
1043 lpfr = (LPFINDREPLACE)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
1046 GetDlgItemText16(hWnd, edt1, lpfr->lpstrFindWhat, lpfr->wFindWhatLen);
1047 GetDlgItemText16(hWnd, edt2, lpfr->lpstrReplaceWith, lpfr->wReplaceWithLen);
1048 if (IsDlgButtonChecked32(hWnd, chx1))
1049 lpfr->Flags |= FR_WHOLEWORD;
1050 else lpfr->Flags &= ~FR_WHOLEWORD;
1051 if (IsDlgButtonChecked32(hWnd, chx2))
1052 lpfr->Flags |= FR_MATCHCASE;
1053 else lpfr->Flags &= ~FR_MATCHCASE;
1054 lpfr->Flags &= ~(FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
1055 lpfr->Flags |= FR_FINDNEXT;
1056 SendMessage16(lpfr->hwndOwner, uFindReplaceMessage, 0,
1057 GetWindowLong32A(hWnd, DWL_USER) );
1060 lpfr->Flags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL);
1061 lpfr->Flags |= FR_DIALOGTERM;
1062 SendMessage16(lpfr->hwndOwner, uFindReplaceMessage, 0,
1063 GetWindowLong32A(hWnd, DWL_USER) );
1064 DestroyWindow16(hWnd);
1067 GetDlgItemText16(hWnd, edt1, lpfr->lpstrFindWhat, lpfr->wFindWhatLen);
1068 GetDlgItemText16(hWnd, edt2, lpfr->lpstrReplaceWith, lpfr->wReplaceWithLen);
1069 if (IsDlgButtonChecked32(hWnd, chx1))
1070 lpfr->Flags |= FR_WHOLEWORD;
1071 else lpfr->Flags &= ~FR_WHOLEWORD;
1072 if (IsDlgButtonChecked32(hWnd, chx2))
1073 lpfr->Flags |= FR_MATCHCASE;
1074 else lpfr->Flags &= ~FR_MATCHCASE;
1075 lpfr->Flags &= ~(FR_FINDNEXT | FR_REPLACEALL | FR_DIALOGTERM);
1076 lpfr->Flags |= FR_REPLACE;
1077 SendMessage16(lpfr->hwndOwner, uFindReplaceMessage, 0,
1078 GetWindowLong32A(hWnd, DWL_USER) );
1081 GetDlgItemText16(hWnd, edt1, lpfr->lpstrFindWhat, lpfr->wFindWhatLen);
1082 GetDlgItemText16(hWnd, edt2, lpfr->lpstrReplaceWith, lpfr->wReplaceWithLen);
1083 if (IsDlgButtonChecked32(hWnd, chx1))
1084 lpfr->Flags |= FR_WHOLEWORD;
1085 else lpfr->Flags &= ~FR_WHOLEWORD;
1086 if (IsDlgButtonChecked32(hWnd, chx2))
1087 lpfr->Flags |= FR_MATCHCASE;
1088 else lpfr->Flags &= ~FR_MATCHCASE;
1089 lpfr->Flags &= ~(FR_FINDNEXT | FR_REPLACE | FR_DIALOGTERM);
1090 lpfr->Flags |= FR_REPLACEALL;
1091 SendMessage16(lpfr->hwndOwner, uFindReplaceMessage, 0,
1092 GetWindowLong32A(hWnd, DWL_USER) );
1095 /* FIXME : should lpfr structure be passed as an argument ??? */
1096 SendMessage16(lpfr->hwndOwner, uHelpMessage, 0, 0);
1103 /***********************************************************************
1104 * ReplaceTextDlgProc (COMMDLG.14)
1106 LRESULT WINAPI ReplaceTextDlgProc(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
1111 return REPLACEDLG_WMInitDialog(hWnd, wParam, lParam);
1113 return REPLACEDLG_WMCommand(hWnd, wParam, lParam);
1119 /***********************************************************************
1120 * PrintDlg16 (COMMDLG.20)
1122 BOOL16 WINAPI PrintDlg16( SEGPTR printdlg )
1125 BOOL16 bRet = FALSE;
1128 LPPRINTDLG16 lpPrint = (LPPRINTDLG16)PTR_SEG_TO_LIN(printdlg);
1130 dprintf_commdlg(stddeb,"PrintDlg(%p) // Flags=%08lX\n", lpPrint, lpPrint->Flags );
1132 if (lpPrint->Flags & PD_RETURNDEFAULT)
1133 /* FIXME: should fill lpPrint->hDevMode and lpPrint->hDevNames here */
1136 if (lpPrint->Flags & PD_PRINTSETUP)
1137 template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT_SETUP );
1139 template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT );
1141 hInst = WIN_GetWindowInstance( lpPrint->hwndOwner );
1142 hwndDialog = DIALOG_CreateIndirect( hInst, template, TRUE,
1144 (DLGPROC16)((lpPrint->Flags & PD_PRINTSETUP) ?
1145 MODULE_GetWndProcEntry16("PrintSetupDlgProc") :
1146 MODULE_GetWndProcEntry16("PrintDlgProc")),
1147 printdlg, WIN_PROC_16 );
1148 if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpPrint->hwndOwner);
1153 /***********************************************************************
1154 * PrintDlg32A (COMDLG32.17)
1156 BOOL32 WINAPI PrintDlg32A( LPPRINTDLG32A printdlg )
1158 fprintf( stdnimp, "PrintDlg32A: empty stub\n" );
1163 /***********************************************************************
1164 * PrintDlg32W (COMDLG32.18)
1166 BOOL32 WINAPI PrintDlg32W( LPPRINTDLG32W printdlg )
1168 fprintf( stdnimp, "PrintDlg32A: empty stub\n" );
1173 /***********************************************************************
1174 * PrintDlgProc (COMMDLG.21)
1176 LRESULT WINAPI PrintDlgProc(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
1182 dprintf_commdlg(stddeb,"PrintDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
1183 ShowWindow16(hWnd, SW_SHOWNORMAL);
1189 EndDialog32(hWnd, TRUE);
1192 EndDialog32(hWnd, FALSE);
1201 /***********************************************************************
1202 * PrintSetupDlgProc (COMMDLG.22)
1204 LRESULT WINAPI PrintSetupDlgProc(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
1210 dprintf_commdlg(stddeb,"PrintSetupDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
1211 ShowWindow16(hWnd, SW_SHOWNORMAL);
1216 EndDialog32(hWnd, TRUE);
1219 EndDialog32(hWnd, FALSE);
1228 /***********************************************************************
1229 * CommDlgExtendedError (COMMDLG.26)
1231 DWORD WINAPI CommDlgExtendedError(void)
1233 return CommDlgLastError;
1236 /***********************************************************************
1237 * GetFileTitleA (COMDLG32.8)
1239 short WINAPI GetFileTitle32A(LPCSTR lpFile, LPSTR lpTitle, UINT32 cbBuf)
1242 dprintf_commdlg(stddeb,"GetFileTitle(%p %p %d); \n", lpFile, lpTitle, cbBuf);
1243 if (lpFile == NULL || lpTitle == NULL)
1245 len = strlen(lpFile);
1248 if (strpbrk(lpFile, "*[]"))
1251 if (lpFile[len] == '/' || lpFile[len] == '\\' || lpFile[len] == ':')
1253 for (i = len; i >= 0; i--)
1254 if (lpFile[i] == '/' || lpFile[i] == '\\' || lpFile[i] == ':')
1259 dprintf_commdlg(stddeb,"\n---> '%s' ", &lpFile[i]);
1261 len = strlen(lpFile+i)+1;
1265 strncpy(lpTitle, &lpFile[i], len);
1270 /***********************************************************************
1271 * GetFileTitleA (COMDLG32.8)
1273 short WINAPI GetFileTitle32W(LPCWSTR lpFile, LPWSTR lpTitle, UINT32 cbBuf)
1275 LPSTR file = HEAP_strdupWtoA(GetProcessHeap(),0,lpFile);
1276 LPSTR title = HeapAlloc(GetProcessHeap(),0,cbBuf);
1279 ret = GetFileTitle32A(file,title,cbBuf);
1281 lstrcpynAtoW(lpTitle,title,cbBuf);
1282 HeapFree(GetProcessHeap(),0,file);
1283 HeapFree(GetProcessHeap(),0,title);
1286 /***********************************************************************
1287 * GetFileTitle (COMMDLG.27)
1289 short WINAPI GetFileTitle16(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf)
1291 return GetFileTitle32A(lpFile,lpTitle,cbBuf);
1295 /* ------------------------ Choose Color Dialog --------------------------- */
1297 /***********************************************************************
1298 * ChooseColor (COMMDLG.5)
1300 BOOL16 WINAPI ChooseColor(LPCHOOSECOLOR lpChCol)
1303 HANDLE16 hDlgTmpl = 0;
1304 BOOL16 bRet = FALSE, win32Format = FALSE;
1308 dprintf_commdlg(stddeb,"ChooseColor\n");
1309 if (!lpChCol) return FALSE;
1311 if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE)
1313 if (!(template = LockResource16( lpChCol->hInstance )))
1315 CommDlgLastError = CDERR_LOADRESFAILURE;
1319 else if (lpChCol->Flags & CC_ENABLETEMPLATE)
1322 if (!(hResInfo = FindResource16(lpChCol->hInstance,
1323 lpChCol->lpTemplateName, RT_DIALOG)))
1325 CommDlgLastError = CDERR_FINDRESFAILURE;
1328 if (!(hDlgTmpl = LoadResource16( lpChCol->hInstance, hResInfo )) ||
1329 !(template = LockResource16( hDlgTmpl )))
1331 CommDlgLastError = CDERR_LOADRESFAILURE;
1337 template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_COLOR );
1341 hInst = WIN_GetWindowInstance( lpChCol->hwndOwner );
1342 hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
1344 (DLGPROC16)MODULE_GetWndProcEntry16("ColorDlgProc"),
1345 (DWORD)lpChCol, WIN_PROC_16 );
1346 if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpChCol->hwndOwner);
1347 if (hDlgTmpl) FreeResource16( hDlgTmpl );
1352 static const COLORREF predefcolors[6][8]=
1354 { 0x008080FFL, 0x0080FFFFL, 0x0080FF80L, 0x0080FF00L,
1355 0x00FFFF80L, 0x00FF8000L, 0x00C080FFL, 0x00FF80FFL },
1356 { 0x000000FFL, 0x0000FFFFL, 0x0000FF80L, 0x0040FF00L,
1357 0x00FFFF00L, 0x00C08000L, 0x00C08080L, 0x00FF00FFL },
1359 { 0x00404080L, 0x004080FFL, 0x0000FF00L, 0x00808000L,
1360 0x00804000L, 0x00FF8080L, 0x00400080L, 0x008000FFL },
1361 { 0x00000080L, 0x000080FFL, 0x00008000L, 0x00408000L,
1362 0x00FF0000L, 0x00A00000L, 0x00800080L, 0x00FF0080L },
1364 { 0x00000040L, 0x00004080L, 0x00004000L, 0x00404000L,
1365 0x00800000L, 0x00400000L, 0x00400040L, 0x00800040L },
1366 { 0x00000000L, 0x00008080L, 0x00408080L, 0x00808080L,
1367 0x00808040L, 0x00C0C0C0L, 0x00400040L, 0x00FFFFFFL },
1372 LPCHOOSECOLOR lpcc; /* points to public known data structure */
1373 int nextuserdef; /* next free place in user defined color array */
1374 HDC16 hdcMem; /* color graph used for BitBlt() */
1375 HBITMAP16 hbmMem; /* color graph bitmap */
1376 RECT16 fullsize; /* original dialog window size */
1377 UINT16 msetrgb; /* # of SETRGBSTRING message (today not used) */
1378 RECT16 old3angle; /* last position of l-marker */
1379 RECT16 oldcross; /* last position of color/satuation marker */
1380 BOOL32 updating; /* to prevent recursive WM_COMMAND/EN_UPDATE procesing */
1383 int l; /* for temporary storing of hue,sat,lum */
1386 /***********************************************************************
1387 * CC_HSLtoRGB [internal]
1389 static int CC_HSLtoRGB(char c,int hue,int sat,int lum)
1396 case 'R':if (hue>80) hue-=80; else hue+=160; break;
1397 case 'G':if (hue>160) hue-=160; else hue+=80; break;
1402 maxrgb=(256*MIN(120,lum))/120; /* 0 .. 256 */
1408 res=(hue-80)* maxrgb; /* 0...10240 */
1409 res/=40; /* 0...256 */
1416 res=(240-hue)* maxrgb;
1419 res=res-maxrgb/2; /* -128...128 */
1422 res=maxrgb/2 + (sat*res) /240; /* 0..256 */
1425 if (lum>120 && res<256)
1426 res+=((lum-120) * (256-res))/120;
1428 return MIN(res,255);
1431 /***********************************************************************
1432 * CC_RGBtoHSL [internal]
1434 static int CC_RGBtoHSL(char c,int r,int g,int b)
1436 WORD maxi,mini,mmsum,mmdif,result=0;
1450 case 'L':mmsum*=120; /* 0...61200=(255+255)*120 */
1451 result=mmsum/255; /* 0...240 */
1454 case 'S':if (!mmsum)
1457 if (!mini || maxi==255)
1461 result=mmdif*240; /* 0...61200=255*240 */
1462 result/= (mmsum>255 ? mmsum=510-mmsum : mmsum); /* 0..255 */
1466 case 'H':if (!mmdif)
1472 iresult=40*(g-b); /* -10200 ... 10200 */
1473 iresult/=(int)mmdif; /* -40 .. 40 */
1475 iresult+=240; /* 0..40 and 200..240 */
1481 iresult/=(int)mmdif;
1482 iresult+=80; /* 40 .. 120 */
1488 iresult/=(int)mmdif;
1489 iresult+=160; /* 120 .. 200 */
1495 return result; /* is this integer arithmetic precise enough ? */
1500 /***********************************************************************
1501 * CC_MouseCheckPredefColorArray [internal]
1503 static int CC_MouseCheckPredefColorArray(HWND16 hDlg,int dlgitem,int rows,int cols,
1504 LPARAM lParam,COLORREF *cr)
1507 POINT16 point = MAKEPOINT16(lParam);
1511 ClientToScreen16(hDlg,&point);
1512 hwnd=GetDlgItem32(hDlg,dlgitem);
1513 GetWindowRect16(hwnd,&rect);
1514 if (PtInRect16(&rect,point))
1516 dx=(rect.right-rect.left)/cols;
1517 dy=(rect.bottom-rect.top)/rows;
1518 ScreenToClient16(hwnd,&point);
1520 if (point.x % dx < (dx-DISTANCE) && point.y % dy < (dy-DISTANCE))
1524 *cr=predefcolors[y][x];
1525 /* FIXME: Draw_a_Focus_Rect() */
1532 /***********************************************************************
1533 * CC_MouseCheckUserColorArray [internal]
1535 static int CC_MouseCheckUserColorArray(HWND16 hDlg,int dlgitem,int rows,int cols,
1536 LPARAM lParam,COLORREF *cr,COLORREF*crarr)
1539 POINT16 point = MAKEPOINT16(lParam);
1543 ClientToScreen16(hDlg,&point);
1544 hwnd=GetDlgItem32(hDlg,dlgitem);
1545 GetWindowRect16(hwnd,&rect);
1546 if (PtInRect16(&rect,point))
1548 dx=(rect.right-rect.left)/cols;
1549 dy=(rect.bottom-rect.top)/rows;
1550 ScreenToClient16(hwnd,&point);
1552 if (point.x % dx < (dx-DISTANCE) && point.y % dy < (dy-DISTANCE))
1556 *cr=crarr[x+cols*y];
1557 /* FIXME: Draw_a_Focus_Rect() */
1567 /* 240 ^...... ^^ 240
1574 /***********************************************************************
1575 * CC_MouseCheckColorGraph [internal]
1577 static int CC_MouseCheckColorGraph(HWND16 hDlg,int dlgitem,int *hori,int *vert,LPARAM lParam)
1580 POINT16 point = MAKEPOINT16(lParam);
1584 ClientToScreen16(hDlg,&point);
1585 hwnd=GetDlgItem32(hDlg,dlgitem);
1586 GetWindowRect16(hwnd,&rect);
1587 if (PtInRect16(&rect,point))
1589 GetClientRect16(hwnd,&rect);
1590 ScreenToClient16(hwnd,&point);
1592 x=(long)point.x*MAXHORI;
1594 y=(long)(rect.bottom-point.y)*MAXVERT;
1606 /***********************************************************************
1607 * CC_MouseCheckResultWindow [internal]
1609 static int CC_MouseCheckResultWindow(HWND16 hDlg,LPARAM lParam)
1612 POINT16 point = MAKEPOINT16(lParam);
1615 ClientToScreen16(hDlg,&point);
1616 hwnd=GetDlgItem32(hDlg,0x2c5);
1617 GetWindowRect16(hwnd,&rect);
1618 if (PtInRect16(&rect,point))
1620 PostMessage16(hDlg,WM_COMMAND,0x2c9,0);
1626 /***********************************************************************
1627 * CC_CheckDigitsInEdit [internal]
1629 static int CC_CheckDigitsInEdit(HWND16 hwnd,int maxval)
1631 int i,k,m,result,value;
1634 GetWindowText32A(hwnd,buffer,sizeof(buffer));
1639 if (buffer[i]<'0' || buffer[i]>'9')
1641 for (k=i+1;k<=m;k++) /* delete bad character */
1643 buffer[i]=buffer[k];
1651 if (value>maxval) /* build a new string */
1653 sprintf(buffer,"%d",maxval);
1658 editpos=SendMessage16(hwnd,EM_GETSEL16,0,0);
1659 SetWindowText32A(hwnd,buffer);
1660 SendMessage16(hwnd,EM_SETSEL16,0,editpos);
1667 /***********************************************************************
1668 * CC_PaintSelectedColor [internal]
1670 static void CC_PaintSelectedColor(HWND16 hDlg,COLORREF cr)
1675 HWND32 hwnd=GetDlgItem32(hDlg,0x2c5);
1676 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
1679 GetClientRect16 (hwnd, &rect) ;
1680 hBrush = CreateSolidBrush32(cr);
1683 hBrush = SelectObject32 (hdc, hBrush) ;
1684 Rectangle32(hdc, rect.left,rect.top,rect.right/2,rect.bottom);
1685 DeleteObject32 (SelectObject32 (hdc,hBrush)) ;
1686 hBrush=CreateSolidBrush32(GetNearestColor32(hdc,cr));
1689 hBrush= SelectObject32 (hdc, hBrush) ;
1690 Rectangle32( hdc, rect.right/2-1,rect.top,rect.right,rect.bottom);
1691 DeleteObject32( SelectObject32 (hdc, hBrush)) ;
1694 ReleaseDC32(hwnd,hdc);
1698 /***********************************************************************
1699 * CC_PaintTriangle [internal]
1701 static void CC_PaintTriangle(HWND16 hDlg,int y)
1705 int w=GetDialogBaseUnits();
1710 HWND16 hwnd=GetDlgItem32(hDlg,0x2be);
1711 struct CCPRIVATE *lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
1713 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
1715 GetClientRect16(hwnd,&rect);
1719 points[0].y=rect.top;
1720 points[0].x=rect.right; /* | /| */
1721 ClientToScreen16(hwnd,points); /* | / | */
1722 ScreenToClient16(hDlg,points); /* |< | */
1723 oben=points[0].y; /* | \ | */
1725 temp=(long)height*(long)y;
1726 points[0].y=oben+height -temp/(long)MAXVERT;
1727 points[1].y=points[0].y+w;
1728 points[2].y=points[0].y-w;
1729 points[2].x=points[1].x=points[0].x + w;
1731 if (lpp->old3angle.left)
1732 FillRect16(hDC,&lpp->old3angle,GetStockObject32(WHITE_BRUSH));
1733 lpp->old3angle.left =points[0].x;
1734 lpp->old3angle.right =points[1].x+1;
1735 lpp->old3angle.top =points[2].y-1;
1736 lpp->old3angle.bottom=points[1].y+1;
1737 Polygon16(hDC,points,3);
1738 ReleaseDC32(hDlg,hDC);
1743 /***********************************************************************
1744 * CC_PaintCross [internal]
1746 static void CC_PaintCross(HWND16 hDlg,int x,int y)
1749 int w=GetDialogBaseUnits();
1750 HWND16 hwnd=GetDlgItem32(hDlg,0x2c6);
1751 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
1756 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
1758 GetClientRect16(hwnd,&rect);
1760 SelectClipRgn32(hDC,CreateRectRgnIndirect16(&rect));
1761 hPen=CreatePen32(PS_SOLID,2,0);
1762 hPen=SelectObject32(hDC,hPen);
1763 point.x=((long)rect.right*(long)x)/(long)MAXHORI;
1764 point.y=rect.bottom-((long)rect.bottom*(long)y)/(long)MAXVERT;
1765 if (lpp->oldcross.left!=lpp->oldcross.right)
1766 BitBlt32(hDC,lpp->oldcross.left,lpp->oldcross.top,
1767 lpp->oldcross.right-lpp->oldcross.left,
1768 lpp->oldcross.bottom-lpp->oldcross.top,
1769 lpp->hdcMem,lpp->oldcross.left,lpp->oldcross.top,SRCCOPY);
1770 lpp->oldcross.left =point.x-w-1;
1771 lpp->oldcross.right =point.x+w+1;
1772 lpp->oldcross.top =point.y-w-1;
1773 lpp->oldcross.bottom=point.y+w+1;
1775 MoveTo(hDC,point.x-w,point.y);
1776 LineTo32(hDC,point.x+w,point.y);
1777 MoveTo(hDC,point.x,point.y-w);
1778 LineTo32(hDC,point.x,point.y+w);
1779 DeleteObject32(SelectObject32(hDC,hPen));
1780 ReleaseDC32(hwnd,hDC);
1789 /***********************************************************************
1790 * CC_PrepareColorGraph [internal]
1792 static void CC_PrepareColorGraph(HWND16 hDlg)
1794 int sdif,hdif,xdif,ydif,r,g,b,hue,sat;
1795 HWND32 hwnd=GetDlgItem32(hDlg,0x2c6);
1796 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
1800 HCURSOR16 hcursor=SetCursor16(LoadCursor16(0,IDC_WAIT));
1802 GetClientRect16(hwnd,&client);
1804 lpp->hdcMem = CreateCompatibleDC32(hdc);
1805 lpp->hbmMem = CreateCompatibleBitmap32(hdc,client.right,client.bottom);
1806 SelectObject32(lpp->hdcMem,lpp->hbmMem);
1808 xdif=client.right /XSTEPS;
1809 ydif=client.bottom/YSTEPS+1;
1812 for(rect.left=hue=0;hue<239+hdif;hue+=hdif)
1814 rect.right=rect.left+xdif;
1815 rect.bottom=client.bottom;
1816 for(sat=0;sat<240+sdif;sat+=sdif)
1818 rect.top=rect.bottom-ydif;
1819 r=CC_HSLtoRGB('R',hue,sat,120);
1820 g=CC_HSLtoRGB('G',hue,sat,120);
1821 b=CC_HSLtoRGB('B',hue,sat,120);
1822 hbrush=CreateSolidBrush32(RGB(r,g,b));
1823 FillRect16(lpp->hdcMem,&rect,hbrush);
1824 DeleteObject32(hbrush);
1825 rect.bottom=rect.top;
1827 rect.left=rect.right;
1829 ReleaseDC32(hwnd,hdc);
1830 SetCursor16(hcursor);
1833 /***********************************************************************
1834 * CC_PaintColorGraph [internal]
1836 static void CC_PaintColorGraph(HWND16 hDlg)
1838 HWND32 hwnd=GetDlgItem32(hDlg,0x2c6);
1839 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
1842 if (IsWindowVisible32(hwnd)) /* if full size */
1845 CC_PrepareColorGraph(hDlg); /* should not be necessary */
1848 GetClientRect16(hwnd,&rect);
1850 BitBlt32(hDC,0,0,rect.right,rect.bottom,lpp->hdcMem,0,0,SRCCOPY);
1852 fprintf(stderr,"choose color: hdcMem is not defined\n");
1853 ReleaseDC32(hwnd,hDC);
1856 /***********************************************************************
1857 * CC_PaintLumBar [internal]
1859 static void CC_PaintLumBar(HWND16 hDlg,int hue,int sat)
1861 HWND32 hwnd=GetDlgItem32(hDlg,0x2be);
1863 int lum,ldif,ydif,r,g,b;
1867 if (IsWindowVisible32(hwnd))
1870 GetClientRect16(hwnd,&client);
1874 ydif=client.bottom/YSTEPS+1;
1875 for(lum=0;lum<240+ldif;lum+=ldif)
1877 rect.top=MAX(0,rect.bottom-ydif);
1878 r=CC_HSLtoRGB('R',hue,sat,lum);
1879 g=CC_HSLtoRGB('G',hue,sat,lum);
1880 b=CC_HSLtoRGB('B',hue,sat,lum);
1881 hbrush=CreateSolidBrush32(RGB(r,g,b));
1882 FillRect16(hDC,&rect,hbrush);
1883 DeleteObject32(hbrush);
1884 rect.bottom=rect.top;
1886 GetClientRect16(hwnd,&rect);
1887 FrameRect16(hDC,&rect,GetStockObject32(BLACK_BRUSH));
1888 ReleaseDC32(hwnd,hDC);
1892 /***********************************************************************
1893 * CC_EditSetRGB [internal]
1895 static void CC_EditSetRGB(HWND16 hDlg,COLORREF cr)
1898 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
1899 int r=GetRValue(cr);
1900 int g=GetGValue(cr);
1901 int b=GetBValue(cr);
1902 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
1905 sprintf(buffer,"%d",r);
1906 SetWindowText32A(GetDlgItem32(hDlg,0x2c2),buffer);
1907 sprintf(buffer,"%d",g);
1908 SetWindowText32A(GetDlgItem32(hDlg,0x2c3),buffer);
1909 sprintf(buffer,"%d",b);
1910 SetWindowText32A(GetDlgItem32(hDlg,0x2c4),buffer);
1911 lpp->updating=FALSE;
1915 /***********************************************************************
1916 * CC_EditSetHSL [internal]
1918 static void CC_EditSetHSL(HWND16 hDlg,int h,int s,int l)
1921 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
1923 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
1926 sprintf(buffer,"%d",h);
1927 SetWindowText32A(GetDlgItem32(hDlg,0x2bf),buffer);
1928 sprintf(buffer,"%d",s);
1929 SetWindowText32A(GetDlgItem32(hDlg,0x2c0),buffer);
1930 sprintf(buffer,"%d",l);
1931 SetWindowText32A(GetDlgItem32(hDlg,0x2c1),buffer);
1932 lpp->updating=FALSE;
1934 CC_PaintLumBar(hDlg,h,s);
1937 /***********************************************************************
1938 * CC_SwitchToFullSize [internal]
1940 static void CC_SwitchToFullSize(HWND16 hDlg,COLORREF result,LPRECT16 lprect)
1943 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
1945 EnableWindow32(GetDlgItem32(hDlg,0x2cf),FALSE);
1946 CC_PrepareColorGraph(hDlg);
1947 for (i=0x2bf;i<0x2c5;i++)
1948 EnableWindow32(GetDlgItem32(hDlg,i),TRUE);
1949 for (i=0x2d3;i<0x2d9;i++)
1950 EnableWindow32(GetDlgItem32(hDlg,i),TRUE);
1951 EnableWindow32(GetDlgItem32(hDlg,0x2c9),TRUE);
1952 EnableWindow32(GetDlgItem32(hDlg,0x2c8),TRUE);
1955 SetWindowPos32(hDlg,NULL,0,0,lprect->right-lprect->left,
1956 lprect->bottom-lprect->top, SWP_NOMOVE|SWP_NOZORDER);
1958 ShowWindow32(GetDlgItem32(hDlg,0x2c6),SW_SHOW);
1959 ShowWindow32(GetDlgItem32(hDlg,0x2be),SW_SHOW);
1960 ShowWindow32(GetDlgItem32(hDlg,0x2c5),SW_SHOW);
1962 CC_EditSetRGB(hDlg,result);
1963 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
1966 /***********************************************************************
1967 * CC_PaintPredefColorArray [internal]
1969 static void CC_PaintPredefColorArray(HWND16 hDlg,int rows,int cols)
1971 HWND32 hwnd=GetDlgItem32(hDlg,0x2d0);
1977 GetClientRect16(hwnd,&rect);
1979 dy=rect.bottom/rows;
1983 GetClientRect16 (hwnd, &rect) ;
1985 for (j=0;j<rows;j++)
1987 for (i=0;i<cols;i++)
1989 hBrush = CreateSolidBrush32(predefcolors[j][i]);
1992 hBrush = SelectObject32 (hdc, hBrush) ;
1993 Rectangle32(hdc, rect.left, rect.top,
1994 rect.left+dx-DISTANCE, rect.top+dy-DISTANCE);
1995 rect.left=rect.left+dx;
1996 DeleteObject32( SelectObject32 (hdc, hBrush)) ;
1999 rect.top=rect.top+dy;
2002 ReleaseDC32(hwnd,hdc);
2003 /* FIXME: draw_a_focus_rect */
2005 /***********************************************************************
2006 * CC_PaintUserColorArray [internal]
2008 static void CC_PaintUserColorArray(HWND16 hDlg,int rows,int cols,COLORREF* lpcr)
2010 HWND32 hwnd=GetDlgItem32(hDlg,0x2d1);
2016 GetClientRect16(hwnd,&rect);
2019 dy=rect.bottom/rows;
2025 for (j=0;j<rows;j++)
2027 for (i=0;i<cols;i++)
2029 hBrush = CreateSolidBrush32(lpcr[i+j*cols]);
2032 hBrush = SelectObject32 (hdc, hBrush) ;
2033 Rectangle32( hdc, rect.left, rect.top,
2034 rect.left+dx-DISTANCE, rect.top+dy-DISTANCE);
2035 rect.left=rect.left+dx;
2036 DeleteObject32( SelectObject32 (hdc, hBrush)) ;
2039 rect.top=rect.top+dy;
2042 ReleaseDC32(hwnd,hdc);
2044 /* FIXME: draw_a_focus_rect */
2049 /***********************************************************************
2050 * CC_HookCallChk [internal]
2052 static BOOL32 CC_HookCallChk(LPCHOOSECOLOR lpcc)
2055 if(lpcc->Flags & CC_ENABLEHOOK)
2061 /***********************************************************************
2062 * CC_WMInitDialog [internal]
2064 static LONG CC_WMInitDialog(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2070 struct CCPRIVATE * lpp;
2072 dprintf_commdlg(stddeb,"ColorDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
2073 lpp=calloc(1,sizeof(struct CCPRIVATE));
2074 lpp->lpcc=(LPCHOOSECOLOR)lParam;
2075 if (lpp->lpcc->lStructSize != sizeof(CHOOSECOLOR))
2077 EndDialog32 (hDlg, 0) ;
2080 SetWindowLong32A(hDlg, DWL_USER, (LONG)lpp);
2082 if (!(lpp->lpcc->Flags & CC_SHOWHELP))
2083 ShowWindow32(GetDlgItem32(hDlg,0x40e),SW_HIDE);
2084 lpp->msetrgb=RegisterWindowMessage32A( SETRGBSTRING );
2086 cpos=MAKELONG(5,7); /* init */
2087 if (lpp->lpcc->Flags & CC_RGBINIT)
2091 if (predefcolors[i][j]==lpp->lpcc->rgbResult)
2098 /* FIXME: Draw_a_focus_rect & set_init_values */
2100 GetWindowRect16(hDlg,&lpp->fullsize);
2101 if (lpp->lpcc->Flags & CC_FULLOPEN || lpp->lpcc->Flags & CC_PREVENTFULLOPEN)
2103 hwnd=GetDlgItem32(hDlg,0x2cf);
2104 EnableWindow32(hwnd,FALSE);
2106 if (!(lpp->lpcc->Flags & CC_FULLOPEN) || lpp->lpcc->Flags & CC_PREVENTFULLOPEN)
2109 res=rect.bottom-rect.top;
2110 hwnd=GetDlgItem32(hDlg,0x2c6); /* cut at left border */
2112 ClientToScreen16(hwnd,&point);
2113 ScreenToClient16(hDlg,&point);
2114 GetClientRect16(hDlg,&rect);
2115 point.x+=GetSystemMetrics32(SM_CXDLGFRAME);
2116 SetWindowPos32(hDlg,NULL,0,0,point.x,res,SWP_NOMOVE|SWP_NOZORDER);
2118 ShowWindow32(GetDlgItem32(hDlg,0x2c6),SW_HIDE);
2119 ShowWindow32(GetDlgItem32(hDlg,0x2c5),SW_HIDE);
2122 CC_SwitchToFullSize(hDlg,lpp->lpcc->rgbResult,NULL);
2124 for (i=0x2bf;i<0x2c5;i++)
2125 SendMessage16(GetDlgItem32(hDlg,i),EM_LIMITTEXT16,3,0); /* max 3 digits: xyz */
2126 if (CC_HookCallChk(lpp->lpcc))
2127 res=CallWindowProc16(lpp->lpcc->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
2131 /***********************************************************************
2132 * CC_WMCommand [internal]
2134 static LRESULT CC_WMCommand(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2140 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2141 dprintf_commdlg(stddeb,"CC_WMCommand wParam=%x lParam=%lx\n",wParam,lParam);
2144 case 0x2c2: /* edit notify RGB */
2147 if (HIWORD(lParam)==EN_UPDATE && !lpp->updating)
2149 i=CC_CheckDigitsInEdit(LOWORD(lParam),255);
2150 r=GetRValue(lpp->lpcc->rgbResult);
2151 g=GetGValue(lpp->lpcc->rgbResult);
2152 b=GetBValue(lpp->lpcc->rgbResult);
2156 case 0x2c2:if ((xx=(i!=r))) r=i;break;
2157 case 0x2c3:if ((xx=(i!=g))) g=i;break;
2158 case 0x2c4:if ((xx=(i!=b))) b=i;break;
2160 if (xx) /* something has changed */
2162 lpp->lpcc->rgbResult=RGB(r,g,b);
2163 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2164 lpp->h=CC_RGBtoHSL('H',r,g,b);
2165 lpp->s=CC_RGBtoHSL('S',r,g,b);
2166 lpp->l=CC_RGBtoHSL('L',r,g,b);
2167 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
2168 CC_PaintCross(hDlg,lpp->h,lpp->s);
2169 CC_PaintTriangle(hDlg,lpp->l);
2174 case 0x2bf: /* edit notify HSL */
2177 if (HIWORD(lParam)==EN_UPDATE && !lpp->updating)
2179 i=CC_CheckDigitsInEdit(LOWORD(lParam),wParam==0x2bf?239:240);
2183 case 0x2bf:if ((xx=(i!=lpp->h))) lpp->h=i;break;
2184 case 0x2c0:if ((xx=(i!=lpp->s))) lpp->s=i;break;
2185 case 0x2c1:if ((xx=(i!=lpp->l))) lpp->l=i;break;
2187 if (xx) /* something has changed */
2189 r=CC_HSLtoRGB('R',lpp->h,lpp->s,lpp->l);
2190 g=CC_HSLtoRGB('G',lpp->h,lpp->s,lpp->l);
2191 b=CC_HSLtoRGB('B',lpp->h,lpp->s,lpp->l);
2192 lpp->lpcc->rgbResult=RGB(r,g,b);
2193 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2194 CC_EditSetRGB(hDlg,lpp->lpcc->rgbResult);
2195 CC_PaintCross(hDlg,lpp->h,lpp->s);
2196 CC_PaintTriangle(hDlg,lpp->l);
2202 CC_SwitchToFullSize(hDlg,lpp->lpcc->rgbResult,&lpp->fullsize);
2203 InvalidateRect32( hDlg, NULL, TRUE );
2204 SetFocus32(GetDlgItem32(hDlg,0x2bf));
2207 case 0x2c8: /* add colors ... column by column */
2208 cr=PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors);
2209 cr[(lpp->nextuserdef%2)*8 + lpp->nextuserdef/2]=lpp->lpcc->rgbResult;
2210 if (++lpp->nextuserdef==16)
2212 CC_PaintUserColorArray(hDlg,2,8,PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors));
2215 case 0x2c9: /* resulting color */
2217 lpp->lpcc->rgbResult=GetNearestColor32(hdc,lpp->lpcc->rgbResult);
2218 ReleaseDC32(hDlg,hdc);
2219 CC_EditSetRGB(hDlg,lpp->lpcc->rgbResult);
2220 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2221 r=GetRValue(lpp->lpcc->rgbResult);
2222 g=GetGValue(lpp->lpcc->rgbResult);
2223 b=GetBValue(lpp->lpcc->rgbResult);
2224 lpp->h=CC_RGBtoHSL('H',r,g,b);
2225 lpp->s=CC_RGBtoHSL('S',r,g,b);
2226 lpp->l=CC_RGBtoHSL('L',r,g,b);
2227 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
2228 CC_PaintCross(hDlg,lpp->h,lpp->s);
2229 CC_PaintTriangle(hDlg,lpp->l);
2232 case 0x40e: /* Help! */ /* The Beatles, 1965 ;-) */
2233 i=RegisterWindowMessage32A( HELPMSGSTRING );
2234 if (lpp->lpcc->hwndOwner)
2235 SendMessage16(lpp->lpcc->hwndOwner,i,0,(LPARAM)lpp->lpcc);
2236 if (CC_HookCallChk(lpp->lpcc))
2237 CallWindowProc16(lpp->lpcc->lpfnHook,hDlg,
2238 WM_COMMAND,psh15,(LPARAM)lpp->lpcc);
2242 cokmsg=RegisterWindowMessage32A( COLOROKSTRING );
2243 if (lpp->lpcc->hwndOwner)
2244 if (SendMessage16(lpp->lpcc->hwndOwner,cokmsg,0,(LPARAM)lpp->lpcc))
2245 break; /* do NOT close */
2247 EndDialog32 (hDlg, 1) ;
2251 EndDialog32 (hDlg, 0) ;
2258 /***********************************************************************
2259 * CC_WMPaint [internal]
2261 static LRESULT CC_WMPaint(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2263 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2264 /* we have to paint dialog children except text and buttons */
2266 CC_PaintPredefColorArray(hDlg,6,8);
2267 CC_PaintUserColorArray(hDlg,2,8,PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors));
2268 CC_PaintColorGraph(hDlg);
2269 CC_PaintLumBar(hDlg,lpp->h,lpp->s);
2270 CC_PaintCross(hDlg,lpp->h,lpp->s);
2271 CC_PaintTriangle(hDlg,lpp->l);
2272 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2274 /* special necessary for Wine */
2275 ValidateRect32(GetDlgItem32(hDlg,0x2d0),NULL);
2276 ValidateRect32(GetDlgItem32(hDlg,0x2d1),NULL);
2277 ValidateRect32(GetDlgItem32(hDlg,0x2c6),NULL);
2278 ValidateRect32(GetDlgItem32(hDlg,0x2be),NULL);
2279 ValidateRect32(GetDlgItem32(hDlg,0x2c5),NULL);
2280 /* hope we can remove it later -->FIXME */
2285 /***********************************************************************
2286 * CC_WMLButtonDown [internal]
2288 static LRESULT CC_WMLButtonDown(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2290 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2293 if (CC_MouseCheckPredefColorArray(hDlg,0x2d0,6,8,lParam,&lpp->lpcc->rgbResult))
2296 if (CC_MouseCheckUserColorArray(hDlg,0x2d1,2,8,lParam,&lpp->lpcc->rgbResult,
2297 PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors)))
2300 if (CC_MouseCheckColorGraph(hDlg,0x2c6,&lpp->h,&lpp->s,lParam))
2303 if (CC_MouseCheckColorGraph(hDlg,0x2be,NULL,&lpp->l,lParam))
2307 r=CC_HSLtoRGB('R',lpp->h,lpp->s,lpp->l);
2308 g=CC_HSLtoRGB('G',lpp->h,lpp->s,lpp->l);
2309 b=CC_HSLtoRGB('B',lpp->h,lpp->s,lpp->l);
2310 lpp->lpcc->rgbResult=RGB(r,g,b);
2314 r=GetRValue(lpp->lpcc->rgbResult);
2315 g=GetGValue(lpp->lpcc->rgbResult);
2316 b=GetBValue(lpp->lpcc->rgbResult);
2317 lpp->h=CC_RGBtoHSL('H',r,g,b);
2318 lpp->s=CC_RGBtoHSL('S',r,g,b);
2319 lpp->l=CC_RGBtoHSL('L',r,g,b);
2323 CC_EditSetRGB(hDlg,lpp->lpcc->rgbResult);
2324 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
2325 CC_PaintCross(hDlg,lpp->h,lpp->s);
2326 CC_PaintTriangle(hDlg,lpp->l);
2327 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2333 /***********************************************************************
2334 * ColorDlgProc (COMMDLG.8)
2336 LRESULT WINAPI ColorDlgProc(HWND16 hDlg, UINT16 message,
2337 WPARAM16 wParam, LONG lParam)
2340 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2341 if (message!=WM_INITDIALOG)
2346 if (CC_HookCallChk(lpp->lpcc))
2347 res=CallWindowProc16(lpp->lpcc->lpfnHook,hDlg,message,wParam,lParam);
2352 /* FIXME: SetRGB message
2353 if (message && message==msetrgb)
2354 return HandleSetRGB(hDlg,lParam);
2360 return CC_WMInitDialog(hDlg,wParam,lParam);
2362 DeleteDC32(lpp->hdcMem);
2363 DeleteObject32(lpp->hbmMem);
2365 SetWindowLong32A(hDlg, DWL_USER, 0L); /* we don't need it anymore */
2368 if (CC_WMCommand(hDlg, wParam, lParam))
2372 CC_WMPaint(hDlg, wParam, lParam);
2374 case WM_LBUTTONDBLCLK:
2375 if (CC_MouseCheckResultWindow(hDlg,lParam))
2378 case WM_MOUSEMOVE: /* FIXME: calculate new hue,sat,lum (if in color graph) */
2380 case WM_LBUTTONUP: /* FIXME: ClipCursor off (if in color graph)*/
2382 case WM_LBUTTONDOWN:/* FIXME: ClipCursor on (if in color graph)*/
2383 if (CC_WMLButtonDown(hDlg, wParam, lParam))
2392 /***********************************************************************
2393 * ChooseFont (COMMDLG.15)
2395 BOOL16 WINAPI ChooseFont(LPCHOOSEFONT lpChFont)
2398 HANDLE16 hDlgTmpl = 0;
2399 BOOL16 bRet = FALSE, win32Format = FALSE;
2403 dprintf_commdlg(stddeb,"ChooseFont\n");
2404 if (!lpChFont) return FALSE;
2406 if (lpChFont->Flags & CF_ENABLETEMPLATEHANDLE)
2408 if (!(template = LockResource16( lpChFont->hInstance )))
2410 CommDlgLastError = CDERR_LOADRESFAILURE;
2414 else if (lpChFont->Flags & CF_ENABLETEMPLATE)
2417 if (!(hResInfo = FindResource16( lpChFont->hInstance,
2418 lpChFont->lpTemplateName, RT_DIALOG)))
2420 CommDlgLastError = CDERR_FINDRESFAILURE;
2423 if (!(hDlgTmpl = LoadResource16( lpChFont->hInstance, hResInfo )) ||
2424 !(template = LockResource16( hDlgTmpl )))
2426 CommDlgLastError = CDERR_LOADRESFAILURE;
2432 template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT );
2436 hInst = WIN_GetWindowInstance( lpChFont->hwndOwner );
2438 hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
2439 lpChFont->hwndOwner,
2440 (DLGPROC16)MODULE_GetWndProcEntry16("FormatCharDlgProc"),
2441 (DWORD)lpChFont, WIN_PROC_16 );
2442 if (hwndDialog) bRet = DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner);
2443 if (hDlgTmpl) FreeResource16( hDlgTmpl );
2448 #define TEXT_EXTRAS 4
2449 #define TEXT_COLORS 16
2451 static const COLORREF textcolors[TEXT_COLORS]=
2453 0x00000000L,0x00000080L,0x00008000L,0x00008080L,
2454 0x00800000L,0x00800080L,0x00808000L,0x00808080L,
2455 0x00c0c0c0L,0x000000ffL,0x0000ff00L,0x0000ffffL,
2456 0x00ff0000L,0x00ff00ffL,0x00ffff00L,0x00FFFFFFL
2459 /***********************************************************************
2460 * CFn_HookCallChk [internal]
2462 static BOOL32 CFn_HookCallChk(LPCHOOSEFONT lpcf)
2465 if(lpcf->Flags & CF_ENABLEHOOK)
2472 /***********************************************************************
2473 * FontFamilyEnumProc (COMMDLG.19)
2475 INT16 WINAPI FontFamilyEnumProc( SEGPTR logfont, SEGPTR metrics,
2476 UINT16 nFontType, LPARAM lParam )
2480 HWND16 hwnd=LOWORD(lParam);
2481 HWND16 hDlg=GetParent16(hwnd);
2482 LPCHOOSEFONT lpcf=(LPCHOOSEFONT)GetWindowLong32A(hDlg, DWL_USER);
2483 LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN( logfont );
2485 dprintf_commdlg(stddeb,"FontFamilyEnumProc: font=%s (nFontType=%d)\n",
2486 lplf->lfFaceName,nFontType);
2488 if (lpcf->Flags & CF_FIXEDPITCHONLY)
2489 if (!(lplf->lfPitchAndFamily & FIXED_PITCH))
2491 if (lpcf->Flags & CF_ANSIONLY)
2492 if (lplf->lfCharSet != ANSI_CHARSET)
2494 if (lpcf->Flags & CF_TTONLY)
2495 if (!(nFontType & 0x0004)) /* this means 'TRUETYPE_FONTTYPE' */
2498 i=SendMessage16(hwnd,CB_ADDSTRING16,0,
2499 (LPARAM)logfont + ((char *)lplf->lfFaceName - (char *)lplf));
2502 w=(lplf->lfCharSet << 8) | lplf->lfPitchAndFamily;
2503 SendMessage16(hwnd, CB_SETITEMDATA16,i,MAKELONG(nFontType,w));
2504 return 1 ; /* store some important font information */
2510 /*************************************************************************
2511 * SetFontStylesToCombo2 [internal]
2513 * Fill font style information into combobox (without using font.c directly)
2515 static int SetFontStylesToCombo2(HWND16 hwnd, HDC16 hdc, LPLOGFONT16 lplf,
2516 LPTEXTMETRIC16 lptm)
2523 static struct FONTSTYLE fontstyles[FSTYLES]={
2524 { 0,FW_NORMAL,"Regular"},{0,FW_BOLD,"Bold"},
2525 { 1,FW_NORMAL,"Italic"}, {1,FW_BOLD,"Bold Italic"}};
2529 for (i=0;i<FSTYLES;i++)
2531 lplf->lfItalic=fontstyles[i].italic;
2532 lplf->lfWeight=fontstyles[i].weight;
2533 hf=CreateFontIndirect16(lplf);
2534 hf=SelectObject32(hdc,hf);
2535 GetTextMetrics16(hdc,lptm);
2536 hf=SelectObject32(hdc,hf);
2539 if (lptm->tmWeight==fontstyles[i].weight &&
2540 lptm->tmItalic==fontstyles[i].italic) /* font successful created ? */
2542 char *str = SEGPTR_STRDUP(fontstyles[i].stname);
2543 j=SendMessage16(hwnd,CB_ADDSTRING16,0,(LPARAM)SEGPTR_GET(str) );
2545 if (j==CB_ERR) return 1;
2546 j=SendMessage16(hwnd, CB_SETITEMDATA16, j,
2547 MAKELONG(fontstyles[i].weight,fontstyles[i].italic));
2548 if (j==CB_ERR) return 1;
2554 /*************************************************************************
2555 * SetFontSizesToCombo3 [internal]
2557 static int SetFontSizesToCombo3(HWND16 hwnd, LPLOGFONT16 lplf, LPCHOOSEFONT lpcf)
2559 static const int sizes[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72,0};
2563 if (!(buffer = SEGPTR_ALLOC(20))) return 1;
2564 for (i=0;sizes[i] && !lplf->lfHeight;i++)
2566 h=lplf->lfHeight ? lplf->lfHeight : sizes[i];
2568 if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
2569 ((lpcf->Flags & CF_LIMITSIZE) && (h >= lpcf->nSizeMin) && (h <= lpcf->nSizeMax)))
2571 sprintf(buffer,"%2d",h);
2572 j=SendMessage16(hwnd,CB_FINDSTRING16,-1,(LPARAM)SEGPTR_GET(buffer));
2575 j=SendMessage16(hwnd,CB_ADDSTRING16,0,(LPARAM)SEGPTR_GET(buffer));
2576 if (j!=CB_ERR) j = SendMessage16(hwnd, CB_SETITEMDATA16, j, h);
2579 SEGPTR_FREE(buffer);
2585 SEGPTR_FREE(buffer);
2590 /***********************************************************************
2591 * FontStyleEnumProc (COMMDLG.18)
2593 INT16 WINAPI FontStyleEnumProc( SEGPTR logfont, SEGPTR metrics,
2594 UINT16 nFontType, LPARAM lParam )
2596 HWND16 hcmb2=LOWORD(lParam);
2597 HWND16 hcmb3=HIWORD(lParam);
2598 HWND16 hDlg=GetParent16(hcmb3);
2599 LPCHOOSEFONT lpcf=(LPCHOOSEFONT)GetWindowLong32A(hDlg, DWL_USER);
2600 LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN(logfont);
2601 TEXTMETRIC16 *lptm = (TEXTMETRIC16 *)PTR_SEG_TO_LIN(metrics);
2604 dprintf_commdlg(stddeb,"FontStyleEnumProc: (nFontType=%d)\n",nFontType);
2605 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",
2606 lplf->lfFaceName,lplf->lfHeight,lplf->lfWidth,lplf->lfEscapement,lplf->lfOrientation,
2607 lplf->lfWeight,lplf->lfItalic,lplf->lfUnderline,lplf->lfStrikeOut,lplf->lfCharSet,
2608 lplf->lfOutPrecision,lplf->lfClipPrecision,lplf->lfQuality,lplf->lfPitchAndFamily);
2610 if (SetFontSizesToCombo3(hcmb3, lplf ,lpcf))
2613 if (!SendMessage16(hcmb2,CB_GETCOUNT16,0,0))
2615 HDC32 hdc= (lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC32(hDlg);
2616 i=SetFontStylesToCombo2(hcmb2,hdc,lplf,lptm);
2617 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
2618 ReleaseDC32(hDlg,hdc);
2626 /***********************************************************************
2627 * CFn_WMInitDialog [internal]
2629 LRESULT CFn_WMInitDialog(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2635 HCURSOR16 hcursor=SetCursor16(LoadCursor16(0,IDC_WAIT));
2638 SetWindowLong32A(hDlg, DWL_USER, lParam);
2639 lpcf=(LPCHOOSEFONT)lParam;
2640 lpxx=PTR_SEG_TO_LIN(lpcf->lpLogFont);
2641 dprintf_commdlg(stddeb,"FormatCharDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam);
2643 if (lpcf->lStructSize != sizeof(CHOOSEFONT))
2645 dprintf_commdlg(stddeb,"WM_INITDIALOG: structure size failure !!!\n");
2646 EndDialog32 (hDlg, 0);
2650 hBitmapTT = LoadBitmap16(0, MAKEINTRESOURCE(OBM_TRTYPE));
2652 if (!(lpcf->Flags & CF_SHOWHELP) || !IsWindow32(lpcf->hwndOwner))
2653 ShowWindow32(GetDlgItem32(hDlg,pshHelp),SW_HIDE);
2654 if (!(lpcf->Flags & CF_APPLY))
2655 ShowWindow32(GetDlgItem32(hDlg,psh3),SW_HIDE);
2656 if (lpcf->Flags & CF_EFFECTS)
2658 for (res=1,i=0;res && i<TEXT_COLORS;i++)
2660 /* FIXME: load color name from resource: res=LoadString(...,i+....,buffer,.....); */
2661 char *name = SEGPTR_ALLOC(20);
2662 strcpy( name, "[color name]" );
2663 j=SendDlgItemMessage16(hDlg,cmb4,CB_ADDSTRING16,0,(LPARAM)SEGPTR_GET(name));
2665 SendDlgItemMessage16(hDlg,cmb4, CB_SETITEMDATA16,j,textcolors[j]);
2666 /* look for a fitting value in color combobox */
2667 if (textcolors[j]==lpcf->rgbColors)
2668 SendDlgItemMessage16(hDlg,cmb4, CB_SETCURSEL16,j,0);
2673 ShowWindow32(GetDlgItem32(hDlg,cmb4),SW_HIDE);
2674 ShowWindow32(GetDlgItem32(hDlg,chx1),SW_HIDE);
2675 ShowWindow32(GetDlgItem32(hDlg,chx2),SW_HIDE);
2676 ShowWindow32(GetDlgItem32(hDlg,grp1),SW_HIDE);
2677 ShowWindow32(GetDlgItem32(hDlg,stc4),SW_HIDE);
2679 hdc= (lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC32(hDlg);
2682 if (!EnumFontFamilies16(hdc, NULL,FontFamilyEnumProc,
2683 (LPARAM)GetDlgItem32(hDlg,cmb1)))
2684 dprintf_commdlg(stddeb,"WM_INITDIALOG: EnumFontFamilies returns 0\n");
2685 if (lpcf->Flags & CF_INITTOLOGFONTSTRUCT)
2687 /* look for fitting font name in combobox1 */
2688 j=SendDlgItemMessage16(hDlg,cmb1,CB_FINDSTRING16,-1,(LONG)lpxx->lfFaceName);
2691 SendDlgItemMessage16(hDlg,cmb1,CB_SETCURSEL16,j,0);
2692 SendMessage16(hDlg,WM_COMMAND,cmb1,
2693 MAKELONG(GetDlgItem32(hDlg,cmb1),CBN_SELCHANGE));
2695 /* look for fitting font style in combobox2 */
2696 l=MAKELONG(lpxx->lfWeight > FW_MEDIUM ? FW_BOLD:FW_NORMAL,lpxx->lfItalic !=0);
2697 for (i=0;i<TEXT_EXTRAS;i++)
2699 if (l==SendDlgItemMessage16(hDlg,cmb2, CB_GETITEMDATA16,i,0))
2700 SendDlgItemMessage16(hDlg,cmb2,CB_SETCURSEL16,i,0);
2703 /* look for fitting font size in combobox3 */
2704 j=SendDlgItemMessage16(hDlg,cmb3,CB_GETCOUNT16,0,0);
2707 if (lpxx->lfHeight==(int)SendDlgItemMessage16(hDlg,cmb3, CB_GETITEMDATA16,i,0))
2708 SendDlgItemMessage16(hDlg,cmb3,CB_SETCURSEL16,i,0);
2713 SendDlgItemMessage16(hDlg,cmb1,CB_SETCURSEL16,0,0);
2714 SendMessage16(hDlg,WM_COMMAND,cmb1,
2715 MAKELONG(GetDlgItem32(hDlg,cmb1),CBN_SELCHANGE));
2718 if (lpcf->Flags & CF_USESTYLE && lpcf->lpszStyle)
2720 j=SendDlgItemMessage16(hDlg,cmb2,CB_FINDSTRING16,-1,(LONG)lpcf->lpszStyle);
2723 j=SendDlgItemMessage16(hDlg,cmb2,CB_SETCURSEL16,j,0);
2724 SendMessage16(hDlg,WM_COMMAND,cmb2,
2725 MAKELONG(GetDlgItem32(hDlg,cmb2),CBN_SELCHANGE));
2731 dprintf_commdlg(stddeb,"WM_INITDIALOG: HDC failure !!!\n");
2732 EndDialog32 (hDlg, 0);
2736 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
2737 ReleaseDC32(hDlg,hdc);
2739 if (CFn_HookCallChk(lpcf))
2740 res=CallWindowProc16(lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
2741 SetCursor16(hcursor);
2746 /***********************************************************************
2747 * CFn_WMMeasureItem [internal]
2749 LRESULT CFn_WMMeasureItem(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2752 LPMEASUREITEMSTRUCT16 lpmi=PTR_SEG_TO_LIN((LPMEASUREITEMSTRUCT16)lParam);
2754 hBitmapTT = LoadBitmap16(0, MAKEINTRESOURCE(OBM_TRTYPE));
2755 GetObject16( hBitmapTT, sizeof(bm), &bm );
2756 lpmi->itemHeight=bm.bmHeight;
2757 /* FIXME: use MAX of bm.bmHeight and tm.tmHeight .*/
2762 /***********************************************************************
2763 * CFn_WMDrawItem [internal]
2765 LRESULT CFn_WMDrawItem(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2775 HBITMAP16 hBitmap; /* for later TT usage */
2777 LPDRAWITEMSTRUCT16 lpdi = (LPDRAWITEMSTRUCT16)PTR_SEG_TO_LIN(lParam);
2779 if (lpdi->itemID == 0xFFFF) /* got no items */
2780 DrawFocusRect16(lpdi->hDC, &lpdi->rcItem);
2783 if (lpdi->CtlType == ODT_COMBOBOX)
2785 hBrush = SelectObject32(lpdi->hDC, GetStockObject32(LTGRAY_BRUSH));
2786 SelectObject32(lpdi->hDC, hBrush);
2787 FillRect16(lpdi->hDC, &lpdi->rcItem, hBrush);
2790 return TRUE; /* this should never happen */
2793 buffer = SEGPTR_ALLOC(40);
2794 switch (lpdi->CtlID)
2796 case cmb1: /* dprintf_commdlg(stddeb,"WM_Drawitem cmb1\n"); */
2797 SendMessage16(lpdi->hwndItem, CB_GETLBTEXT16, lpdi->itemID,
2798 (LPARAM)SEGPTR_GET(buffer));
2799 GetObject16( hBitmapTT, sizeof(bm), &bm );
2800 TextOut16(lpdi->hDC, lpdi->rcItem.left + bm.bmWidth + 10,
2801 lpdi->rcItem.top, buffer, lstrlen16(buffer));
2803 nFontType = SendMessage16(lpdi->hwndItem, CB_GETITEMDATA16, lpdi->itemID,0L);
2804 /* FIXME: draw bitmap if truetype usage */
2805 if (nFontType&TRUETYPE_FONTTYPE)
2807 hMemDC = CreateCompatibleDC32(lpdi->hDC);
2808 hBitmap = SelectObject32(hMemDC, hBitmapTT);
2809 BitBlt32(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top,
2810 bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
2811 SelectObject32(hMemDC, hBitmap);
2817 case cmb3: /* dprintf_commdlg(stddeb,"WM_DRAWITEN cmb2,cmb3\n"); */
2818 SendMessage16(lpdi->hwndItem, CB_GETLBTEXT16, lpdi->itemID,
2819 (LPARAM)SEGPTR_GET(buffer));
2820 TextOut16(lpdi->hDC, lpdi->rcItem.left,
2821 lpdi->rcItem.top, buffer, lstrlen16(buffer));
2824 case cmb4: /* dprintf_commdlg(stddeb,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
2825 SendMessage16(lpdi->hwndItem, CB_GETLBTEXT16, lpdi->itemID,
2826 (LPARAM)SEGPTR_GET(buffer));
2827 TextOut16(lpdi->hDC, lpdi->rcItem.left + 25+5,
2828 lpdi->rcItem.top, buffer, lstrlen16(buffer));
2829 cr = SendMessage16(lpdi->hwndItem, CB_GETITEMDATA16, lpdi->itemID,0L);
2830 hBrush = CreateSolidBrush32(cr);
2833 hBrush = SelectObject32 (lpdi->hDC, hBrush) ;
2834 rect.right=rect.left+25;
2838 Rectangle32( lpdi->hDC, rect.left, rect.top,
2839 rect.right, rect.bottom );
2840 DeleteObject32( SelectObject32 (lpdi->hDC, hBrush)) ;
2846 default: return TRUE; /* this should never happen */
2848 SEGPTR_FREE(buffer);
2849 if (lpdi->itemState ==ODS_SELECTED)
2850 InvertRect16(lpdi->hDC, &rect);
2855 /***********************************************************************
2856 * CFn_WMCtlColor [internal]
2858 LRESULT CFn_WMCtlColor(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2860 LPCHOOSEFONT lpcf=(LPCHOOSEFONT)GetWindowLong32A(hDlg, DWL_USER);
2862 if (lpcf->Flags & CF_EFFECTS)
2863 if (HIWORD(lParam)==CTLCOLOR_STATIC && GetDlgCtrlID32(LOWORD(lParam))==stc6)
2865 SetTextColor32(wParam,lpcf->rgbColors);
2866 return GetStockObject32(WHITE_BRUSH);
2871 /***********************************************************************
2872 * CFn_WMCommand [internal]
2874 LRESULT CFn_WMCommand(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2880 LPCHOOSEFONT lpcf=(LPCHOOSEFONT)GetWindowLong32A(hDlg, DWL_USER);
2881 LPLOGFONT16 lpxx=PTR_SEG_TO_LIN(lpcf->lpLogFont);
2883 dprintf_commdlg(stddeb,"FormatCharDlgProc // WM_COMMAND lParam=%08lX\n", lParam);
2886 case cmb1:if (HIWORD(lParam)==CBN_SELCHANGE)
2888 hdc=(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC32(hDlg);
2891 SendDlgItemMessage16(hDlg,cmb2,CB_RESETCONTENT16,0,0);
2892 SendDlgItemMessage16(hDlg,cmb3,CB_RESETCONTENT16,0,0);
2893 i=SendDlgItemMessage16(hDlg,cmb1,CB_GETCURSEL16,0,0);
2896 HCURSOR16 hcursor=SetCursor16(LoadCursor16(0,IDC_WAIT));
2897 char *str = SEGPTR_ALLOC(256);
2898 SendDlgItemMessage16(hDlg,cmb1,CB_GETLBTEXT16,i,
2899 (LPARAM)SEGPTR_GET(str));
2900 dprintf_commdlg(stddeb,"WM_COMMAND/cmb1 =>%s\n",str);
2901 EnumFontFamilies16(hdc,str,FontStyleEnumProc,
2902 MAKELONG(GetDlgItem32(hDlg,cmb2),GetDlgItem32(hDlg,cmb3)));
2903 SetCursor16(hcursor);
2906 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
2907 ReleaseDC32(hDlg,hdc);
2911 dprintf_commdlg(stddeb,"WM_COMMAND: HDC failure !!!\n");
2912 EndDialog32 (hDlg, 0);
2919 case cmb3:if (HIWORD(lParam)==CBN_SELCHANGE || HIWORD(lParam)== BN_CLICKED )
2921 char *str = SEGPTR_ALLOC(256);
2922 dprintf_commdlg(stddeb,"WM_COMMAND/cmb2,3 =%08lX\n", lParam);
2923 i=SendDlgItemMessage16(hDlg,cmb1,CB_GETCURSEL16,0,0);
2925 i=GetDlgItemText32A( hDlg, cmb1, str, 256 );
2928 SendDlgItemMessage16(hDlg,cmb1,CB_GETLBTEXT16,i,
2929 (LPARAM)SEGPTR_GET(str));
2930 l=SendDlgItemMessage16(hDlg,cmb1,CB_GETITEMDATA16,i,0);
2932 lpcf->nFontType = LOWORD(l);
2933 /* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */
2934 /* same value reported to the EnumFonts
2935 call back with the extra FONTTYPE_... bits added */
2936 lpxx->lfPitchAndFamily=j&0xff;
2937 lpxx->lfCharSet=j>>8;
2939 strcpy(lpxx->lfFaceName,str);
2941 i=SendDlgItemMessage16(hDlg,cmb2,CB_GETCURSEL16,0,0);
2944 l=SendDlgItemMessage16(hDlg,cmb2,CB_GETITEMDATA16,i,0);
2945 if (0!=(lpxx->lfItalic=HIWORD(l)))
2946 lpcf->nFontType |= ITALIC_FONTTYPE;
2947 if ((lpxx->lfWeight=LOWORD(l)) > FW_MEDIUM)
2948 lpcf->nFontType |= BOLD_FONTTYPE;
2950 i=SendDlgItemMessage16(hDlg,cmb3,CB_GETCURSEL16,0,0);
2952 lpxx->lfHeight=-LOWORD(SendDlgItemMessage16(hDlg,cmb3,CB_GETITEMDATA16,i,0));
2955 lpxx->lfStrikeOut=IsDlgButtonChecked32(hDlg,chx1);
2956 lpxx->lfUnderline=IsDlgButtonChecked32(hDlg,chx2);
2957 lpxx->lfWidth=lpxx->lfOrientation=lpxx->lfEscapement=0;
2958 lpxx->lfOutPrecision=OUT_DEFAULT_PRECIS;
2959 lpxx->lfClipPrecision=CLIP_DEFAULT_PRECIS;
2960 lpxx->lfQuality=DEFAULT_QUALITY;
2961 lpcf->iPointSize= -10*lpxx->lfHeight;
2963 hFont=CreateFontIndirect16(lpxx);
2965 SendDlgItemMessage16(hDlg,stc6,WM_SETFONT,hFont,TRUE);
2966 /* FIXME: Delete old font ...? */
2970 case cmb4:i=SendDlgItemMessage16(hDlg,cmb4,CB_GETCURSEL16,0,0);
2973 lpcf->rgbColors=textcolors[i];
2974 InvalidateRect32( GetDlgItem32(hDlg,stc6), NULL, 0 );
2978 case psh15:i=RegisterWindowMessage32A( HELPMSGSTRING );
2979 if (lpcf->hwndOwner)
2980 SendMessage16(lpcf->hwndOwner,i,0,(LPARAM)lpcf);
2981 if (CFn_HookCallChk(lpcf))
2982 CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);
2985 case IDOK:if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
2986 ( (lpcf->Flags & CF_LIMITSIZE) &&
2987 (-lpxx->lfHeight >= lpcf->nSizeMin) &&
2988 (-lpxx->lfHeight <= lpcf->nSizeMax)))
2989 EndDialog32(hDlg, TRUE);
2993 sprintf(buffer,"Select a font size between %d and %d points.",
2994 lpcf->nSizeMin,lpcf->nSizeMax);
2995 MessageBox16(hDlg,buffer,NULL,MB_OK);
2998 case IDCANCEL:EndDialog32(hDlg, FALSE);
3005 /***********************************************************************
3006 * FormatCharDlgProc (COMMDLG.16)
3007 FIXME: 1. some strings are "hardcoded", but it's better load from sysres
3008 2. some CF_.. flags are not supported
3009 3. some TType extensions
3011 LRESULT WINAPI FormatCharDlgProc(HWND16 hDlg, UINT16 message, WPARAM16 wParam,
3014 LPCHOOSEFONT lpcf=(LPCHOOSEFONT)GetWindowLong32A(hDlg, DWL_USER);
3015 if (message!=WM_INITDIALOG)
3020 if (CFn_HookCallChk(lpcf))
3021 res=CallWindowProc16(lpcf->lpfnHook,hDlg,message,wParam,lParam);
3026 return CFn_WMInitDialog(hDlg,wParam,lParam);
3029 case WM_MEASUREITEM:
3030 return CFn_WMMeasureItem(hDlg,wParam,lParam);
3032 return CFn_WMDrawItem(hDlg,wParam,lParam);
3034 return CFn_WMCtlColor(hDlg,wParam,lParam);
3036 return CFn_WMCommand(hDlg,wParam,lParam);
3037 case WM_CHOOSEFONT_GETLOGFONT:
3038 dprintf_commdlg(stddeb,
3039 "FormatCharDlgProc // WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n", lParam);
3040 /* FIXME: current logfont back to caller */
3047 #define GET_XXX_FILENAME(xxx) \
3048 BOOL32 WINAPI xxx##32A( LPOPENFILENAME32A ofn ) \
3051 LPOPENFILENAME16 ofn16 = SEGPTR_ALLOC(sizeof(OPENFILENAME16)); \
3053 memset(ofn16,'\0',sizeof(*ofn16)); \
3054 ofn16->lStructSize = sizeof(*ofn16); \
3055 ofn16->hwndOwner = ofn->hwndOwner; \
3056 /* FIXME: OPENFILENAME16 got only 16 bit for HINSTANCE... */ \
3057 ofn16->hInstance = MODULE_HANDLEtoHMODULE16(ofn->hInstance); \
3058 if (ofn->lpstrFilter) { \
3061 /* filter is a list... title\0ext\0......\0\0 */ \
3062 s = (LPSTR)ofn->lpstrFilter; \
3064 s = s+strlen(s)+1; \
3066 x = (LPSTR)SEGPTR_ALLOC(s-ofn->lpstrFilter); \
3067 memcpy(x,ofn->lpstrFilter,s-ofn->lpstrFilter); \
3068 ofn16->lpstrFilter = SEGPTR_GET(x); \
3070 if (ofn->lpstrCustomFilter) { \
3073 /* filter is a list... title\0ext\0......\0\0 */ \
3074 s = (LPSTR)ofn->lpstrCustomFilter; \
3076 s = s+strlen(s)+1; \
3077 x = SEGPTR_ALLOC(s-ofn->lpstrCustomFilter); \
3079 memcpy(x,ofn->lpstrCustomFilter,s-ofn->lpstrCustomFilter);\
3080 ofn16->lpstrCustomFilter = SEGPTR_GET(x); \
3082 ofn16->nMaxCustFilter = ofn->nMaxCustFilter; \
3083 ofn16->nFilterIndex = ofn->nFilterIndex; \
3084 ofn16->lpstrFile = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFile)); \
3085 ofn16->nMaxFile = ofn->nMaxFile; \
3086 if (ofn->lpstrFileTitle) \
3087 ofn16->lpstrFileTitle= SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrFileTitle));\
3088 ofn16->nMaxFileTitle = ofn->nMaxFileTitle; \
3089 if (ofn->lpstrInitialDir) \
3090 ofn16->lpstrInitialDir = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrInitialDir));\
3091 if (ofn->lpstrTitle) \
3092 ofn16->lpstrTitle = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrTitle));\
3093 ofn16->Flags = ofn->Flags|OFN_WINE32; \
3094 ofn16->nFileOffset = ofn->nFileOffset; \
3095 ofn16->nFileExtension = ofn->nFileExtension; \
3096 if (ofn->lpstrDefExt) \
3097 ofn16->lpstrDefExt = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrDefExt));\
3098 ofn16->lCustData = ofn->lCustData; \
3099 ofn16->lpfnHook = (WNDPROC16)ofn->lpfnHook; \
3101 if (ofn->lpTemplateName) \
3102 ofn16->lpTemplateName = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpTemplateName));\
3104 ret = xxx##16(SEGPTR_GET(ofn16)); \
3106 if (ofn16->lpstrFilter) \
3107 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFilter)); \
3108 if (ofn16->lpTemplateName) \
3109 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpTemplateName)); \
3110 if (ofn16->lpstrDefExt) \
3111 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrDefExt)); \
3112 if (ofn16->lpstrTitle) \
3113 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrTitle)); \
3114 if (ofn16->lpstrInitialDir) \
3115 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrInitialDir)); \
3116 if (ofn16->lpstrCustomFilter) \
3117 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrCustomFilter)); \
3119 strcpy(ofn->lpstrFile,PTR_SEG_TO_LIN(ofn16->lpstrFile)); \
3120 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFile)); \
3122 if (ofn16->lpstrFileTitle) \
3123 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFileTitle)); \
3124 SEGPTR_FREE(ofn16); \
3128 BOOL32 WINAPI xxx##32W( LPOPENFILENAME32W ofn ) \
3131 LPOPENFILENAME16 ofn16 = SEGPTR_ALLOC(sizeof(OPENFILENAME16)); \
3133 memset(ofn16,'\0',sizeof(*ofn16)); \
3134 ofn16->lStructSize = sizeof(*ofn16); \
3135 ofn16->hwndOwner = ofn->hwndOwner; \
3136 /* FIXME: OPENFILENAME16 got only 16 bit for HINSTANCE... */ \
3137 ofn16->hInstance = MODULE_HANDLEtoHMODULE16(ofn->hInstance); \
3138 if (ofn->lpstrFilter) { \
3143 /* filter is a list... title\0ext\0......\0\0 */ \
3144 s = (LPWSTR)ofn->lpstrFilter; \
3146 s = s+lstrlen32W(s)+1; \
3148 n = s - ofn->lpstrFilter; /* already divides by 2. ptr magic */\
3149 x = y = (LPSTR)SEGPTR_ALLOC(n); \
3150 s = (LPWSTR)ofn->lpstrFilter; \
3153 x+=lstrlen32A(x)+1; \
3154 s+=lstrlen32W(s)+1; \
3157 ofn16->lpstrFilter = SEGPTR_GET(y); \
3159 if (ofn->lpstrCustomFilter) { \
3164 /* filter is a list... title\0ext\0......\0\0 */ \
3165 s = (LPWSTR)ofn->lpstrCustomFilter; \
3167 s = s+lstrlen32W(s)+1; \
3169 n = s - ofn->lpstrCustomFilter; \
3170 x = y = (LPSTR)SEGPTR_ALLOC(n); \
3171 s = (LPWSTR)ofn->lpstrCustomFilter; \
3174 x+=lstrlen32A(x)+1; \
3175 s+=lstrlen32W(s)+1; \
3178 ofn16->lpstrCustomFilter = SEGPTR_GET(y); \
3180 ofn16->nMaxCustFilter = ofn->nMaxCustFilter; \
3181 ofn16->nFilterIndex = ofn->nFilterIndex; \
3182 ofn16->lpstrFile = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFile)); \
3183 ofn16->nMaxFile = ofn->nMaxFile; \
3184 if (ofn->lpstrFileTitle) \
3185 ofn16->lpstrFileTitle= SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrFileTitle));\
3186 ofn16->nMaxFileTitle = ofn->nMaxFileTitle; \
3187 if (ofn->lpstrInitialDir) \
3188 ofn16->lpstrInitialDir = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrInitialDir));\
3189 if (ofn->lpstrTitle) \
3190 ofn16->lpstrTitle = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrTitle));\
3191 ofn16->Flags = ofn->Flags|OFN_WINE32|OFN_UNICODE; \
3192 ofn16->nFileOffset = ofn->nFileOffset; \
3193 ofn16->nFileExtension = ofn->nFileExtension; \
3194 if (ofn->lpstrDefExt) \
3195 ofn16->lpstrDefExt = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrDefExt));\
3196 ofn16->lCustData = ofn->lCustData; \
3197 ofn16->lpfnHook = (WNDPROC16)ofn->lpfnHook; \
3198 if (ofn->lpTemplateName) { \
3199 ofn16->lpTemplateName = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpTemplateName));\
3201 ret = xxx##16(SEGPTR_GET(ofn16)); \
3203 if (ofn16->lpstrFilter) \
3204 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFilter)); \
3205 if (ofn16->lpTemplateName) \
3206 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpTemplateName)); \
3207 if (ofn16->lpstrDefExt) \
3208 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrDefExt)); \
3209 if (ofn16->lpstrTitle) \
3210 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrTitle)); \
3211 if (ofn16->lpstrInitialDir) \
3212 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrInitialDir)); \
3213 if (ofn16->lpstrCustomFilter) \
3214 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrCustomFilter)); \
3216 lstrcpyAtoW(ofn->lpstrFile,PTR_SEG_TO_LIN(ofn16->lpstrFile)); \
3217 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFile)); \
3219 if (ofn16->lpstrFileTitle) \
3220 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFileTitle)); \
3221 SEGPTR_FREE(ofn16); \
3225 GET_XXX_FILENAME(GetOpenFileName)
3226 GET_XXX_FILENAME(GetSaveFileName)