4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
24 static DWORD CommDlgLastError = 0;
26 static HBITMAP16 hFolder = 0;
27 static HBITMAP16 hFolder2 = 0;
28 static HBITMAP16 hFloppy = 0;
29 static HBITMAP16 hHDisk = 0;
30 static HBITMAP16 hCDRom = 0;
31 static HBITMAP16 hBitmapTT = 0;
32 static const char defaultfilter[]=" \0\0";
34 /***********************************************************************
35 * FileDlg_Init [internal]
37 static BOOL32 FileDlg_Init()
39 static BOOL32 initialized = 0;
42 if (!hFolder) hFolder = LoadBitmap16(0, MAKEINTRESOURCE16(OBM_FOLDER));
43 if (!hFolder2) hFolder2 = LoadBitmap16(0, MAKEINTRESOURCE16(OBM_FOLDER2));
44 if (!hFloppy) hFloppy = LoadBitmap16(0, MAKEINTRESOURCE16(OBM_FLOPPY));
45 if (!hHDisk) hHDisk = LoadBitmap16(0, MAKEINTRESOURCE16(OBM_HDISK));
46 if (!hCDRom) hCDRom = LoadBitmap16(0, MAKEINTRESOURCE16(OBM_CDROM));
47 if (hFolder == 0 || hFolder2 == 0 || hFloppy == 0 ||
48 hHDisk == 0 || hCDRom == 0)
50 WARN(commdlg, "Error loading bitmaps !\nprin");
58 /***********************************************************************
59 * GetOpenFileName (COMMDLG.1)
61 BOOL16 WINAPI GetOpenFileName16( SEGPTR ofn )
64 HANDLE32 hDlgTmpl = 0, hResInfo;
65 BOOL32 bRet = FALSE, win32Format = FALSE;
67 LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(ofn);
69 char defaultopen[]="Open File";
72 if (!lpofn || !FileDlg_Init()) return FALSE;
74 if (lpofn->Flags & OFN_WINE32) {
75 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
77 if (!(template = LockResource32( lpofn->hInstance )))
79 CommDlgLastError = CDERR_LOADRESFAILURE;
83 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
85 if (!(hResInfo = FindResource32A(lpofn->hInstance,
86 PTR_SEG_TO_LIN(lpofn->lpTemplateName), RT_DIALOG32A)))
88 CommDlgLastError = CDERR_FINDRESFAILURE;
91 if (!(hDlgTmpl = LoadResource32( lpofn->hInstance, hResInfo )) ||
92 !(template = LockResource32( hDlgTmpl )))
94 CommDlgLastError = CDERR_LOADRESFAILURE;
98 template = SYSRES_GetResPtr( SYSRES_DIALOG_OPEN_FILE );
102 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
104 if (!(template = LockResource16( lpofn->hInstance )))
106 CommDlgLastError = CDERR_LOADRESFAILURE;
110 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
112 if (!(hResInfo = FindResource16(lpofn->hInstance,
113 lpofn->lpTemplateName,
116 CommDlgLastError = CDERR_FINDRESFAILURE;
119 if (!(hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo )) ||
120 !(template = LockResource16( hDlgTmpl )))
122 CommDlgLastError = CDERR_LOADRESFAILURE;
126 template = SYSRES_GetResPtr( SYSRES_DIALOG_OPEN_FILE );
131 hInst = WIN_GetWindowInstance( lpofn->hwndOwner );
133 if (!(lpofn->lpstrFilter))
135 str = SEGPTR_ALLOC(sizeof(defaultfilter));
136 TRACE(commdlg,"Alloc %p default for Filetype in GetOpenFileName\n",str);
137 memcpy(str,defaultfilter,sizeof(defaultfilter));
138 lpofn->lpstrFilter=SEGPTR_GET(str);
141 if (!(lpofn->lpstrTitle))
143 str1 = SEGPTR_ALLOC(strlen(defaultopen)+1);
144 TRACE(commdlg,"Alloc %p default for Title in GetOpenFileName\n",str1);
145 strcpy(str1,defaultopen);
146 lpofn->lpstrTitle=SEGPTR_GET(str1);
149 /* FIXME: doesn't handle win32 format correctly yet */
150 hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
152 (DLGPROC16)MODULE_GetWndProcEntry16("FileOpenDlgProc"),
154 if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpofn->hwndOwner );
158 TRACE(commdlg,"Freeing %p default for Title in GetOpenFileName\n",str1);
165 TRACE(commdlg,"Freeing %p default for Filetype in GetOpenFileName\n",str);
167 lpofn->lpstrFilter=0;
171 if (lpofn->Flags & OFN_WINE32)
172 FreeResource32( hDlgTmpl );
174 FreeResource16( hDlgTmpl );
177 TRACE(commdlg,"return lpstrFile='%s' !\n",
178 (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
183 /***********************************************************************
184 * GetSaveFileName (COMMDLG.2)
186 BOOL16 WINAPI GetSaveFileName16( SEGPTR ofn)
189 HANDLE32 hDlgTmpl = 0;
190 BOOL32 bRet = FALSE, win32Format = FALSE;
191 LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(ofn);
194 char defaultsave[]="Save as";
195 char *str =0,*str1=0;
197 if (!lpofn || !FileDlg_Init()) return FALSE;
199 if (lpofn->Flags & OFN_WINE32) {
200 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
202 if (!(template = LockResource32( lpofn->hInstance )))
204 CommDlgLastError = CDERR_LOADRESFAILURE;
208 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
211 if (!(hResInfo = FindResource32A(lpofn->hInstance,
212 PTR_SEG_TO_LIN(lpofn->lpTemplateName),
215 CommDlgLastError = CDERR_FINDRESFAILURE;
218 if (!(hDlgTmpl = LoadResource32(lpofn->hInstance,hResInfo)) ||
219 !(template = LockResource32(hDlgTmpl)))
221 CommDlgLastError = CDERR_LOADRESFAILURE;
226 template = SYSRES_GetResPtr( SYSRES_DIALOG_SAVE_FILE );
230 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
232 if (!(template = LockResource16( lpofn->hInstance )))
234 CommDlgLastError = CDERR_LOADRESFAILURE;
238 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
241 if (!(hResInfo = FindResource16(lpofn->hInstance,
242 lpofn->lpTemplateName,
245 CommDlgLastError = CDERR_FINDRESFAILURE;
248 if (!(hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo )) ||
249 !(template = LockResource16( hDlgTmpl )))
251 CommDlgLastError = CDERR_LOADRESFAILURE;
255 template = SYSRES_GetResPtr( SYSRES_DIALOG_SAVE_FILE );
260 hInst = WIN_GetWindowInstance( lpofn->hwndOwner );
262 if (!(lpofn->lpstrFilter))
264 str = SEGPTR_ALLOC(sizeof(defaultfilter));
265 TRACE(commdlg,"Alloc default for Filetype in GetSaveFileName\n");
266 memcpy(str,defaultfilter,sizeof(defaultfilter));
267 lpofn->lpstrFilter=SEGPTR_GET(str);
270 if (!(lpofn->lpstrTitle))
272 str1 = SEGPTR_ALLOC(sizeof(defaultsave)+1);
273 TRACE(commdlg,"Alloc default for Title in GetSaveFileName\n");
274 strcpy(str1,defaultsave);
275 lpofn->lpstrTitle=SEGPTR_GET(str1);
278 hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
280 (DLGPROC16)MODULE_GetWndProcEntry16("FileSaveDlgProc"),
282 if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpofn->hwndOwner );
286 TRACE(commdlg,"Freeing %p default for Title in GetSaveFileName\n",str1);
293 TRACE(commdlg,"Freeing %p default for Filetype in GetSaveFileName\n",str);
295 lpofn->lpstrFilter=0;
299 if (lpofn->Flags & OFN_WINE32)
300 FreeResource32( hDlgTmpl );
302 FreeResource16( hDlgTmpl );
305 TRACE(commdlg, "return lpstrFile='%s' !\n",
306 (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
310 /***********************************************************************
311 * FILEDLG_StripEditControl [internal]
312 * Strip pathnames off the contents of the edit control.
314 static void FILEDLG_StripEditControl(HWND16 hwnd)
318 GetDlgItemText32A( hwnd, edt1, temp, sizeof(temp) );
319 cp = strrchr(temp, '\\');
323 cp = strrchr(temp, ':');
327 /* FIXME: shouldn't we do something with the result here? ;-) */
330 /***********************************************************************
331 * FILEDLG_ScanDir [internal]
333 static BOOL32 FILEDLG_ScanDir(HWND16 hWnd, LPSTR newPath)
338 lstrcpyn32A( str, newPath, 512 );
340 GetDlgItemText32A( hWnd, edt1, str + len, sizeof(str) - len );
341 if (!DlgDirList32A( hWnd, str, lst1, 0, 0x0000 )) return FALSE;
342 strcpy( str, "*.*" );
343 return DlgDirList32A( hWnd, str, lst2, stc1, 0x8010 );
346 /***********************************************************************
347 * FILEDLG_GetFileType [internal]
350 static LPSTR FILEDLG_GetFileType(LPSTR cfptr, LPSTR fptr, WORD index)
355 for ( ;(n = strlen(cfptr)) != 0; i++)
360 cfptr += strlen(cfptr) + 1;
363 for ( ;(n = strlen(fptr)) != 0; i++)
368 fptr += strlen(fptr) + 1;
370 return "*.*"; /* FIXME */
373 /***********************************************************************
374 * FILEDLG_WMDrawItem [internal]
376 static LONG FILEDLG_WMDrawItem(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam,int savedlg)
378 LPDRAWITEMSTRUCT16 lpdis = (LPDRAWITEMSTRUCT16)PTR_SEG_TO_LIN(lParam);
381 HBITMAP16 hBitmap, hPrevBitmap;
385 if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst1)
387 if (!(str = SEGPTR_ALLOC(512))) return FALSE;
388 hBrush = SelectObject32(lpdis->hDC, GetStockObject32(LTGRAY_BRUSH));
389 SelectObject32(lpdis->hDC, hBrush);
390 FillRect16(lpdis->hDC, &lpdis->rcItem, hBrush);
391 SendMessage16(lpdis->hwndItem, LB_GETTEXT16, lpdis->itemID,
392 (LPARAM)SEGPTR_GET(str));
394 if (savedlg) /* use _gray_ text in FileSaveDlg */
395 if (!lpdis->itemState)
396 SetTextColor32(lpdis->hDC,GetSysColor32(COLOR_GRAYTEXT) );
398 SetTextColor32(lpdis->hDC,GetSysColor32(COLOR_WINDOWTEXT) );
399 /* inversion of gray would be bad readable */
401 TextOut16(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
403 if (lpdis->itemState != 0) {
404 InvertRect16(lpdis->hDC, &lpdis->rcItem);
410 if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst2)
412 if (!(str = SEGPTR_ALLOC(512))) return FALSE;
413 hBrush = SelectObject32(lpdis->hDC, GetStockObject32(LTGRAY_BRUSH));
414 SelectObject32(lpdis->hDC, hBrush);
415 FillRect16(lpdis->hDC, &lpdis->rcItem, hBrush);
416 SendMessage16(lpdis->hwndItem, LB_GETTEXT16, lpdis->itemID,
417 (LPARAM)SEGPTR_GET(str));
420 GetObject16( hBitmap, sizeof(bm), &bm );
421 TextOut16(lpdis->hDC, lpdis->rcItem.left + bm.bmWidth,
422 lpdis->rcItem.top, str, strlen(str));
423 hMemDC = CreateCompatibleDC32(lpdis->hDC);
424 hPrevBitmap = SelectObject32(hMemDC, hBitmap);
425 BitBlt32(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
426 bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
427 SelectObject32(hMemDC, hPrevBitmap);
429 if (lpdis->itemState != 0) InvertRect16(lpdis->hDC, &lpdis->rcItem);
433 if (lpdis->CtlType == ODT_COMBOBOX && lpdis->CtlID == cmb2)
435 if (!(str = SEGPTR_ALLOC(512))) return FALSE;
436 hBrush = SelectObject32(lpdis->hDC, GetStockObject32(LTGRAY_BRUSH));
437 SelectObject32(lpdis->hDC, hBrush);
438 FillRect16(lpdis->hDC, &lpdis->rcItem, hBrush);
439 SendMessage16(lpdis->hwndItem, CB_GETLBTEXT16, lpdis->itemID,
440 (LPARAM)SEGPTR_GET(str));
441 switch(DRIVE_GetType( str[2] - 'a' ))
443 case TYPE_FLOPPY: hBitmap = hFloppy; break;
444 case TYPE_CDROM: hBitmap = hCDRom; break;
447 default: hBitmap = hHDisk; break;
449 GetObject16( hBitmap, sizeof(bm), &bm );
450 TextOut16(lpdis->hDC, lpdis->rcItem.left + bm.bmWidth,
451 lpdis->rcItem.top, str, strlen(str));
452 hMemDC = CreateCompatibleDC32(lpdis->hDC);
453 hPrevBitmap = SelectObject32(hMemDC, hBitmap);
454 BitBlt32( lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
455 bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY );
456 SelectObject32(hMemDC, hPrevBitmap);
458 if (lpdis->itemState != 0) InvertRect16(lpdis->hDC, &lpdis->rcItem);
465 /***********************************************************************
466 * FILEDLG_WMMeasureItem [internal]
468 static LONG FILEDLG_WMMeasureItem(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
471 LPMEASUREITEMSTRUCT16 lpmeasure;
473 GetObject16( hFolder2, sizeof(bm), &bm );
474 lpmeasure = (LPMEASUREITEMSTRUCT16)PTR_SEG_TO_LIN(lParam);
475 lpmeasure->itemHeight = bm.bmHeight;
479 /***********************************************************************
480 * FILEDLG_HookCallChk [internal]
482 static int FILEDLG_HookCallChk(LPOPENFILENAME16 lpofn)
485 if (lpofn->Flags & OFN_ENABLEHOOK)
491 /***********************************************************************
492 * FILEDLG_CallWindowProc [internal]
494 * Adapt the structures back for win32 calls so the callee can read lpCustData
496 static BOOL32 FILEDLG_CallWindowProc(LPOPENFILENAME16 lpofn,HWND32 hwnd,
497 UINT32 wMsg,WPARAM32 wParam,LPARAM lParam
502 needstruct = (PTR_SEG_TO_LIN(lParam) == lpofn);
504 if (!(lpofn->Flags & OFN_WINE32))
505 return (BOOL32)CallWindowProc16(
506 lpofn->lpfnHook,hwnd,(UINT16)wMsg,(WPARAM16)wParam,lParam
509 if (lpofn->Flags & OFN_UNICODE) {
511 OPENFILENAME32W ofnw;
513 /* FIXME: probably needs more converted */
514 ofnw.lCustData = lpofn->lCustData;
515 return (BOOL32)CallWindowProc32W(
516 (WNDPROC32)lpofn->lpfnHook,hwnd,wMsg,wParam,(LPARAM)&ofnw
519 return (BOOL32)CallWindowProc32W(
520 (WNDPROC32)lpofn->lpfnHook,hwnd,wMsg,wParam,lParam
525 OPENFILENAME32A ofna;
527 /* FIXME: probably needs more converted */
528 ofna.lCustData = lpofn->lCustData;
529 return (BOOL32)CallWindowProc32A(
530 (WNDPROC32)lpofn->lpfnHook,hwnd,wMsg,wParam,(LPARAM)&ofna
533 return (BOOL32)CallWindowProc32A(
534 (WNDPROC32)lpofn->lpfnHook,hwnd,wMsg,wParam,lParam
539 /***********************************************************************
540 * FILEDLG_WMInitDialog [internal]
543 static LONG FILEDLG_WMInitDialog(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
546 LPOPENFILENAME16 lpofn;
548 LPSTR pstr, old_pstr;
549 SetWindowLong32A(hWnd, DWL_USER, lParam);
550 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(lParam);
551 if (lpofn->lpstrTitle) SetWindowText16( hWnd, lpofn->lpstrTitle );
552 /* read custom filter information */
553 if (lpofn->lpstrCustomFilter)
555 pstr = (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter);
557 TRACE(commdlg,"lpstrCustomFilter = %p\n", pstr);
561 i = SendDlgItemMessage16(hWnd, cmb1, CB_ADDSTRING16, 0,
562 (LPARAM)lpofn->lpstrCustomFilter + n );
563 n += strlen(pstr) + 1;
564 pstr += strlen(pstr) + 1;
565 TRACE(commdlg,"add str='%s' "
566 "associated to '%s'\n", old_pstr, pstr);
567 SendDlgItemMessage16(hWnd, cmb1, CB_SETITEMDATA16, i, (LPARAM)pstr);
568 n += strlen(pstr) + 1;
569 pstr += strlen(pstr) + 1;
572 /* read filter information */
573 if (lpofn->lpstrFilter) {
574 pstr = (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFilter);
578 i = SendDlgItemMessage16(hWnd, cmb1, CB_ADDSTRING16, 0,
579 (LPARAM)lpofn->lpstrFilter + n );
580 n += strlen(pstr) + 1;
581 pstr += strlen(pstr) + 1;
582 TRACE(commdlg,"add str='%s' "
583 "associated to '%s'\n", old_pstr, pstr);
584 SendDlgItemMessage16(hWnd, cmb1, CB_SETITEMDATA16, i, (LPARAM)pstr);
585 n += strlen(pstr) + 1;
586 pstr += strlen(pstr) + 1;
589 /* set default filter */
590 if (lpofn->nFilterIndex == 0 && lpofn->lpstrCustomFilter == (SEGPTR)NULL)
591 lpofn->nFilterIndex = 1;
592 SendDlgItemMessage16(hWnd, cmb1, CB_SETCURSEL16, lpofn->nFilterIndex - 1, 0);
593 strncpy(tmpstr, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter),
594 PTR_SEG_TO_LIN(lpofn->lpstrFilter), lpofn->nFilterIndex - 1),511);
596 TRACE(commdlg,"nFilterIndex = %ld, SetText of edt1 to '%s'\n",
597 lpofn->nFilterIndex, tmpstr);
598 SetDlgItemText32A( hWnd, edt1, tmpstr );
601 DlgDirListComboBox32A(hWnd, tmpstr, cmb2, 0, 0xC000);
602 /* read initial directory */
603 if (PTR_SEG_TO_LIN(lpofn->lpstrInitialDir) != NULL)
605 strncpy(tmpstr, PTR_SEG_TO_LIN(lpofn->lpstrInitialDir), 510);
607 if (strlen(tmpstr) > 0 && tmpstr[strlen(tmpstr)-1] != '\\'
608 && tmpstr[strlen(tmpstr)-1] != ':')
613 if (!FILEDLG_ScanDir(hWnd, tmpstr)) {
615 if (!FILEDLG_ScanDir(hWnd, tmpstr))
616 WARN(commdlg, "Couldn't read initial directory %s!\n",tmpstr);
618 /* select current drive in combo 2, omit missing drives */
619 for(i=0, n=-1; i<=DRIVE_GetCurrentDrive(); i++)
620 if (DRIVE_IsValid(i)) n++;
621 SendDlgItemMessage16(hWnd, cmb2, CB_SETCURSEL16, n, 0);
622 if (!(lpofn->Flags & OFN_SHOWHELP))
623 ShowWindow32(GetDlgItem32(hWnd, pshHelp), SW_HIDE);
624 if (lpofn->Flags & OFN_HIDEREADONLY)
625 ShowWindow32(GetDlgItem32(hWnd, chx1), SW_HIDE);
626 if (FILEDLG_HookCallChk(lpofn))
627 return (BOOL16)FILEDLG_CallWindowProc(lpofn,hWnd,WM_INITDIALOG,wParam,lParam );
632 /***********************************************************************
633 * FILEDLG_WMCommand [internal]
635 BOOL32 in_update=FALSE;
637 static LRESULT FILEDLG_WMCommand(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
640 LPOPENFILENAME16 lpofn;
642 char tmpstr[512], tmpstr2[512];
644 UINT16 control,notification;
646 /* Notifications are packaged differently in Win32 */
648 notification = HIWORD(lParam);
650 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
653 case lst1: /* file list */
654 FILEDLG_StripEditControl(hWnd);
655 if (notification == LBN_DBLCLK)
657 lRet = SendDlgItemMessage16(hWnd, lst1, LB_GETCURSEL16, 0, 0);
658 if (lRet == LB_ERR) return TRUE;
659 if ((pstr = SEGPTR_ALLOC(512)))
661 SendDlgItemMessage16(hWnd, lst1, LB_GETTEXT16, lRet,
662 (LPARAM)SEGPTR_GET(pstr));
663 SetDlgItemText32A( hWnd, edt1, pstr );
666 if (FILEDLG_HookCallChk(lpofn))
667 FILEDLG_CallWindowProc(lpofn,hWnd,
668 RegisterWindowMessage32A( LBSELCHSTRING ),
669 control, MAKELONG(lRet,CD_LBSELCHANGE));
670 /* FIXME: for OFN_ALLOWMULTISELECT we need CD_LBSELSUB, CD_SELADD, CD_LBSELNOITEMS */
672 case lst2: /* directory list */
673 FILEDLG_StripEditControl(hWnd);
674 if (notification == LBN_DBLCLK)
676 lRet = SendDlgItemMessage16(hWnd, lst2, LB_GETCURSEL16, 0, 0);
677 if (lRet == LB_ERR) return TRUE;
678 pstr = SEGPTR_ALLOC(512);
679 SendDlgItemMessage16(hWnd, lst2, LB_GETTEXT16, lRet,
680 (LPARAM)SEGPTR_GET(pstr));
681 strcpy( tmpstr, pstr );
683 if (tmpstr[0] == '[')
685 tmpstr[strlen(tmpstr) - 1] = 0;
686 strcpy(tmpstr,tmpstr+1);
688 strcat(tmpstr, "\\");
692 case cmb1: /* file type drop list */
693 if (notification == CBN_SELCHANGE)
703 case cmb2: /* disk drop list */
704 FILEDLG_StripEditControl(hWnd);
705 lRet = SendDlgItemMessage16(hWnd, cmb2, CB_GETCURSEL16, 0, 0L);
706 if (lRet == LB_ERR) return 0;
707 pstr = SEGPTR_ALLOC(512);
708 SendDlgItemMessage16(hWnd, cmb2, CB_GETLBTEXT16, lRet,
709 (LPARAM)SEGPTR_GET(pstr));
710 sprintf(tmpstr, "%c:", pstr[2]);
713 lRet = SendDlgItemMessage16(hWnd, cmb1, CB_GETCURSEL16, 0, 0);
716 pstr = (LPSTR)SendDlgItemMessage16(hWnd, cmb1, CB_GETITEMDATA16, lRet, 0);
717 TRACE(commdlg,"Selected filter : %s\n", pstr);
718 SetDlgItemText32A( hWnd, edt1, pstr );
719 FILEDLG_ScanDir(hWnd, tmpstr);
723 ofn2=*lpofn; /* for later restoring */
724 GetDlgItemText32A( hWnd, edt1, tmpstr, sizeof(tmpstr) );
725 pstr = strrchr(tmpstr, '\\');
727 pstr = strrchr(tmpstr, ':');
728 if (strchr(tmpstr,'*') != NULL || strchr(tmpstr,'?') != NULL)
730 /* edit control contains wildcards */
733 strncpy(tmpstr2, pstr+1, 511); tmpstr2[511]=0;
738 strcpy(tmpstr2, tmpstr);
741 TRACE(commdlg,"tmpstr=%s, tmpstr2=%s\n", tmpstr, tmpstr2);
742 SetDlgItemText32A( hWnd, edt1, tmpstr2 );
743 FILEDLG_ScanDir(hWnd, tmpstr);
746 /* no wildcards, we might have a directory or a filename */
747 /* try appending a wildcard and reading the directory */
748 pstr2 = tmpstr + strlen(tmpstr);
749 if (pstr == NULL || *(pstr+1) != 0)
750 strcat(tmpstr, "\\");
751 lRet = SendDlgItemMessage16(hWnd, cmb1, CB_GETCURSEL16, 0, 0);
752 if (lRet == LB_ERR) return TRUE;
753 lpofn->nFilterIndex = lRet + 1;
754 TRACE(commdlg,"lpofn->nFilterIndex=%ld\n", lpofn->nFilterIndex);
756 FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter),
757 PTR_SEG_TO_LIN(lpofn->lpstrFilter),
758 lRet), sizeof(tmpstr2));
759 SetDlgItemText32A( hWnd, edt1, tmpstr2 );
761 /* if ScanDir succeeds, we have changed the directory */
762 if (FILEDLG_ScanDir(hWnd, tmpstr)) return TRUE;
763 /* if not, this must be a filename */
767 /* strip off the pathname */
769 SetDlgItemText32A( hWnd, edt1, pstr + 1 );
770 lstrcpyn32A(tmpstr2, pstr+1, sizeof(tmpstr2) );
771 /* Should we MessageBox() if this fails? */
772 if (!FILEDLG_ScanDir(hWnd, tmpstr)) return TRUE;
773 strcpy(tmpstr, tmpstr2);
775 else SetDlgItemText32A( hWnd, edt1, tmpstr );
777 ShowWindow16(hWnd, SW_HIDE); /* this should not be necessary ?! (%%%) */
780 int drive = DRIVE_GetCurrentDrive();
781 tmpstr2[0] = 'A'+ drive;
784 strncpy(tmpstr2 + 3, DRIVE_GetDosCwd(drive), 507); tmpstr2[510]=0;
785 if (strlen(tmpstr2) > 3)
786 strcat(tmpstr2, "\\");
787 strncat(tmpstr2, tmpstr, 511-strlen(tmpstr2)); tmpstr2[511]=0;
788 if (lpofn->lpstrFile)
789 lstrcpyn32A(PTR_SEG_TO_LIN(lpofn->lpstrFile), tmpstr2,lpofn->nMaxFile);
791 lpofn->nFileOffset = strrchr(tmpstr2,'\\') - tmpstr2 +1;
792 lpofn->nFileExtension = 0;
793 while(tmpstr2[lpofn->nFileExtension] != '.' && tmpstr2[lpofn->nFileExtension] != '\0')
794 lpofn->nFileExtension++;
795 if (lpofn->nFileExtension == '\0')
796 lpofn->nFileExtension = 0;
798 lpofn->nFileExtension++;
802 if (FILEDLG_HookCallChk(lpofn))
803 FILEDLG_CallWindowProc(lpofn,hWnd,
804 RegisterWindowMessage32A( LBSELCHSTRING ),
805 control, MAKELONG(lRet,CD_LBSELCHANGE));
810 if (PTR_SEG_TO_LIN(lpofn->lpstrFileTitle) != NULL)
812 lRet = SendDlgItemMessage16(hWnd, lst1, LB_GETCURSEL16, 0, 0);
813 SendDlgItemMessage16(hWnd, lst1, LB_GETTEXT16, lRet,
814 lpofn->lpstrFileTitle );
816 if (FILEDLG_HookCallChk(lpofn))
818 lRet= (BOOL16)FILEDLG_CallWindowProc(lpofn,
819 hWnd, RegisterWindowMessage32A( FILEOKSTRING ), 0, lParam );
822 *lpofn=ofn2; /* restore old state */
824 ShowWindow16(hWnd, SW_SHOW); /* only if above (%%%) SW_HIDE used */
829 EndDialog32(hWnd, TRUE);
832 EndDialog32(hWnd, FALSE);
839 /***********************************************************************
840 * FileOpenDlgProc (COMMDLG.6)
842 LRESULT WINAPI FileOpenDlgProc(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
845 LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
847 if (wMsg!=WM_INITDIALOG)
848 if (FILEDLG_HookCallChk(lpofn))
850 LRESULT lRet=(BOOL16)FILEDLG_CallWindowProc(lpofn,hWnd,wMsg,wParam,lParam);
852 return lRet; /* else continue message processing */
857 return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
859 return FILEDLG_WMMeasureItem(hWnd, wParam, lParam);
861 return FILEDLG_WMDrawItem(hWnd, wParam, lParam, FALSE);
863 return FILEDLG_WMCommand(hWnd, wParam, lParam);
866 SetBkColor((HDC16)wParam, 0x00C0C0C0);
867 switch (HIWORD(lParam))
870 SetTextColor((HDC16)wParam, 0x00000000);
872 case CTLCOLOR_STATIC:
873 SetTextColor((HDC16)wParam, 0x00000000);
883 /***********************************************************************
884 * FileSaveDlgProc (COMMDLG.7)
886 LRESULT WINAPI FileSaveDlgProc(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
889 LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
891 if (wMsg!=WM_INITDIALOG)
892 if (FILEDLG_HookCallChk(lpofn))
894 LRESULT lRet=(BOOL16)FILEDLG_CallWindowProc(lpofn,hWnd,wMsg,wParam,lParam);
896 return lRet; /* else continue message processing */
900 return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
903 return FILEDLG_WMMeasureItem(hWnd, wParam, lParam);
906 return FILEDLG_WMDrawItem(hWnd, wParam, lParam, TRUE);
909 return FILEDLG_WMCommand(hWnd, wParam, lParam);
914 SetBkColor((HDC16)wParam, 0x00C0C0C0);
915 switch (HIWORD(lParam))
918 SetTextColor((HDC16)wParam, 0x00000000);
920 case CTLCOLOR_STATIC:
921 SetTextColor((HDC16)wParam, 0x00000000);
931 /***********************************************************************
932 * FindText16 (COMMDLG.11)
934 HWND16 WINAPI FindText16( SEGPTR find )
938 LPFINDREPLACE16 lpFind = (LPFINDREPLACE16)PTR_SEG_TO_LIN(find);
941 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
942 * For now, only the standard dialog works.
944 if (lpFind->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE |
945 FR_ENABLEHOOK)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
946 ptr = SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT );
947 hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
948 return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
949 (DLGPROC16)MODULE_GetWndProcEntry16("FindTextDlgProc"),
953 /***********************************************************************
954 * FindText32A (COMMDLG.6)
956 HWND32 WINAPI FindText32A( LPFINDREPLACE32A lpFind )
962 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
963 * For now, only the standard dialog works.
965 if (lpFind->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE |
966 FR_ENABLEHOOK)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
967 ptr = SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT );
968 hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
969 return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
970 (DLGPROC16)FindTextDlgProc32A, (LPARAM)lpFind, WIN_PROC_32A );
973 /***********************************************************************
974 * FindText32W (COMMDLG.7)
976 HWND32 WINAPI FindText32W( LPFINDREPLACE32W lpFind )
982 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
983 * For now, only the standard dialog works.
985 if (lpFind->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE |
986 FR_ENABLEHOOK)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
987 ptr = SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT );
988 hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
989 return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
990 (DLGPROC16)FindTextDlgProc32W, (LPARAM)lpFind, WIN_PROC_32W );
993 /***********************************************************************
994 * ReplaceText16 (COMMDLG.12)
996 HWND16 WINAPI ReplaceText16( SEGPTR find )
1000 LPFINDREPLACE16 lpFind = (LPFINDREPLACE16)PTR_SEG_TO_LIN(find);
1003 * FIXME : We should do error checking on the lpFind structure here
1004 * and make CommDlgExtendedError() return the error condition.
1006 if (lpFind->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE |
1007 FR_ENABLEHOOK)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
1008 ptr = SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT );
1009 hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
1010 return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
1011 (DLGPROC16)MODULE_GetWndProcEntry16("ReplaceTextDlgProc"),
1012 find, WIN_PROC_16 );
1015 /***********************************************************************
1016 * ReplaceText32A (COMDLG32.19)
1018 HWND32 WINAPI ReplaceText32A( LPFINDREPLACE32A lpFind )
1024 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
1025 * For now, only the standard dialog works.
1027 if (lpFind->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE |
1028 FR_ENABLEHOOK)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
1029 ptr = SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT );
1030 hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
1031 return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
1032 (DLGPROC16)ReplaceTextDlgProc32A, (LPARAM)lpFind, WIN_PROC_32A );
1035 /***********************************************************************
1036 * ReplaceText32W (COMDLG32.20)
1038 HWND32 WINAPI ReplaceText32W( LPFINDREPLACE32W lpFind )
1044 * FIXME : We should do error checking on the lpFind structure here
1045 * and make CommDlgExtendedError() return the error condition.
1047 if (lpFind->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE |
1048 FR_ENABLEHOOK)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
1049 ptr = SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT );
1050 hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
1051 return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
1052 (DLGPROC16)ReplaceTextDlgProc32W, (LPARAM)lpFind, WIN_PROC_32W );
1056 /***********************************************************************
1057 * FINDDLG_WMInitDialog [internal]
1059 static LRESULT FINDDLG_WMInitDialog(HWND32 hWnd, LPARAM lParam, LPDWORD lpFlags,
1060 LPSTR lpstrFindWhat, BOOL32 fUnicode)
1062 SetWindowLong32A(hWnd, DWL_USER, lParam);
1063 *lpFlags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
1065 * FIXME : If the initial FindWhat string is empty, we should disable the
1066 * FindNext (IDOK) button. Only after typing some text, the button should be
1069 if (fUnicode) SetDlgItemText32W(hWnd, edt1, (LPWSTR)lpstrFindWhat);
1070 else SetDlgItemText32A(hWnd, edt1, lpstrFindWhat);
1071 CheckRadioButton32(hWnd, rad1, rad2, (*lpFlags & FR_DOWN) ? rad2 : rad1);
1072 if (*lpFlags & (FR_HIDEUPDOWN | FR_NOUPDOWN)) {
1073 EnableWindow32(GetDlgItem32(hWnd, rad1), FALSE);
1074 EnableWindow32(GetDlgItem32(hWnd, rad2), FALSE);
1076 if (*lpFlags & FR_HIDEUPDOWN) {
1077 ShowWindow32(GetDlgItem32(hWnd, rad1), SW_HIDE);
1078 ShowWindow32(GetDlgItem32(hWnd, rad2), SW_HIDE);
1079 ShowWindow32(GetDlgItem32(hWnd, grp1), SW_HIDE);
1081 CheckDlgButton32(hWnd, chx1, (*lpFlags & FR_WHOLEWORD) ? 1 : 0);
1082 if (*lpFlags & (FR_HIDEWHOLEWORD | FR_NOWHOLEWORD))
1083 EnableWindow32(GetDlgItem32(hWnd, chx1), FALSE);
1084 if (*lpFlags & FR_HIDEWHOLEWORD)
1085 ShowWindow32(GetDlgItem32(hWnd, chx1), SW_HIDE);
1086 CheckDlgButton32(hWnd, chx2, (*lpFlags & FR_MATCHCASE) ? 1 : 0);
1087 if (*lpFlags & (FR_HIDEMATCHCASE | FR_NOMATCHCASE))
1088 EnableWindow32(GetDlgItem32(hWnd, chx2), FALSE);
1089 if (*lpFlags & FR_HIDEMATCHCASE)
1090 ShowWindow32(GetDlgItem32(hWnd, chx2), SW_HIDE);
1091 if (!(*lpFlags & FR_SHOWHELP)) {
1092 EnableWindow32(GetDlgItem32(hWnd, pshHelp), FALSE);
1093 ShowWindow32(GetDlgItem32(hWnd, pshHelp), SW_HIDE);
1095 ShowWindow32(hWnd, SW_SHOWNORMAL);
1100 /***********************************************************************
1101 * FINDDLG_WMCommand [internal]
1103 static LRESULT FINDDLG_WMCommand(HWND32 hWnd, WPARAM32 wParam,
1104 HWND32 hwndOwner, LPDWORD lpFlags,
1105 LPSTR lpstrFindWhat, WORD wFindWhatLen,
1108 int uFindReplaceMessage = RegisterWindowMessage32A( FINDMSGSTRING );
1109 int uHelpMessage = RegisterWindowMessage32A( HELPMSGSTRING );
1114 GetDlgItemText32W(hWnd, edt1, (LPWSTR)lpstrFindWhat, wFindWhatLen/2);
1115 else GetDlgItemText32A(hWnd, edt1, lpstrFindWhat, wFindWhatLen);
1116 if (IsDlgButtonChecked32(hWnd, rad2))
1117 *lpFlags |= FR_DOWN;
1118 else *lpFlags &= ~FR_DOWN;
1119 if (IsDlgButtonChecked32(hWnd, chx1))
1120 *lpFlags |= FR_WHOLEWORD;
1121 else *lpFlags &= ~FR_WHOLEWORD;
1122 if (IsDlgButtonChecked32(hWnd, chx2))
1123 *lpFlags |= FR_MATCHCASE;
1124 else *lpFlags &= ~FR_MATCHCASE;
1125 *lpFlags &= ~(FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
1126 *lpFlags |= FR_FINDNEXT;
1127 SendMessage32A(hwndOwner, uFindReplaceMessage, 0,
1128 GetWindowLong32A(hWnd, DWL_USER) );
1131 *lpFlags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL);
1132 *lpFlags |= FR_DIALOGTERM;
1133 SendMessage32A(hwndOwner, uFindReplaceMessage, 0,
1134 GetWindowLong32A(hWnd, DWL_USER) );
1135 DestroyWindow32(hWnd);
1138 /* FIXME : should lpfr structure be passed as an argument ??? */
1139 SendMessage32A(hwndOwner, uHelpMessage, 0, 0);
1146 /***********************************************************************
1147 * FindTextDlgProc16 (COMMDLG.13)
1149 LRESULT WINAPI FindTextDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
1152 LPFINDREPLACE16 lpfr;
1155 lpfr=(LPFINDREPLACE16)PTR_SEG_TO_LIN(lParam);
1156 return FINDDLG_WMInitDialog(hWnd, lParam, &(lpfr->Flags),
1157 PTR_SEG_TO_LIN(lpfr->lpstrFindWhat), FALSE);
1159 lpfr=(LPFINDREPLACE16)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
1160 return FINDDLG_WMCommand(hWnd, wParam, lpfr->hwndOwner,
1161 &lpfr->Flags, PTR_SEG_TO_LIN(lpfr->lpstrFindWhat),
1162 lpfr->wFindWhatLen, FALSE);
1167 /***********************************************************************
1168 * FindTextDlgProc32A
1170 LRESULT WINAPI FindTextDlgProc32A(HWND32 hWnd, UINT32 wMsg, WPARAM32 wParam,
1173 LPFINDREPLACE32A lpfr;
1176 lpfr=(LPFINDREPLACE32A)lParam;
1177 return FINDDLG_WMInitDialog(hWnd, lParam, &(lpfr->Flags),
1178 lpfr->lpstrFindWhat, FALSE);
1180 lpfr=(LPFINDREPLACE32A)GetWindowLong32A(hWnd, DWL_USER);
1181 return FINDDLG_WMCommand(hWnd, wParam, lpfr->hwndOwner,
1182 &lpfr->Flags, lpfr->lpstrFindWhat, lpfr->wFindWhatLen,
1188 /***********************************************************************
1189 * FindTextDlgProc32W
1191 LRESULT WINAPI FindTextDlgProc32W(HWND32 hWnd, UINT32 wMsg, WPARAM32 wParam,
1194 LPFINDREPLACE32W lpfr;
1197 lpfr=(LPFINDREPLACE32W)lParam;
1198 return FINDDLG_WMInitDialog(hWnd, lParam, &(lpfr->Flags),
1199 (LPSTR)lpfr->lpstrFindWhat, TRUE);
1201 lpfr=(LPFINDREPLACE32W)GetWindowLong32A(hWnd, DWL_USER);
1202 return FINDDLG_WMCommand(hWnd, wParam, lpfr->hwndOwner,
1203 &lpfr->Flags, (LPSTR)lpfr->lpstrFindWhat, lpfr->wFindWhatLen,
1210 /***********************************************************************
1211 * REPLACEDLG_WMInitDialog [internal]
1213 static LRESULT REPLACEDLG_WMInitDialog(HWND32 hWnd, LPARAM lParam,
1214 LPDWORD lpFlags, LPSTR lpstrFindWhat,
1215 LPSTR lpstrReplaceWith, BOOL32 fUnicode)
1217 SetWindowLong32A(hWnd, DWL_USER, lParam);
1218 *lpFlags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
1220 * FIXME : If the initial FindWhat string is empty, we should disable the FinNext /
1221 * Replace / ReplaceAll buttons. Only after typing some text, the buttons should be
1226 SetDlgItemText32W(hWnd, edt1, (LPWSTR)lpstrFindWhat);
1227 SetDlgItemText32W(hWnd, edt2, (LPWSTR)lpstrReplaceWith);
1230 SetDlgItemText32A(hWnd, edt1, lpstrFindWhat);
1231 SetDlgItemText32A(hWnd, edt2, lpstrReplaceWith);
1233 CheckDlgButton32(hWnd, chx1, (*lpFlags & FR_WHOLEWORD) ? 1 : 0);
1234 if (*lpFlags & (FR_HIDEWHOLEWORD | FR_NOWHOLEWORD))
1235 EnableWindow32(GetDlgItem32(hWnd, chx1), FALSE);
1236 if (*lpFlags & FR_HIDEWHOLEWORD)
1237 ShowWindow32(GetDlgItem32(hWnd, chx1), SW_HIDE);
1238 CheckDlgButton32(hWnd, chx2, (*lpFlags & FR_MATCHCASE) ? 1 : 0);
1239 if (*lpFlags & (FR_HIDEMATCHCASE | FR_NOMATCHCASE))
1240 EnableWindow32(GetDlgItem32(hWnd, chx2), FALSE);
1241 if (*lpFlags & FR_HIDEMATCHCASE)
1242 ShowWindow32(GetDlgItem32(hWnd, chx2), SW_HIDE);
1243 if (!(*lpFlags & FR_SHOWHELP)) {
1244 EnableWindow32(GetDlgItem32(hWnd, pshHelp), FALSE);
1245 ShowWindow32(GetDlgItem32(hWnd, pshHelp), SW_HIDE);
1247 ShowWindow32(hWnd, SW_SHOWNORMAL);
1252 /***********************************************************************
1253 * REPLACEDLG_WMCommand [internal]
1255 static LRESULT REPLACEDLG_WMCommand(HWND32 hWnd, WPARAM16 wParam,
1256 HWND32 hwndOwner, LPDWORD lpFlags,
1257 LPSTR lpstrFindWhat, WORD wFindWhatLen,
1258 LPSTR lpstrReplaceWith, WORD wReplaceWithLen,
1261 int uFindReplaceMessage = RegisterWindowMessage32A( FINDMSGSTRING );
1262 int uHelpMessage = RegisterWindowMessage32A( HELPMSGSTRING );
1268 GetDlgItemText32W(hWnd, edt1, (LPWSTR)lpstrFindWhat, wFindWhatLen/2);
1269 GetDlgItemText32W(hWnd, edt2, (LPWSTR)lpstrReplaceWith, wReplaceWithLen/2);
1272 GetDlgItemText32A(hWnd, edt1, lpstrFindWhat, wFindWhatLen);
1273 GetDlgItemText32A(hWnd, edt2, lpstrReplaceWith, wReplaceWithLen);
1275 if (IsDlgButtonChecked32(hWnd, chx1))
1276 *lpFlags |= FR_WHOLEWORD;
1277 else *lpFlags &= ~FR_WHOLEWORD;
1278 if (IsDlgButtonChecked32(hWnd, chx2))
1279 *lpFlags |= FR_MATCHCASE;
1280 else *lpFlags &= ~FR_MATCHCASE;
1281 *lpFlags &= ~(FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
1282 *lpFlags |= FR_FINDNEXT;
1283 SendMessage32A(hwndOwner, uFindReplaceMessage, 0,
1284 GetWindowLong32A(hWnd, DWL_USER) );
1287 *lpFlags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL);
1288 *lpFlags |= FR_DIALOGTERM;
1289 SendMessage32A(hwndOwner, uFindReplaceMessage, 0,
1290 GetWindowLong32A(hWnd, DWL_USER) );
1291 DestroyWindow32(hWnd);
1296 GetDlgItemText32W(hWnd, edt1, (LPWSTR)lpstrFindWhat, wFindWhatLen/2);
1297 GetDlgItemText32W(hWnd, edt2, (LPWSTR)lpstrReplaceWith, wReplaceWithLen/2);
1300 GetDlgItemText32A(hWnd, edt1, lpstrFindWhat, wFindWhatLen);
1301 GetDlgItemText32A(hWnd, edt2, lpstrReplaceWith, wReplaceWithLen);
1303 if (IsDlgButtonChecked32(hWnd, chx1))
1304 *lpFlags |= FR_WHOLEWORD;
1305 else *lpFlags &= ~FR_WHOLEWORD;
1306 if (IsDlgButtonChecked32(hWnd, chx2))
1307 *lpFlags |= FR_MATCHCASE;
1308 else *lpFlags &= ~FR_MATCHCASE;
1309 *lpFlags &= ~(FR_FINDNEXT | FR_REPLACEALL | FR_DIALOGTERM);
1310 *lpFlags |= FR_REPLACE;
1311 SendMessage32A(hwndOwner, uFindReplaceMessage, 0,
1312 GetWindowLong32A(hWnd, DWL_USER) );
1317 GetDlgItemText32W(hWnd, edt1, (LPWSTR)lpstrFindWhat, wFindWhatLen/2);
1318 GetDlgItemText32W(hWnd, edt2, (LPWSTR)lpstrReplaceWith, wReplaceWithLen/2);
1321 GetDlgItemText32A(hWnd, edt1, lpstrFindWhat, wFindWhatLen);
1322 GetDlgItemText32A(hWnd, edt2, lpstrReplaceWith, wReplaceWithLen);
1324 if (IsDlgButtonChecked32(hWnd, chx1))
1325 *lpFlags |= FR_WHOLEWORD;
1326 else *lpFlags &= ~FR_WHOLEWORD;
1327 if (IsDlgButtonChecked32(hWnd, chx2))
1328 *lpFlags |= FR_MATCHCASE;
1329 else *lpFlags &= ~FR_MATCHCASE;
1330 *lpFlags &= ~(FR_FINDNEXT | FR_REPLACE | FR_DIALOGTERM);
1331 *lpFlags |= FR_REPLACEALL;
1332 SendMessage32A(hwndOwner, uFindReplaceMessage, 0,
1333 GetWindowLong32A(hWnd, DWL_USER) );
1336 /* FIXME : should lpfr structure be passed as an argument ??? */
1337 SendMessage32A(hwndOwner, uHelpMessage, 0, 0);
1344 /***********************************************************************
1345 * ReplaceTextDlgProc16 (COMMDLG.14)
1347 LRESULT WINAPI ReplaceTextDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
1350 LPFINDREPLACE16 lpfr;
1353 lpfr=(LPFINDREPLACE16)PTR_SEG_TO_LIN(lParam);
1354 return REPLACEDLG_WMInitDialog(hWnd, lParam, &lpfr->Flags,
1355 PTR_SEG_TO_LIN(lpfr->lpstrFindWhat),
1356 PTR_SEG_TO_LIN(lpfr->lpstrReplaceWith), FALSE);
1358 lpfr=(LPFINDREPLACE16)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
1359 return REPLACEDLG_WMCommand(hWnd, wParam, lpfr->hwndOwner,
1360 &lpfr->Flags, PTR_SEG_TO_LIN(lpfr->lpstrFindWhat),
1361 lpfr->wFindWhatLen, PTR_SEG_TO_LIN(lpfr->lpstrReplaceWith),
1362 lpfr->wReplaceWithLen, FALSE);
1367 /***********************************************************************
1368 * ReplaceTextDlgProc32A
1370 LRESULT WINAPI ReplaceTextDlgProc32A(HWND32 hWnd, UINT32 wMsg, WPARAM32 wParam,
1373 LPFINDREPLACE32A lpfr;
1376 lpfr=(LPFINDREPLACE32A)lParam;
1377 return REPLACEDLG_WMInitDialog(hWnd, lParam, &lpfr->Flags,
1378 lpfr->lpstrFindWhat, lpfr->lpstrReplaceWith, FALSE);
1380 lpfr=(LPFINDREPLACE32A)GetWindowLong32A(hWnd, DWL_USER);
1381 return REPLACEDLG_WMCommand(hWnd, wParam, lpfr->hwndOwner,
1382 &lpfr->Flags, lpfr->lpstrFindWhat, lpfr->wFindWhatLen,
1383 lpfr->lpstrReplaceWith, lpfr->wReplaceWithLen, FALSE);
1388 /***********************************************************************
1389 * ReplaceTextDlgProc32W
1391 LRESULT WINAPI ReplaceTextDlgProc32W(HWND32 hWnd, UINT32 wMsg, WPARAM32 wParam,
1394 LPFINDREPLACE32W lpfr;
1397 lpfr=(LPFINDREPLACE32W)lParam;
1398 return REPLACEDLG_WMInitDialog(hWnd, lParam, &lpfr->Flags,
1399 (LPSTR)lpfr->lpstrFindWhat, (LPSTR)lpfr->lpstrReplaceWith,
1402 lpfr=(LPFINDREPLACE32W)GetWindowLong32A(hWnd, DWL_USER);
1403 return REPLACEDLG_WMCommand(hWnd, wParam, lpfr->hwndOwner,
1404 &lpfr->Flags, (LPSTR)lpfr->lpstrFindWhat, lpfr->wFindWhatLen,
1405 (LPSTR)lpfr->lpstrReplaceWith, lpfr->wReplaceWithLen, TRUE);
1411 /***********************************************************************
1412 * PrintDlg16 (COMMDLG.20)
1414 BOOL16 WINAPI PrintDlg16( SEGPTR printdlg )
1417 BOOL16 bRet = FALSE;
1420 LPPRINTDLG16 lpPrint = (LPPRINTDLG16)PTR_SEG_TO_LIN(printdlg);
1422 TRACE(commdlg,"(%p) -- Flags=%08lX\n", lpPrint, lpPrint->Flags );
1424 if (lpPrint->Flags & PD_RETURNDEFAULT)
1425 /* FIXME: should fill lpPrint->hDevMode and lpPrint->hDevNames here */
1428 if (lpPrint->Flags & PD_PRINTSETUP)
1429 template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT_SETUP );
1431 template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT );
1433 hInst = WIN_GetWindowInstance( lpPrint->hwndOwner );
1434 hwndDialog = DIALOG_CreateIndirect( hInst, template, TRUE,
1436 (DLGPROC16)((lpPrint->Flags & PD_PRINTSETUP) ?
1437 MODULE_GetWndProcEntry16("PrintSetupDlgProc") :
1438 MODULE_GetWndProcEntry16("PrintDlgProc")),
1439 printdlg, WIN_PROC_16 );
1440 if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpPrint->hwndOwner);
1445 /***********************************************************************
1446 * PrintDlg32A (COMDLG32.17)
1448 BOOL32 WINAPI PrintDlg32A( LPPRINTDLG32A printdlg )
1450 FIXME(commdlg, "empty stub\n" );
1455 /***********************************************************************
1456 * PrintDlg32W (COMDLG32.18)
1458 BOOL32 WINAPI PrintDlg32W( LPPRINTDLG32W printdlg )
1460 FIXME(commdlg, "empty stub\n" );
1465 /***********************************************************************
1466 * PrintDlgProc (COMMDLG.21)
1468 LRESULT WINAPI PrintDlgProc(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
1474 TRACE(commdlg,"WM_INITDIALOG lParam=%08lX\n", lParam);
1475 ShowWindow16(hWnd, SW_SHOWNORMAL);
1481 EndDialog32(hWnd, TRUE);
1484 EndDialog32(hWnd, FALSE);
1493 /***********************************************************************
1494 * PrintSetupDlgProc (COMMDLG.22)
1496 LRESULT WINAPI PrintSetupDlgProc(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
1502 TRACE(commdlg,"WM_INITDIALOG lParam=%08lX\n", lParam);
1503 ShowWindow16(hWnd, SW_SHOWNORMAL);
1508 EndDialog32(hWnd, TRUE);
1511 EndDialog32(hWnd, FALSE);
1520 /***********************************************************************
1521 * CommDlgExtendedError (COMMDLG.26)
1523 DWORD WINAPI CommDlgExtendedError(void)
1525 return CommDlgLastError;
1528 /***********************************************************************
1529 * GetFileTitleA (COMDLG32.8)
1531 short WINAPI GetFileTitle32A(LPCSTR lpFile, LPSTR lpTitle, UINT32 cbBuf)
1534 TRACE(commdlg,"(%p %p %d); \n", lpFile, lpTitle, cbBuf);
1535 if (lpFile == NULL || lpTitle == NULL)
1537 len = strlen(lpFile);
1540 if (strpbrk(lpFile, "*[]"))
1543 if (lpFile[len] == '/' || lpFile[len] == '\\' || lpFile[len] == ':')
1545 for (i = len; i >= 0; i--)
1546 if (lpFile[i] == '/' || lpFile[i] == '\\' || lpFile[i] == ':')
1551 TRACE(commdlg,"---> '%s' \n", &lpFile[i]);
1553 len = strlen(lpFile+i)+1;
1557 strncpy(lpTitle, &lpFile[i], len);
1562 /***********************************************************************
1563 * GetFileTitleA (COMDLG32.8)
1565 short WINAPI GetFileTitle32W(LPCWSTR lpFile, LPWSTR lpTitle, UINT32 cbBuf)
1567 LPSTR file = HEAP_strdupWtoA(GetProcessHeap(),0,lpFile);
1568 LPSTR title = HeapAlloc(GetProcessHeap(),0,cbBuf);
1571 ret = GetFileTitle32A(file,title,cbBuf);
1573 lstrcpynAtoW(lpTitle,title,cbBuf);
1574 HeapFree(GetProcessHeap(),0,file);
1575 HeapFree(GetProcessHeap(),0,title);
1578 /***********************************************************************
1579 * GetFileTitle (COMMDLG.27)
1581 short WINAPI GetFileTitle16(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf)
1583 return GetFileTitle32A(lpFile,lpTitle,cbBuf);
1587 /* ------------------------ Choose Color Dialog --------------------------- */
1589 /***********************************************************************
1590 * ChooseColor (COMMDLG.5)
1592 BOOL16 WINAPI ChooseColor(LPCHOOSECOLOR lpChCol)
1595 HANDLE16 hDlgTmpl = 0;
1596 BOOL16 bRet = FALSE, win32Format = FALSE;
1600 TRACE(commdlg,"ChooseColor\n");
1601 if (!lpChCol) return FALSE;
1603 if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE)
1605 if (!(template = LockResource16( lpChCol->hInstance )))
1607 CommDlgLastError = CDERR_LOADRESFAILURE;
1611 else if (lpChCol->Flags & CC_ENABLETEMPLATE)
1614 if (!(hResInfo = FindResource16(lpChCol->hInstance,
1615 lpChCol->lpTemplateName,
1618 CommDlgLastError = CDERR_FINDRESFAILURE;
1621 if (!(hDlgTmpl = LoadResource16( lpChCol->hInstance, hResInfo )) ||
1622 !(template = LockResource16( hDlgTmpl )))
1624 CommDlgLastError = CDERR_LOADRESFAILURE;
1630 template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_COLOR );
1634 hInst = WIN_GetWindowInstance( lpChCol->hwndOwner );
1635 hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
1637 (DLGPROC16)MODULE_GetWndProcEntry16("ColorDlgProc"),
1638 (DWORD)lpChCol, WIN_PROC_16 );
1639 if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpChCol->hwndOwner);
1640 if (hDlgTmpl) FreeResource16( hDlgTmpl );
1645 static const COLORREF predefcolors[6][8]=
1647 { 0x008080FFL, 0x0080FFFFL, 0x0080FF80L, 0x0080FF00L,
1648 0x00FFFF80L, 0x00FF8000L, 0x00C080FFL, 0x00FF80FFL },
1649 { 0x000000FFL, 0x0000FFFFL, 0x0000FF80L, 0x0040FF00L,
1650 0x00FFFF00L, 0x00C08000L, 0x00C08080L, 0x00FF00FFL },
1652 { 0x00404080L, 0x004080FFL, 0x0000FF00L, 0x00808000L,
1653 0x00804000L, 0x00FF8080L, 0x00400080L, 0x008000FFL },
1654 { 0x00000080L, 0x000080FFL, 0x00008000L, 0x00408000L,
1655 0x00FF0000L, 0x00A00000L, 0x00800080L, 0x00FF0080L },
1657 { 0x00000040L, 0x00004080L, 0x00004000L, 0x00404000L,
1658 0x00800000L, 0x00400000L, 0x00400040L, 0x00800040L },
1659 { 0x00000000L, 0x00008080L, 0x00408080L, 0x00808080L,
1660 0x00808040L, 0x00C0C0C0L, 0x00400040L, 0x00FFFFFFL },
1665 LPCHOOSECOLOR lpcc; /* points to public known data structure */
1666 int nextuserdef; /* next free place in user defined color array */
1667 HDC16 hdcMem; /* color graph used for BitBlt() */
1668 HBITMAP16 hbmMem; /* color graph bitmap */
1669 RECT16 fullsize; /* original dialog window size */
1670 UINT16 msetrgb; /* # of SETRGBSTRING message (today not used) */
1671 RECT16 old3angle; /* last position of l-marker */
1672 RECT16 oldcross; /* last position of color/satuation marker */
1673 BOOL32 updating; /* to prevent recursive WM_COMMAND/EN_UPDATE procesing */
1676 int l; /* for temporary storing of hue,sat,lum */
1679 /***********************************************************************
1680 * CC_HSLtoRGB [internal]
1682 static int CC_HSLtoRGB(char c,int hue,int sat,int lum)
1689 case 'R':if (hue>80) hue-=80; else hue+=160; break;
1690 case 'G':if (hue>160) hue-=160; else hue+=80; break;
1695 maxrgb=(256*MIN(120,lum))/120; /* 0 .. 256 */
1701 res=(hue-80)* maxrgb; /* 0...10240 */
1702 res/=40; /* 0...256 */
1709 res=(240-hue)* maxrgb;
1712 res=res-maxrgb/2; /* -128...128 */
1715 res=maxrgb/2 + (sat*res) /240; /* 0..256 */
1718 if (lum>120 && res<256)
1719 res+=((lum-120) * (256-res))/120;
1721 return MIN(res,255);
1724 /***********************************************************************
1725 * CC_RGBtoHSL [internal]
1727 static int CC_RGBtoHSL(char c,int r,int g,int b)
1729 WORD maxi,mini,mmsum,mmdif,result=0;
1743 case 'L':mmsum*=120; /* 0...61200=(255+255)*120 */
1744 result=mmsum/255; /* 0...240 */
1747 case 'S':if (!mmsum)
1750 if (!mini || maxi==255)
1754 result=mmdif*240; /* 0...61200=255*240 */
1755 result/= (mmsum>255 ? mmsum=510-mmsum : mmsum); /* 0..255 */
1759 case 'H':if (!mmdif)
1765 iresult=40*(g-b); /* -10200 ... 10200 */
1766 iresult/=(int)mmdif; /* -40 .. 40 */
1768 iresult+=240; /* 0..40 and 200..240 */
1774 iresult/=(int)mmdif;
1775 iresult+=80; /* 40 .. 120 */
1781 iresult/=(int)mmdif;
1782 iresult+=160; /* 120 .. 200 */
1788 return result; /* is this integer arithmetic precise enough ? */
1793 /***********************************************************************
1794 * CC_MouseCheckPredefColorArray [internal]
1796 static int CC_MouseCheckPredefColorArray(HWND16 hDlg,int dlgitem,int rows,int cols,
1797 LPARAM lParam,COLORREF *cr)
1800 POINT16 point = MAKEPOINT16(lParam);
1804 ClientToScreen16(hDlg,&point);
1805 hwnd=GetDlgItem32(hDlg,dlgitem);
1806 GetWindowRect16(hwnd,&rect);
1807 if (PtInRect16(&rect,point))
1809 dx=(rect.right-rect.left)/cols;
1810 dy=(rect.bottom-rect.top)/rows;
1811 ScreenToClient16(hwnd,&point);
1813 if (point.x % dx < (dx-DISTANCE) && point.y % dy < (dy-DISTANCE))
1817 *cr=predefcolors[y][x];
1818 /* FIXME: Draw_a_Focus_Rect() */
1825 /***********************************************************************
1826 * CC_MouseCheckUserColorArray [internal]
1828 static int CC_MouseCheckUserColorArray(HWND16 hDlg,int dlgitem,int rows,int cols,
1829 LPARAM lParam,COLORREF *cr,COLORREF*crarr)
1832 POINT16 point = MAKEPOINT16(lParam);
1836 ClientToScreen16(hDlg,&point);
1837 hwnd=GetDlgItem32(hDlg,dlgitem);
1838 GetWindowRect16(hwnd,&rect);
1839 if (PtInRect16(&rect,point))
1841 dx=(rect.right-rect.left)/cols;
1842 dy=(rect.bottom-rect.top)/rows;
1843 ScreenToClient16(hwnd,&point);
1845 if (point.x % dx < (dx-DISTANCE) && point.y % dy < (dy-DISTANCE))
1849 *cr=crarr[x+cols*y];
1850 /* FIXME: Draw_a_Focus_Rect() */
1860 /* 240 ^...... ^^ 240
1867 /***********************************************************************
1868 * CC_MouseCheckColorGraph [internal]
1870 static int CC_MouseCheckColorGraph(HWND16 hDlg,int dlgitem,int *hori,int *vert,LPARAM lParam)
1873 POINT16 point = MAKEPOINT16(lParam);
1877 ClientToScreen16(hDlg,&point);
1878 hwnd=GetDlgItem32(hDlg,dlgitem);
1879 GetWindowRect16(hwnd,&rect);
1880 if (PtInRect16(&rect,point))
1882 GetClientRect16(hwnd,&rect);
1883 ScreenToClient16(hwnd,&point);
1885 x=(long)point.x*MAXHORI;
1887 y=(long)(rect.bottom-point.y)*MAXVERT;
1899 /***********************************************************************
1900 * CC_MouseCheckResultWindow [internal]
1902 static int CC_MouseCheckResultWindow(HWND16 hDlg,LPARAM lParam)
1905 POINT16 point = MAKEPOINT16(lParam);
1908 ClientToScreen16(hDlg,&point);
1909 hwnd=GetDlgItem32(hDlg,0x2c5);
1910 GetWindowRect16(hwnd,&rect);
1911 if (PtInRect16(&rect,point))
1913 PostMessage16(hDlg,WM_COMMAND,0x2c9,0);
1919 /***********************************************************************
1920 * CC_CheckDigitsInEdit [internal]
1922 static int CC_CheckDigitsInEdit(HWND16 hwnd,int maxval)
1924 int i,k,m,result,value;
1927 GetWindowText32A(hwnd,buffer,sizeof(buffer));
1932 if (buffer[i]<'0' || buffer[i]>'9')
1934 for (k=i+1;k<=m;k++) /* delete bad character */
1936 buffer[i]=buffer[k];
1944 if (value>maxval) /* build a new string */
1946 sprintf(buffer,"%d",maxval);
1951 editpos=SendMessage16(hwnd,EM_GETSEL16,0,0);
1952 SetWindowText32A(hwnd,buffer);
1953 SendMessage16(hwnd,EM_SETSEL16,0,editpos);
1960 /***********************************************************************
1961 * CC_PaintSelectedColor [internal]
1963 static void CC_PaintSelectedColor(HWND16 hDlg,COLORREF cr)
1968 HWND32 hwnd=GetDlgItem32(hDlg,0x2c5);
1969 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
1972 GetClientRect16 (hwnd, &rect) ;
1973 hBrush = CreateSolidBrush32(cr);
1976 hBrush = SelectObject32 (hdc, hBrush) ;
1977 Rectangle32(hdc, rect.left,rect.top,rect.right/2,rect.bottom);
1978 DeleteObject32 (SelectObject32 (hdc,hBrush)) ;
1979 hBrush=CreateSolidBrush32(GetNearestColor32(hdc,cr));
1982 hBrush= SelectObject32 (hdc, hBrush) ;
1983 Rectangle32( hdc, rect.right/2-1,rect.top,rect.right,rect.bottom);
1984 DeleteObject32( SelectObject32 (hdc, hBrush)) ;
1987 ReleaseDC32(hwnd,hdc);
1991 /***********************************************************************
1992 * CC_PaintTriangle [internal]
1994 static void CC_PaintTriangle(HWND16 hDlg,int y)
1998 int w=GetDialogBaseUnits();
2003 HWND16 hwnd=GetDlgItem32(hDlg,0x2be);
2004 struct CCPRIVATE *lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2006 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
2008 GetClientRect16(hwnd,&rect);
2012 points[0].y=rect.top;
2013 points[0].x=rect.right; /* | /| */
2014 ClientToScreen16(hwnd,points); /* | / | */
2015 ScreenToClient16(hDlg,points); /* |< | */
2016 oben=points[0].y; /* | \ | */
2018 temp=(long)height*(long)y;
2019 points[0].y=oben+height -temp/(long)MAXVERT;
2020 points[1].y=points[0].y+w;
2021 points[2].y=points[0].y-w;
2022 points[2].x=points[1].x=points[0].x + w;
2024 if (lpp->old3angle.left)
2025 FillRect16(hDC,&lpp->old3angle,GetStockObject32(WHITE_BRUSH));
2026 lpp->old3angle.left =points[0].x;
2027 lpp->old3angle.right =points[1].x+1;
2028 lpp->old3angle.top =points[2].y-1;
2029 lpp->old3angle.bottom=points[1].y+1;
2030 Polygon16(hDC,points,3);
2031 ReleaseDC32(hDlg,hDC);
2036 /***********************************************************************
2037 * CC_PaintCross [internal]
2039 static void CC_PaintCross(HWND16 hDlg,int x,int y)
2042 int w=GetDialogBaseUnits();
2043 HWND16 hwnd=GetDlgItem32(hDlg,0x2c6);
2044 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2049 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
2051 GetClientRect16(hwnd,&rect);
2053 SelectClipRgn32(hDC,CreateRectRgnIndirect16(&rect));
2054 hPen=CreatePen32(PS_SOLID,2,0);
2055 hPen=SelectObject32(hDC,hPen);
2056 point.x=((long)rect.right*(long)x)/(long)MAXHORI;
2057 point.y=rect.bottom-((long)rect.bottom*(long)y)/(long)MAXVERT;
2058 if (lpp->oldcross.left!=lpp->oldcross.right)
2059 BitBlt32(hDC,lpp->oldcross.left,lpp->oldcross.top,
2060 lpp->oldcross.right-lpp->oldcross.left,
2061 lpp->oldcross.bottom-lpp->oldcross.top,
2062 lpp->hdcMem,lpp->oldcross.left,lpp->oldcross.top,SRCCOPY);
2063 lpp->oldcross.left =point.x-w-1;
2064 lpp->oldcross.right =point.x+w+1;
2065 lpp->oldcross.top =point.y-w-1;
2066 lpp->oldcross.bottom=point.y+w+1;
2068 MoveTo(hDC,point.x-w,point.y);
2069 LineTo32(hDC,point.x+w,point.y);
2070 MoveTo(hDC,point.x,point.y-w);
2071 LineTo32(hDC,point.x,point.y+w);
2072 DeleteObject32(SelectObject32(hDC,hPen));
2073 ReleaseDC32(hwnd,hDC);
2082 /***********************************************************************
2083 * CC_PrepareColorGraph [internal]
2085 static void CC_PrepareColorGraph(HWND16 hDlg)
2087 int sdif,hdif,xdif,ydif,r,g,b,hue,sat;
2088 HWND32 hwnd=GetDlgItem32(hDlg,0x2c6);
2089 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2093 HCURSOR16 hcursor=SetCursor16(LoadCursor16(0,IDC_WAIT16));
2095 GetClientRect16(hwnd,&client);
2097 lpp->hdcMem = CreateCompatibleDC32(hdc);
2098 lpp->hbmMem = CreateCompatibleBitmap32(hdc,client.right,client.bottom);
2099 SelectObject32(lpp->hdcMem,lpp->hbmMem);
2101 xdif=client.right /XSTEPS;
2102 ydif=client.bottom/YSTEPS+1;
2105 for(rect.left=hue=0;hue<239+hdif;hue+=hdif)
2107 rect.right=rect.left+xdif;
2108 rect.bottom=client.bottom;
2109 for(sat=0;sat<240+sdif;sat+=sdif)
2111 rect.top=rect.bottom-ydif;
2112 r=CC_HSLtoRGB('R',hue,sat,120);
2113 g=CC_HSLtoRGB('G',hue,sat,120);
2114 b=CC_HSLtoRGB('B',hue,sat,120);
2115 hbrush=CreateSolidBrush32(RGB(r,g,b));
2116 FillRect16(lpp->hdcMem,&rect,hbrush);
2117 DeleteObject32(hbrush);
2118 rect.bottom=rect.top;
2120 rect.left=rect.right;
2122 ReleaseDC32(hwnd,hdc);
2123 SetCursor16(hcursor);
2126 /***********************************************************************
2127 * CC_PaintColorGraph [internal]
2129 static void CC_PaintColorGraph(HWND16 hDlg)
2131 HWND32 hwnd=GetDlgItem32(hDlg,0x2c6);
2132 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2135 if (IsWindowVisible32(hwnd)) /* if full size */
2138 CC_PrepareColorGraph(hDlg); /* should not be necessary */
2141 GetClientRect16(hwnd,&rect);
2143 BitBlt32(hDC,0,0,rect.right,rect.bottom,lpp->hdcMem,0,0,SRCCOPY);
2145 WARN(commdlg,"choose color: hdcMem is not defined\n");
2146 ReleaseDC32(hwnd,hDC);
2149 /***********************************************************************
2150 * CC_PaintLumBar [internal]
2152 static void CC_PaintLumBar(HWND16 hDlg,int hue,int sat)
2154 HWND32 hwnd=GetDlgItem32(hDlg,0x2be);
2156 int lum,ldif,ydif,r,g,b;
2160 if (IsWindowVisible32(hwnd))
2163 GetClientRect16(hwnd,&client);
2167 ydif=client.bottom/YSTEPS+1;
2168 for(lum=0;lum<240+ldif;lum+=ldif)
2170 rect.top=MAX(0,rect.bottom-ydif);
2171 r=CC_HSLtoRGB('R',hue,sat,lum);
2172 g=CC_HSLtoRGB('G',hue,sat,lum);
2173 b=CC_HSLtoRGB('B',hue,sat,lum);
2174 hbrush=CreateSolidBrush32(RGB(r,g,b));
2175 FillRect16(hDC,&rect,hbrush);
2176 DeleteObject32(hbrush);
2177 rect.bottom=rect.top;
2179 GetClientRect16(hwnd,&rect);
2180 FrameRect16(hDC,&rect,GetStockObject32(BLACK_BRUSH));
2181 ReleaseDC32(hwnd,hDC);
2185 /***********************************************************************
2186 * CC_EditSetRGB [internal]
2188 static void CC_EditSetRGB(HWND16 hDlg,COLORREF cr)
2191 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2192 int r=GetRValue(cr);
2193 int g=GetGValue(cr);
2194 int b=GetBValue(cr);
2195 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
2198 sprintf(buffer,"%d",r);
2199 SetWindowText32A(GetDlgItem32(hDlg,0x2c2),buffer);
2200 sprintf(buffer,"%d",g);
2201 SetWindowText32A(GetDlgItem32(hDlg,0x2c3),buffer);
2202 sprintf(buffer,"%d",b);
2203 SetWindowText32A(GetDlgItem32(hDlg,0x2c4),buffer);
2204 lpp->updating=FALSE;
2208 /***********************************************************************
2209 * CC_EditSetHSL [internal]
2211 static void CC_EditSetHSL(HWND16 hDlg,int h,int s,int l)
2214 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2216 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
2219 sprintf(buffer,"%d",h);
2220 SetWindowText32A(GetDlgItem32(hDlg,0x2bf),buffer);
2221 sprintf(buffer,"%d",s);
2222 SetWindowText32A(GetDlgItem32(hDlg,0x2c0),buffer);
2223 sprintf(buffer,"%d",l);
2224 SetWindowText32A(GetDlgItem32(hDlg,0x2c1),buffer);
2225 lpp->updating=FALSE;
2227 CC_PaintLumBar(hDlg,h,s);
2230 /***********************************************************************
2231 * CC_SwitchToFullSize [internal]
2233 static void CC_SwitchToFullSize(HWND16 hDlg,COLORREF result,LPRECT16 lprect)
2236 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2238 EnableWindow32(GetDlgItem32(hDlg,0x2cf),FALSE);
2239 CC_PrepareColorGraph(hDlg);
2240 for (i=0x2bf;i<0x2c5;i++)
2241 EnableWindow32(GetDlgItem32(hDlg,i),TRUE);
2242 for (i=0x2d3;i<0x2d9;i++)
2243 EnableWindow32(GetDlgItem32(hDlg,i),TRUE);
2244 EnableWindow32(GetDlgItem32(hDlg,0x2c9),TRUE);
2245 EnableWindow32(GetDlgItem32(hDlg,0x2c8),TRUE);
2248 SetWindowPos32(hDlg,NULL,0,0,lprect->right-lprect->left,
2249 lprect->bottom-lprect->top, SWP_NOMOVE|SWP_NOZORDER);
2251 ShowWindow32(GetDlgItem32(hDlg,0x2c6),SW_SHOW);
2252 ShowWindow32(GetDlgItem32(hDlg,0x2be),SW_SHOW);
2253 ShowWindow32(GetDlgItem32(hDlg,0x2c5),SW_SHOW);
2255 CC_EditSetRGB(hDlg,result);
2256 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
2259 /***********************************************************************
2260 * CC_PaintPredefColorArray [internal]
2262 static void CC_PaintPredefColorArray(HWND16 hDlg,int rows,int cols)
2264 HWND32 hwnd=GetDlgItem32(hDlg,0x2d0);
2270 GetClientRect16(hwnd,&rect);
2272 dy=rect.bottom/rows;
2276 GetClientRect16 (hwnd, &rect) ;
2278 for (j=0;j<rows;j++)
2280 for (i=0;i<cols;i++)
2282 hBrush = CreateSolidBrush32(predefcolors[j][i]);
2285 hBrush = SelectObject32 (hdc, hBrush) ;
2286 Rectangle32(hdc, rect.left, rect.top,
2287 rect.left+dx-DISTANCE, rect.top+dy-DISTANCE);
2288 rect.left=rect.left+dx;
2289 DeleteObject32( SelectObject32 (hdc, hBrush)) ;
2292 rect.top=rect.top+dy;
2295 ReleaseDC32(hwnd,hdc);
2296 /* FIXME: draw_a_focus_rect */
2298 /***********************************************************************
2299 * CC_PaintUserColorArray [internal]
2301 static void CC_PaintUserColorArray(HWND16 hDlg,int rows,int cols,COLORREF* lpcr)
2303 HWND32 hwnd=GetDlgItem32(hDlg,0x2d1);
2309 GetClientRect16(hwnd,&rect);
2312 dy=rect.bottom/rows;
2318 for (j=0;j<rows;j++)
2320 for (i=0;i<cols;i++)
2322 hBrush = CreateSolidBrush32(lpcr[i+j*cols]);
2325 hBrush = SelectObject32 (hdc, hBrush) ;
2326 Rectangle32( hdc, rect.left, rect.top,
2327 rect.left+dx-DISTANCE, rect.top+dy-DISTANCE);
2328 rect.left=rect.left+dx;
2329 DeleteObject32( SelectObject32 (hdc, hBrush)) ;
2332 rect.top=rect.top+dy;
2335 ReleaseDC32(hwnd,hdc);
2337 /* FIXME: draw_a_focus_rect */
2342 /***********************************************************************
2343 * CC_HookCallChk [internal]
2345 static BOOL32 CC_HookCallChk(LPCHOOSECOLOR lpcc)
2348 if(lpcc->Flags & CC_ENABLEHOOK)
2354 /***********************************************************************
2355 * CC_WMInitDialog [internal]
2357 static LONG CC_WMInitDialog(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2363 struct CCPRIVATE * lpp;
2365 TRACE(commdlg,"WM_INITDIALOG lParam=%08lX\n", lParam);
2366 lpp=calloc(1,sizeof(struct CCPRIVATE));
2367 lpp->lpcc=(LPCHOOSECOLOR)lParam;
2368 if (lpp->lpcc->lStructSize != sizeof(CHOOSECOLOR))
2370 EndDialog32 (hDlg, 0) ;
2373 SetWindowLong32A(hDlg, DWL_USER, (LONG)lpp);
2375 if (!(lpp->lpcc->Flags & CC_SHOWHELP))
2376 ShowWindow32(GetDlgItem32(hDlg,0x40e),SW_HIDE);
2377 lpp->msetrgb=RegisterWindowMessage32A( SETRGBSTRING );
2379 cpos=MAKELONG(5,7); /* init */
2380 if (lpp->lpcc->Flags & CC_RGBINIT)
2384 if (predefcolors[i][j]==lpp->lpcc->rgbResult)
2391 /* FIXME: Draw_a_focus_rect & set_init_values */
2393 GetWindowRect16(hDlg,&lpp->fullsize);
2394 if (lpp->lpcc->Flags & CC_FULLOPEN || lpp->lpcc->Flags & CC_PREVENTFULLOPEN)
2396 hwnd=GetDlgItem32(hDlg,0x2cf);
2397 EnableWindow32(hwnd,FALSE);
2399 if (!(lpp->lpcc->Flags & CC_FULLOPEN) || lpp->lpcc->Flags & CC_PREVENTFULLOPEN)
2402 res=rect.bottom-rect.top;
2403 hwnd=GetDlgItem32(hDlg,0x2c6); /* cut at left border */
2405 ClientToScreen16(hwnd,&point);
2406 ScreenToClient16(hDlg,&point);
2407 GetClientRect16(hDlg,&rect);
2408 point.x+=GetSystemMetrics32(SM_CXDLGFRAME);
2409 SetWindowPos32(hDlg,NULL,0,0,point.x,res,SWP_NOMOVE|SWP_NOZORDER);
2411 ShowWindow32(GetDlgItem32(hDlg,0x2c6),SW_HIDE);
2412 ShowWindow32(GetDlgItem32(hDlg,0x2c5),SW_HIDE);
2415 CC_SwitchToFullSize(hDlg,lpp->lpcc->rgbResult,NULL);
2417 for (i=0x2bf;i<0x2c5;i++)
2418 SendMessage16(GetDlgItem32(hDlg,i),EM_LIMITTEXT16,3,0); /* max 3 digits: xyz */
2419 if (CC_HookCallChk(lpp->lpcc))
2420 res=CallWindowProc16(lpp->lpcc->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
2424 /***********************************************************************
2425 * CC_WMCommand [internal]
2427 static LRESULT CC_WMCommand(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2433 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2434 TRACE(commdlg,"CC_WMCommand wParam=%x lParam=%lx\n",wParam,lParam);
2437 case 0x2c2: /* edit notify RGB */
2440 if (HIWORD(lParam)==EN_UPDATE && !lpp->updating)
2442 i=CC_CheckDigitsInEdit(LOWORD(lParam),255);
2443 r=GetRValue(lpp->lpcc->rgbResult);
2444 g=GetGValue(lpp->lpcc->rgbResult);
2445 b=GetBValue(lpp->lpcc->rgbResult);
2449 case 0x2c2:if ((xx=(i!=r))) r=i;break;
2450 case 0x2c3:if ((xx=(i!=g))) g=i;break;
2451 case 0x2c4:if ((xx=(i!=b))) b=i;break;
2453 if (xx) /* something has changed */
2455 lpp->lpcc->rgbResult=RGB(r,g,b);
2456 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2457 lpp->h=CC_RGBtoHSL('H',r,g,b);
2458 lpp->s=CC_RGBtoHSL('S',r,g,b);
2459 lpp->l=CC_RGBtoHSL('L',r,g,b);
2460 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
2461 CC_PaintCross(hDlg,lpp->h,lpp->s);
2462 CC_PaintTriangle(hDlg,lpp->l);
2467 case 0x2bf: /* edit notify HSL */
2470 if (HIWORD(lParam)==EN_UPDATE && !lpp->updating)
2472 i=CC_CheckDigitsInEdit(LOWORD(lParam),wParam==0x2bf?239:240);
2476 case 0x2bf:if ((xx=(i!=lpp->h))) lpp->h=i;break;
2477 case 0x2c0:if ((xx=(i!=lpp->s))) lpp->s=i;break;
2478 case 0x2c1:if ((xx=(i!=lpp->l))) lpp->l=i;break;
2480 if (xx) /* something has changed */
2482 r=CC_HSLtoRGB('R',lpp->h,lpp->s,lpp->l);
2483 g=CC_HSLtoRGB('G',lpp->h,lpp->s,lpp->l);
2484 b=CC_HSLtoRGB('B',lpp->h,lpp->s,lpp->l);
2485 lpp->lpcc->rgbResult=RGB(r,g,b);
2486 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2487 CC_EditSetRGB(hDlg,lpp->lpcc->rgbResult);
2488 CC_PaintCross(hDlg,lpp->h,lpp->s);
2489 CC_PaintTriangle(hDlg,lpp->l);
2495 CC_SwitchToFullSize(hDlg,lpp->lpcc->rgbResult,&lpp->fullsize);
2496 InvalidateRect32( hDlg, NULL, TRUE );
2497 SetFocus32(GetDlgItem32(hDlg,0x2bf));
2500 case 0x2c8: /* add colors ... column by column */
2501 cr=PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors);
2502 cr[(lpp->nextuserdef%2)*8 + lpp->nextuserdef/2]=lpp->lpcc->rgbResult;
2503 if (++lpp->nextuserdef==16)
2505 CC_PaintUserColorArray(hDlg,2,8,PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors));
2508 case 0x2c9: /* resulting color */
2510 lpp->lpcc->rgbResult=GetNearestColor32(hdc,lpp->lpcc->rgbResult);
2511 ReleaseDC32(hDlg,hdc);
2512 CC_EditSetRGB(hDlg,lpp->lpcc->rgbResult);
2513 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2514 r=GetRValue(lpp->lpcc->rgbResult);
2515 g=GetGValue(lpp->lpcc->rgbResult);
2516 b=GetBValue(lpp->lpcc->rgbResult);
2517 lpp->h=CC_RGBtoHSL('H',r,g,b);
2518 lpp->s=CC_RGBtoHSL('S',r,g,b);
2519 lpp->l=CC_RGBtoHSL('L',r,g,b);
2520 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
2521 CC_PaintCross(hDlg,lpp->h,lpp->s);
2522 CC_PaintTriangle(hDlg,lpp->l);
2525 case 0x40e: /* Help! */ /* The Beatles, 1965 ;-) */
2526 i=RegisterWindowMessage32A( HELPMSGSTRING );
2527 if (lpp->lpcc->hwndOwner)
2528 SendMessage16(lpp->lpcc->hwndOwner,i,0,(LPARAM)lpp->lpcc);
2529 if (CC_HookCallChk(lpp->lpcc))
2530 CallWindowProc16(lpp->lpcc->lpfnHook,hDlg,
2531 WM_COMMAND,psh15,(LPARAM)lpp->lpcc);
2535 cokmsg=RegisterWindowMessage32A( COLOROKSTRING );
2536 if (lpp->lpcc->hwndOwner)
2537 if (SendMessage16(lpp->lpcc->hwndOwner,cokmsg,0,(LPARAM)lpp->lpcc))
2538 break; /* do NOT close */
2540 EndDialog32 (hDlg, 1) ;
2544 EndDialog32 (hDlg, 0) ;
2551 /***********************************************************************
2552 * CC_WMPaint [internal]
2554 static LRESULT CC_WMPaint(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2556 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2557 /* we have to paint dialog children except text and buttons */
2559 CC_PaintPredefColorArray(hDlg,6,8);
2560 CC_PaintUserColorArray(hDlg,2,8,PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors));
2561 CC_PaintColorGraph(hDlg);
2562 CC_PaintLumBar(hDlg,lpp->h,lpp->s);
2563 CC_PaintCross(hDlg,lpp->h,lpp->s);
2564 CC_PaintTriangle(hDlg,lpp->l);
2565 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2567 /* special necessary for Wine */
2568 ValidateRect32(GetDlgItem32(hDlg,0x2d0),NULL);
2569 ValidateRect32(GetDlgItem32(hDlg,0x2d1),NULL);
2570 ValidateRect32(GetDlgItem32(hDlg,0x2c6),NULL);
2571 ValidateRect32(GetDlgItem32(hDlg,0x2be),NULL);
2572 ValidateRect32(GetDlgItem32(hDlg,0x2c5),NULL);
2573 /* hope we can remove it later -->FIXME */
2578 /***********************************************************************
2579 * CC_WMLButtonDown [internal]
2581 static LRESULT CC_WMLButtonDown(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2583 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2586 if (CC_MouseCheckPredefColorArray(hDlg,0x2d0,6,8,lParam,&lpp->lpcc->rgbResult))
2589 if (CC_MouseCheckUserColorArray(hDlg,0x2d1,2,8,lParam,&lpp->lpcc->rgbResult,
2590 PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors)))
2593 if (CC_MouseCheckColorGraph(hDlg,0x2c6,&lpp->h,&lpp->s,lParam))
2596 if (CC_MouseCheckColorGraph(hDlg,0x2be,NULL,&lpp->l,lParam))
2600 r=CC_HSLtoRGB('R',lpp->h,lpp->s,lpp->l);
2601 g=CC_HSLtoRGB('G',lpp->h,lpp->s,lpp->l);
2602 b=CC_HSLtoRGB('B',lpp->h,lpp->s,lpp->l);
2603 lpp->lpcc->rgbResult=RGB(r,g,b);
2607 r=GetRValue(lpp->lpcc->rgbResult);
2608 g=GetGValue(lpp->lpcc->rgbResult);
2609 b=GetBValue(lpp->lpcc->rgbResult);
2610 lpp->h=CC_RGBtoHSL('H',r,g,b);
2611 lpp->s=CC_RGBtoHSL('S',r,g,b);
2612 lpp->l=CC_RGBtoHSL('L',r,g,b);
2616 CC_EditSetRGB(hDlg,lpp->lpcc->rgbResult);
2617 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
2618 CC_PaintCross(hDlg,lpp->h,lpp->s);
2619 CC_PaintTriangle(hDlg,lpp->l);
2620 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2626 /***********************************************************************
2627 * ColorDlgProc (COMMDLG.8)
2629 LRESULT WINAPI ColorDlgProc(HWND16 hDlg, UINT16 message,
2630 WPARAM16 wParam, LONG lParam)
2633 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2634 if (message!=WM_INITDIALOG)
2639 if (CC_HookCallChk(lpp->lpcc))
2640 res=CallWindowProc16(lpp->lpcc->lpfnHook,hDlg,message,wParam,lParam);
2645 /* FIXME: SetRGB message
2646 if (message && message==msetrgb)
2647 return HandleSetRGB(hDlg,lParam);
2653 return CC_WMInitDialog(hDlg,wParam,lParam);
2655 DeleteDC32(lpp->hdcMem);
2656 DeleteObject32(lpp->hbmMem);
2658 SetWindowLong32A(hDlg, DWL_USER, 0L); /* we don't need it anymore */
2661 if (CC_WMCommand(hDlg, wParam, lParam))
2665 CC_WMPaint(hDlg, wParam, lParam);
2667 case WM_LBUTTONDBLCLK:
2668 if (CC_MouseCheckResultWindow(hDlg,lParam))
2671 case WM_MOUSEMOVE: /* FIXME: calculate new hue,sat,lum (if in color graph) */
2673 case WM_LBUTTONUP: /* FIXME: ClipCursor off (if in color graph)*/
2675 case WM_LBUTTONDOWN:/* FIXME: ClipCursor on (if in color graph)*/
2676 if (CC_WMLButtonDown(hDlg, wParam, lParam))
2683 static void CFn_CHOOSEFONT16to32A(LPCHOOSEFONT16 chf16, LPCHOOSEFONT32A chf32a)
2685 chf32a->lStructSize=sizeof(CHOOSEFONT32A);
2686 chf32a->hwndOwner=chf16->hwndOwner;
2687 chf32a->hDC=chf16->hDC;
2688 chf32a->iPointSize=chf16->iPointSize;
2689 chf32a->Flags=chf16->Flags;
2690 chf32a->rgbColors=chf16->rgbColors;
2691 chf32a->lCustData=chf16->lCustData;
2692 chf32a->lpfnHook=NULL;
2693 chf32a->lpTemplateName=PTR_SEG_TO_LIN(chf16->lpTemplateName);
2694 chf32a->hInstance=chf16->hInstance;
2695 chf32a->lpszStyle=PTR_SEG_TO_LIN(chf16->lpszStyle);
2696 chf32a->nFontType=chf16->nFontType;
2697 chf32a->nSizeMax=chf16->nSizeMax;
2698 chf32a->nSizeMin=chf16->nSizeMin;
2699 FONT_LogFont16To32A(PTR_SEG_TO_LIN(chf16->lpLogFont), chf32a->lpLogFont);
2703 /***********************************************************************
2704 * ChooseFont16 (COMMDLG.15)
2706 BOOL16 WINAPI ChooseFont16(LPCHOOSEFONT16 lpChFont)
2709 HANDLE16 hDlgTmpl = 0;
2710 BOOL16 bRet = FALSE, win32Format = FALSE;
2713 CHOOSEFONT32A cf32a;
2715 SEGPTR lpTemplateName;
2717 cf32a.lpLogFont=&lf32a;
2718 CFn_CHOOSEFONT16to32A(lpChFont, &cf32a);
2720 TRACE(commdlg,"ChooseFont\n");
2721 if (!lpChFont) return FALSE;
2723 if (lpChFont->Flags & CF_ENABLETEMPLATEHANDLE)
2725 if (!(template = LockResource16( lpChFont->hInstance )))
2727 CommDlgLastError = CDERR_LOADRESFAILURE;
2731 else if (lpChFont->Flags & CF_ENABLETEMPLATE)
2734 if (!(hResInfo = FindResource16( lpChFont->hInstance,
2735 lpChFont->lpTemplateName,
2738 CommDlgLastError = CDERR_FINDRESFAILURE;
2741 if (!(hDlgTmpl = LoadResource16( lpChFont->hInstance, hResInfo )) ||
2742 !(template = LockResource16( hDlgTmpl )))
2744 CommDlgLastError = CDERR_LOADRESFAILURE;
2750 template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT );
2754 hInst = WIN_GetWindowInstance( lpChFont->hwndOwner );
2756 /* lpTemplateName is not used in the dialog */
2757 lpTemplateName=lpChFont->lpTemplateName;
2758 lpChFont->lpTemplateName=(SEGPTR)&cf32a;
2760 hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
2761 lpChFont->hwndOwner,
2762 (DLGPROC16)MODULE_GetWndProcEntry16("FormatCharDlgProc"),
2763 (DWORD)lpChFont, WIN_PROC_16 );
2764 if (hwndDialog) bRet = DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner);
2765 if (hDlgTmpl) FreeResource16( hDlgTmpl );
2766 lpChFont->lpTemplateName=lpTemplateName;
2767 FONT_LogFont32ATo16(cf32a.lpLogFont,
2768 (LPLOGFONT16)(PTR_SEG_TO_LIN(lpChFont->lpLogFont)));
2773 /***********************************************************************
2774 * ChooseFont32A (COMDLG32.3)
2776 BOOL32 WINAPI ChooseFont32A(LPCHOOSEFONT32A lpChFont)
2780 HINSTANCE32 hInst=WIN_GetWindowInstance( lpChFont->hwndOwner );
2781 LPCVOID template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT );
2782 if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS | CF_ENABLETEMPLATE |
2783 CF_ENABLETEMPLATEHANDLE)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
2784 hwndDialog = DIALOG_CreateIndirect(hInst, template, TRUE, lpChFont->hwndOwner,
2785 (DLGPROC16)FormatCharDlgProc32A, (LPARAM)lpChFont, WIN_PROC_32A );
2786 if (hwndDialog) bRet = DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner);
2790 /***********************************************************************
2791 * ChooseFont32W (COMDLG32.4)
2793 BOOL32 WINAPI ChooseFont32W(LPCHOOSEFONT32W lpChFont)
2797 HINSTANCE32 hInst=WIN_GetWindowInstance( lpChFont->hwndOwner );
2798 CHOOSEFONT32A cf32a;
2800 LPCVOID template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT );
2801 if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS | CF_ENABLETEMPLATE |
2802 CF_ENABLETEMPLATEHANDLE)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
2803 memcpy(&cf32a, lpChFont, sizeof(cf32a));
2804 memcpy(&lf32a, lpChFont->lpLogFont, sizeof(LOGFONT32A));
2805 lstrcpynWtoA(lf32a.lfFaceName, lpChFont->lpLogFont->lfFaceName, LF_FACESIZE);
2806 cf32a.lpLogFont=&lf32a;
2807 cf32a.lpszStyle=HEAP_strdupWtoA(GetProcessHeap(), 0, lpChFont->lpszStyle);
2808 lpChFont->lpTemplateName=(LPWSTR)&cf32a;
2809 hwndDialog=DIALOG_CreateIndirect(hInst, template, TRUE, lpChFont->hwndOwner,
2810 (DLGPROC16)FormatCharDlgProc32W, (LPARAM)lpChFont, WIN_PROC_32W );
2811 if (hwndDialog)bRet=DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner);
2812 HeapFree(GetProcessHeap(), 0, cf32a.lpszStyle);
2813 lpChFont->lpTemplateName=(LPWSTR)cf32a.lpTemplateName;
2814 memcpy(lpChFont->lpLogFont, &lf32a, sizeof(CHOOSEFONT32A));
2815 lstrcpynAtoW(lpChFont->lpLogFont->lfFaceName, lf32a.lfFaceName, LF_FACESIZE);
2820 #define TEXT_EXTRAS 4
2821 #define TEXT_COLORS 16
2823 static const COLORREF textcolors[TEXT_COLORS]=
2825 0x00000000L,0x00000080L,0x00008000L,0x00008080L,
2826 0x00800000L,0x00800080L,0x00808000L,0x00808080L,
2827 0x00c0c0c0L,0x000000ffL,0x0000ff00L,0x0000ffffL,
2828 0x00ff0000L,0x00ff00ffL,0x00ffff00L,0x00FFFFFFL
2831 /***********************************************************************
2832 * CFn_HookCallChk [internal]
2834 static BOOL32 CFn_HookCallChk(LPCHOOSEFONT16 lpcf)
2837 if(lpcf->Flags & CF_ENABLEHOOK)
2843 /***********************************************************************
2844 * CFn_HookCallChk32 [internal]
2846 static BOOL32 CFn_HookCallChk32(LPCHOOSEFONT32A lpcf)
2849 if(lpcf->Flags & CF_ENABLEHOOK)
2856 /*************************************************************************
2857 * AddFontFamily [internal]
2859 static INT32 AddFontFamily(LPLOGFONT32A lplf, UINT32 nFontType,
2860 LPCHOOSEFONT32A lpcf, HWND32 hwnd)
2865 TRACE(commdlg,"font=%s (nFontType=%d)\n", lplf->lfFaceName,nFontType);
2867 if (lpcf->Flags & CF_FIXEDPITCHONLY)
2868 if (!(lplf->lfPitchAndFamily & FIXED_PITCH))
2870 if (lpcf->Flags & CF_ANSIONLY)
2871 if (lplf->lfCharSet != ANSI_CHARSET)
2873 if (lpcf->Flags & CF_TTONLY)
2874 if (!(nFontType & TRUETYPE_FONTTYPE))
2877 i=SendMessage32A(hwnd, CB_ADDSTRING32, 0, (LPARAM)lplf->lfFaceName);
2880 w=(lplf->lfCharSet << 8) | lplf->lfPitchAndFamily;
2881 SendMessage32A(hwnd, CB_SETITEMDATA32, i, MAKELONG(nFontType,w));
2882 return 1 ; /* store some important font information */
2892 LPCHOOSEFONT32A lpcf32a;
2893 } CFn_ENUMSTRUCT, *LPCFn_ENUMSTRUCT;
2895 /*************************************************************************
2896 * FontFamilyEnumProc32 [internal]
2898 INT32 WINAPI FontFamilyEnumProc32(LPENUMLOGFONT32A lpEnumLogFont,
2899 LPNEWTEXTMETRIC32A metrics, UINT32 nFontType, LPARAM lParam)
2902 e=(LPCFn_ENUMSTRUCT)lParam;
2903 return AddFontFamily(&lpEnumLogFont->elfLogFont, nFontType, e->lpcf32a, e->hWnd1);
2906 /***********************************************************************
2907 * FontFamilyEnumProc16 (COMMDLG.19)
2909 INT16 WINAPI FontFamilyEnumProc16( SEGPTR logfont, SEGPTR metrics,
2910 UINT16 nFontType, LPARAM lParam )
2912 HWND16 hwnd=LOWORD(lParam);
2913 HWND16 hDlg=GetParent16(hwnd);
2914 LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLong32A(hDlg, DWL_USER);
2915 LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN( logfont );
2917 FONT_LogFont16To32A(lplf, &lf32a);
2918 return AddFontFamily(&lf32a, nFontType, (LPCHOOSEFONT32A)lpcf->lpTemplateName,
2922 /*************************************************************************
2923 * SetFontStylesToCombo2 [internal]
2925 * Fill font style information into combobox (without using font.c directly)
2927 static int SetFontStylesToCombo2(HWND32 hwnd, HDC32 hdc, LPLOGFONT32A lplf)
2934 static struct FONTSTYLE fontstyles[FSTYLES]={
2935 { 0,FW_NORMAL,"Regular"},{0,FW_BOLD,"Bold"},
2936 { 1,FW_NORMAL,"Italic"}, {1,FW_BOLD,"Bold Italic"}};
2941 for (i=0;i<FSTYLES;i++)
2943 lplf->lfItalic=fontstyles[i].italic;
2944 lplf->lfWeight=fontstyles[i].weight;
2945 hf=CreateFontIndirect32A(lplf);
2946 hf=SelectObject32(hdc,hf);
2947 GetTextMetrics16(hdc,&tm);
2948 hf=SelectObject32(hdc,hf);
2951 if (tm.tmWeight==fontstyles[i].weight &&
2952 tm.tmItalic==fontstyles[i].italic) /* font successful created ? */
2954 char *str = SEGPTR_STRDUP(fontstyles[i].stname);
2955 j=SendMessage16(hwnd,CB_ADDSTRING16,0,(LPARAM)SEGPTR_GET(str) );
2957 if (j==CB_ERR) return 1;
2958 j=SendMessage16(hwnd, CB_SETITEMDATA16, j,
2959 MAKELONG(fontstyles[i].weight,fontstyles[i].italic));
2960 if (j==CB_ERR) return 1;
2966 /*************************************************************************
2967 * AddFontSizeToCombo3 [internal]
2969 static int AddFontSizeToCombo3(HWND32 hwnd, UINT32 h, LPCHOOSEFONT32A lpcf)
2974 if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
2975 ((lpcf->Flags & CF_LIMITSIZE) && (h >= lpcf->nSizeMin) && (h <= lpcf->nSizeMax)))
2977 sprintf(buffer, "%2d", h);
2978 j=SendMessage32A(hwnd, CB_FINDSTRINGEXACT32, -1, (LPARAM)buffer);
2981 j=SendMessage32A(hwnd, CB_ADDSTRING32, 0, (LPARAM)buffer);
2982 if (j!=CB_ERR) j = SendMessage32A(hwnd, CB_SETITEMDATA32, j, h);
2983 if (j==CB_ERR) return 1;
2989 /*************************************************************************
2990 * SetFontSizesToCombo3 [internal]
2992 static int SetFontSizesToCombo3(HWND32 hwnd, LPCHOOSEFONT32A lpcf)
2994 static const int sizes[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72,0};
2997 for (i=0; sizes[i]; i++)
2998 if (AddFontSizeToCombo3(hwnd, sizes[i], lpcf)) return 1;
3002 /***********************************************************************
3003 * AddFontStyle [internal]
3005 INT32 AddFontStyle(LPLOGFONT32A lplf, UINT32 nFontType,
3006 LPCHOOSEFONT32A lpcf, HWND32 hcmb2, HWND32 hcmb3, HWND32 hDlg)
3010 TRACE(commdlg,"(nFontType=%d)\n",nFontType);
3011 TRACE(commdlg," %s h=%d w=%d e=%d o=%d wg=%d i=%d u=%d s=%d"
3012 " ch=%d op=%d cp=%d q=%d pf=%xh\n",
3013 lplf->lfFaceName,lplf->lfHeight,lplf->lfWidth,
3014 lplf->lfEscapement,lplf->lfOrientation,
3015 lplf->lfWeight,lplf->lfItalic,lplf->lfUnderline,
3016 lplf->lfStrikeOut,lplf->lfCharSet, lplf->lfOutPrecision,
3017 lplf->lfClipPrecision,lplf->lfQuality, lplf->lfPitchAndFamily);
3018 if (nFontType & RASTER_FONTTYPE)
3020 if (AddFontSizeToCombo3(hcmb3, lplf->lfHeight, lpcf)) return 0;
3021 } else if (SetFontSizesToCombo3(hcmb3, lpcf)) return 0;
3023 if (!SendMessage32A(hcmb2, CB_GETCOUNT32, 0, 0))
3025 HDC32 hdc= (lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC32(hDlg);
3026 i=SetFontStylesToCombo2(hcmb2,hdc,lplf);
3027 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
3028 ReleaseDC32(hDlg,hdc);
3036 /***********************************************************************
3037 * FontStyleEnumProc16 (COMMDLG.18)
3039 INT16 WINAPI FontStyleEnumProc16( SEGPTR logfont, SEGPTR metrics,
3040 UINT16 nFontType, LPARAM lParam )
3042 HWND16 hcmb2=LOWORD(lParam);
3043 HWND16 hcmb3=HIWORD(lParam);
3044 HWND16 hDlg=GetParent16(hcmb3);
3045 LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLong32A(hDlg, DWL_USER);
3046 LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN(logfont);
3048 FONT_LogFont16To32A(lplf, &lf32a);
3049 return AddFontStyle(&lf32a, nFontType, (LPCHOOSEFONT32A)lpcf->lpTemplateName,
3050 hcmb2, hcmb3, hDlg);
3053 /***********************************************************************
3054 * FontStyleEnumProc32 [internal]
3056 INT32 WINAPI FontStyleEnumProc32( LPENUMLOGFONT32A lpFont,
3057 LPNEWTEXTMETRIC32A metrics, UINT32 nFontType, LPARAM lParam )
3059 LPCFn_ENUMSTRUCT s=(LPCFn_ENUMSTRUCT)lParam;
3060 HWND32 hcmb2=s->hWnd1;
3061 HWND32 hcmb3=s->hWnd2;
3062 HWND32 hDlg=GetParent32(hcmb3);
3063 return AddFontStyle(&lpFont->elfLogFont, nFontType, s->lpcf32a, hcmb2,
3067 /***********************************************************************
3068 * CFn_WMInitDialog [internal]
3070 LRESULT CFn_WMInitDialog(HWND32 hDlg, WPARAM32 wParam, LPARAM lParam,
3071 LPCHOOSEFONT32A lpcf)
3077 HCURSOR32 hcursor=SetCursor32(LoadCursor32A(0,IDC_WAIT32A));
3079 SetWindowLong32A(hDlg, DWL_USER, lParam);
3080 lpxx=lpcf->lpLogFont;
3081 TRACE(commdlg,"WM_INITDIALOG lParam=%08lX\n", lParam);
3083 if (lpcf->lStructSize != sizeof(CHOOSEFONT32A))
3085 ERR(commdlg,"structure size failure !!!\n");
3086 EndDialog32 (hDlg, 0);
3090 hBitmapTT = LoadBitmap32A(0, MAKEINTRESOURCE32A(OBM_TRTYPE));
3092 /* This font will be deleted by WM_COMMAND */
3093 SendDlgItemMessage32A(hDlg,stc6,WM_SETFONT,
3094 CreateFont32A(0, 0, 1, 1, 400, 0, 0, 0, 0, 0, 0, 0, 0, NULL),FALSE);
3096 if (!(lpcf->Flags & CF_SHOWHELP) || !IsWindow32(lpcf->hwndOwner))
3097 ShowWindow32(GetDlgItem32(hDlg,pshHelp),SW_HIDE);
3098 if (!(lpcf->Flags & CF_APPLY))
3099 ShowWindow32(GetDlgItem32(hDlg,psh3),SW_HIDE);
3100 if (lpcf->Flags & CF_EFFECTS)
3102 for (res=1,i=0;res && i<TEXT_COLORS;i++)
3104 /* FIXME: load color name from resource: res=LoadString(...,i+....,buffer,.....); */
3106 strcpy( name, "[color name]" );
3107 j=SendDlgItemMessage32A(hDlg, cmb4, CB_ADDSTRING32, 0, (LPARAM)name);
3108 SendDlgItemMessage32A(hDlg, cmb4, CB_SETITEMDATA16, j, textcolors[j]);
3109 /* look for a fitting value in color combobox */
3110 if (textcolors[j]==lpcf->rgbColors)
3111 SendDlgItemMessage32A(hDlg,cmb4, CB_SETCURSEL32,j,0);
3116 ShowWindow32(GetDlgItem32(hDlg,cmb4),SW_HIDE);
3117 ShowWindow32(GetDlgItem32(hDlg,chx1),SW_HIDE);
3118 ShowWindow32(GetDlgItem32(hDlg,chx2),SW_HIDE);
3119 ShowWindow32(GetDlgItem32(hDlg,grp1),SW_HIDE);
3120 ShowWindow32(GetDlgItem32(hDlg,stc4),SW_HIDE);
3122 hdc= (lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC32(hDlg);
3126 s.hWnd1=GetDlgItem32(hDlg,cmb1);
3128 if (!EnumFontFamilies32A(hdc, NULL, FontFamilyEnumProc32, (LPARAM)&s))
3129 TRACE(commdlg,"EnumFontFamilies returns 0\n");
3130 if (lpcf->Flags & CF_INITTOLOGFONTSTRUCT)
3132 /* look for fitting font name in combobox1 */
3133 j=SendDlgItemMessage32A(hDlg,cmb1,CB_FINDSTRING32,-1,(LONG)lpxx->lfFaceName);
3136 SendDlgItemMessage32A(hDlg, cmb1, CB_SETCURSEL32, j, 0);
3137 SendMessage32A(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
3138 GetDlgItem32(hDlg,cmb1));
3140 /* look for fitting font style in combobox2 */
3141 l=MAKELONG(lpxx->lfWeight > FW_MEDIUM ? FW_BOLD:FW_NORMAL,lpxx->lfItalic !=0);
3142 for (i=0;i<TEXT_EXTRAS;i++)
3144 if (l==SendDlgItemMessage32A(hDlg, cmb2, CB_GETITEMDATA32, i, 0))
3145 SendDlgItemMessage32A(hDlg, cmb2, CB_SETCURSEL32, i, 0);
3148 /* look for fitting font size in combobox3 */
3149 j=SendDlgItemMessage32A(hDlg, cmb3, CB_GETCOUNT32, 0, 0);
3152 if (lpxx->lfHeight==(int)SendDlgItemMessage32A(hDlg,cmb3, CB_GETITEMDATA32,i,0))
3153 SendDlgItemMessage32A(hDlg,cmb3,CB_SETCURSEL32,i,0);
3159 SendDlgItemMessage32A(hDlg,cmb1,CB_SETCURSEL32,0,0);
3160 SendMessage32A(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
3161 GetDlgItem32(hDlg,cmb1));
3163 if (lpcf->Flags & CF_USESTYLE && lpcf->lpszStyle)
3165 j=SendDlgItemMessage32A(hDlg,cmb2,CB_FINDSTRING32,-1,(LONG)lpcf->lpszStyle);
3168 j=SendDlgItemMessage32A(hDlg,cmb2,CB_SETCURSEL32,j,0);
3169 SendMessage32A(hDlg,WM_COMMAND,cmb2,
3170 MAKELONG(GetDlgItem32(hDlg,cmb2),CBN_SELCHANGE));
3176 WARN(commdlg,"HDC failure !!!\n");
3177 EndDialog32 (hDlg, 0);
3181 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
3182 ReleaseDC32(hDlg,hdc);
3183 SetCursor32(hcursor);
3188 /***********************************************************************
3189 * CFn_WMMeasureItem [internal]
3191 LRESULT CFn_WMMeasureItem(HWND32 hDlg, WPARAM32 wParam, LPARAM lParam)
3194 LPMEASUREITEMSTRUCT32 lpmi=(LPMEASUREITEMSTRUCT32)lParam;
3196 hBitmapTT = LoadBitmap32A(0, MAKEINTRESOURCE32A(OBM_TRTYPE));
3197 GetObject32A( hBitmapTT, sizeof(bm), &bm );
3198 lpmi->itemHeight=bm.bmHeight;
3199 /* FIXME: use MAX of bm.bmHeight and tm.tmHeight .*/
3204 /***********************************************************************
3205 * CFn_WMDrawItem [internal]
3207 LRESULT CFn_WMDrawItem(HWND32 hDlg, WPARAM32 wParam, LPARAM lParam)
3212 COLORREF cr, oldText=0, oldBk=0;
3217 HBITMAP32 hBitmap; /* for later TT usage */
3219 LPDRAWITEMSTRUCT32 lpdi = (LPDRAWITEMSTRUCT32)lParam;
3221 if (lpdi->itemID == 0xFFFF) /* got no items */
3222 DrawFocusRect32(lpdi->hDC, &lpdi->rcItem);
3225 if (lpdi->CtlType == ODT_COMBOBOX)
3227 if (lpdi->itemState ==ODS_SELECTED)
3229 hBrush=GetSysColorBrush32(COLOR_HIGHLIGHT);
3230 oldText=SetTextColor32(lpdi->hDC, GetSysColor32(COLOR_HIGHLIGHTTEXT));
3231 oldBk=SetBkColor32(lpdi->hDC, GetSysColor32(COLOR_HIGHLIGHT));
3234 hBrush = SelectObject32(lpdi->hDC, GetStockObject32(LTGRAY_BRUSH));
3235 SelectObject32(lpdi->hDC, hBrush);
3237 FillRect32(lpdi->hDC, &lpdi->rcItem, hBrush);
3240 return TRUE; /* this should never happen */
3243 switch (lpdi->CtlID)
3245 case cmb1: /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
3246 SendMessage32A(lpdi->hwndItem, CB_GETLBTEXT32, lpdi->itemID,
3248 GetObject32A( hBitmapTT, sizeof(bm), &bm );
3249 TextOut32A(lpdi->hDC, lpdi->rcItem.left + bm.bmWidth + 10,
3250 lpdi->rcItem.top, buffer, lstrlen32A(buffer));
3252 nFontType = SendMessage32A(lpdi->hwndItem, CB_GETITEMDATA32, lpdi->itemID,0L);
3253 /* FIXME: draw bitmap if truetype usage */
3254 if (nFontType&TRUETYPE_FONTTYPE)
3256 hMemDC = CreateCompatibleDC32(lpdi->hDC);
3257 hBitmap = SelectObject32(hMemDC, hBitmapTT);
3258 BitBlt32(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top,
3259 bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
3260 SelectObject32(hMemDC, hBitmap);
3266 case cmb3: /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
3267 SendMessage32A(lpdi->hwndItem, CB_GETLBTEXT32, lpdi->itemID,
3269 TextOut32A(lpdi->hDC, lpdi->rcItem.left,
3270 lpdi->rcItem.top, buffer, lstrlen32A(buffer));
3273 case cmb4: /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
3274 SendMessage32A(lpdi->hwndItem, CB_GETLBTEXT32, lpdi->itemID,
3276 TextOut32A(lpdi->hDC, lpdi->rcItem.left + 25+5,
3277 lpdi->rcItem.top, buffer, lstrlen32A(buffer));
3278 cr = SendMessage32A(lpdi->hwndItem, CB_GETITEMDATA32, lpdi->itemID,0L);
3279 hBrush = CreateSolidBrush32(cr);
3282 hBrush = SelectObject32 (lpdi->hDC, hBrush) ;
3283 rect.right=rect.left+25;
3287 Rectangle32( lpdi->hDC, rect.left, rect.top,
3288 rect.right, rect.bottom );
3289 DeleteObject32( SelectObject32 (lpdi->hDC, hBrush)) ;
3295 default: return TRUE; /* this should never happen */
3297 if (lpdi->itemState == ODS_SELECTED)
3299 SetTextColor32(lpdi->hDC, oldText);
3300 SetBkColor32(lpdi->hDC, oldBk);
3306 /***********************************************************************
3307 * CFn_WMCtlColor [internal]
3309 LRESULT CFn_WMCtlColorStatic(HWND32 hDlg, WPARAM32 wParam, LPARAM lParam,
3310 LPCHOOSEFONT32A lpcf)
3312 if (lpcf->Flags & CF_EFFECTS)
3313 if (GetDlgCtrlID32(lParam)==stc6)
3315 SetTextColor32((HDC32)wParam, lpcf->rgbColors);
3316 return GetStockObject32(WHITE_BRUSH);
3321 /***********************************************************************
3322 * CFn_WMCommand [internal]
3324 LRESULT CFn_WMCommand(HWND32 hDlg, WPARAM32 wParam, LPARAM lParam,
3325 LPCHOOSEFONT32A lpcf)
3331 LPLOGFONT32A lpxx=lpcf->lpLogFont;
3333 TRACE(commdlg,"WM_COMMAND wParam=%08lX lParam=%08lX\n", (LONG)wParam, lParam);
3334 switch (LOWORD(wParam))
3336 case cmb1:if (HIWORD(wParam)==CBN_SELCHANGE)
3338 hdc=(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC32(hDlg);
3341 SendDlgItemMessage32A(hDlg, cmb2, CB_RESETCONTENT16, 0, 0);
3342 SendDlgItemMessage32A(hDlg, cmb3, CB_RESETCONTENT16, 0, 0);
3343 i=SendDlgItemMessage32A(hDlg, cmb1, CB_GETCURSEL16, 0, 0);
3346 HCURSOR32 hcursor=SetCursor32(LoadCursor32A(0,IDC_WAIT32A));
3349 SendDlgItemMessage32A(hDlg, cmb1, CB_GETLBTEXT32, i,
3351 TRACE(commdlg,"WM_COMMAND/cmb1 =>%s\n",str);
3352 s.hWnd1=GetDlgItem32(hDlg, cmb2);
3353 s.hWnd2=GetDlgItem32(hDlg, cmb3);
3355 EnumFontFamilies32A(hdc, str, FontStyleEnumProc32, (LPARAM)&s);
3356 SetCursor32(hcursor);
3358 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
3359 ReleaseDC32(hDlg,hdc);
3363 WARN(commdlg,"HDC failure !!!\n");
3364 EndDialog32 (hDlg, 0);
3371 case cmb3:if (HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)== BN_CLICKED )
3374 TRACE(commdlg,"WM_COMMAND/cmb2,3 =%08lX\n", lParam);
3375 i=SendDlgItemMessage32A(hDlg,cmb1,CB_GETCURSEL32,0,0);
3377 i=GetDlgItemText32A( hDlg, cmb1, str, 256 );
3380 SendDlgItemMessage32A(hDlg,cmb1,CB_GETLBTEXT32,i,
3382 l=SendDlgItemMessage32A(hDlg,cmb1,CB_GETITEMDATA32,i,0);
3384 lpcf->nFontType = LOWORD(l);
3385 /* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */
3386 /* same value reported to the EnumFonts
3387 call back with the extra FONTTYPE_... bits added */
3388 lpxx->lfPitchAndFamily=j&0xff;
3389 lpxx->lfCharSet=j>>8;
3391 strcpy(lpxx->lfFaceName,str);
3392 i=SendDlgItemMessage32A(hDlg, cmb2, CB_GETCURSEL32, 0, 0);
3395 l=SendDlgItemMessage32A(hDlg, cmb2, CB_GETITEMDATA32, i, 0);
3396 if (0!=(lpxx->lfItalic=HIWORD(l)))
3397 lpcf->nFontType |= ITALIC_FONTTYPE;
3398 if ((lpxx->lfWeight=LOWORD(l)) > FW_MEDIUM)
3399 lpcf->nFontType |= BOLD_FONTTYPE;
3401 i=SendDlgItemMessage32A(hDlg, cmb3, CB_GETCURSEL32, 0, 0);
3403 lpxx->lfHeight=-LOWORD(SendDlgItemMessage32A(hDlg, cmb3, CB_GETITEMDATA32, i, 0));
3406 lpxx->lfStrikeOut=IsDlgButtonChecked32(hDlg,chx1);
3407 lpxx->lfUnderline=IsDlgButtonChecked32(hDlg,chx2);
3408 lpxx->lfWidth=lpxx->lfOrientation=lpxx->lfEscapement=0;
3409 lpxx->lfOutPrecision=OUT_DEFAULT_PRECIS;
3410 lpxx->lfClipPrecision=CLIP_DEFAULT_PRECIS;
3411 lpxx->lfQuality=DEFAULT_QUALITY;
3412 lpcf->iPointSize= -10*lpxx->lfHeight;
3414 hFont=CreateFontIndirect32A(lpxx);
3417 HFONT32 oldFont=SendDlgItemMessage32A(hDlg, stc6,
3419 SendDlgItemMessage32A(hDlg,stc6,WM_SETFONT,hFont,TRUE);
3420 DeleteObject32(oldFont);
3425 case cmb4:i=SendDlgItemMessage32A(hDlg, cmb4, CB_GETCURSEL32, 0, 0);
3428 lpcf->rgbColors=textcolors[i];
3429 InvalidateRect32( GetDlgItem32(hDlg,stc6), NULL, 0 );
3433 case psh15:i=RegisterWindowMessage32A( HELPMSGSTRING );
3434 if (lpcf->hwndOwner)
3435 SendMessage32A(lpcf->hwndOwner, i, 0, (LPARAM)GetWindowLong32A(hDlg, DWL_USER));
3436 /* if (CFn_HookCallChk(lpcf))
3437 CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/
3440 case IDOK:if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
3441 ( (lpcf->Flags & CF_LIMITSIZE) &&
3442 (-lpxx->lfHeight >= lpcf->nSizeMin) &&
3443 (-lpxx->lfHeight <= lpcf->nSizeMax)))
3444 EndDialog32(hDlg, TRUE);
3448 sprintf(buffer,"Select a font size between %d and %d points.",
3449 lpcf->nSizeMin,lpcf->nSizeMax);
3450 MessageBox32A(hDlg, buffer, NULL, MB_OK);
3453 case IDCANCEL:EndDialog32(hDlg, FALSE);
3459 static LRESULT CFn_WMDestroy(HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
3461 DeleteObject32(SendDlgItemMessage32A(hwnd, stc6, WM_GETFONT, 0, 0));
3466 /***********************************************************************
3467 * FormatCharDlgProc16 (COMMDLG.16)
3468 FIXME: 1. some strings are "hardcoded", but it's better load from sysres
3469 2. some CF_.. flags are not supported
3470 3. some TType extensions
3472 LRESULT WINAPI FormatCharDlgProc16(HWND16 hDlg, UINT16 message, WPARAM16 wParam,
3475 LPCHOOSEFONT16 lpcf;
3476 LPCHOOSEFONT32A lpcf32a;
3480 if (message!=WM_INITDIALOG)
3482 lpcf=(LPCHOOSEFONT16)GetWindowLong32A(hDlg, DWL_USER);
3485 if (CFn_HookCallChk(lpcf))
3486 res=CallWindowProc16(lpcf->lpfnHook,hDlg,message,wParam,lParam);
3492 lpcf=(LPCHOOSEFONT16)lParam;
3493 lpcf32a=(LPCHOOSEFONT32A)lpcf->lpTemplateName;
3494 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a))
3496 TRACE(commdlg, "CFn_WMInitDialog returned FALSE\n");
3499 if (CFn_HookCallChk(lpcf))
3500 return CallWindowProc16(lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
3502 WINPROC_MapMsg16To32A(message, wParam, &uMsg32, &wParam32, &lParam);
3503 lpcf32a=(LPCHOOSEFONT32A)lpcf->lpTemplateName;
3506 case WM_MEASUREITEM:
3507 res=CFn_WMMeasureItem(hDlg, wParam32, lParam);
3510 res=CFn_WMDrawItem(hDlg, wParam32, lParam);
3512 case WM_CTLCOLORSTATIC:
3513 res=CFn_WMCtlColorStatic(hDlg, wParam32, lParam, lpcf32a);
3516 res=CFn_WMCommand(hDlg, wParam32, lParam, lpcf32a);
3519 res=CFn_WMDestroy(hDlg, wParam32, lParam);
3521 case WM_CHOOSEFONT_GETLOGFONT:
3522 TRACE(commdlg,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3524 FIXME(commdlg, "current logfont back to caller\n");
3527 WINPROC_UnmapMsg16To32A(uMsg32, wParam32, lParam, res);
3531 /***********************************************************************
3532 * FormatCharDlgProc32A [internal]
3534 LRESULT WINAPI FormatCharDlgProc32A(HWND32 hDlg, UINT32 uMsg, WPARAM32 wParam,
3537 LPCHOOSEFONT32A lpcf;
3539 if (uMsg!=WM_INITDIALOG)
3541 lpcf=(LPCHOOSEFONT32A)GetWindowLong32A(hDlg, DWL_USER);
3544 if (CFn_HookCallChk32(lpcf))
3545 res=CallWindowProc32A(lpcf->lpfnHook, hDlg, uMsg, wParam, lParam);
3551 lpcf=(LPCHOOSEFONT32A)lParam;
3552 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf))
3554 TRACE(commdlg, "CFn_WMInitDialog returned FALSE\n");
3557 if (CFn_HookCallChk32(lpcf))
3558 return CallWindowProc32A(lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
3562 case WM_MEASUREITEM:
3563 return CFn_WMMeasureItem(hDlg, wParam, lParam);
3565 return CFn_WMDrawItem(hDlg, wParam, lParam);
3566 case WM_CTLCOLORSTATIC:
3567 return CFn_WMCtlColorStatic(hDlg, wParam, lParam, lpcf);
3569 return CFn_WMCommand(hDlg, wParam, lParam, lpcf);
3571 return CFn_WMDestroy(hDlg, wParam, lParam);
3572 case WM_CHOOSEFONT_GETLOGFONT:
3573 TRACE(commdlg,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3575 FIXME(commdlg, "current logfont back to caller\n");
3581 /***********************************************************************
3582 * FormatCharDlgProc32W [internal]
3584 LRESULT WINAPI FormatCharDlgProc32W(HWND32 hDlg, UINT32 uMsg, WPARAM32 wParam,
3587 LPCHOOSEFONT32W lpcf32w;
3588 LPCHOOSEFONT32A lpcf32a;
3590 if (uMsg!=WM_INITDIALOG)
3592 lpcf32w=(LPCHOOSEFONT32W)GetWindowLong32A(hDlg, DWL_USER);
3595 if (CFn_HookCallChk32((LPCHOOSEFONT32A)lpcf32w))
3596 res=CallWindowProc32W(lpcf32w->lpfnHook, hDlg, uMsg, wParam, lParam);
3602 lpcf32w=(LPCHOOSEFONT32W)lParam;
3603 lpcf32a=(LPCHOOSEFONT32A)lpcf32w->lpTemplateName;
3604 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a))
3606 TRACE(commdlg, "CFn_WMInitDialog returned FALSE\n");
3609 if (CFn_HookCallChk32((LPCHOOSEFONT32A)lpcf32w))
3610 return CallWindowProc32W(lpcf32w->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
3612 lpcf32a=(LPCHOOSEFONT32A)lpcf32w->lpTemplateName;
3615 case WM_MEASUREITEM:
3616 return CFn_WMMeasureItem(hDlg, wParam, lParam);
3618 return CFn_WMDrawItem(hDlg, wParam, lParam);
3619 case WM_CTLCOLORSTATIC:
3620 return CFn_WMCtlColorStatic(hDlg, wParam, lParam, lpcf32a);
3622 return CFn_WMCommand(hDlg, wParam, lParam, lpcf32a);
3624 return CFn_WMDestroy(hDlg, wParam, lParam);
3625 case WM_CHOOSEFONT_GETLOGFONT:
3626 TRACE(commdlg,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3628 FIXME(commdlg, "current logfont back to caller\n");
3635 static BOOL32 Commdlg_GetFileName32A( BOOL16 (*dofunction)(),
3636 LPOPENFILENAME32A ofn )
3639 LPOPENFILENAME16 ofn16 = SEGPTR_ALLOC(sizeof(OPENFILENAME16));
3641 memset(ofn16,'\0',sizeof(*ofn16));
3642 ofn16->lStructSize = sizeof(*ofn16);
3643 ofn16->hwndOwner = ofn->hwndOwner;
3644 /* FIXME: OPENFILENAME16 got only 16 bit for HINSTANCE... */
3645 ofn16->hInstance = MODULE_HANDLEtoHMODULE16(ofn->hInstance);
3646 if (ofn->lpstrFilter) {
3649 /* filter is a list... title\0ext\0......\0\0 */
3650 s = (LPSTR)ofn->lpstrFilter;
3654 x = (LPSTR)SEGPTR_ALLOC(s-ofn->lpstrFilter);
3655 memcpy(x,ofn->lpstrFilter,s-ofn->lpstrFilter);
3656 ofn16->lpstrFilter = SEGPTR_GET(x);
3658 if (ofn->lpstrCustomFilter) {
3661 /* filter is a list... title\0ext\0......\0\0 */
3662 s = (LPSTR)ofn->lpstrCustomFilter;
3665 x = SEGPTR_ALLOC(s-ofn->lpstrCustomFilter);
3667 memcpy(x,ofn->lpstrCustomFilter,s-ofn->lpstrCustomFilter);
3668 ofn16->lpstrCustomFilter = SEGPTR_GET(x);
3670 ofn16->nMaxCustFilter = ofn->nMaxCustFilter;
3671 ofn16->nFilterIndex = ofn->nFilterIndex;
3673 ofn16->lpstrFile = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFile));
3674 ofn16->nMaxFile = ofn->nMaxFile;
3675 ofn16->nMaxFileTitle = ofn->nMaxFileTitle;
3676 if (ofn16->nMaxFileTitle)
3677 ofn16->lpstrFileTitle = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFileTitle));
3678 if (ofn->lpstrInitialDir)
3679 ofn16->lpstrInitialDir = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrInitialDir));
3680 if (ofn->lpstrTitle)
3681 ofn16->lpstrTitle = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrTitle));
3682 ofn16->Flags = ofn->Flags|OFN_WINE32;
3683 ofn16->nFileOffset = ofn->nFileOffset;
3684 ofn16->nFileExtension = ofn->nFileExtension;
3685 if (ofn->lpstrDefExt)
3686 ofn16->lpstrDefExt = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrDefExt));
3687 ofn16->lCustData = ofn->lCustData;
3688 ofn16->lpfnHook = (WNDPROC16)ofn->lpfnHook;
3690 if (ofn->lpTemplateName)
3691 ofn16->lpTemplateName = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpTemplateName));
3693 ret = dofunction(SEGPTR_GET(ofn16));
3695 ofn->nFileOffset = ofn16->nFileOffset;
3696 ofn->nFileExtension = ofn16->nFileExtension;
3697 if (ofn16->lpstrFilter)
3698 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFilter));
3699 if (ofn16->lpTemplateName)
3700 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpTemplateName));
3701 if (ofn16->lpstrDefExt)
3702 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrDefExt));
3703 if (ofn16->lpstrTitle)
3704 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrTitle));
3705 if (ofn16->lpstrInitialDir)
3706 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrInitialDir));
3707 if (ofn16->lpstrCustomFilter)
3708 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrCustomFilter));
3710 if (ofn16->lpstrFile)
3712 strcpy(ofn->lpstrFile,PTR_SEG_TO_LIN(ofn16->lpstrFile));
3713 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFile));
3716 if (ofn16->lpstrFileTitle)
3718 strcpy(ofn->lpstrFileTitle,PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
3719 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
3725 static BOOL32 Commdlg_GetFileName32W( BOOL16 (*dofunction)(),
3726 LPOPENFILENAME32W ofn )
3729 LPOPENFILENAME16 ofn16 = SEGPTR_ALLOC(sizeof(OPENFILENAME16));
3731 memset(ofn16,'\0',sizeof(*ofn16));
3732 ofn16->lStructSize = sizeof(*ofn16);
3733 ofn16->hwndOwner = ofn->hwndOwner;
3734 /* FIXME: OPENFILENAME16 got only 16 bit for HINSTANCE... */
3735 ofn16->hInstance = MODULE_HANDLEtoHMODULE16(ofn->hInstance);
3736 if (ofn->lpstrFilter) {
3741 /* filter is a list... title\0ext\0......\0\0 */
3742 s = (LPWSTR)ofn->lpstrFilter;
3744 s = s+lstrlen32W(s)+1;
3746 n = s - ofn->lpstrFilter; /* already divides by 2. ptr magic */
3747 x = y = (LPSTR)SEGPTR_ALLOC(n);
3748 s = (LPWSTR)ofn->lpstrFilter;
3755 ofn16->lpstrFilter = SEGPTR_GET(y);
3757 if (ofn->lpstrCustomFilter) {
3762 /* filter is a list... title\0ext\0......\0\0 */
3763 s = (LPWSTR)ofn->lpstrCustomFilter;
3765 s = s+lstrlen32W(s)+1;
3767 n = s - ofn->lpstrCustomFilter;
3768 x = y = (LPSTR)SEGPTR_ALLOC(n);
3769 s = (LPWSTR)ofn->lpstrCustomFilter;
3776 ofn16->lpstrCustomFilter = SEGPTR_GET(y);
3778 ofn16->nMaxCustFilter = ofn->nMaxCustFilter;
3779 ofn16->nFilterIndex = ofn->nFilterIndex;
3781 ofn16->lpstrFile = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFile));
3782 ofn16->nMaxFile = ofn->nMaxFile;
3783 ofn16->nMaxFileTitle = ofn->nMaxFileTitle;
3784 if (ofn->nMaxFileTitle)
3785 ofn16->lpstrFileTitle = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFileTitle));
3786 if (ofn->lpstrInitialDir)
3787 ofn16->lpstrInitialDir = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrInitialDir));
3788 if (ofn->lpstrTitle)
3789 ofn16->lpstrTitle = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrTitle));
3790 ofn16->Flags = ofn->Flags|OFN_WINE32|OFN_UNICODE;
3791 ofn16->nFileOffset = ofn->nFileOffset;
3792 ofn16->nFileExtension = ofn->nFileExtension;
3793 if (ofn->lpstrDefExt)
3794 ofn16->lpstrDefExt = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrDefExt));
3795 ofn16->lCustData = ofn->lCustData;
3796 ofn16->lpfnHook = (WNDPROC16)ofn->lpfnHook;
3797 if (ofn->lpTemplateName)
3798 ofn16->lpTemplateName = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpTemplateName));
3799 ret = dofunction(SEGPTR_GET(ofn16));
3801 ofn->nFileOffset = ofn16->nFileOffset;
3802 ofn->nFileExtension = ofn16->nFileExtension;
3803 if (ofn16->lpstrFilter)
3804 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFilter));
3805 if (ofn16->lpTemplateName)
3806 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpTemplateName));
3807 if (ofn16->lpstrDefExt)
3808 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrDefExt));
3809 if (ofn16->lpstrTitle)
3810 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrTitle));
3811 if (ofn16->lpstrInitialDir)
3812 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrInitialDir));
3813 if (ofn16->lpstrCustomFilter)
3814 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrCustomFilter));
3816 if (ofn16->lpstrFile) {
3817 lstrcpyAtoW(ofn->lpstrFile,PTR_SEG_TO_LIN(ofn16->lpstrFile));
3818 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFile));
3821 if (ofn16->lpstrFileTitle) {
3822 lstrcpyAtoW(ofn->lpstrFileTitle,PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
3823 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
3829 /***********************************************************************
3830 * GetOpenFileName32A (COMDLG32.10)
3832 BOOL32 WINAPI GetOpenFileName32A( LPOPENFILENAME32A ofn )
3834 BOOL16 (WINAPI * dofunction)(SEGPTR ofn16) = GetOpenFileName16;
3835 return Commdlg_GetFileName32A(dofunction,ofn);
3838 /***********************************************************************
3839 * GetOpenFileName32W (COMDLG32.11)
3841 BOOL32 WINAPI GetOpenFileName32W( LPOPENFILENAME32W ofn )
3843 BOOL16 (WINAPI * dofunction)(SEGPTR ofn16) = GetOpenFileName16;
3844 return Commdlg_GetFileName32W(dofunction,ofn);
3847 /***********************************************************************
3848 * GetSaveFileName32A (COMDLG32.12)
3850 BOOL32 WINAPI GetSaveFileName32A( LPOPENFILENAME32A ofn )
3852 BOOL16 (WINAPI * dofunction)(SEGPTR ofn16) = GetSaveFileName16;
3853 return Commdlg_GetFileName32A(dofunction,ofn);
3856 /***********************************************************************
3857 * GetSaveFileName32W (COMDLG32.13)
3859 BOOL32 WINAPI GetSaveFileName32W( LPOPENFILENAME32W ofn )
3861 BOOL16 (WINAPI * dofunction)(SEGPTR ofn16) = GetSaveFileName16;
3862 return Commdlg_GetFileName32W(dofunction,ofn);