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( MapHModuleSL(lpofn->hInstance ))))
79 CommDlgLastError = CDERR_LOADRESFAILURE;
83 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
85 if (!(hResInfo = FindResource32A(MapHModuleSL(lpofn->hInstance),
86 PTR_SEG_TO_LIN(lpofn->lpTemplateName), RT_DIALOG32A)))
88 CommDlgLastError = CDERR_FINDRESFAILURE;
91 if (!(hDlgTmpl = LoadResource32( MapHModuleSL(lpofn->hInstance),
93 !(template = LockResource32( hDlgTmpl )))
95 CommDlgLastError = CDERR_LOADRESFAILURE;
99 template = SYSRES_GetResPtr( SYSRES_DIALOG_OPEN_FILE );
103 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
105 if (!(template = LockResource16( lpofn->hInstance )))
107 CommDlgLastError = CDERR_LOADRESFAILURE;
111 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
113 if (!(hResInfo = FindResource16(lpofn->hInstance,
114 lpofn->lpTemplateName,
117 CommDlgLastError = CDERR_FINDRESFAILURE;
120 if (!(hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo )) ||
121 !(template = LockResource16( hDlgTmpl )))
123 CommDlgLastError = CDERR_LOADRESFAILURE;
127 template = SYSRES_GetResPtr( SYSRES_DIALOG_OPEN_FILE );
132 hInst = WIN_GetWindowInstance( lpofn->hwndOwner );
134 if (!(lpofn->lpstrFilter))
136 str = SEGPTR_ALLOC(sizeof(defaultfilter));
137 TRACE(commdlg,"Alloc %p default for Filetype in GetOpenFileName\n",str);
138 memcpy(str,defaultfilter,sizeof(defaultfilter));
139 lpofn->lpstrFilter=SEGPTR_GET(str);
142 if (!(lpofn->lpstrTitle))
144 str1 = SEGPTR_ALLOC(strlen(defaultopen)+1);
145 TRACE(commdlg,"Alloc %p default for Title in GetOpenFileName\n",str1);
146 strcpy(str1,defaultopen);
147 lpofn->lpstrTitle=SEGPTR_GET(str1);
150 /* FIXME: doesn't handle win32 format correctly yet */
151 hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
153 (DLGPROC16)MODULE_GetWndProcEntry16("FileOpenDlgProc"),
155 if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpofn->hwndOwner );
159 TRACE(commdlg,"Freeing %p default for Title in GetOpenFileName\n",str1);
166 TRACE(commdlg,"Freeing %p default for Filetype in GetOpenFileName\n",str);
168 lpofn->lpstrFilter=0;
172 if (lpofn->Flags & OFN_WINE32)
173 FreeResource32( hDlgTmpl );
175 FreeResource16( hDlgTmpl );
178 TRACE(commdlg,"return lpstrFile='%s' !\n",
179 (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
184 /***********************************************************************
185 * GetSaveFileName (COMMDLG.2)
187 BOOL16 WINAPI GetSaveFileName16( SEGPTR ofn)
190 HANDLE32 hDlgTmpl = 0;
191 BOOL32 bRet = FALSE, win32Format = FALSE;
192 LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(ofn);
195 char defaultsave[]="Save as";
196 char *str =0,*str1=0;
198 if (!lpofn || !FileDlg_Init()) return FALSE;
200 if (lpofn->Flags & OFN_WINE32) {
201 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
203 if (!(template = LockResource32( MapHModuleSL(lpofn->hInstance ))))
205 CommDlgLastError = CDERR_LOADRESFAILURE;
209 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
212 if (!(hResInfo = FindResource32A(MapHModuleSL(lpofn->hInstance),
213 PTR_SEG_TO_LIN(lpofn->lpTemplateName),
216 CommDlgLastError = CDERR_FINDRESFAILURE;
219 if (!(hDlgTmpl = LoadResource32(MapHModuleSL(lpofn->hInstance),
221 !(template = LockResource32(hDlgTmpl)))
223 CommDlgLastError = CDERR_LOADRESFAILURE;
228 template = SYSRES_GetResPtr( SYSRES_DIALOG_SAVE_FILE );
232 if (lpofn->Flags & OFN_ENABLETEMPLATEHANDLE)
234 if (!(template = LockResource16( lpofn->hInstance )))
236 CommDlgLastError = CDERR_LOADRESFAILURE;
240 else if (lpofn->Flags & OFN_ENABLETEMPLATE)
243 if (!(hResInfo = FindResource16(lpofn->hInstance,
244 lpofn->lpTemplateName,
247 CommDlgLastError = CDERR_FINDRESFAILURE;
250 if (!(hDlgTmpl = LoadResource16( lpofn->hInstance, hResInfo )) ||
251 !(template = LockResource16( hDlgTmpl )))
253 CommDlgLastError = CDERR_LOADRESFAILURE;
257 template = SYSRES_GetResPtr( SYSRES_DIALOG_SAVE_FILE );
262 hInst = WIN_GetWindowInstance( lpofn->hwndOwner );
264 if (!(lpofn->lpstrFilter))
266 str = SEGPTR_ALLOC(sizeof(defaultfilter));
267 TRACE(commdlg,"Alloc default for Filetype in GetSaveFileName\n");
268 memcpy(str,defaultfilter,sizeof(defaultfilter));
269 lpofn->lpstrFilter=SEGPTR_GET(str);
272 if (!(lpofn->lpstrTitle))
274 str1 = SEGPTR_ALLOC(sizeof(defaultsave)+1);
275 TRACE(commdlg,"Alloc default for Title in GetSaveFileName\n");
276 strcpy(str1,defaultsave);
277 lpofn->lpstrTitle=SEGPTR_GET(str1);
280 hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
282 (DLGPROC16)MODULE_GetWndProcEntry16("FileSaveDlgProc"),
284 if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpofn->hwndOwner );
288 TRACE(commdlg,"Freeing %p default for Title in GetSaveFileName\n",str1);
295 TRACE(commdlg,"Freeing %p default for Filetype in GetSaveFileName\n",str);
297 lpofn->lpstrFilter=0;
301 if (lpofn->Flags & OFN_WINE32)
302 FreeResource32( hDlgTmpl );
304 FreeResource16( hDlgTmpl );
307 TRACE(commdlg, "return lpstrFile='%s' !\n",
308 (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFile));
312 /***********************************************************************
313 * FILEDLG_StripEditControl [internal]
314 * Strip pathnames off the contents of the edit control.
316 static void FILEDLG_StripEditControl(HWND16 hwnd)
320 GetDlgItemText32A( hwnd, edt1, temp, sizeof(temp) );
321 cp = strrchr(temp, '\\');
325 cp = strrchr(temp, ':');
329 /* FIXME: shouldn't we do something with the result here? ;-) */
332 /***********************************************************************
333 * FILEDLG_ScanDir [internal]
335 static BOOL32 FILEDLG_ScanDir(HWND16 hWnd, LPSTR newPath)
342 lstrcpyn32A(buffer, newPath, sizeof(buffer));
344 if (str[0] && (str[1] == ':')) {
345 drive = toupper(str[0]) - 'A';
347 if (!DRIVE_SetCurrentDrive(drive))
350 drive = DRIVE_GetCurrentDrive();
353 if (str[0] && !DRIVE_Chdir(drive, str)) {
357 GetDlgItemText32A(hWnd, edt1, buffer, sizeof(buffer));
358 if ((hlb = GetDlgItem32(hWnd, lst1)) != 0) {
359 char* scptr; /* ptr on semi-colon */
360 char* filter = buffer;
362 TRACE(commdlg, "Using filter %s\n", filter);
363 SendMessage32A(hlb, LB_RESETCONTENT32, 0, 0);
365 scptr = strchr(filter, ';');
366 if (scptr) *scptr = 0;
367 TRACE(commdlg, "Using file spec %s\n", filter);
368 if (SendMessage32A(hlb, LB_DIR32, 0, (LPARAM)filter) == LB_ERR)
370 if (scptr) *scptr = ';';
371 filter = (scptr) ? (scptr + 1) : 0;
375 strcpy(buffer, "*.*");
376 return DlgDirList32A(hWnd, buffer, lst2, stc1, 0x8010);
379 /***********************************************************************
380 * FILEDLG_GetFileType [internal]
383 static LPSTR FILEDLG_GetFileType(LPSTR cfptr, LPSTR fptr, WORD index)
388 for ( ;(n = strlen(cfptr)) != 0; i++)
393 cfptr += strlen(cfptr) + 1;
396 for ( ;(n = strlen(fptr)) != 0; i++)
401 fptr += strlen(fptr) + 1;
403 return "*.*"; /* FIXME */
406 /***********************************************************************
407 * FILEDLG_WMDrawItem [internal]
409 static LONG FILEDLG_WMDrawItem(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam,int savedlg)
411 LPDRAWITEMSTRUCT16 lpdis = (LPDRAWITEMSTRUCT16)PTR_SEG_TO_LIN(lParam);
414 HBITMAP16 hBitmap, hPrevBitmap;
418 if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst1)
420 if (!(str = SEGPTR_ALLOC(512))) return FALSE;
421 hBrush = SelectObject32(lpdis->hDC, GetStockObject32(LTGRAY_BRUSH));
422 SelectObject32(lpdis->hDC, hBrush);
423 FillRect16(lpdis->hDC, &lpdis->rcItem, hBrush);
424 SendMessage16(lpdis->hwndItem, LB_GETTEXT16, lpdis->itemID,
425 (LPARAM)SEGPTR_GET(str));
427 if (savedlg) /* use _gray_ text in FileSaveDlg */
429 if (!lpdis->itemState)
430 SetTextColor32(lpdis->hDC,GetSysColor32(COLOR_GRAYTEXT) );
432 SetTextColor32(lpdis->hDC,GetSysColor32(COLOR_WINDOWTEXT) );
433 /* inversion of gray would be bad readable */
436 TextOut16(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
438 if (lpdis->itemState != 0) {
439 InvertRect16(lpdis->hDC, &lpdis->rcItem);
445 if (lpdis->CtlType == ODT_LISTBOX && lpdis->CtlID == lst2)
447 if (!(str = SEGPTR_ALLOC(512))) return FALSE;
448 hBrush = SelectObject32(lpdis->hDC, GetStockObject32(LTGRAY_BRUSH));
449 SelectObject32(lpdis->hDC, hBrush);
450 FillRect16(lpdis->hDC, &lpdis->rcItem, hBrush);
451 SendMessage16(lpdis->hwndItem, LB_GETTEXT16, lpdis->itemID,
452 (LPARAM)SEGPTR_GET(str));
455 GetObject16( hBitmap, sizeof(bm), &bm );
456 TextOut16(lpdis->hDC, lpdis->rcItem.left + bm.bmWidth,
457 lpdis->rcItem.top, str, strlen(str));
458 hMemDC = CreateCompatibleDC32(lpdis->hDC);
459 hPrevBitmap = SelectObject32(hMemDC, hBitmap);
460 BitBlt32(lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
461 bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
462 SelectObject32(hMemDC, hPrevBitmap);
464 if (lpdis->itemState != 0) InvertRect16(lpdis->hDC, &lpdis->rcItem);
468 if (lpdis->CtlType == ODT_COMBOBOX && lpdis->CtlID == cmb2)
470 if (!(str = SEGPTR_ALLOC(512))) return FALSE;
471 hBrush = SelectObject32(lpdis->hDC, GetStockObject32(LTGRAY_BRUSH));
472 SelectObject32(lpdis->hDC, hBrush);
473 FillRect16(lpdis->hDC, &lpdis->rcItem, hBrush);
474 SendMessage16(lpdis->hwndItem, CB_GETLBTEXT16, lpdis->itemID,
475 (LPARAM)SEGPTR_GET(str));
476 switch(DRIVE_GetType( str[2] - 'a' ))
478 case TYPE_FLOPPY: hBitmap = hFloppy; break;
479 case TYPE_CDROM: hBitmap = hCDRom; break;
482 default: hBitmap = hHDisk; break;
484 GetObject16( hBitmap, sizeof(bm), &bm );
485 TextOut16(lpdis->hDC, lpdis->rcItem.left + bm.bmWidth,
486 lpdis->rcItem.top, str, strlen(str));
487 hMemDC = CreateCompatibleDC32(lpdis->hDC);
488 hPrevBitmap = SelectObject32(hMemDC, hBitmap);
489 BitBlt32( lpdis->hDC, lpdis->rcItem.left, lpdis->rcItem.top,
490 bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY );
491 SelectObject32(hMemDC, hPrevBitmap);
493 if (lpdis->itemState != 0) InvertRect16(lpdis->hDC, &lpdis->rcItem);
500 /***********************************************************************
501 * FILEDLG_WMMeasureItem [internal]
503 static LONG FILEDLG_WMMeasureItem(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
506 LPMEASUREITEMSTRUCT16 lpmeasure;
508 GetObject16( hFolder2, sizeof(bm), &bm );
509 lpmeasure = (LPMEASUREITEMSTRUCT16)PTR_SEG_TO_LIN(lParam);
510 lpmeasure->itemHeight = bm.bmHeight;
514 /***********************************************************************
515 * FILEDLG_HookCallChk [internal]
517 static int FILEDLG_HookCallChk(LPOPENFILENAME16 lpofn)
520 if (lpofn->Flags & OFN_ENABLEHOOK)
526 /***********************************************************************
527 * FILEDLG_CallWindowProc [internal]
529 * Adapt the structures back for win32 calls so the callee can read lpCustData
531 static BOOL32 FILEDLG_CallWindowProc(LPOPENFILENAME16 lpofn,HWND32 hwnd,
532 UINT32 wMsg,WPARAM32 wParam,LPARAM lParam
537 needstruct = (PTR_SEG_TO_LIN(lParam) == lpofn);
539 if (!(lpofn->Flags & OFN_WINE32))
540 return (BOOL32)CallWindowProc16(
541 lpofn->lpfnHook,hwnd,(UINT16)wMsg,(WPARAM16)wParam,lParam
544 if (lpofn->Flags & OFN_UNICODE) {
546 OPENFILENAME32W ofnw;
548 /* FIXME: probably needs more converted */
549 ofnw.lCustData = lpofn->lCustData;
550 return (BOOL32)CallWindowProc32W(
551 (WNDPROC32)lpofn->lpfnHook,hwnd,wMsg,wParam,(LPARAM)&ofnw
554 return (BOOL32)CallWindowProc32W(
555 (WNDPROC32)lpofn->lpfnHook,hwnd,wMsg,wParam,lParam
560 OPENFILENAME32A ofna;
562 /* FIXME: probably needs more converted */
563 ofna.lCustData = lpofn->lCustData;
564 return (BOOL32)CallWindowProc32A(
565 (WNDPROC32)lpofn->lpfnHook,hwnd,wMsg,wParam,(LPARAM)&ofna
568 return (BOOL32)CallWindowProc32A(
569 (WNDPROC32)lpofn->lpfnHook,hwnd,wMsg,wParam,lParam
574 /***********************************************************************
575 * FILEDLG_WMInitDialog [internal]
578 static LONG FILEDLG_WMInitDialog(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
581 LPOPENFILENAME16 lpofn;
583 LPSTR pstr, old_pstr;
584 SetWindowLong32A(hWnd, DWL_USER, lParam);
585 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(lParam);
586 if (lpofn->lpstrTitle) SetWindowText16( hWnd, lpofn->lpstrTitle );
587 /* read custom filter information */
588 if (lpofn->lpstrCustomFilter)
590 pstr = (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter);
592 TRACE(commdlg,"lpstrCustomFilter = %p\n", pstr);
596 i = SendDlgItemMessage16(hWnd, cmb1, CB_ADDSTRING16, 0,
597 (LPARAM)lpofn->lpstrCustomFilter + n );
598 n += strlen(pstr) + 1;
599 pstr += strlen(pstr) + 1;
600 TRACE(commdlg,"add str='%s' "
601 "associated to '%s'\n", old_pstr, pstr);
602 SendDlgItemMessage16(hWnd, cmb1, CB_SETITEMDATA16, i, (LPARAM)pstr);
603 n += strlen(pstr) + 1;
604 pstr += strlen(pstr) + 1;
607 /* read filter information */
608 if (lpofn->lpstrFilter) {
609 pstr = (LPSTR)PTR_SEG_TO_LIN(lpofn->lpstrFilter);
613 i = SendDlgItemMessage16(hWnd, cmb1, CB_ADDSTRING16, 0,
614 (LPARAM)lpofn->lpstrFilter + n );
615 n += strlen(pstr) + 1;
616 pstr += strlen(pstr) + 1;
617 TRACE(commdlg,"add str='%s' "
618 "associated to '%s'\n", old_pstr, pstr);
619 SendDlgItemMessage16(hWnd, cmb1, CB_SETITEMDATA16, i, (LPARAM)pstr);
620 n += strlen(pstr) + 1;
621 pstr += strlen(pstr) + 1;
624 /* set default filter */
625 if (lpofn->nFilterIndex == 0 && lpofn->lpstrCustomFilter == (SEGPTR)NULL)
626 lpofn->nFilterIndex = 1;
627 SendDlgItemMessage16(hWnd, cmb1, CB_SETCURSEL16, lpofn->nFilterIndex - 1, 0);
628 strncpy(tmpstr, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter),
629 PTR_SEG_TO_LIN(lpofn->lpstrFilter), lpofn->nFilterIndex - 1),511);
631 TRACE(commdlg,"nFilterIndex = %ld, SetText of edt1 to '%s'\n",
632 lpofn->nFilterIndex, tmpstr);
633 SetDlgItemText32A( hWnd, edt1, tmpstr );
636 DlgDirListComboBox32A(hWnd, tmpstr, cmb2, 0, 0xC000);
637 /* read initial directory */
638 if (PTR_SEG_TO_LIN(lpofn->lpstrInitialDir) != NULL)
640 strncpy(tmpstr, PTR_SEG_TO_LIN(lpofn->lpstrInitialDir), 510);
642 if (strlen(tmpstr) > 0 && tmpstr[strlen(tmpstr)-1] != '\\'
643 && tmpstr[strlen(tmpstr)-1] != ':')
648 if (!FILEDLG_ScanDir(hWnd, tmpstr)) {
650 if (!FILEDLG_ScanDir(hWnd, tmpstr))
651 WARN(commdlg, "Couldn't read initial directory %s!\n",tmpstr);
653 /* select current drive in combo 2, omit missing drives */
654 for(i=0, n=-1; i<=DRIVE_GetCurrentDrive(); i++)
655 if (DRIVE_IsValid(i)) n++;
656 SendDlgItemMessage16(hWnd, cmb2, CB_SETCURSEL16, n, 0);
657 if (!(lpofn->Flags & OFN_SHOWHELP))
658 ShowWindow32(GetDlgItem32(hWnd, pshHelp), SW_HIDE);
659 if (lpofn->Flags & OFN_HIDEREADONLY)
660 ShowWindow32(GetDlgItem32(hWnd, chx1), SW_HIDE);
661 if (FILEDLG_HookCallChk(lpofn))
662 return (BOOL16)FILEDLG_CallWindowProc(lpofn,hWnd,WM_INITDIALOG,wParam,lParam );
667 /***********************************************************************
668 * FILEDLG_WMCommand [internal]
670 BOOL32 in_update=FALSE;
672 static LRESULT FILEDLG_WMCommand(HWND16 hWnd, WPARAM16 wParam, LPARAM lParam)
675 LPOPENFILENAME16 lpofn;
677 char tmpstr[512], tmpstr2[512];
679 UINT16 control,notification;
681 /* Notifications are packaged differently in Win32 */
683 notification = HIWORD(lParam);
685 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
688 case lst1: /* file list */
689 FILEDLG_StripEditControl(hWnd);
690 if (notification == LBN_DBLCLK)
692 lRet = SendDlgItemMessage16(hWnd, lst1, LB_GETCURSEL16, 0, 0);
693 if (lRet == LB_ERR) return TRUE;
694 if ((pstr = SEGPTR_ALLOC(512)))
696 SendDlgItemMessage16(hWnd, lst1, LB_GETTEXT16, lRet,
697 (LPARAM)SEGPTR_GET(pstr));
698 SetDlgItemText32A( hWnd, edt1, pstr );
701 if (FILEDLG_HookCallChk(lpofn))
702 FILEDLG_CallWindowProc(lpofn,hWnd,
703 RegisterWindowMessage32A( LBSELCHSTRING ),
704 control, MAKELONG(lRet,CD_LBSELCHANGE));
705 /* FIXME: for OFN_ALLOWMULTISELECT we need CD_LBSELSUB, CD_SELADD, CD_LBSELNOITEMS */
707 case lst2: /* directory list */
708 FILEDLG_StripEditControl(hWnd);
709 if (notification == LBN_DBLCLK)
711 lRet = SendDlgItemMessage16(hWnd, lst2, LB_GETCURSEL16, 0, 0);
712 if (lRet == LB_ERR) return TRUE;
713 pstr = SEGPTR_ALLOC(512);
714 SendDlgItemMessage16(hWnd, lst2, LB_GETTEXT16, lRet,
715 (LPARAM)SEGPTR_GET(pstr));
716 strcpy( tmpstr, pstr );
718 if (tmpstr[0] == '[')
720 tmpstr[strlen(tmpstr) - 1] = 0;
721 strcpy(tmpstr,tmpstr+1);
723 strcat(tmpstr, "\\");
727 case cmb1: /* file type drop list */
728 if (notification == CBN_SELCHANGE)
738 case cmb2: /* disk drop list */
739 FILEDLG_StripEditControl(hWnd);
740 lRet = SendDlgItemMessage16(hWnd, cmb2, CB_GETCURSEL16, 0, 0L);
741 if (lRet == LB_ERR) return 0;
742 pstr = SEGPTR_ALLOC(512);
743 SendDlgItemMessage16(hWnd, cmb2, CB_GETLBTEXT16, lRet,
744 (LPARAM)SEGPTR_GET(pstr));
745 sprintf(tmpstr, "%c:", pstr[2]);
748 lRet = SendDlgItemMessage16(hWnd, cmb1, CB_GETCURSEL16, 0, 0);
751 pstr = (LPSTR)SendDlgItemMessage16(hWnd, cmb1, CB_GETITEMDATA16, lRet, 0);
752 TRACE(commdlg,"Selected filter : %s\n", pstr);
753 SetDlgItemText32A( hWnd, edt1, pstr );
754 FILEDLG_ScanDir(hWnd, tmpstr);
758 ofn2=*lpofn; /* for later restoring */
759 GetDlgItemText32A( hWnd, edt1, tmpstr, sizeof(tmpstr) );
760 pstr = strrchr(tmpstr, '\\');
762 pstr = strrchr(tmpstr, ':');
763 if (strchr(tmpstr,'*') != NULL || strchr(tmpstr,'?') != NULL)
765 /* edit control contains wildcards */
768 strncpy(tmpstr2, pstr+1, 511); tmpstr2[511]=0;
773 strcpy(tmpstr2, tmpstr);
776 TRACE(commdlg,"tmpstr=%s, tmpstr2=%s\n", tmpstr, tmpstr2);
777 SetDlgItemText32A( hWnd, edt1, tmpstr2 );
778 FILEDLG_ScanDir(hWnd, tmpstr);
781 /* no wildcards, we might have a directory or a filename */
782 /* try appending a wildcard and reading the directory */
783 pstr2 = tmpstr + strlen(tmpstr);
784 if (pstr == NULL || *(pstr+1) != 0)
785 strcat(tmpstr, "\\");
786 lRet = SendDlgItemMessage16(hWnd, cmb1, CB_GETCURSEL16, 0, 0);
787 if (lRet == LB_ERR) return TRUE;
788 lpofn->nFilterIndex = lRet + 1;
789 TRACE(commdlg,"lpofn->nFilterIndex=%ld\n", lpofn->nFilterIndex);
791 FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn->lpstrCustomFilter),
792 PTR_SEG_TO_LIN(lpofn->lpstrFilter),
793 lRet), sizeof(tmpstr2));
794 SetDlgItemText32A( hWnd, edt1, tmpstr2 );
796 /* if ScanDir succeeds, we have changed the directory */
797 if (FILEDLG_ScanDir(hWnd, tmpstr)) return TRUE;
798 /* if not, this must be a filename */
802 /* strip off the pathname */
804 SetDlgItemText32A( hWnd, edt1, pstr + 1 );
805 lstrcpyn32A(tmpstr2, pstr+1, sizeof(tmpstr2) );
806 /* Should we MessageBox() if this fails? */
807 if (!FILEDLG_ScanDir(hWnd, tmpstr)) return TRUE;
808 strcpy(tmpstr, tmpstr2);
810 else SetDlgItemText32A( hWnd, edt1, tmpstr );
812 ShowWindow16(hWnd, SW_HIDE); /* this should not be necessary ?! (%%%) */
815 int drive = DRIVE_GetCurrentDrive();
816 tmpstr2[0] = 'A'+ drive;
819 strncpy(tmpstr2 + 3, DRIVE_GetDosCwd(drive), 507); tmpstr2[510]=0;
820 if (strlen(tmpstr2) > 3)
821 strcat(tmpstr2, "\\");
822 strncat(tmpstr2, tmpstr, 511-strlen(tmpstr2)); tmpstr2[511]=0;
823 if (lpofn->lpstrFile)
824 lstrcpyn32A(PTR_SEG_TO_LIN(lpofn->lpstrFile), tmpstr2,lpofn->nMaxFile);
826 lpofn->nFileOffset = strrchr(tmpstr2,'\\') - tmpstr2 +1;
827 lpofn->nFileExtension = 0;
828 while(tmpstr2[lpofn->nFileExtension] != '.' && tmpstr2[lpofn->nFileExtension] != '\0')
829 lpofn->nFileExtension++;
830 if (tmpstr2[lpofn->nFileExtension] == '\0')
831 lpofn->nFileExtension = 0;
833 lpofn->nFileExtension++;
837 if (FILEDLG_HookCallChk(lpofn))
838 FILEDLG_CallWindowProc(lpofn,hWnd,
839 RegisterWindowMessage32A( LBSELCHSTRING ),
840 control, MAKELONG(lRet,CD_LBSELCHANGE));
845 if (PTR_SEG_TO_LIN(lpofn->lpstrFileTitle) != NULL)
847 lRet = SendDlgItemMessage16(hWnd, lst1, LB_GETCURSEL16, 0, 0);
848 SendDlgItemMessage16(hWnd, lst1, LB_GETTEXT16, lRet,
849 lpofn->lpstrFileTitle );
851 if (FILEDLG_HookCallChk(lpofn))
853 lRet= (BOOL16)FILEDLG_CallWindowProc(lpofn,
854 hWnd, RegisterWindowMessage32A( FILEOKSTRING ), 0, lParam );
857 *lpofn=ofn2; /* restore old state */
859 ShowWindow16(hWnd, SW_SHOW); /* only if above (%%%) SW_HIDE used */
864 EndDialog32(hWnd, TRUE);
867 EndDialog32(hWnd, FALSE);
874 /***********************************************************************
875 * FileOpenDlgProc (COMMDLG.6)
877 LRESULT WINAPI FileOpenDlgProc(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
880 LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
882 if (wMsg!=WM_INITDIALOG)
883 if (FILEDLG_HookCallChk(lpofn))
885 LRESULT lRet=(BOOL16)FILEDLG_CallWindowProc(lpofn,hWnd,wMsg,wParam,lParam);
887 return lRet; /* else continue message processing */
892 return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
894 return FILEDLG_WMMeasureItem(hWnd, wParam, lParam);
896 return FILEDLG_WMDrawItem(hWnd, wParam, lParam, FALSE);
898 return FILEDLG_WMCommand(hWnd, wParam, lParam);
901 SetBkColor((HDC16)wParam, 0x00C0C0C0);
902 switch (HIWORD(lParam))
905 SetTextColor((HDC16)wParam, 0x00000000);
907 case CTLCOLOR_STATIC:
908 SetTextColor((HDC16)wParam, 0x00000000);
918 /***********************************************************************
919 * FileSaveDlgProc (COMMDLG.7)
921 LRESULT WINAPI FileSaveDlgProc(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
924 LPOPENFILENAME16 lpofn = (LPOPENFILENAME16)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
926 if (wMsg!=WM_INITDIALOG)
927 if (FILEDLG_HookCallChk(lpofn))
929 LRESULT lRet=(BOOL16)FILEDLG_CallWindowProc(lpofn,hWnd,wMsg,wParam,lParam);
931 return lRet; /* else continue message processing */
935 return FILEDLG_WMInitDialog(hWnd, wParam, lParam);
938 return FILEDLG_WMMeasureItem(hWnd, wParam, lParam);
941 return FILEDLG_WMDrawItem(hWnd, wParam, lParam, TRUE);
944 return FILEDLG_WMCommand(hWnd, wParam, lParam);
949 SetBkColor((HDC16)wParam, 0x00C0C0C0);
950 switch (HIWORD(lParam))
953 SetTextColor((HDC16)wParam, 0x00000000);
955 case CTLCOLOR_STATIC:
956 SetTextColor((HDC16)wParam, 0x00000000);
966 /***********************************************************************
967 * FindText16 (COMMDLG.11)
969 HWND16 WINAPI FindText16( SEGPTR find )
973 LPFINDREPLACE16 lpFind = (LPFINDREPLACE16)PTR_SEG_TO_LIN(find);
976 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
977 * For now, only the standard dialog works.
979 if (lpFind->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE |
980 FR_ENABLEHOOK)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
981 ptr = SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT );
982 hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
983 return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
984 (DLGPROC16)MODULE_GetWndProcEntry16("FindTextDlgProc"),
988 /***********************************************************************
989 * FindText32A (COMMDLG.6)
991 HWND32 WINAPI FindText32A( LPFINDREPLACE32A lpFind )
997 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
998 * For now, only the standard dialog works.
1000 if (lpFind->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE |
1001 FR_ENABLEHOOK)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
1002 ptr = SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT );
1003 hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
1004 return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
1005 (DLGPROC16)FindTextDlgProc32A, (LPARAM)lpFind, WIN_PROC_32A );
1008 /***********************************************************************
1009 * FindText32W (COMMDLG.7)
1011 HWND32 WINAPI FindText32W( LPFINDREPLACE32W lpFind )
1017 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
1018 * For now, only the standard dialog works.
1020 if (lpFind->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE |
1021 FR_ENABLEHOOK)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
1022 ptr = SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT );
1023 hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
1024 return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
1025 (DLGPROC16)FindTextDlgProc32W, (LPARAM)lpFind, WIN_PROC_32W );
1028 /***********************************************************************
1029 * ReplaceText16 (COMMDLG.12)
1031 HWND16 WINAPI ReplaceText16( SEGPTR find )
1035 LPFINDREPLACE16 lpFind = (LPFINDREPLACE16)PTR_SEG_TO_LIN(find);
1038 * FIXME : We should do error checking on the lpFind structure here
1039 * and make CommDlgExtendedError() return the error condition.
1041 if (lpFind->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE |
1042 FR_ENABLEHOOK)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
1043 ptr = SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT );
1044 hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
1045 return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
1046 (DLGPROC16)MODULE_GetWndProcEntry16("ReplaceTextDlgProc"),
1047 find, WIN_PROC_16 );
1050 /***********************************************************************
1051 * ReplaceText32A (COMDLG32.19)
1053 HWND32 WINAPI ReplaceText32A( LPFINDREPLACE32A lpFind )
1059 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
1060 * For now, only the standard dialog works.
1062 if (lpFind->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE |
1063 FR_ENABLEHOOK)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
1064 ptr = SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT );
1065 hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
1066 return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
1067 (DLGPROC16)ReplaceTextDlgProc32A, (LPARAM)lpFind, WIN_PROC_32A );
1070 /***********************************************************************
1071 * ReplaceText32W (COMDLG32.20)
1073 HWND32 WINAPI ReplaceText32W( LPFINDREPLACE32W lpFind )
1079 * FIXME : We should do error checking on the lpFind structure here
1080 * and make CommDlgExtendedError() return the error condition.
1082 if (lpFind->Flags & (FR_ENABLETEMPLATE | FR_ENABLETEMPLATEHANDLE |
1083 FR_ENABLEHOOK)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
1084 ptr = SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT );
1085 hInst = WIN_GetWindowInstance( lpFind->hwndOwner );
1086 return DIALOG_CreateIndirect( hInst, ptr, TRUE, lpFind->hwndOwner,
1087 (DLGPROC16)ReplaceTextDlgProc32W, (LPARAM)lpFind, WIN_PROC_32W );
1091 /***********************************************************************
1092 * FINDDLG_WMInitDialog [internal]
1094 static LRESULT FINDDLG_WMInitDialog(HWND32 hWnd, LPARAM lParam, LPDWORD lpFlags,
1095 LPSTR lpstrFindWhat, BOOL32 fUnicode)
1097 SetWindowLong32A(hWnd, DWL_USER, lParam);
1098 *lpFlags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
1100 * FIXME : If the initial FindWhat string is empty, we should disable the
1101 * FindNext (IDOK) button. Only after typing some text, the button should be
1104 if (fUnicode) SetDlgItemText32W(hWnd, edt1, (LPWSTR)lpstrFindWhat);
1105 else SetDlgItemText32A(hWnd, edt1, lpstrFindWhat);
1106 CheckRadioButton32(hWnd, rad1, rad2, (*lpFlags & FR_DOWN) ? rad2 : rad1);
1107 if (*lpFlags & (FR_HIDEUPDOWN | FR_NOUPDOWN)) {
1108 EnableWindow32(GetDlgItem32(hWnd, rad1), FALSE);
1109 EnableWindow32(GetDlgItem32(hWnd, rad2), FALSE);
1111 if (*lpFlags & FR_HIDEUPDOWN) {
1112 ShowWindow32(GetDlgItem32(hWnd, rad1), SW_HIDE);
1113 ShowWindow32(GetDlgItem32(hWnd, rad2), SW_HIDE);
1114 ShowWindow32(GetDlgItem32(hWnd, grp1), SW_HIDE);
1116 CheckDlgButton32(hWnd, chx1, (*lpFlags & FR_WHOLEWORD) ? 1 : 0);
1117 if (*lpFlags & (FR_HIDEWHOLEWORD | FR_NOWHOLEWORD))
1118 EnableWindow32(GetDlgItem32(hWnd, chx1), FALSE);
1119 if (*lpFlags & FR_HIDEWHOLEWORD)
1120 ShowWindow32(GetDlgItem32(hWnd, chx1), SW_HIDE);
1121 CheckDlgButton32(hWnd, chx2, (*lpFlags & FR_MATCHCASE) ? 1 : 0);
1122 if (*lpFlags & (FR_HIDEMATCHCASE | FR_NOMATCHCASE))
1123 EnableWindow32(GetDlgItem32(hWnd, chx2), FALSE);
1124 if (*lpFlags & FR_HIDEMATCHCASE)
1125 ShowWindow32(GetDlgItem32(hWnd, chx2), SW_HIDE);
1126 if (!(*lpFlags & FR_SHOWHELP)) {
1127 EnableWindow32(GetDlgItem32(hWnd, pshHelp), FALSE);
1128 ShowWindow32(GetDlgItem32(hWnd, pshHelp), SW_HIDE);
1130 ShowWindow32(hWnd, SW_SHOWNORMAL);
1135 /***********************************************************************
1136 * FINDDLG_WMCommand [internal]
1138 static LRESULT FINDDLG_WMCommand(HWND32 hWnd, WPARAM32 wParam,
1139 HWND32 hwndOwner, LPDWORD lpFlags,
1140 LPSTR lpstrFindWhat, WORD wFindWhatLen,
1143 int uFindReplaceMessage = RegisterWindowMessage32A( FINDMSGSTRING );
1144 int uHelpMessage = RegisterWindowMessage32A( HELPMSGSTRING );
1149 GetDlgItemText32W(hWnd, edt1, (LPWSTR)lpstrFindWhat, wFindWhatLen/2);
1150 else GetDlgItemText32A(hWnd, edt1, lpstrFindWhat, wFindWhatLen);
1151 if (IsDlgButtonChecked32(hWnd, rad2))
1152 *lpFlags |= FR_DOWN;
1153 else *lpFlags &= ~FR_DOWN;
1154 if (IsDlgButtonChecked32(hWnd, chx1))
1155 *lpFlags |= FR_WHOLEWORD;
1156 else *lpFlags &= ~FR_WHOLEWORD;
1157 if (IsDlgButtonChecked32(hWnd, chx2))
1158 *lpFlags |= FR_MATCHCASE;
1159 else *lpFlags &= ~FR_MATCHCASE;
1160 *lpFlags &= ~(FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
1161 *lpFlags |= FR_FINDNEXT;
1162 SendMessage32A(hwndOwner, uFindReplaceMessage, 0,
1163 GetWindowLong32A(hWnd, DWL_USER) );
1166 *lpFlags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL);
1167 *lpFlags |= FR_DIALOGTERM;
1168 SendMessage32A(hwndOwner, uFindReplaceMessage, 0,
1169 GetWindowLong32A(hWnd, DWL_USER) );
1170 DestroyWindow32(hWnd);
1173 /* FIXME : should lpfr structure be passed as an argument ??? */
1174 SendMessage32A(hwndOwner, uHelpMessage, 0, 0);
1181 /***********************************************************************
1182 * FindTextDlgProc16 (COMMDLG.13)
1184 LRESULT WINAPI FindTextDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
1187 LPFINDREPLACE16 lpfr;
1190 lpfr=(LPFINDREPLACE16)PTR_SEG_TO_LIN(lParam);
1191 return FINDDLG_WMInitDialog(hWnd, lParam, &(lpfr->Flags),
1192 PTR_SEG_TO_LIN(lpfr->lpstrFindWhat), FALSE);
1194 lpfr=(LPFINDREPLACE16)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
1195 return FINDDLG_WMCommand(hWnd, wParam, lpfr->hwndOwner,
1196 &lpfr->Flags, PTR_SEG_TO_LIN(lpfr->lpstrFindWhat),
1197 lpfr->wFindWhatLen, FALSE);
1202 /***********************************************************************
1203 * FindTextDlgProc32A
1205 LRESULT WINAPI FindTextDlgProc32A(HWND32 hWnd, UINT32 wMsg, WPARAM32 wParam,
1208 LPFINDREPLACE32A lpfr;
1211 lpfr=(LPFINDREPLACE32A)lParam;
1212 return FINDDLG_WMInitDialog(hWnd, lParam, &(lpfr->Flags),
1213 lpfr->lpstrFindWhat, FALSE);
1215 lpfr=(LPFINDREPLACE32A)GetWindowLong32A(hWnd, DWL_USER);
1216 return FINDDLG_WMCommand(hWnd, wParam, lpfr->hwndOwner,
1217 &lpfr->Flags, lpfr->lpstrFindWhat, lpfr->wFindWhatLen,
1223 /***********************************************************************
1224 * FindTextDlgProc32W
1226 LRESULT WINAPI FindTextDlgProc32W(HWND32 hWnd, UINT32 wMsg, WPARAM32 wParam,
1229 LPFINDREPLACE32W lpfr;
1232 lpfr=(LPFINDREPLACE32W)lParam;
1233 return FINDDLG_WMInitDialog(hWnd, lParam, &(lpfr->Flags),
1234 (LPSTR)lpfr->lpstrFindWhat, TRUE);
1236 lpfr=(LPFINDREPLACE32W)GetWindowLong32A(hWnd, DWL_USER);
1237 return FINDDLG_WMCommand(hWnd, wParam, lpfr->hwndOwner,
1238 &lpfr->Flags, (LPSTR)lpfr->lpstrFindWhat, lpfr->wFindWhatLen,
1245 /***********************************************************************
1246 * REPLACEDLG_WMInitDialog [internal]
1248 static LRESULT REPLACEDLG_WMInitDialog(HWND32 hWnd, LPARAM lParam,
1249 LPDWORD lpFlags, LPSTR lpstrFindWhat,
1250 LPSTR lpstrReplaceWith, BOOL32 fUnicode)
1252 SetWindowLong32A(hWnd, DWL_USER, lParam);
1253 *lpFlags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
1255 * FIXME : If the initial FindWhat string is empty, we should disable the FinNext /
1256 * Replace / ReplaceAll buttons. Only after typing some text, the buttons should be
1261 SetDlgItemText32W(hWnd, edt1, (LPWSTR)lpstrFindWhat);
1262 SetDlgItemText32W(hWnd, edt2, (LPWSTR)lpstrReplaceWith);
1265 SetDlgItemText32A(hWnd, edt1, lpstrFindWhat);
1266 SetDlgItemText32A(hWnd, edt2, lpstrReplaceWith);
1268 CheckDlgButton32(hWnd, chx1, (*lpFlags & FR_WHOLEWORD) ? 1 : 0);
1269 if (*lpFlags & (FR_HIDEWHOLEWORD | FR_NOWHOLEWORD))
1270 EnableWindow32(GetDlgItem32(hWnd, chx1), FALSE);
1271 if (*lpFlags & FR_HIDEWHOLEWORD)
1272 ShowWindow32(GetDlgItem32(hWnd, chx1), SW_HIDE);
1273 CheckDlgButton32(hWnd, chx2, (*lpFlags & FR_MATCHCASE) ? 1 : 0);
1274 if (*lpFlags & (FR_HIDEMATCHCASE | FR_NOMATCHCASE))
1275 EnableWindow32(GetDlgItem32(hWnd, chx2), FALSE);
1276 if (*lpFlags & FR_HIDEMATCHCASE)
1277 ShowWindow32(GetDlgItem32(hWnd, chx2), SW_HIDE);
1278 if (!(*lpFlags & FR_SHOWHELP)) {
1279 EnableWindow32(GetDlgItem32(hWnd, pshHelp), FALSE);
1280 ShowWindow32(GetDlgItem32(hWnd, pshHelp), SW_HIDE);
1282 ShowWindow32(hWnd, SW_SHOWNORMAL);
1287 /***********************************************************************
1288 * REPLACEDLG_WMCommand [internal]
1290 static LRESULT REPLACEDLG_WMCommand(HWND32 hWnd, WPARAM16 wParam,
1291 HWND32 hwndOwner, LPDWORD lpFlags,
1292 LPSTR lpstrFindWhat, WORD wFindWhatLen,
1293 LPSTR lpstrReplaceWith, WORD wReplaceWithLen,
1296 int uFindReplaceMessage = RegisterWindowMessage32A( FINDMSGSTRING );
1297 int uHelpMessage = RegisterWindowMessage32A( HELPMSGSTRING );
1303 GetDlgItemText32W(hWnd, edt1, (LPWSTR)lpstrFindWhat, wFindWhatLen/2);
1304 GetDlgItemText32W(hWnd, edt2, (LPWSTR)lpstrReplaceWith, wReplaceWithLen/2);
1307 GetDlgItemText32A(hWnd, edt1, lpstrFindWhat, wFindWhatLen);
1308 GetDlgItemText32A(hWnd, edt2, lpstrReplaceWith, wReplaceWithLen);
1310 if (IsDlgButtonChecked32(hWnd, chx1))
1311 *lpFlags |= FR_WHOLEWORD;
1312 else *lpFlags &= ~FR_WHOLEWORD;
1313 if (IsDlgButtonChecked32(hWnd, chx2))
1314 *lpFlags |= FR_MATCHCASE;
1315 else *lpFlags &= ~FR_MATCHCASE;
1316 *lpFlags &= ~(FR_REPLACE | FR_REPLACEALL | FR_DIALOGTERM);
1317 *lpFlags |= FR_FINDNEXT;
1318 SendMessage32A(hwndOwner, uFindReplaceMessage, 0,
1319 GetWindowLong32A(hWnd, DWL_USER) );
1322 *lpFlags &= ~(FR_FINDNEXT | FR_REPLACE | FR_REPLACEALL);
1323 *lpFlags |= FR_DIALOGTERM;
1324 SendMessage32A(hwndOwner, uFindReplaceMessage, 0,
1325 GetWindowLong32A(hWnd, DWL_USER) );
1326 DestroyWindow32(hWnd);
1331 GetDlgItemText32W(hWnd, edt1, (LPWSTR)lpstrFindWhat, wFindWhatLen/2);
1332 GetDlgItemText32W(hWnd, edt2, (LPWSTR)lpstrReplaceWith, wReplaceWithLen/2);
1335 GetDlgItemText32A(hWnd, edt1, lpstrFindWhat, wFindWhatLen);
1336 GetDlgItemText32A(hWnd, edt2, lpstrReplaceWith, wReplaceWithLen);
1338 if (IsDlgButtonChecked32(hWnd, chx1))
1339 *lpFlags |= FR_WHOLEWORD;
1340 else *lpFlags &= ~FR_WHOLEWORD;
1341 if (IsDlgButtonChecked32(hWnd, chx2))
1342 *lpFlags |= FR_MATCHCASE;
1343 else *lpFlags &= ~FR_MATCHCASE;
1344 *lpFlags &= ~(FR_FINDNEXT | FR_REPLACEALL | FR_DIALOGTERM);
1345 *lpFlags |= FR_REPLACE;
1346 SendMessage32A(hwndOwner, uFindReplaceMessage, 0,
1347 GetWindowLong32A(hWnd, DWL_USER) );
1352 GetDlgItemText32W(hWnd, edt1, (LPWSTR)lpstrFindWhat, wFindWhatLen/2);
1353 GetDlgItemText32W(hWnd, edt2, (LPWSTR)lpstrReplaceWith, wReplaceWithLen/2);
1356 GetDlgItemText32A(hWnd, edt1, lpstrFindWhat, wFindWhatLen);
1357 GetDlgItemText32A(hWnd, edt2, lpstrReplaceWith, wReplaceWithLen);
1359 if (IsDlgButtonChecked32(hWnd, chx1))
1360 *lpFlags |= FR_WHOLEWORD;
1361 else *lpFlags &= ~FR_WHOLEWORD;
1362 if (IsDlgButtonChecked32(hWnd, chx2))
1363 *lpFlags |= FR_MATCHCASE;
1364 else *lpFlags &= ~FR_MATCHCASE;
1365 *lpFlags &= ~(FR_FINDNEXT | FR_REPLACE | FR_DIALOGTERM);
1366 *lpFlags |= FR_REPLACEALL;
1367 SendMessage32A(hwndOwner, uFindReplaceMessage, 0,
1368 GetWindowLong32A(hWnd, DWL_USER) );
1371 /* FIXME : should lpfr structure be passed as an argument ??? */
1372 SendMessage32A(hwndOwner, uHelpMessage, 0, 0);
1379 /***********************************************************************
1380 * ReplaceTextDlgProc16 (COMMDLG.14)
1382 LRESULT WINAPI ReplaceTextDlgProc16(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
1385 LPFINDREPLACE16 lpfr;
1388 lpfr=(LPFINDREPLACE16)PTR_SEG_TO_LIN(lParam);
1389 return REPLACEDLG_WMInitDialog(hWnd, lParam, &lpfr->Flags,
1390 PTR_SEG_TO_LIN(lpfr->lpstrFindWhat),
1391 PTR_SEG_TO_LIN(lpfr->lpstrReplaceWith), FALSE);
1393 lpfr=(LPFINDREPLACE16)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd, DWL_USER));
1394 return REPLACEDLG_WMCommand(hWnd, wParam, lpfr->hwndOwner,
1395 &lpfr->Flags, PTR_SEG_TO_LIN(lpfr->lpstrFindWhat),
1396 lpfr->wFindWhatLen, PTR_SEG_TO_LIN(lpfr->lpstrReplaceWith),
1397 lpfr->wReplaceWithLen, FALSE);
1402 /***********************************************************************
1403 * ReplaceTextDlgProc32A
1405 LRESULT WINAPI ReplaceTextDlgProc32A(HWND32 hWnd, UINT32 wMsg, WPARAM32 wParam,
1408 LPFINDREPLACE32A lpfr;
1411 lpfr=(LPFINDREPLACE32A)lParam;
1412 return REPLACEDLG_WMInitDialog(hWnd, lParam, &lpfr->Flags,
1413 lpfr->lpstrFindWhat, lpfr->lpstrReplaceWith, FALSE);
1415 lpfr=(LPFINDREPLACE32A)GetWindowLong32A(hWnd, DWL_USER);
1416 return REPLACEDLG_WMCommand(hWnd, wParam, lpfr->hwndOwner,
1417 &lpfr->Flags, lpfr->lpstrFindWhat, lpfr->wFindWhatLen,
1418 lpfr->lpstrReplaceWith, lpfr->wReplaceWithLen, FALSE);
1423 /***********************************************************************
1424 * ReplaceTextDlgProc32W
1426 LRESULT WINAPI ReplaceTextDlgProc32W(HWND32 hWnd, UINT32 wMsg, WPARAM32 wParam,
1429 LPFINDREPLACE32W lpfr;
1432 lpfr=(LPFINDREPLACE32W)lParam;
1433 return REPLACEDLG_WMInitDialog(hWnd, lParam, &lpfr->Flags,
1434 (LPSTR)lpfr->lpstrFindWhat, (LPSTR)lpfr->lpstrReplaceWith,
1437 lpfr=(LPFINDREPLACE32W)GetWindowLong32A(hWnd, DWL_USER);
1438 return REPLACEDLG_WMCommand(hWnd, wParam, lpfr->hwndOwner,
1439 &lpfr->Flags, (LPSTR)lpfr->lpstrFindWhat, lpfr->wFindWhatLen,
1440 (LPSTR)lpfr->lpstrReplaceWith, lpfr->wReplaceWithLen, TRUE);
1446 /***********************************************************************
1447 * PrintDlg16 (COMMDLG.20)
1449 BOOL16 WINAPI PrintDlg16( SEGPTR printdlg )
1452 BOOL16 bRet = FALSE;
1455 LPPRINTDLG16 lpPrint = (LPPRINTDLG16)PTR_SEG_TO_LIN(printdlg);
1457 TRACE(commdlg,"(%p) -- Flags=%08lX\n", lpPrint, lpPrint->Flags );
1459 if (lpPrint->Flags & PD_RETURNDEFAULT)
1460 /* FIXME: should fill lpPrint->hDevMode and lpPrint->hDevNames here */
1463 if (lpPrint->Flags & PD_PRINTSETUP)
1464 template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT_SETUP );
1466 template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT );
1468 hInst = WIN_GetWindowInstance( lpPrint->hwndOwner );
1469 hwndDialog = DIALOG_CreateIndirect( hInst, template, TRUE,
1471 (DLGPROC16)((lpPrint->Flags & PD_PRINTSETUP) ?
1472 MODULE_GetWndProcEntry16("PrintSetupDlgProc") :
1473 MODULE_GetWndProcEntry16("PrintDlgProc")),
1474 printdlg, WIN_PROC_16 );
1475 if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpPrint->hwndOwner);
1480 /***********************************************************************
1481 * PrintDlg32A (COMDLG32.17)
1483 BOOL32 WINAPI PrintDlg32A( LPPRINTDLG32A printdlg )
1485 FIXME(commdlg, "(%p): stub\n",printdlg);
1486 /* Altough returning FALSE is theoricaly the right thing
1487 * most programs check for a printer at startup, and if
1488 * none is found popup PrintDlg32A(), if it fails the program
1489 * terminates; by returning TRUE the programs can still run
1490 * as long as no printer related stuff is used
1496 /***********************************************************************
1497 * PrintDlg32W (COMDLG32.18)
1499 BOOL32 WINAPI PrintDlg32W( LPPRINTDLG32W printdlg )
1501 FIXME(commdlg, "empty stub\n" );
1506 /***********************************************************************
1507 * PrintDlgProc (COMMDLG.21)
1509 LRESULT WINAPI PrintDlgProc(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
1515 TRACE(commdlg,"WM_INITDIALOG lParam=%08lX\n", lParam);
1516 ShowWindow16(hWnd, SW_SHOWNORMAL);
1522 EndDialog32(hWnd, TRUE);
1525 EndDialog32(hWnd, FALSE);
1534 /***********************************************************************
1535 * PrintSetupDlgProc (COMMDLG.22)
1537 LRESULT WINAPI PrintSetupDlgProc(HWND16 hWnd, UINT16 wMsg, WPARAM16 wParam,
1543 TRACE(commdlg,"WM_INITDIALOG lParam=%08lX\n", lParam);
1544 ShowWindow16(hWnd, SW_SHOWNORMAL);
1549 EndDialog32(hWnd, TRUE);
1552 EndDialog32(hWnd, FALSE);
1561 /***********************************************************************
1562 * CommDlgExtendedError (COMMDLG.26)
1564 DWORD WINAPI CommDlgExtendedError(void)
1566 return CommDlgLastError;
1569 /***********************************************************************
1570 * GetFileTitleA (COMDLG32.8)
1572 short WINAPI GetFileTitle32A(LPCSTR lpFile, LPSTR lpTitle, UINT32 cbBuf)
1575 TRACE(commdlg,"(%p %p %d); \n", lpFile, lpTitle, cbBuf);
1576 if (lpFile == NULL || lpTitle == NULL)
1578 len = strlen(lpFile);
1581 if (strpbrk(lpFile, "*[]"))
1584 if (lpFile[len] == '/' || lpFile[len] == '\\' || lpFile[len] == ':')
1586 for (i = len; i >= 0; i--)
1587 if (lpFile[i] == '/' || lpFile[i] == '\\' || lpFile[i] == ':')
1592 TRACE(commdlg,"---> '%s' \n", &lpFile[i]);
1594 len = strlen(lpFile+i)+1;
1598 strncpy(lpTitle, &lpFile[i], len);
1603 /***********************************************************************
1604 * GetFileTitleA (COMDLG32.8)
1606 short WINAPI GetFileTitle32W(LPCWSTR lpFile, LPWSTR lpTitle, UINT32 cbBuf)
1608 LPSTR file = HEAP_strdupWtoA(GetProcessHeap(),0,lpFile);
1609 LPSTR title = HeapAlloc(GetProcessHeap(),0,cbBuf);
1612 ret = GetFileTitle32A(file,title,cbBuf);
1614 lstrcpynAtoW(lpTitle,title,cbBuf);
1615 HeapFree(GetProcessHeap(),0,file);
1616 HeapFree(GetProcessHeap(),0,title);
1619 /***********************************************************************
1620 * GetFileTitle (COMMDLG.27)
1622 short WINAPI GetFileTitle16(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf)
1624 return GetFileTitle32A(lpFile,lpTitle,cbBuf);
1628 /* ------------------------ Choose Color Dialog --------------------------- */
1630 /***********************************************************************
1631 * ChooseColor (COMMDLG.5)
1633 BOOL16 WINAPI ChooseColor16(LPCHOOSECOLOR16 lpChCol)
1636 HANDLE16 hDlgTmpl = 0;
1637 BOOL16 bRet = FALSE, win32Format = FALSE;
1641 TRACE(commdlg,"ChooseColor\n");
1642 if (!lpChCol) return FALSE;
1644 if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE)
1646 if (!(template = LockResource16( lpChCol->hInstance )))
1648 CommDlgLastError = CDERR_LOADRESFAILURE;
1652 else if (lpChCol->Flags & CC_ENABLETEMPLATE)
1655 if (!(hResInfo = FindResource16(lpChCol->hInstance,
1656 lpChCol->lpTemplateName,
1659 CommDlgLastError = CDERR_FINDRESFAILURE;
1662 if (!(hDlgTmpl = LoadResource16( lpChCol->hInstance, hResInfo )) ||
1663 !(template = LockResource16( hDlgTmpl )))
1665 CommDlgLastError = CDERR_LOADRESFAILURE;
1671 template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_COLOR );
1675 hInst = WIN_GetWindowInstance( lpChCol->hwndOwner );
1676 hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
1678 (DLGPROC16)MODULE_GetWndProcEntry16("ColorDlgProc"),
1679 (DWORD)lpChCol, WIN_PROC_16 );
1680 if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpChCol->hwndOwner);
1681 if (hDlgTmpl) FreeResource16( hDlgTmpl );
1686 static const COLORREF predefcolors[6][8]=
1688 { 0x008080FFL, 0x0080FFFFL, 0x0080FF80L, 0x0080FF00L,
1689 0x00FFFF80L, 0x00FF8000L, 0x00C080FFL, 0x00FF80FFL },
1690 { 0x000000FFL, 0x0000FFFFL, 0x0000FF80L, 0x0040FF00L,
1691 0x00FFFF00L, 0x00C08000L, 0x00C08080L, 0x00FF00FFL },
1693 { 0x00404080L, 0x004080FFL, 0x0000FF00L, 0x00808000L,
1694 0x00804000L, 0x00FF8080L, 0x00400080L, 0x008000FFL },
1695 { 0x00000080L, 0x000080FFL, 0x00008000L, 0x00408000L,
1696 0x00FF0000L, 0x00A00000L, 0x00800080L, 0x00FF0080L },
1698 { 0x00000040L, 0x00004080L, 0x00004000L, 0x00404000L,
1699 0x00800000L, 0x00400000L, 0x00400040L, 0x00800040L },
1700 { 0x00000000L, 0x00008080L, 0x00408080L, 0x00808080L,
1701 0x00808040L, 0x00C0C0C0L, 0x00400040L, 0x00FFFFFFL },
1706 LPCHOOSECOLOR16 lpcc; /* points to public known data structure */
1707 int nextuserdef; /* next free place in user defined color array */
1708 HDC16 hdcMem; /* color graph used for BitBlt() */
1709 HBITMAP16 hbmMem; /* color graph bitmap */
1710 RECT16 fullsize; /* original dialog window size */
1711 UINT16 msetrgb; /* # of SETRGBSTRING message (today not used) */
1712 RECT16 old3angle; /* last position of l-marker */
1713 RECT16 oldcross; /* last position of color/satuation marker */
1714 BOOL32 updating; /* to prevent recursive WM_COMMAND/EN_UPDATE procesing */
1717 int l; /* for temporary storing of hue,sat,lum */
1720 /***********************************************************************
1721 * CC_HSLtoRGB [internal]
1723 static int CC_HSLtoRGB(char c,int hue,int sat,int lum)
1730 case 'R':if (hue>80) hue-=80; else hue+=160; break;
1731 case 'G':if (hue>160) hue-=160; else hue+=80; break;
1736 maxrgb=(256*MIN(120,lum))/120; /* 0 .. 256 */
1742 res=(hue-80)* maxrgb; /* 0...10240 */
1743 res/=40; /* 0...256 */
1750 res=(240-hue)* maxrgb;
1753 res=res-maxrgb/2; /* -128...128 */
1756 res=maxrgb/2 + (sat*res) /240; /* 0..256 */
1759 if (lum>120 && res<256)
1760 res+=((lum-120) * (256-res))/120;
1762 return MIN(res,255);
1765 /***********************************************************************
1766 * CC_RGBtoHSL [internal]
1768 static int CC_RGBtoHSL(char c,int r,int g,int b)
1770 WORD maxi,mini,mmsum,mmdif,result=0;
1784 case 'L':mmsum*=120; /* 0...61200=(255+255)*120 */
1785 result=mmsum/255; /* 0...240 */
1788 case 'S':if (!mmsum)
1791 if (!mini || maxi==255)
1795 result=mmdif*240; /* 0...61200=255*240 */
1796 result/= (mmsum>255 ? mmsum=510-mmsum : mmsum); /* 0..255 */
1800 case 'H':if (!mmdif)
1806 iresult=40*(g-b); /* -10200 ... 10200 */
1807 iresult/=(int)mmdif; /* -40 .. 40 */
1809 iresult+=240; /* 0..40 and 200..240 */
1815 iresult/=(int)mmdif;
1816 iresult+=80; /* 40 .. 120 */
1822 iresult/=(int)mmdif;
1823 iresult+=160; /* 120 .. 200 */
1829 return result; /* is this integer arithmetic precise enough ? */
1834 /***********************************************************************
1835 * CC_MouseCheckPredefColorArray [internal]
1837 static int CC_MouseCheckPredefColorArray(HWND16 hDlg,int dlgitem,int rows,int cols,
1838 LPARAM lParam,COLORREF *cr)
1841 POINT16 point = MAKEPOINT16(lParam);
1845 ClientToScreen16(hDlg,&point);
1846 hwnd=GetDlgItem32(hDlg,dlgitem);
1847 GetWindowRect16(hwnd,&rect);
1848 if (PtInRect16(&rect,point))
1850 dx=(rect.right-rect.left)/cols;
1851 dy=(rect.bottom-rect.top)/rows;
1852 ScreenToClient16(hwnd,&point);
1854 if (point.x % dx < (dx-DISTANCE) && point.y % dy < (dy-DISTANCE))
1858 *cr=predefcolors[y][x];
1859 /* FIXME: Draw_a_Focus_Rect() */
1866 /***********************************************************************
1867 * CC_MouseCheckUserColorArray [internal]
1869 static int CC_MouseCheckUserColorArray(HWND16 hDlg,int dlgitem,int rows,int cols,
1870 LPARAM lParam,COLORREF *cr,COLORREF*crarr)
1873 POINT16 point = MAKEPOINT16(lParam);
1877 ClientToScreen16(hDlg,&point);
1878 hwnd=GetDlgItem32(hDlg,dlgitem);
1879 GetWindowRect16(hwnd,&rect);
1880 if (PtInRect16(&rect,point))
1882 dx=(rect.right-rect.left)/cols;
1883 dy=(rect.bottom-rect.top)/rows;
1884 ScreenToClient16(hwnd,&point);
1886 if (point.x % dx < (dx-DISTANCE) && point.y % dy < (dy-DISTANCE))
1890 *cr=crarr[x+cols*y];
1891 /* FIXME: Draw_a_Focus_Rect() */
1901 /* 240 ^...... ^^ 240
1908 /***********************************************************************
1909 * CC_MouseCheckColorGraph [internal]
1911 static int CC_MouseCheckColorGraph(HWND16 hDlg,int dlgitem,int *hori,int *vert,LPARAM lParam)
1914 POINT16 point = MAKEPOINT16(lParam);
1918 ClientToScreen16(hDlg,&point);
1919 hwnd=GetDlgItem32(hDlg,dlgitem);
1920 GetWindowRect16(hwnd,&rect);
1921 if (PtInRect16(&rect,point))
1923 GetClientRect16(hwnd,&rect);
1924 ScreenToClient16(hwnd,&point);
1926 x=(long)point.x*MAXHORI;
1928 y=(long)(rect.bottom-point.y)*MAXVERT;
1940 /***********************************************************************
1941 * CC_MouseCheckResultWindow [internal]
1943 static int CC_MouseCheckResultWindow(HWND16 hDlg,LPARAM lParam)
1946 POINT16 point = MAKEPOINT16(lParam);
1949 ClientToScreen16(hDlg,&point);
1950 hwnd=GetDlgItem32(hDlg,0x2c5);
1951 GetWindowRect16(hwnd,&rect);
1952 if (PtInRect16(&rect,point))
1954 PostMessage16(hDlg,WM_COMMAND,0x2c9,0);
1960 /***********************************************************************
1961 * CC_CheckDigitsInEdit [internal]
1963 static int CC_CheckDigitsInEdit(HWND16 hwnd,int maxval)
1965 int i,k,m,result,value;
1968 GetWindowText32A(hwnd,buffer,sizeof(buffer));
1973 if (buffer[i]<'0' || buffer[i]>'9')
1975 for (k=i+1;k<=m;k++) /* delete bad character */
1977 buffer[i]=buffer[k];
1985 if (value>maxval) /* build a new string */
1987 sprintf(buffer,"%d",maxval);
1992 editpos=SendMessage16(hwnd,EM_GETSEL16,0,0);
1993 SetWindowText32A(hwnd,buffer);
1994 SendMessage16(hwnd,EM_SETSEL16,0,editpos);
2001 /***********************************************************************
2002 * CC_PaintSelectedColor [internal]
2004 static void CC_PaintSelectedColor(HWND16 hDlg,COLORREF cr)
2009 HWND32 hwnd=GetDlgItem32(hDlg,0x2c5);
2010 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
2013 GetClientRect16 (hwnd, &rect) ;
2014 hBrush = CreateSolidBrush32(cr);
2017 hBrush = SelectObject32 (hdc, hBrush) ;
2018 Rectangle32(hdc, rect.left,rect.top,rect.right/2,rect.bottom);
2019 DeleteObject32 (SelectObject32 (hdc,hBrush)) ;
2020 hBrush=CreateSolidBrush32(GetNearestColor32(hdc,cr));
2023 hBrush= SelectObject32 (hdc, hBrush) ;
2024 Rectangle32( hdc, rect.right/2-1,rect.top,rect.right,rect.bottom);
2025 DeleteObject32( SelectObject32 (hdc, hBrush)) ;
2028 ReleaseDC32(hwnd,hdc);
2032 /***********************************************************************
2033 * CC_PaintTriangle [internal]
2035 static void CC_PaintTriangle(HWND16 hDlg,int y)
2039 int w=GetDialogBaseUnits();
2044 HWND16 hwnd=GetDlgItem32(hDlg,0x2be);
2045 struct CCPRIVATE *lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2047 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
2049 GetClientRect16(hwnd,&rect);
2053 points[0].y=rect.top;
2054 points[0].x=rect.right; /* | /| */
2055 ClientToScreen16(hwnd,points); /* | / | */
2056 ScreenToClient16(hDlg,points); /* |< | */
2057 oben=points[0].y; /* | \ | */
2059 temp=(long)height*(long)y;
2060 points[0].y=oben+height -temp/(long)MAXVERT;
2061 points[1].y=points[0].y+w;
2062 points[2].y=points[0].y-w;
2063 points[2].x=points[1].x=points[0].x + w;
2065 if (lpp->old3angle.left)
2066 FillRect16(hDC,&lpp->old3angle,GetStockObject32(WHITE_BRUSH));
2067 lpp->old3angle.left =points[0].x;
2068 lpp->old3angle.right =points[1].x+1;
2069 lpp->old3angle.top =points[2].y-1;
2070 lpp->old3angle.bottom=points[1].y+1;
2071 Polygon16(hDC,points,3);
2072 ReleaseDC32(hDlg,hDC);
2077 /***********************************************************************
2078 * CC_PaintCross [internal]
2080 static void CC_PaintCross(HWND16 hDlg,int x,int y)
2083 int w=GetDialogBaseUnits();
2084 HWND16 hwnd=GetDlgItem32(hDlg,0x2c6);
2085 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2090 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
2092 GetClientRect16(hwnd,&rect);
2094 SelectClipRgn32(hDC,CreateRectRgnIndirect16(&rect));
2095 hPen=CreatePen32(PS_SOLID,2,0);
2096 hPen=SelectObject32(hDC,hPen);
2097 point.x=((long)rect.right*(long)x)/(long)MAXHORI;
2098 point.y=rect.bottom-((long)rect.bottom*(long)y)/(long)MAXVERT;
2099 if (lpp->oldcross.left!=lpp->oldcross.right)
2100 BitBlt32(hDC,lpp->oldcross.left,lpp->oldcross.top,
2101 lpp->oldcross.right-lpp->oldcross.left,
2102 lpp->oldcross.bottom-lpp->oldcross.top,
2103 lpp->hdcMem,lpp->oldcross.left,lpp->oldcross.top,SRCCOPY);
2104 lpp->oldcross.left =point.x-w-1;
2105 lpp->oldcross.right =point.x+w+1;
2106 lpp->oldcross.top =point.y-w-1;
2107 lpp->oldcross.bottom=point.y+w+1;
2109 MoveTo(hDC,point.x-w,point.y);
2110 LineTo32(hDC,point.x+w,point.y);
2111 MoveTo(hDC,point.x,point.y-w);
2112 LineTo32(hDC,point.x,point.y+w);
2113 DeleteObject32(SelectObject32(hDC,hPen));
2114 ReleaseDC32(hwnd,hDC);
2123 /***********************************************************************
2124 * CC_PrepareColorGraph [internal]
2126 static void CC_PrepareColorGraph(HWND16 hDlg)
2128 int sdif,hdif,xdif,ydif,r,g,b,hue,sat;
2129 HWND32 hwnd=GetDlgItem32(hDlg,0x2c6);
2130 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2134 HCURSOR16 hcursor=SetCursor16(LoadCursor16(0,IDC_WAIT16));
2136 GetClientRect16(hwnd,&client);
2138 lpp->hdcMem = CreateCompatibleDC32(hdc);
2139 lpp->hbmMem = CreateCompatibleBitmap32(hdc,client.right,client.bottom);
2140 SelectObject32(lpp->hdcMem,lpp->hbmMem);
2142 xdif=client.right /XSTEPS;
2143 ydif=client.bottom/YSTEPS+1;
2146 for(rect.left=hue=0;hue<239+hdif;hue+=hdif)
2148 rect.right=rect.left+xdif;
2149 rect.bottom=client.bottom;
2150 for(sat=0;sat<240+sdif;sat+=sdif)
2152 rect.top=rect.bottom-ydif;
2153 r=CC_HSLtoRGB('R',hue,sat,120);
2154 g=CC_HSLtoRGB('G',hue,sat,120);
2155 b=CC_HSLtoRGB('B',hue,sat,120);
2156 hbrush=CreateSolidBrush32(RGB(r,g,b));
2157 FillRect16(lpp->hdcMem,&rect,hbrush);
2158 DeleteObject32(hbrush);
2159 rect.bottom=rect.top;
2161 rect.left=rect.right;
2163 ReleaseDC32(hwnd,hdc);
2164 SetCursor16(hcursor);
2167 /***********************************************************************
2168 * CC_PaintColorGraph [internal]
2170 static void CC_PaintColorGraph(HWND16 hDlg)
2172 HWND32 hwnd=GetDlgItem32(hDlg,0x2c6);
2173 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2176 if (IsWindowVisible32(hwnd)) /* if full size */
2179 CC_PrepareColorGraph(hDlg); /* should not be necessary */
2182 GetClientRect16(hwnd,&rect);
2184 BitBlt32(hDC,0,0,rect.right,rect.bottom,lpp->hdcMem,0,0,SRCCOPY);
2186 WARN(commdlg,"choose color: hdcMem is not defined\n");
2187 ReleaseDC32(hwnd,hDC);
2190 /***********************************************************************
2191 * CC_PaintLumBar [internal]
2193 static void CC_PaintLumBar(HWND16 hDlg,int hue,int sat)
2195 HWND32 hwnd=GetDlgItem32(hDlg,0x2be);
2197 int lum,ldif,ydif,r,g,b;
2201 if (IsWindowVisible32(hwnd))
2204 GetClientRect16(hwnd,&client);
2208 ydif=client.bottom/YSTEPS+1;
2209 for(lum=0;lum<240+ldif;lum+=ldif)
2211 rect.top=MAX(0,rect.bottom-ydif);
2212 r=CC_HSLtoRGB('R',hue,sat,lum);
2213 g=CC_HSLtoRGB('G',hue,sat,lum);
2214 b=CC_HSLtoRGB('B',hue,sat,lum);
2215 hbrush=CreateSolidBrush32(RGB(r,g,b));
2216 FillRect16(hDC,&rect,hbrush);
2217 DeleteObject32(hbrush);
2218 rect.bottom=rect.top;
2220 GetClientRect16(hwnd,&rect);
2221 FrameRect16(hDC,&rect,GetStockObject32(BLACK_BRUSH));
2222 ReleaseDC32(hwnd,hDC);
2226 /***********************************************************************
2227 * CC_EditSetRGB [internal]
2229 static void CC_EditSetRGB(HWND16 hDlg,COLORREF cr)
2232 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2233 int r=GetRValue(cr);
2234 int g=GetGValue(cr);
2235 int b=GetBValue(cr);
2236 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
2239 sprintf(buffer,"%d",r);
2240 SetWindowText32A(GetDlgItem32(hDlg,0x2c2),buffer);
2241 sprintf(buffer,"%d",g);
2242 SetWindowText32A(GetDlgItem32(hDlg,0x2c3),buffer);
2243 sprintf(buffer,"%d",b);
2244 SetWindowText32A(GetDlgItem32(hDlg,0x2c4),buffer);
2245 lpp->updating=FALSE;
2249 /***********************************************************************
2250 * CC_EditSetHSL [internal]
2252 static void CC_EditSetHSL(HWND16 hDlg,int h,int s,int l)
2255 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2257 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
2260 sprintf(buffer,"%d",h);
2261 SetWindowText32A(GetDlgItem32(hDlg,0x2bf),buffer);
2262 sprintf(buffer,"%d",s);
2263 SetWindowText32A(GetDlgItem32(hDlg,0x2c0),buffer);
2264 sprintf(buffer,"%d",l);
2265 SetWindowText32A(GetDlgItem32(hDlg,0x2c1),buffer);
2266 lpp->updating=FALSE;
2268 CC_PaintLumBar(hDlg,h,s);
2271 /***********************************************************************
2272 * CC_SwitchToFullSize [internal]
2274 static void CC_SwitchToFullSize(HWND16 hDlg,COLORREF result,LPRECT16 lprect)
2277 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2279 EnableWindow32(GetDlgItem32(hDlg,0x2cf),FALSE);
2280 CC_PrepareColorGraph(hDlg);
2281 for (i=0x2bf;i<0x2c5;i++)
2282 EnableWindow32(GetDlgItem32(hDlg,i),TRUE);
2283 for (i=0x2d3;i<0x2d9;i++)
2284 EnableWindow32(GetDlgItem32(hDlg,i),TRUE);
2285 EnableWindow32(GetDlgItem32(hDlg,0x2c9),TRUE);
2286 EnableWindow32(GetDlgItem32(hDlg,0x2c8),TRUE);
2289 SetWindowPos32(hDlg,NULL,0,0,lprect->right-lprect->left,
2290 lprect->bottom-lprect->top, SWP_NOMOVE|SWP_NOZORDER);
2292 ShowWindow32(GetDlgItem32(hDlg,0x2c6),SW_SHOW);
2293 ShowWindow32(GetDlgItem32(hDlg,0x2be),SW_SHOW);
2294 ShowWindow32(GetDlgItem32(hDlg,0x2c5),SW_SHOW);
2296 CC_EditSetRGB(hDlg,result);
2297 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
2300 /***********************************************************************
2301 * CC_PaintPredefColorArray [internal]
2303 static void CC_PaintPredefColorArray(HWND16 hDlg,int rows,int cols)
2305 HWND32 hwnd=GetDlgItem32(hDlg,0x2d0);
2311 GetClientRect16(hwnd,&rect);
2313 dy=rect.bottom/rows;
2317 GetClientRect16 (hwnd, &rect) ;
2319 for (j=0;j<rows;j++)
2321 for (i=0;i<cols;i++)
2323 hBrush = CreateSolidBrush32(predefcolors[j][i]);
2326 hBrush = SelectObject32 (hdc, hBrush) ;
2327 Rectangle32(hdc, rect.left, rect.top,
2328 rect.left+dx-DISTANCE, rect.top+dy-DISTANCE);
2329 rect.left=rect.left+dx;
2330 DeleteObject32( SelectObject32 (hdc, hBrush)) ;
2333 rect.top=rect.top+dy;
2336 ReleaseDC32(hwnd,hdc);
2337 /* FIXME: draw_a_focus_rect */
2339 /***********************************************************************
2340 * CC_PaintUserColorArray [internal]
2342 static void CC_PaintUserColorArray(HWND16 hDlg,int rows,int cols,COLORREF* lpcr)
2344 HWND32 hwnd=GetDlgItem32(hDlg,0x2d1);
2350 GetClientRect16(hwnd,&rect);
2353 dy=rect.bottom/rows;
2359 for (j=0;j<rows;j++)
2361 for (i=0;i<cols;i++)
2363 hBrush = CreateSolidBrush32(lpcr[i+j*cols]);
2366 hBrush = SelectObject32 (hdc, hBrush) ;
2367 Rectangle32( hdc, rect.left, rect.top,
2368 rect.left+dx-DISTANCE, rect.top+dy-DISTANCE);
2369 rect.left=rect.left+dx;
2370 DeleteObject32( SelectObject32 (hdc, hBrush)) ;
2373 rect.top=rect.top+dy;
2376 ReleaseDC32(hwnd,hdc);
2378 /* FIXME: draw_a_focus_rect */
2383 /***********************************************************************
2384 * CC_HookCallChk [internal]
2386 static BOOL32 CC_HookCallChk(LPCHOOSECOLOR16 lpcc)
2389 if(lpcc->Flags & CC_ENABLEHOOK)
2395 /***********************************************************************
2396 * CC_WMInitDialog [internal]
2398 static LONG CC_WMInitDialog(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2404 struct CCPRIVATE * lpp;
2406 TRACE(commdlg,"WM_INITDIALOG lParam=%08lX\n", lParam);
2407 lpp=calloc(1,sizeof(struct CCPRIVATE));
2408 lpp->lpcc=(LPCHOOSECOLOR16)lParam;
2409 if (lpp->lpcc->lStructSize != sizeof(CHOOSECOLOR16))
2411 EndDialog32 (hDlg, 0) ;
2414 SetWindowLong32A(hDlg, DWL_USER, (LONG)lpp);
2416 if (!(lpp->lpcc->Flags & CC_SHOWHELP))
2417 ShowWindow32(GetDlgItem32(hDlg,0x40e),SW_HIDE);
2418 lpp->msetrgb=RegisterWindowMessage32A( SETRGBSTRING );
2420 cpos=MAKELONG(5,7); /* init */
2421 if (lpp->lpcc->Flags & CC_RGBINIT)
2425 if (predefcolors[i][j]==lpp->lpcc->rgbResult)
2432 /* FIXME: Draw_a_focus_rect & set_init_values */
2434 GetWindowRect16(hDlg,&lpp->fullsize);
2435 if (lpp->lpcc->Flags & CC_FULLOPEN || lpp->lpcc->Flags & CC_PREVENTFULLOPEN)
2437 hwnd=GetDlgItem32(hDlg,0x2cf);
2438 EnableWindow32(hwnd,FALSE);
2440 if (!(lpp->lpcc->Flags & CC_FULLOPEN) || lpp->lpcc->Flags & CC_PREVENTFULLOPEN)
2443 res=rect.bottom-rect.top;
2444 hwnd=GetDlgItem32(hDlg,0x2c6); /* cut at left border */
2446 ClientToScreen16(hwnd,&point);
2447 ScreenToClient16(hDlg,&point);
2448 GetClientRect16(hDlg,&rect);
2449 point.x+=GetSystemMetrics32(SM_CXDLGFRAME);
2450 SetWindowPos32(hDlg,NULL,0,0,point.x,res,SWP_NOMOVE|SWP_NOZORDER);
2452 ShowWindow32(GetDlgItem32(hDlg,0x2c6),SW_HIDE);
2453 ShowWindow32(GetDlgItem32(hDlg,0x2c5),SW_HIDE);
2456 CC_SwitchToFullSize(hDlg,lpp->lpcc->rgbResult,NULL);
2458 for (i=0x2bf;i<0x2c5;i++)
2459 SendMessage16(GetDlgItem32(hDlg,i),EM_LIMITTEXT16,3,0); /* max 3 digits: xyz */
2460 if (CC_HookCallChk(lpp->lpcc))
2461 res=CallWindowProc16(lpp->lpcc->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
2465 /***********************************************************************
2466 * CC_WMCommand [internal]
2468 static LRESULT CC_WMCommand(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2474 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2475 TRACE(commdlg,"CC_WMCommand wParam=%x lParam=%lx\n",wParam,lParam);
2478 case 0x2c2: /* edit notify RGB */
2481 if (HIWORD(lParam)==EN_UPDATE && !lpp->updating)
2483 i=CC_CheckDigitsInEdit(LOWORD(lParam),255);
2484 r=GetRValue(lpp->lpcc->rgbResult);
2485 g=GetGValue(lpp->lpcc->rgbResult);
2486 b=GetBValue(lpp->lpcc->rgbResult);
2490 case 0x2c2:if ((xx=(i!=r))) r=i;break;
2491 case 0x2c3:if ((xx=(i!=g))) g=i;break;
2492 case 0x2c4:if ((xx=(i!=b))) b=i;break;
2494 if (xx) /* something has changed */
2496 lpp->lpcc->rgbResult=RGB(r,g,b);
2497 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2498 lpp->h=CC_RGBtoHSL('H',r,g,b);
2499 lpp->s=CC_RGBtoHSL('S',r,g,b);
2500 lpp->l=CC_RGBtoHSL('L',r,g,b);
2501 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
2502 CC_PaintCross(hDlg,lpp->h,lpp->s);
2503 CC_PaintTriangle(hDlg,lpp->l);
2508 case 0x2bf: /* edit notify HSL */
2511 if (HIWORD(lParam)==EN_UPDATE && !lpp->updating)
2513 i=CC_CheckDigitsInEdit(LOWORD(lParam),wParam==0x2bf?239:240);
2517 case 0x2bf:if ((xx=(i!=lpp->h))) lpp->h=i;break;
2518 case 0x2c0:if ((xx=(i!=lpp->s))) lpp->s=i;break;
2519 case 0x2c1:if ((xx=(i!=lpp->l))) lpp->l=i;break;
2521 if (xx) /* something has changed */
2523 r=CC_HSLtoRGB('R',lpp->h,lpp->s,lpp->l);
2524 g=CC_HSLtoRGB('G',lpp->h,lpp->s,lpp->l);
2525 b=CC_HSLtoRGB('B',lpp->h,lpp->s,lpp->l);
2526 lpp->lpcc->rgbResult=RGB(r,g,b);
2527 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2528 CC_EditSetRGB(hDlg,lpp->lpcc->rgbResult);
2529 CC_PaintCross(hDlg,lpp->h,lpp->s);
2530 CC_PaintTriangle(hDlg,lpp->l);
2536 CC_SwitchToFullSize(hDlg,lpp->lpcc->rgbResult,&lpp->fullsize);
2537 InvalidateRect32( hDlg, NULL, TRUE );
2538 SetFocus32(GetDlgItem32(hDlg,0x2bf));
2541 case 0x2c8: /* add colors ... column by column */
2542 cr=PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors);
2543 cr[(lpp->nextuserdef%2)*8 + lpp->nextuserdef/2]=lpp->lpcc->rgbResult;
2544 if (++lpp->nextuserdef==16)
2546 CC_PaintUserColorArray(hDlg,2,8,PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors));
2549 case 0x2c9: /* resulting color */
2551 lpp->lpcc->rgbResult=GetNearestColor32(hdc,lpp->lpcc->rgbResult);
2552 ReleaseDC32(hDlg,hdc);
2553 CC_EditSetRGB(hDlg,lpp->lpcc->rgbResult);
2554 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2555 r=GetRValue(lpp->lpcc->rgbResult);
2556 g=GetGValue(lpp->lpcc->rgbResult);
2557 b=GetBValue(lpp->lpcc->rgbResult);
2558 lpp->h=CC_RGBtoHSL('H',r,g,b);
2559 lpp->s=CC_RGBtoHSL('S',r,g,b);
2560 lpp->l=CC_RGBtoHSL('L',r,g,b);
2561 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
2562 CC_PaintCross(hDlg,lpp->h,lpp->s);
2563 CC_PaintTriangle(hDlg,lpp->l);
2566 case 0x40e: /* Help! */ /* The Beatles, 1965 ;-) */
2567 i=RegisterWindowMessage32A( HELPMSGSTRING );
2568 if (lpp->lpcc->hwndOwner)
2569 SendMessage16(lpp->lpcc->hwndOwner,i,0,(LPARAM)lpp->lpcc);
2570 if (CC_HookCallChk(lpp->lpcc))
2571 CallWindowProc16(lpp->lpcc->lpfnHook,hDlg,
2572 WM_COMMAND,psh15,(LPARAM)lpp->lpcc);
2576 cokmsg=RegisterWindowMessage32A( COLOROKSTRING );
2577 if (lpp->lpcc->hwndOwner)
2578 if (SendMessage16(lpp->lpcc->hwndOwner,cokmsg,0,(LPARAM)lpp->lpcc))
2579 break; /* do NOT close */
2581 EndDialog32 (hDlg, 1) ;
2585 EndDialog32 (hDlg, 0) ;
2592 /***********************************************************************
2593 * CC_WMPaint [internal]
2595 static LRESULT CC_WMPaint(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2597 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2598 /* we have to paint dialog children except text and buttons */
2600 CC_PaintPredefColorArray(hDlg,6,8);
2601 CC_PaintUserColorArray(hDlg,2,8,PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors));
2602 CC_PaintColorGraph(hDlg);
2603 CC_PaintLumBar(hDlg,lpp->h,lpp->s);
2604 CC_PaintCross(hDlg,lpp->h,lpp->s);
2605 CC_PaintTriangle(hDlg,lpp->l);
2606 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2608 /* special necessary for Wine */
2609 ValidateRect32(GetDlgItem32(hDlg,0x2d0),NULL);
2610 ValidateRect32(GetDlgItem32(hDlg,0x2d1),NULL);
2611 ValidateRect32(GetDlgItem32(hDlg,0x2c6),NULL);
2612 ValidateRect32(GetDlgItem32(hDlg,0x2be),NULL);
2613 ValidateRect32(GetDlgItem32(hDlg,0x2c5),NULL);
2614 /* hope we can remove it later -->FIXME */
2619 /***********************************************************************
2620 * CC_WMLButtonDown [internal]
2622 static LRESULT CC_WMLButtonDown(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2624 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2627 if (CC_MouseCheckPredefColorArray(hDlg,0x2d0,6,8,lParam,&lpp->lpcc->rgbResult))
2630 if (CC_MouseCheckUserColorArray(hDlg,0x2d1,2,8,lParam,&lpp->lpcc->rgbResult,
2631 PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors)))
2634 if (CC_MouseCheckColorGraph(hDlg,0x2c6,&lpp->h,&lpp->s,lParam))
2637 if (CC_MouseCheckColorGraph(hDlg,0x2be,NULL,&lpp->l,lParam))
2641 r=CC_HSLtoRGB('R',lpp->h,lpp->s,lpp->l);
2642 g=CC_HSLtoRGB('G',lpp->h,lpp->s,lpp->l);
2643 b=CC_HSLtoRGB('B',lpp->h,lpp->s,lpp->l);
2644 lpp->lpcc->rgbResult=RGB(r,g,b);
2648 r=GetRValue(lpp->lpcc->rgbResult);
2649 g=GetGValue(lpp->lpcc->rgbResult);
2650 b=GetBValue(lpp->lpcc->rgbResult);
2651 lpp->h=CC_RGBtoHSL('H',r,g,b);
2652 lpp->s=CC_RGBtoHSL('S',r,g,b);
2653 lpp->l=CC_RGBtoHSL('L',r,g,b);
2657 CC_EditSetRGB(hDlg,lpp->lpcc->rgbResult);
2658 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
2659 CC_PaintCross(hDlg,lpp->h,lpp->s);
2660 CC_PaintTriangle(hDlg,lpp->l);
2661 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2667 /***********************************************************************
2668 * ColorDlgProc (COMMDLG.8)
2670 LRESULT WINAPI ColorDlgProc(HWND16 hDlg, UINT16 message,
2671 WPARAM16 wParam, LONG lParam)
2674 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2675 if (message!=WM_INITDIALOG)
2680 if (CC_HookCallChk(lpp->lpcc))
2681 res=CallWindowProc16(lpp->lpcc->lpfnHook,hDlg,message,wParam,lParam);
2686 /* FIXME: SetRGB message
2687 if (message && message==msetrgb)
2688 return HandleSetRGB(hDlg,lParam);
2694 return CC_WMInitDialog(hDlg,wParam,lParam);
2696 DeleteDC32(lpp->hdcMem);
2697 DeleteObject32(lpp->hbmMem);
2699 SetWindowLong32A(hDlg, DWL_USER, 0L); /* we don't need it anymore */
2702 if (CC_WMCommand(hDlg, wParam, lParam))
2706 CC_WMPaint(hDlg, wParam, lParam);
2708 case WM_LBUTTONDBLCLK:
2709 if (CC_MouseCheckResultWindow(hDlg,lParam))
2712 case WM_MOUSEMOVE: /* FIXME: calculate new hue,sat,lum (if in color graph) */
2714 case WM_LBUTTONUP: /* FIXME: ClipCursor off (if in color graph)*/
2716 case WM_LBUTTONDOWN:/* FIXME: ClipCursor on (if in color graph)*/
2717 if (CC_WMLButtonDown(hDlg, wParam, lParam))
2724 static void CFn_CHOOSEFONT16to32A(LPCHOOSEFONT16 chf16, LPCHOOSEFONT32A chf32a)
2726 chf32a->lStructSize=sizeof(CHOOSEFONT32A);
2727 chf32a->hwndOwner=chf16->hwndOwner;
2728 chf32a->hDC=chf16->hDC;
2729 chf32a->iPointSize=chf16->iPointSize;
2730 chf32a->Flags=chf16->Flags;
2731 chf32a->rgbColors=chf16->rgbColors;
2732 chf32a->lCustData=chf16->lCustData;
2733 chf32a->lpfnHook=NULL;
2734 chf32a->lpTemplateName=PTR_SEG_TO_LIN(chf16->lpTemplateName);
2735 chf32a->hInstance=chf16->hInstance;
2736 chf32a->lpszStyle=PTR_SEG_TO_LIN(chf16->lpszStyle);
2737 chf32a->nFontType=chf16->nFontType;
2738 chf32a->nSizeMax=chf16->nSizeMax;
2739 chf32a->nSizeMin=chf16->nSizeMin;
2740 FONT_LogFont16To32A(PTR_SEG_TO_LIN(chf16->lpLogFont), chf32a->lpLogFont);
2744 /***********************************************************************
2745 * ChooseFont16 (COMMDLG.15)
2747 BOOL16 WINAPI ChooseFont16(LPCHOOSEFONT16 lpChFont)
2750 HANDLE16 hDlgTmpl = 0;
2751 BOOL16 bRet = FALSE, win32Format = FALSE;
2754 CHOOSEFONT32A cf32a;
2756 SEGPTR lpTemplateName;
2758 cf32a.lpLogFont=&lf32a;
2759 CFn_CHOOSEFONT16to32A(lpChFont, &cf32a);
2761 TRACE(commdlg,"ChooseFont\n");
2762 if (!lpChFont) return FALSE;
2764 if (lpChFont->Flags & CF_ENABLETEMPLATEHANDLE)
2766 if (!(template = LockResource16( lpChFont->hInstance )))
2768 CommDlgLastError = CDERR_LOADRESFAILURE;
2772 else if (lpChFont->Flags & CF_ENABLETEMPLATE)
2775 if (!(hResInfo = FindResource16( lpChFont->hInstance,
2776 lpChFont->lpTemplateName,
2779 CommDlgLastError = CDERR_FINDRESFAILURE;
2782 if (!(hDlgTmpl = LoadResource16( lpChFont->hInstance, hResInfo )) ||
2783 !(template = LockResource16( hDlgTmpl )))
2785 CommDlgLastError = CDERR_LOADRESFAILURE;
2791 template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT );
2795 hInst = WIN_GetWindowInstance( lpChFont->hwndOwner );
2797 /* lpTemplateName is not used in the dialog */
2798 lpTemplateName=lpChFont->lpTemplateName;
2799 lpChFont->lpTemplateName=(SEGPTR)&cf32a;
2801 hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
2802 lpChFont->hwndOwner,
2803 (DLGPROC16)MODULE_GetWndProcEntry16("FormatCharDlgProc"),
2804 (DWORD)lpChFont, WIN_PROC_16 );
2805 if (hwndDialog) bRet = DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner);
2806 if (hDlgTmpl) FreeResource16( hDlgTmpl );
2807 lpChFont->lpTemplateName=lpTemplateName;
2808 FONT_LogFont32ATo16(cf32a.lpLogFont,
2809 (LPLOGFONT16)(PTR_SEG_TO_LIN(lpChFont->lpLogFont)));
2814 /***********************************************************************
2815 * ChooseFont32A (COMDLG32.3)
2817 BOOL32 WINAPI ChooseFont32A(LPCHOOSEFONT32A lpChFont)
2821 HINSTANCE32 hInst=WIN_GetWindowInstance( lpChFont->hwndOwner );
2822 LPCVOID template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT );
2823 if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS | CF_ENABLETEMPLATE |
2824 CF_ENABLETEMPLATEHANDLE)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
2825 hwndDialog = DIALOG_CreateIndirect(hInst, template, TRUE, lpChFont->hwndOwner,
2826 (DLGPROC16)FormatCharDlgProc32A, (LPARAM)lpChFont, WIN_PROC_32A );
2827 if (hwndDialog) bRet = DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner);
2831 /***********************************************************************
2832 * ChooseFont32W (COMDLG32.4)
2834 BOOL32 WINAPI ChooseFont32W(LPCHOOSEFONT32W lpChFont)
2838 HINSTANCE32 hInst=WIN_GetWindowInstance( lpChFont->hwndOwner );
2839 CHOOSEFONT32A cf32a;
2841 LPCVOID template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT );
2842 if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS | CF_ENABLETEMPLATE |
2843 CF_ENABLETEMPLATEHANDLE)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
2844 memcpy(&cf32a, lpChFont, sizeof(cf32a));
2845 memcpy(&lf32a, lpChFont->lpLogFont, sizeof(LOGFONT32A));
2846 lstrcpynWtoA(lf32a.lfFaceName, lpChFont->lpLogFont->lfFaceName, LF_FACESIZE);
2847 cf32a.lpLogFont=&lf32a;
2848 cf32a.lpszStyle=HEAP_strdupWtoA(GetProcessHeap(), 0, lpChFont->lpszStyle);
2849 lpChFont->lpTemplateName=(LPWSTR)&cf32a;
2850 hwndDialog=DIALOG_CreateIndirect(hInst, template, TRUE, lpChFont->hwndOwner,
2851 (DLGPROC16)FormatCharDlgProc32W, (LPARAM)lpChFont, WIN_PROC_32W );
2852 if (hwndDialog)bRet=DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner);
2853 HeapFree(GetProcessHeap(), 0, cf32a.lpszStyle);
2854 lpChFont->lpTemplateName=(LPWSTR)cf32a.lpTemplateName;
2855 memcpy(lpChFont->lpLogFont, &lf32a, sizeof(CHOOSEFONT32A));
2856 lstrcpynAtoW(lpChFont->lpLogFont->lfFaceName, lf32a.lfFaceName, LF_FACESIZE);
2861 #define TEXT_EXTRAS 4
2862 #define TEXT_COLORS 16
2864 static const COLORREF textcolors[TEXT_COLORS]=
2866 0x00000000L,0x00000080L,0x00008000L,0x00008080L,
2867 0x00800000L,0x00800080L,0x00808000L,0x00808080L,
2868 0x00c0c0c0L,0x000000ffL,0x0000ff00L,0x0000ffffL,
2869 0x00ff0000L,0x00ff00ffL,0x00ffff00L,0x00FFFFFFL
2872 /***********************************************************************
2873 * CFn_HookCallChk [internal]
2875 static BOOL32 CFn_HookCallChk(LPCHOOSEFONT16 lpcf)
2878 if(lpcf->Flags & CF_ENABLEHOOK)
2884 /***********************************************************************
2885 * CFn_HookCallChk32 [internal]
2887 static BOOL32 CFn_HookCallChk32(LPCHOOSEFONT32A lpcf)
2890 if(lpcf->Flags & CF_ENABLEHOOK)
2897 /*************************************************************************
2898 * AddFontFamily [internal]
2900 static INT32 AddFontFamily(LPLOGFONT32A lplf, UINT32 nFontType,
2901 LPCHOOSEFONT32A lpcf, HWND32 hwnd)
2906 TRACE(commdlg,"font=%s (nFontType=%d)\n", lplf->lfFaceName,nFontType);
2908 if (lpcf->Flags & CF_FIXEDPITCHONLY)
2909 if (!(lplf->lfPitchAndFamily & FIXED_PITCH))
2911 if (lpcf->Flags & CF_ANSIONLY)
2912 if (lplf->lfCharSet != ANSI_CHARSET)
2914 if (lpcf->Flags & CF_TTONLY)
2915 if (!(nFontType & TRUETYPE_FONTTYPE))
2918 i=SendMessage32A(hwnd, CB_ADDSTRING32, 0, (LPARAM)lplf->lfFaceName);
2921 w=(lplf->lfCharSet << 8) | lplf->lfPitchAndFamily;
2922 SendMessage32A(hwnd, CB_SETITEMDATA32, i, MAKELONG(nFontType,w));
2923 return 1 ; /* store some important font information */
2933 LPCHOOSEFONT32A lpcf32a;
2934 } CFn_ENUMSTRUCT, *LPCFn_ENUMSTRUCT;
2936 /*************************************************************************
2937 * FontFamilyEnumProc32 [internal]
2939 INT32 WINAPI FontFamilyEnumProc32(LPENUMLOGFONT32A lpEnumLogFont,
2940 LPNEWTEXTMETRIC32A metrics, UINT32 nFontType, LPARAM lParam)
2943 e=(LPCFn_ENUMSTRUCT)lParam;
2944 return AddFontFamily(&lpEnumLogFont->elfLogFont, nFontType, e->lpcf32a, e->hWnd1);
2947 /***********************************************************************
2948 * FontFamilyEnumProc16 (COMMDLG.19)
2950 INT16 WINAPI FontFamilyEnumProc16( SEGPTR logfont, SEGPTR metrics,
2951 UINT16 nFontType, LPARAM lParam )
2953 HWND16 hwnd=LOWORD(lParam);
2954 HWND16 hDlg=GetParent16(hwnd);
2955 LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLong32A(hDlg, DWL_USER);
2956 LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN( logfont );
2958 FONT_LogFont16To32A(lplf, &lf32a);
2959 return AddFontFamily(&lf32a, nFontType, (LPCHOOSEFONT32A)lpcf->lpTemplateName,
2963 /*************************************************************************
2964 * SetFontStylesToCombo2 [internal]
2966 * Fill font style information into combobox (without using font.c directly)
2968 static int SetFontStylesToCombo2(HWND32 hwnd, HDC32 hdc, LPLOGFONT32A lplf)
2975 static struct FONTSTYLE fontstyles[FSTYLES]={
2976 { 0,FW_NORMAL,"Regular"},{0,FW_BOLD,"Bold"},
2977 { 1,FW_NORMAL,"Italic"}, {1,FW_BOLD,"Bold Italic"}};
2982 for (i=0;i<FSTYLES;i++)
2984 lplf->lfItalic=fontstyles[i].italic;
2985 lplf->lfWeight=fontstyles[i].weight;
2986 hf=CreateFontIndirect32A(lplf);
2987 hf=SelectObject32(hdc,hf);
2988 GetTextMetrics16(hdc,&tm);
2989 hf=SelectObject32(hdc,hf);
2992 if (tm.tmWeight==fontstyles[i].weight &&
2993 tm.tmItalic==fontstyles[i].italic) /* font successful created ? */
2995 char *str = SEGPTR_STRDUP(fontstyles[i].stname);
2996 j=SendMessage16(hwnd,CB_ADDSTRING16,0,(LPARAM)SEGPTR_GET(str) );
2998 if (j==CB_ERR) return 1;
2999 j=SendMessage16(hwnd, CB_SETITEMDATA16, j,
3000 MAKELONG(fontstyles[i].weight,fontstyles[i].italic));
3001 if (j==CB_ERR) return 1;
3007 /*************************************************************************
3008 * AddFontSizeToCombo3 [internal]
3010 static int AddFontSizeToCombo3(HWND32 hwnd, UINT32 h, LPCHOOSEFONT32A lpcf)
3015 if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
3016 ((lpcf->Flags & CF_LIMITSIZE) && (h >= lpcf->nSizeMin) && (h <= lpcf->nSizeMax)))
3018 sprintf(buffer, "%2d", h);
3019 j=SendMessage32A(hwnd, CB_FINDSTRINGEXACT32, -1, (LPARAM)buffer);
3022 j=SendMessage32A(hwnd, CB_ADDSTRING32, 0, (LPARAM)buffer);
3023 if (j!=CB_ERR) j = SendMessage32A(hwnd, CB_SETITEMDATA32, j, h);
3024 if (j==CB_ERR) return 1;
3030 /*************************************************************************
3031 * SetFontSizesToCombo3 [internal]
3033 static int SetFontSizesToCombo3(HWND32 hwnd, LPCHOOSEFONT32A lpcf)
3035 static const int sizes[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72,0};
3038 for (i=0; sizes[i]; i++)
3039 if (AddFontSizeToCombo3(hwnd, sizes[i], lpcf)) return 1;
3043 /***********************************************************************
3044 * AddFontStyle [internal]
3046 INT32 AddFontStyle(LPLOGFONT32A lplf, UINT32 nFontType,
3047 LPCHOOSEFONT32A lpcf, HWND32 hcmb2, HWND32 hcmb3, HWND32 hDlg)
3051 TRACE(commdlg,"(nFontType=%d)\n",nFontType);
3052 TRACE(commdlg," %s h=%d w=%d e=%d o=%d wg=%d i=%d u=%d s=%d"
3053 " ch=%d op=%d cp=%d q=%d pf=%xh\n",
3054 lplf->lfFaceName,lplf->lfHeight,lplf->lfWidth,
3055 lplf->lfEscapement,lplf->lfOrientation,
3056 lplf->lfWeight,lplf->lfItalic,lplf->lfUnderline,
3057 lplf->lfStrikeOut,lplf->lfCharSet, lplf->lfOutPrecision,
3058 lplf->lfClipPrecision,lplf->lfQuality, lplf->lfPitchAndFamily);
3059 if (nFontType & RASTER_FONTTYPE)
3061 if (AddFontSizeToCombo3(hcmb3, lplf->lfHeight, lpcf)) return 0;
3062 } else if (SetFontSizesToCombo3(hcmb3, lpcf)) return 0;
3064 if (!SendMessage32A(hcmb2, CB_GETCOUNT32, 0, 0))
3066 HDC32 hdc= (lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC32(hDlg);
3067 i=SetFontStylesToCombo2(hcmb2,hdc,lplf);
3068 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
3069 ReleaseDC32(hDlg,hdc);
3077 /***********************************************************************
3078 * FontStyleEnumProc16 (COMMDLG.18)
3080 INT16 WINAPI FontStyleEnumProc16( SEGPTR logfont, SEGPTR metrics,
3081 UINT16 nFontType, LPARAM lParam )
3083 HWND16 hcmb2=LOWORD(lParam);
3084 HWND16 hcmb3=HIWORD(lParam);
3085 HWND16 hDlg=GetParent16(hcmb3);
3086 LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLong32A(hDlg, DWL_USER);
3087 LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN(logfont);
3089 FONT_LogFont16To32A(lplf, &lf32a);
3090 return AddFontStyle(&lf32a, nFontType, (LPCHOOSEFONT32A)lpcf->lpTemplateName,
3091 hcmb2, hcmb3, hDlg);
3094 /***********************************************************************
3095 * FontStyleEnumProc32 [internal]
3097 INT32 WINAPI FontStyleEnumProc32( LPENUMLOGFONT32A lpFont,
3098 LPNEWTEXTMETRIC32A metrics, UINT32 nFontType, LPARAM lParam )
3100 LPCFn_ENUMSTRUCT s=(LPCFn_ENUMSTRUCT)lParam;
3101 HWND32 hcmb2=s->hWnd1;
3102 HWND32 hcmb3=s->hWnd2;
3103 HWND32 hDlg=GetParent32(hcmb3);
3104 return AddFontStyle(&lpFont->elfLogFont, nFontType, s->lpcf32a, hcmb2,
3108 /***********************************************************************
3109 * CFn_WMInitDialog [internal]
3111 LRESULT CFn_WMInitDialog(HWND32 hDlg, WPARAM32 wParam, LPARAM lParam,
3112 LPCHOOSEFONT32A lpcf)
3118 HCURSOR32 hcursor=SetCursor32(LoadCursor32A(0,IDC_WAIT32A));
3120 SetWindowLong32A(hDlg, DWL_USER, lParam);
3121 lpxx=lpcf->lpLogFont;
3122 TRACE(commdlg,"WM_INITDIALOG lParam=%08lX\n", lParam);
3124 if (lpcf->lStructSize != sizeof(CHOOSEFONT32A))
3126 ERR(commdlg,"structure size failure !!!\n");
3127 EndDialog32 (hDlg, 0);
3131 hBitmapTT = LoadBitmap32A(0, MAKEINTRESOURCE32A(OBM_TRTYPE));
3133 /* This font will be deleted by WM_COMMAND */
3134 SendDlgItemMessage32A(hDlg,stc6,WM_SETFONT,
3135 CreateFont32A(0, 0, 1, 1, 400, 0, 0, 0, 0, 0, 0, 0, 0, NULL),FALSE);
3137 if (!(lpcf->Flags & CF_SHOWHELP) || !IsWindow32(lpcf->hwndOwner))
3138 ShowWindow32(GetDlgItem32(hDlg,pshHelp),SW_HIDE);
3139 if (!(lpcf->Flags & CF_APPLY))
3140 ShowWindow32(GetDlgItem32(hDlg,psh3),SW_HIDE);
3141 if (lpcf->Flags & CF_EFFECTS)
3143 for (res=1,i=0;res && i<TEXT_COLORS;i++)
3145 /* FIXME: load color name from resource: res=LoadString(...,i+....,buffer,.....); */
3147 strcpy( name, "[color name]" );
3148 j=SendDlgItemMessage32A(hDlg, cmb4, CB_ADDSTRING32, 0, (LPARAM)name);
3149 SendDlgItemMessage32A(hDlg, cmb4, CB_SETITEMDATA16, j, textcolors[j]);
3150 /* look for a fitting value in color combobox */
3151 if (textcolors[j]==lpcf->rgbColors)
3152 SendDlgItemMessage32A(hDlg,cmb4, CB_SETCURSEL32,j,0);
3157 ShowWindow32(GetDlgItem32(hDlg,cmb4),SW_HIDE);
3158 ShowWindow32(GetDlgItem32(hDlg,chx1),SW_HIDE);
3159 ShowWindow32(GetDlgItem32(hDlg,chx2),SW_HIDE);
3160 ShowWindow32(GetDlgItem32(hDlg,grp1),SW_HIDE);
3161 ShowWindow32(GetDlgItem32(hDlg,stc4),SW_HIDE);
3163 hdc= (lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC32(hDlg);
3167 s.hWnd1=GetDlgItem32(hDlg,cmb1);
3169 if (!EnumFontFamilies32A(hdc, NULL, FontFamilyEnumProc32, (LPARAM)&s))
3170 TRACE(commdlg,"EnumFontFamilies returns 0\n");
3171 if (lpcf->Flags & CF_INITTOLOGFONTSTRUCT)
3173 /* look for fitting font name in combobox1 */
3174 j=SendDlgItemMessage32A(hDlg,cmb1,CB_FINDSTRING32,-1,(LONG)lpxx->lfFaceName);
3177 SendDlgItemMessage32A(hDlg, cmb1, CB_SETCURSEL32, j, 0);
3178 SendMessage32A(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
3179 GetDlgItem32(hDlg,cmb1));
3181 /* look for fitting font style in combobox2 */
3182 l=MAKELONG(lpxx->lfWeight > FW_MEDIUM ? FW_BOLD:FW_NORMAL,lpxx->lfItalic !=0);
3183 for (i=0;i<TEXT_EXTRAS;i++)
3185 if (l==SendDlgItemMessage32A(hDlg, cmb2, CB_GETITEMDATA32, i, 0))
3186 SendDlgItemMessage32A(hDlg, cmb2, CB_SETCURSEL32, i, 0);
3189 /* look for fitting font size in combobox3 */
3190 j=SendDlgItemMessage32A(hDlg, cmb3, CB_GETCOUNT32, 0, 0);
3193 if (lpxx->lfHeight==(int)SendDlgItemMessage32A(hDlg,cmb3, CB_GETITEMDATA32,i,0))
3194 SendDlgItemMessage32A(hDlg,cmb3,CB_SETCURSEL32,i,0);
3200 SendDlgItemMessage32A(hDlg,cmb1,CB_SETCURSEL32,0,0);
3201 SendMessage32A(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
3202 GetDlgItem32(hDlg,cmb1));
3204 if (lpcf->Flags & CF_USESTYLE && lpcf->lpszStyle)
3206 j=SendDlgItemMessage32A(hDlg,cmb2,CB_FINDSTRING32,-1,(LONG)lpcf->lpszStyle);
3209 j=SendDlgItemMessage32A(hDlg,cmb2,CB_SETCURSEL32,j,0);
3210 SendMessage32A(hDlg,WM_COMMAND,cmb2,
3211 MAKELONG(GetDlgItem32(hDlg,cmb2),CBN_SELCHANGE));
3217 WARN(commdlg,"HDC failure !!!\n");
3218 EndDialog32 (hDlg, 0);
3222 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
3223 ReleaseDC32(hDlg,hdc);
3224 SetCursor32(hcursor);
3229 /***********************************************************************
3230 * CFn_WMMeasureItem [internal]
3232 LRESULT CFn_WMMeasureItem(HWND32 hDlg, WPARAM32 wParam, LPARAM lParam)
3235 LPMEASUREITEMSTRUCT32 lpmi=(LPMEASUREITEMSTRUCT32)lParam;
3237 hBitmapTT = LoadBitmap32A(0, MAKEINTRESOURCE32A(OBM_TRTYPE));
3238 GetObject32A( hBitmapTT, sizeof(bm), &bm );
3239 lpmi->itemHeight=bm.bmHeight;
3240 /* FIXME: use MAX of bm.bmHeight and tm.tmHeight .*/
3245 /***********************************************************************
3246 * CFn_WMDrawItem [internal]
3248 LRESULT CFn_WMDrawItem(HWND32 hDlg, WPARAM32 wParam, LPARAM lParam)
3253 COLORREF cr, oldText=0, oldBk=0;
3258 HBITMAP32 hBitmap; /* for later TT usage */
3260 LPDRAWITEMSTRUCT32 lpdi = (LPDRAWITEMSTRUCT32)lParam;
3262 if (lpdi->itemID == 0xFFFF) /* got no items */
3263 DrawFocusRect32(lpdi->hDC, &lpdi->rcItem);
3266 if (lpdi->CtlType == ODT_COMBOBOX)
3268 if (lpdi->itemState ==ODS_SELECTED)
3270 hBrush=GetSysColorBrush32(COLOR_HIGHLIGHT);
3271 oldText=SetTextColor32(lpdi->hDC, GetSysColor32(COLOR_HIGHLIGHTTEXT));
3272 oldBk=SetBkColor32(lpdi->hDC, GetSysColor32(COLOR_HIGHLIGHT));
3275 hBrush = SelectObject32(lpdi->hDC, GetStockObject32(LTGRAY_BRUSH));
3276 SelectObject32(lpdi->hDC, hBrush);
3278 FillRect32(lpdi->hDC, &lpdi->rcItem, hBrush);
3281 return TRUE; /* this should never happen */
3284 switch (lpdi->CtlID)
3286 case cmb1: /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
3287 SendMessage32A(lpdi->hwndItem, CB_GETLBTEXT32, lpdi->itemID,
3289 GetObject32A( hBitmapTT, sizeof(bm), &bm );
3290 TextOut32A(lpdi->hDC, lpdi->rcItem.left + bm.bmWidth + 10,
3291 lpdi->rcItem.top, buffer, lstrlen32A(buffer));
3293 nFontType = SendMessage32A(lpdi->hwndItem, CB_GETITEMDATA32, lpdi->itemID,0L);
3294 /* FIXME: draw bitmap if truetype usage */
3295 if (nFontType&TRUETYPE_FONTTYPE)
3297 hMemDC = CreateCompatibleDC32(lpdi->hDC);
3298 hBitmap = SelectObject32(hMemDC, hBitmapTT);
3299 BitBlt32(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top,
3300 bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
3301 SelectObject32(hMemDC, hBitmap);
3307 case cmb3: /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
3308 SendMessage32A(lpdi->hwndItem, CB_GETLBTEXT32, lpdi->itemID,
3310 TextOut32A(lpdi->hDC, lpdi->rcItem.left,
3311 lpdi->rcItem.top, buffer, lstrlen32A(buffer));
3314 case cmb4: /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
3315 SendMessage32A(lpdi->hwndItem, CB_GETLBTEXT32, lpdi->itemID,
3317 TextOut32A(lpdi->hDC, lpdi->rcItem.left + 25+5,
3318 lpdi->rcItem.top, buffer, lstrlen32A(buffer));
3319 cr = SendMessage32A(lpdi->hwndItem, CB_GETITEMDATA32, lpdi->itemID,0L);
3320 hBrush = CreateSolidBrush32(cr);
3323 hBrush = SelectObject32 (lpdi->hDC, hBrush) ;
3324 rect.right=rect.left+25;
3328 Rectangle32( lpdi->hDC, rect.left, rect.top,
3329 rect.right, rect.bottom );
3330 DeleteObject32( SelectObject32 (lpdi->hDC, hBrush)) ;
3336 default: return TRUE; /* this should never happen */
3338 if (lpdi->itemState == ODS_SELECTED)
3340 SetTextColor32(lpdi->hDC, oldText);
3341 SetBkColor32(lpdi->hDC, oldBk);
3347 /***********************************************************************
3348 * CFn_WMCtlColor [internal]
3350 LRESULT CFn_WMCtlColorStatic(HWND32 hDlg, WPARAM32 wParam, LPARAM lParam,
3351 LPCHOOSEFONT32A lpcf)
3353 if (lpcf->Flags & CF_EFFECTS)
3354 if (GetDlgCtrlID32(lParam)==stc6)
3356 SetTextColor32((HDC32)wParam, lpcf->rgbColors);
3357 return GetStockObject32(WHITE_BRUSH);
3362 /***********************************************************************
3363 * CFn_WMCommand [internal]
3365 LRESULT CFn_WMCommand(HWND32 hDlg, WPARAM32 wParam, LPARAM lParam,
3366 LPCHOOSEFONT32A lpcf)
3372 LPLOGFONT32A lpxx=lpcf->lpLogFont;
3374 TRACE(commdlg,"WM_COMMAND wParam=%08lX lParam=%08lX\n", (LONG)wParam, lParam);
3375 switch (LOWORD(wParam))
3377 case cmb1:if (HIWORD(wParam)==CBN_SELCHANGE)
3379 hdc=(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC32(hDlg);
3382 SendDlgItemMessage32A(hDlg, cmb2, CB_RESETCONTENT16, 0, 0);
3383 SendDlgItemMessage32A(hDlg, cmb3, CB_RESETCONTENT16, 0, 0);
3384 i=SendDlgItemMessage32A(hDlg, cmb1, CB_GETCURSEL16, 0, 0);
3387 HCURSOR32 hcursor=SetCursor32(LoadCursor32A(0,IDC_WAIT32A));
3390 SendDlgItemMessage32A(hDlg, cmb1, CB_GETLBTEXT32, i,
3392 TRACE(commdlg,"WM_COMMAND/cmb1 =>%s\n",str);
3393 s.hWnd1=GetDlgItem32(hDlg, cmb2);
3394 s.hWnd2=GetDlgItem32(hDlg, cmb3);
3396 EnumFontFamilies32A(hdc, str, FontStyleEnumProc32, (LPARAM)&s);
3397 SetCursor32(hcursor);
3399 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
3400 ReleaseDC32(hDlg,hdc);
3404 WARN(commdlg,"HDC failure !!!\n");
3405 EndDialog32 (hDlg, 0);
3412 case cmb3:if (HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)== BN_CLICKED )
3415 TRACE(commdlg,"WM_COMMAND/cmb2,3 =%08lX\n", lParam);
3416 i=SendDlgItemMessage32A(hDlg,cmb1,CB_GETCURSEL32,0,0);
3418 i=GetDlgItemText32A( hDlg, cmb1, str, 256 );
3421 SendDlgItemMessage32A(hDlg,cmb1,CB_GETLBTEXT32,i,
3423 l=SendDlgItemMessage32A(hDlg,cmb1,CB_GETITEMDATA32,i,0);
3425 lpcf->nFontType = LOWORD(l);
3426 /* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */
3427 /* same value reported to the EnumFonts
3428 call back with the extra FONTTYPE_... bits added */
3429 lpxx->lfPitchAndFamily=j&0xff;
3430 lpxx->lfCharSet=j>>8;
3432 strcpy(lpxx->lfFaceName,str);
3433 i=SendDlgItemMessage32A(hDlg, cmb2, CB_GETCURSEL32, 0, 0);
3436 l=SendDlgItemMessage32A(hDlg, cmb2, CB_GETITEMDATA32, i, 0);
3437 if (0!=(lpxx->lfItalic=HIWORD(l)))
3438 lpcf->nFontType |= ITALIC_FONTTYPE;
3439 if ((lpxx->lfWeight=LOWORD(l)) > FW_MEDIUM)
3440 lpcf->nFontType |= BOLD_FONTTYPE;
3442 i=SendDlgItemMessage32A(hDlg, cmb3, CB_GETCURSEL32, 0, 0);
3444 lpxx->lfHeight=-LOWORD(SendDlgItemMessage32A(hDlg, cmb3, CB_GETITEMDATA32, i, 0));
3447 lpxx->lfStrikeOut=IsDlgButtonChecked32(hDlg,chx1);
3448 lpxx->lfUnderline=IsDlgButtonChecked32(hDlg,chx2);
3449 lpxx->lfWidth=lpxx->lfOrientation=lpxx->lfEscapement=0;
3450 lpxx->lfOutPrecision=OUT_DEFAULT_PRECIS;
3451 lpxx->lfClipPrecision=CLIP_DEFAULT_PRECIS;
3452 lpxx->lfQuality=DEFAULT_QUALITY;
3453 lpcf->iPointSize= -10*lpxx->lfHeight;
3455 hFont=CreateFontIndirect32A(lpxx);
3458 HFONT32 oldFont=SendDlgItemMessage32A(hDlg, stc6,
3460 SendDlgItemMessage32A(hDlg,stc6,WM_SETFONT,hFont,TRUE);
3461 DeleteObject32(oldFont);
3466 case cmb4:i=SendDlgItemMessage32A(hDlg, cmb4, CB_GETCURSEL32, 0, 0);
3469 lpcf->rgbColors=textcolors[i];
3470 InvalidateRect32( GetDlgItem32(hDlg,stc6), NULL, 0 );
3474 case psh15:i=RegisterWindowMessage32A( HELPMSGSTRING );
3475 if (lpcf->hwndOwner)
3476 SendMessage32A(lpcf->hwndOwner, i, 0, (LPARAM)GetWindowLong32A(hDlg, DWL_USER));
3477 /* if (CFn_HookCallChk(lpcf))
3478 CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/
3481 case IDOK:if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
3482 ( (lpcf->Flags & CF_LIMITSIZE) &&
3483 (-lpxx->lfHeight >= lpcf->nSizeMin) &&
3484 (-lpxx->lfHeight <= lpcf->nSizeMax)))
3485 EndDialog32(hDlg, TRUE);
3489 sprintf(buffer,"Select a font size between %d and %d points.",
3490 lpcf->nSizeMin,lpcf->nSizeMax);
3491 MessageBox32A(hDlg, buffer, NULL, MB_OK);
3494 case IDCANCEL:EndDialog32(hDlg, FALSE);
3500 static LRESULT CFn_WMDestroy(HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
3502 DeleteObject32(SendDlgItemMessage32A(hwnd, stc6, WM_GETFONT, 0, 0));
3507 /***********************************************************************
3508 * FormatCharDlgProc16 (COMMDLG.16)
3509 FIXME: 1. some strings are "hardcoded", but it's better load from sysres
3510 2. some CF_.. flags are not supported
3511 3. some TType extensions
3513 LRESULT WINAPI FormatCharDlgProc16(HWND16 hDlg, UINT16 message, WPARAM16 wParam,
3516 LPCHOOSEFONT16 lpcf;
3517 LPCHOOSEFONT32A lpcf32a;
3521 if (message!=WM_INITDIALOG)
3523 lpcf=(LPCHOOSEFONT16)GetWindowLong32A(hDlg, DWL_USER);
3526 if (CFn_HookCallChk(lpcf))
3527 res=CallWindowProc16(lpcf->lpfnHook,hDlg,message,wParam,lParam);
3533 lpcf=(LPCHOOSEFONT16)lParam;
3534 lpcf32a=(LPCHOOSEFONT32A)lpcf->lpTemplateName;
3535 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a))
3537 TRACE(commdlg, "CFn_WMInitDialog returned FALSE\n");
3540 if (CFn_HookCallChk(lpcf))
3541 return CallWindowProc16(lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
3543 WINPROC_MapMsg16To32A(message, wParam, &uMsg32, &wParam32, &lParam);
3544 lpcf32a=(LPCHOOSEFONT32A)lpcf->lpTemplateName;
3547 case WM_MEASUREITEM:
3548 res=CFn_WMMeasureItem(hDlg, wParam32, lParam);
3551 res=CFn_WMDrawItem(hDlg, wParam32, lParam);
3553 case WM_CTLCOLORSTATIC:
3554 res=CFn_WMCtlColorStatic(hDlg, wParam32, lParam, lpcf32a);
3557 res=CFn_WMCommand(hDlg, wParam32, lParam, lpcf32a);
3560 res=CFn_WMDestroy(hDlg, wParam32, lParam);
3562 case WM_CHOOSEFONT_GETLOGFONT:
3563 TRACE(commdlg,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3565 FIXME(commdlg, "current logfont back to caller\n");
3568 WINPROC_UnmapMsg16To32A(uMsg32, wParam32, lParam, res);
3572 /***********************************************************************
3573 * FormatCharDlgProc32A [internal]
3575 LRESULT WINAPI FormatCharDlgProc32A(HWND32 hDlg, UINT32 uMsg, WPARAM32 wParam,
3578 LPCHOOSEFONT32A lpcf;
3580 if (uMsg!=WM_INITDIALOG)
3582 lpcf=(LPCHOOSEFONT32A)GetWindowLong32A(hDlg, DWL_USER);
3585 if (CFn_HookCallChk32(lpcf))
3586 res=CallWindowProc32A(lpcf->lpfnHook, hDlg, uMsg, wParam, lParam);
3592 lpcf=(LPCHOOSEFONT32A)lParam;
3593 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf))
3595 TRACE(commdlg, "CFn_WMInitDialog returned FALSE\n");
3598 if (CFn_HookCallChk32(lpcf))
3599 return CallWindowProc32A(lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
3603 case WM_MEASUREITEM:
3604 return CFn_WMMeasureItem(hDlg, wParam, lParam);
3606 return CFn_WMDrawItem(hDlg, wParam, lParam);
3607 case WM_CTLCOLORSTATIC:
3608 return CFn_WMCtlColorStatic(hDlg, wParam, lParam, lpcf);
3610 return CFn_WMCommand(hDlg, wParam, lParam, lpcf);
3612 return CFn_WMDestroy(hDlg, wParam, lParam);
3613 case WM_CHOOSEFONT_GETLOGFONT:
3614 TRACE(commdlg,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3616 FIXME(commdlg, "current logfont back to caller\n");
3622 /***********************************************************************
3623 * FormatCharDlgProc32W [internal]
3625 LRESULT WINAPI FormatCharDlgProc32W(HWND32 hDlg, UINT32 uMsg, WPARAM32 wParam,
3628 LPCHOOSEFONT32W lpcf32w;
3629 LPCHOOSEFONT32A lpcf32a;
3631 if (uMsg!=WM_INITDIALOG)
3633 lpcf32w=(LPCHOOSEFONT32W)GetWindowLong32A(hDlg, DWL_USER);
3636 if (CFn_HookCallChk32((LPCHOOSEFONT32A)lpcf32w))
3637 res=CallWindowProc32W(lpcf32w->lpfnHook, hDlg, uMsg, wParam, lParam);
3643 lpcf32w=(LPCHOOSEFONT32W)lParam;
3644 lpcf32a=(LPCHOOSEFONT32A)lpcf32w->lpTemplateName;
3645 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a))
3647 TRACE(commdlg, "CFn_WMInitDialog returned FALSE\n");
3650 if (CFn_HookCallChk32((LPCHOOSEFONT32A)lpcf32w))
3651 return CallWindowProc32W(lpcf32w->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
3653 lpcf32a=(LPCHOOSEFONT32A)lpcf32w->lpTemplateName;
3656 case WM_MEASUREITEM:
3657 return CFn_WMMeasureItem(hDlg, wParam, lParam);
3659 return CFn_WMDrawItem(hDlg, wParam, lParam);
3660 case WM_CTLCOLORSTATIC:
3661 return CFn_WMCtlColorStatic(hDlg, wParam, lParam, lpcf32a);
3663 return CFn_WMCommand(hDlg, wParam, lParam, lpcf32a);
3665 return CFn_WMDestroy(hDlg, wParam, lParam);
3666 case WM_CHOOSEFONT_GETLOGFONT:
3667 TRACE(commdlg,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3669 FIXME(commdlg, "current logfont back to caller\n");
3676 static BOOL32 Commdlg_GetFileName32A( BOOL16 (CALLBACK *dofunction)(SEGPTR x),
3677 LPOPENFILENAME32A ofn )
3680 LPOPENFILENAME16 ofn16 = SEGPTR_ALLOC(sizeof(OPENFILENAME16));
3682 memset(ofn16,'\0',sizeof(*ofn16));
3683 ofn16->lStructSize = sizeof(*ofn16);
3684 ofn16->hwndOwner = ofn->hwndOwner;
3685 ofn16->hInstance = MapHModuleLS(ofn->hInstance);
3686 if (ofn->lpstrFilter) {
3689 /* filter is a list... title\0ext\0......\0\0 */
3690 s = (LPSTR)ofn->lpstrFilter;
3694 x = (LPSTR)SEGPTR_ALLOC(s-ofn->lpstrFilter);
3695 memcpy(x,ofn->lpstrFilter,s-ofn->lpstrFilter);
3696 ofn16->lpstrFilter = SEGPTR_GET(x);
3698 if (ofn->lpstrCustomFilter) {
3701 /* filter is a list... title\0ext\0......\0\0 */
3702 s = (LPSTR)ofn->lpstrCustomFilter;
3706 x = SEGPTR_ALLOC(s-ofn->lpstrCustomFilter);
3707 memcpy(x,ofn->lpstrCustomFilter,s-ofn->lpstrCustomFilter);
3708 ofn16->lpstrCustomFilter = SEGPTR_GET(x);
3710 ofn16->nMaxCustFilter = ofn->nMaxCustFilter;
3711 ofn16->nFilterIndex = ofn->nFilterIndex;
3713 ofn16->lpstrFile = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFile));
3714 ofn16->nMaxFile = ofn->nMaxFile;
3715 ofn16->nMaxFileTitle = ofn->nMaxFileTitle;
3716 if (ofn16->nMaxFileTitle)
3717 ofn16->lpstrFileTitle = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFileTitle));
3718 if (ofn->lpstrInitialDir)
3719 ofn16->lpstrInitialDir = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrInitialDir));
3720 if (ofn->lpstrTitle)
3721 ofn16->lpstrTitle = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrTitle));
3722 ofn16->Flags = ofn->Flags|OFN_WINE32;
3723 ofn16->nFileOffset = ofn->nFileOffset;
3724 ofn16->nFileExtension = ofn->nFileExtension;
3725 if (ofn->lpstrDefExt)
3726 ofn16->lpstrDefExt = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrDefExt));
3727 ofn16->lCustData = ofn->lCustData;
3728 ofn16->lpfnHook = (WNDPROC16)ofn->lpfnHook;
3730 if (ofn->lpTemplateName)
3731 ofn16->lpTemplateName = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpTemplateName));
3733 ret = dofunction(SEGPTR_GET(ofn16));
3735 ofn->nFileOffset = ofn16->nFileOffset;
3736 ofn->nFileExtension = ofn16->nFileExtension;
3737 if (ofn16->lpstrFilter)
3738 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFilter));
3739 if (ofn16->lpTemplateName)
3740 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpTemplateName));
3741 if (ofn16->lpstrDefExt)
3742 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrDefExt));
3743 if (ofn16->lpstrTitle)
3744 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrTitle));
3745 if (ofn16->lpstrInitialDir)
3746 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrInitialDir));
3747 if (ofn16->lpstrCustomFilter)
3748 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrCustomFilter));
3750 if (ofn16->lpstrFile)
3752 strcpy(ofn->lpstrFile,PTR_SEG_TO_LIN(ofn16->lpstrFile));
3753 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFile));
3756 if (ofn16->lpstrFileTitle)
3758 strcpy(ofn->lpstrFileTitle,PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
3759 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
3765 static BOOL32 Commdlg_GetFileName32W( BOOL16 (CALLBACK *dofunction)(SEGPTR x),
3766 LPOPENFILENAME32W ofn )
3769 LPOPENFILENAME16 ofn16 = SEGPTR_ALLOC(sizeof(OPENFILENAME16));
3771 memset(ofn16,'\0',sizeof(*ofn16));
3772 ofn16->lStructSize = sizeof(*ofn16);
3773 ofn16->hwndOwner = ofn->hwndOwner;
3774 ofn16->hInstance = MapHModuleLS(ofn->hInstance);
3775 if (ofn->lpstrFilter) {
3780 /* filter is a list... title\0ext\0......\0\0 */
3781 s = (LPWSTR)ofn->lpstrFilter;
3783 s = s+lstrlen32W(s)+1;
3785 n = s - ofn->lpstrFilter; /* already divides by 2. ptr magic */
3786 x = y = (LPSTR)SEGPTR_ALLOC(n);
3787 s = (LPWSTR)ofn->lpstrFilter;
3794 ofn16->lpstrFilter = SEGPTR_GET(y);
3796 if (ofn->lpstrCustomFilter) {
3801 /* filter is a list... title\0ext\0......\0\0 */
3802 s = (LPWSTR)ofn->lpstrCustomFilter;
3804 s = s+lstrlen32W(s)+1;
3806 n = s - ofn->lpstrCustomFilter;
3807 x = y = (LPSTR)SEGPTR_ALLOC(n);
3808 s = (LPWSTR)ofn->lpstrCustomFilter;
3815 ofn16->lpstrCustomFilter = SEGPTR_GET(y);
3817 ofn16->nMaxCustFilter = ofn->nMaxCustFilter;
3818 ofn16->nFilterIndex = ofn->nFilterIndex;
3820 ofn16->lpstrFile = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFile));
3821 ofn16->nMaxFile = ofn->nMaxFile;
3822 ofn16->nMaxFileTitle = ofn->nMaxFileTitle;
3823 if (ofn->nMaxFileTitle)
3824 ofn16->lpstrFileTitle = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFileTitle));
3825 if (ofn->lpstrInitialDir)
3826 ofn16->lpstrInitialDir = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrInitialDir));
3827 if (ofn->lpstrTitle)
3828 ofn16->lpstrTitle = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrTitle));
3829 ofn16->Flags = ofn->Flags|OFN_WINE32|OFN_UNICODE;
3830 ofn16->nFileOffset = ofn->nFileOffset;
3831 ofn16->nFileExtension = ofn->nFileExtension;
3832 if (ofn->lpstrDefExt)
3833 ofn16->lpstrDefExt = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrDefExt));
3834 ofn16->lCustData = ofn->lCustData;
3835 ofn16->lpfnHook = (WNDPROC16)ofn->lpfnHook;
3836 if (ofn->lpTemplateName)
3837 ofn16->lpTemplateName = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpTemplateName));
3838 ret = dofunction(SEGPTR_GET(ofn16));
3840 ofn->nFileOffset = ofn16->nFileOffset;
3841 ofn->nFileExtension = ofn16->nFileExtension;
3842 if (ofn16->lpstrFilter)
3843 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFilter));
3844 if (ofn16->lpTemplateName)
3845 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpTemplateName));
3846 if (ofn16->lpstrDefExt)
3847 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrDefExt));
3848 if (ofn16->lpstrTitle)
3849 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrTitle));
3850 if (ofn16->lpstrInitialDir)
3851 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrInitialDir));
3852 if (ofn16->lpstrCustomFilter)
3853 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrCustomFilter));
3855 if (ofn16->lpstrFile) {
3856 lstrcpyAtoW(ofn->lpstrFile,PTR_SEG_TO_LIN(ofn16->lpstrFile));
3857 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFile));
3860 if (ofn16->lpstrFileTitle) {
3861 lstrcpyAtoW(ofn->lpstrFileTitle,PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
3862 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
3868 /***********************************************************************
3869 * GetOpenFileName32A (COMDLG32.10)
3871 BOOL32 WINAPI GetOpenFileName32A( LPOPENFILENAME32A ofn )
3873 BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetOpenFileName16;
3874 return Commdlg_GetFileName32A(dofunction,ofn);
3877 /***********************************************************************
3878 * GetOpenFileName32W (COMDLG32.11)
3880 BOOL32 WINAPI GetOpenFileName32W( LPOPENFILENAME32W ofn )
3882 BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetOpenFileName16;
3883 return Commdlg_GetFileName32W(dofunction,ofn);
3886 /***********************************************************************
3887 * GetSaveFileName32A (COMDLG32.12)
3889 BOOL32 WINAPI GetSaveFileName32A( LPOPENFILENAME32A ofn )
3891 BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetSaveFileName16;
3892 return Commdlg_GetFileName32A(dofunction,ofn);
3895 /***********************************************************************
3896 * GetSaveFileName32W (COMDLG32.13)
3898 BOOL32 WINAPI GetSaveFileName32W( LPOPENFILENAME32W ofn )
3900 BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetSaveFileName16;
3901 return Commdlg_GetFileName32W(dofunction,ofn);
3904 /***********************************************************************
3905 * ChooseColorA (COMDLG32.1)
3907 BOOL32 WINAPI ChooseColor32A(LPCHOOSECOLOR32A lpChCol )
3912 COLORREF* ccref=SEGPTR_ALLOC(64);
3913 LPCHOOSECOLOR16 lpcc16=SEGPTR_ALLOC(sizeof(CHOOSECOLOR16));
3915 memset(lpcc16,'\0',sizeof(*lpcc16));
3916 lpcc16->lStructSize=sizeof(*lpcc16);
3917 lpcc16->hwndOwner=lpChCol->hwndOwner;
3918 lpcc16->hInstance=MapHModuleLS(lpChCol->hInstance);
3919 lpcc16->rgbResult=lpChCol->rgbResult;
3920 memcpy(ccref,lpChCol->lpCustColors,64);
3921 lpcc16->lpCustColors=(COLORREF*)SEGPTR_GET(ccref);
3922 lpcc16->Flags=lpChCol->Flags;
3923 lpcc16->lCustData=lpChCol->lCustData;
3924 lpcc16->lpfnHook=(WNDPROC16)lpChCol->lpfnHook;
3925 if (lpChCol->lpTemplateName)
3926 str = SEGPTR_STRDUP(lpChCol->lpTemplateName );
3927 lpcc16->lpTemplateName=SEGPTR_GET(str);
3929 ret = ChooseColor16(lpcc16);
3932 memcpy(lpChCol->lpCustColors,ccref,64);
3934 SEGPTR_FREE(lpcc16);
3938 /***********************************************************************
3939 * ChooseColorW (COMDLG32.2)
3941 BOOL32 WINAPI ChooseColor32W(LPCHOOSECOLOR32W lpChCol )
3946 COLORREF* ccref=SEGPTR_ALLOC(64);
3947 LPCHOOSECOLOR16 lpcc16=SEGPTR_ALLOC(sizeof(CHOOSECOLOR16));
3949 memset(lpcc16,'\0',sizeof(*lpcc16));
3950 lpcc16->lStructSize=sizeof(*lpcc16);
3951 lpcc16->hwndOwner=lpChCol->hwndOwner;
3952 lpcc16->hInstance=MapHModuleLS(lpChCol->hInstance);
3953 lpcc16->rgbResult=lpChCol->rgbResult;
3954 memcpy(ccref,lpChCol->lpCustColors,64);
3955 lpcc16->lpCustColors=(COLORREF*)SEGPTR_GET(ccref);
3956 lpcc16->Flags=lpChCol->Flags;
3957 lpcc16->lCustData=lpChCol->lCustData;
3958 lpcc16->lpfnHook=(WNDPROC16)lpChCol->lpfnHook;
3959 if (lpChCol->lpTemplateName)
3960 str = SEGPTR_STRDUP_WtoA(lpChCol->lpTemplateName );
3961 lpcc16->lpTemplateName=SEGPTR_GET(str);
3963 ret = ChooseColor16(lpcc16);
3966 memcpy(lpChCol->lpCustColors,ccref,64);
3968 SEGPTR_FREE(lpcc16);
3972 /***********************************************************************
3973 * PageSetupDlgA (COMDLG32.15)
3975 BOOL32 WINAPI PageSetupDlg32A(LPPAGESETUPDLG32A setupdlg) {
3976 FIXME(commdlg,"(%p), stub!\n",setupdlg);