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(void)
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] == ':')
1594 TRACE(commdlg,"---> '%s' \n", &lpFile[i]);
1596 len = strlen(lpFile+i)+1;
1600 strncpy(lpTitle, &lpFile[i], len);
1605 /***********************************************************************
1606 * GetFileTitleA (COMDLG32.8)
1608 short WINAPI GetFileTitle32W(LPCWSTR lpFile, LPWSTR lpTitle, UINT32 cbBuf)
1610 LPSTR file = HEAP_strdupWtoA(GetProcessHeap(),0,lpFile);
1611 LPSTR title = HeapAlloc(GetProcessHeap(),0,cbBuf);
1614 ret = GetFileTitle32A(file,title,cbBuf);
1616 lstrcpynAtoW(lpTitle,title,cbBuf);
1617 HeapFree(GetProcessHeap(),0,file);
1618 HeapFree(GetProcessHeap(),0,title);
1621 /***********************************************************************
1622 * GetFileTitle (COMMDLG.27)
1624 short WINAPI GetFileTitle16(LPCSTR lpFile, LPSTR lpTitle, UINT16 cbBuf)
1626 return GetFileTitle32A(lpFile,lpTitle,cbBuf);
1630 /* ------------------------ Choose Color Dialog --------------------------- */
1632 /***********************************************************************
1633 * ChooseColor (COMMDLG.5)
1635 BOOL16 WINAPI ChooseColor16(LPCHOOSECOLOR16 lpChCol)
1638 HANDLE16 hDlgTmpl = 0;
1639 BOOL16 bRet = FALSE, win32Format = FALSE;
1643 TRACE(commdlg,"ChooseColor\n");
1644 if (!lpChCol) return FALSE;
1646 if (lpChCol->Flags & CC_ENABLETEMPLATEHANDLE)
1648 if (!(template = LockResource16( lpChCol->hInstance )))
1650 CommDlgLastError = CDERR_LOADRESFAILURE;
1654 else if (lpChCol->Flags & CC_ENABLETEMPLATE)
1657 if (!(hResInfo = FindResource16(lpChCol->hInstance,
1658 lpChCol->lpTemplateName,
1661 CommDlgLastError = CDERR_FINDRESFAILURE;
1664 if (!(hDlgTmpl = LoadResource16( lpChCol->hInstance, hResInfo )) ||
1665 !(template = LockResource16( hDlgTmpl )))
1667 CommDlgLastError = CDERR_LOADRESFAILURE;
1673 template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_COLOR );
1677 hInst = WIN_GetWindowInstance( lpChCol->hwndOwner );
1678 hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
1680 (DLGPROC16)MODULE_GetWndProcEntry16("ColorDlgProc"),
1681 (DWORD)lpChCol, WIN_PROC_16 );
1682 if (hwndDialog) bRet = DIALOG_DoDialogBox( hwndDialog, lpChCol->hwndOwner);
1683 if (hDlgTmpl) FreeResource16( hDlgTmpl );
1688 static const COLORREF predefcolors[6][8]=
1690 { 0x008080FFL, 0x0080FFFFL, 0x0080FF80L, 0x0080FF00L,
1691 0x00FFFF80L, 0x00FF8000L, 0x00C080FFL, 0x00FF80FFL },
1692 { 0x000000FFL, 0x0000FFFFL, 0x0000FF80L, 0x0040FF00L,
1693 0x00FFFF00L, 0x00C08000L, 0x00C08080L, 0x00FF00FFL },
1695 { 0x00404080L, 0x004080FFL, 0x0000FF00L, 0x00808000L,
1696 0x00804000L, 0x00FF8080L, 0x00400080L, 0x008000FFL },
1697 { 0x00000080L, 0x000080FFL, 0x00008000L, 0x00408000L,
1698 0x00FF0000L, 0x00A00000L, 0x00800080L, 0x00FF0080L },
1700 { 0x00000040L, 0x00004080L, 0x00004000L, 0x00404000L,
1701 0x00800000L, 0x00400000L, 0x00400040L, 0x00800040L },
1702 { 0x00000000L, 0x00008080L, 0x00408080L, 0x00808080L,
1703 0x00808040L, 0x00C0C0C0L, 0x00400040L, 0x00FFFFFFL },
1708 LPCHOOSECOLOR16 lpcc; /* points to public known data structure */
1709 int nextuserdef; /* next free place in user defined color array */
1710 HDC16 hdcMem; /* color graph used for BitBlt() */
1711 HBITMAP16 hbmMem; /* color graph bitmap */
1712 RECT16 fullsize; /* original dialog window size */
1713 UINT16 msetrgb; /* # of SETRGBSTRING message (today not used) */
1714 RECT16 old3angle; /* last position of l-marker */
1715 RECT16 oldcross; /* last position of color/satuation marker */
1716 BOOL32 updating; /* to prevent recursive WM_COMMAND/EN_UPDATE procesing */
1719 int l; /* for temporary storing of hue,sat,lum */
1722 /***********************************************************************
1723 * CC_HSLtoRGB [internal]
1725 static int CC_HSLtoRGB(char c,int hue,int sat,int lum)
1732 case 'R':if (hue>80) hue-=80; else hue+=160; break;
1733 case 'G':if (hue>160) hue-=160; else hue+=80; break;
1738 maxrgb=(256*MIN(120,lum))/120; /* 0 .. 256 */
1744 res=(hue-80)* maxrgb; /* 0...10240 */
1745 res/=40; /* 0...256 */
1752 res=(240-hue)* maxrgb;
1755 res=res-maxrgb/2; /* -128...128 */
1758 res=maxrgb/2 + (sat*res) /240; /* 0..256 */
1761 if (lum>120 && res<256)
1762 res+=((lum-120) * (256-res))/120;
1764 return MIN(res,255);
1767 /***********************************************************************
1768 * CC_RGBtoHSL [internal]
1770 static int CC_RGBtoHSL(char c,int r,int g,int b)
1772 WORD maxi,mini,mmsum,mmdif,result=0;
1786 case 'L':mmsum*=120; /* 0...61200=(255+255)*120 */
1787 result=mmsum/255; /* 0...240 */
1790 case 'S':if (!mmsum)
1793 if (!mini || maxi==255)
1797 result=mmdif*240; /* 0...61200=255*240 */
1798 result/= (mmsum>255 ? mmsum=510-mmsum : mmsum); /* 0..255 */
1802 case 'H':if (!mmdif)
1808 iresult=40*(g-b); /* -10200 ... 10200 */
1809 iresult/=(int)mmdif; /* -40 .. 40 */
1811 iresult+=240; /* 0..40 and 200..240 */
1817 iresult/=(int)mmdif;
1818 iresult+=80; /* 40 .. 120 */
1824 iresult/=(int)mmdif;
1825 iresult+=160; /* 120 .. 200 */
1831 return result; /* is this integer arithmetic precise enough ? */
1836 /***********************************************************************
1837 * CC_MouseCheckPredefColorArray [internal]
1839 static int CC_MouseCheckPredefColorArray(HWND16 hDlg,int dlgitem,int rows,int cols,
1840 LPARAM lParam,COLORREF *cr)
1843 POINT16 point = MAKEPOINT16(lParam);
1847 ClientToScreen16(hDlg,&point);
1848 hwnd=GetDlgItem32(hDlg,dlgitem);
1849 GetWindowRect16(hwnd,&rect);
1850 if (PtInRect16(&rect,point))
1852 dx=(rect.right-rect.left)/cols;
1853 dy=(rect.bottom-rect.top)/rows;
1854 ScreenToClient16(hwnd,&point);
1856 if (point.x % dx < (dx-DISTANCE) && point.y % dy < (dy-DISTANCE))
1860 *cr=predefcolors[y][x];
1861 /* FIXME: Draw_a_Focus_Rect() */
1868 /***********************************************************************
1869 * CC_MouseCheckUserColorArray [internal]
1871 static int CC_MouseCheckUserColorArray(HWND16 hDlg,int dlgitem,int rows,int cols,
1872 LPARAM lParam,COLORREF *cr,COLORREF*crarr)
1875 POINT16 point = MAKEPOINT16(lParam);
1879 ClientToScreen16(hDlg,&point);
1880 hwnd=GetDlgItem32(hDlg,dlgitem);
1881 GetWindowRect16(hwnd,&rect);
1882 if (PtInRect16(&rect,point))
1884 dx=(rect.right-rect.left)/cols;
1885 dy=(rect.bottom-rect.top)/rows;
1886 ScreenToClient16(hwnd,&point);
1888 if (point.x % dx < (dx-DISTANCE) && point.y % dy < (dy-DISTANCE))
1892 *cr=crarr[x+cols*y];
1893 /* FIXME: Draw_a_Focus_Rect() */
1903 /* 240 ^...... ^^ 240
1910 /***********************************************************************
1911 * CC_MouseCheckColorGraph [internal]
1913 static int CC_MouseCheckColorGraph(HWND16 hDlg,int dlgitem,int *hori,int *vert,LPARAM lParam)
1916 POINT16 point = MAKEPOINT16(lParam);
1920 ClientToScreen16(hDlg,&point);
1921 hwnd=GetDlgItem32(hDlg,dlgitem);
1922 GetWindowRect16(hwnd,&rect);
1923 if (PtInRect16(&rect,point))
1925 GetClientRect16(hwnd,&rect);
1926 ScreenToClient16(hwnd,&point);
1928 x=(long)point.x*MAXHORI;
1930 y=(long)(rect.bottom-point.y)*MAXVERT;
1942 /***********************************************************************
1943 * CC_MouseCheckResultWindow [internal]
1945 static int CC_MouseCheckResultWindow(HWND16 hDlg,LPARAM lParam)
1948 POINT16 point = MAKEPOINT16(lParam);
1951 ClientToScreen16(hDlg,&point);
1952 hwnd=GetDlgItem32(hDlg,0x2c5);
1953 GetWindowRect16(hwnd,&rect);
1954 if (PtInRect16(&rect,point))
1956 PostMessage16(hDlg,WM_COMMAND,0x2c9,0);
1962 /***********************************************************************
1963 * CC_CheckDigitsInEdit [internal]
1965 static int CC_CheckDigitsInEdit(HWND16 hwnd,int maxval)
1967 int i,k,m,result,value;
1970 GetWindowText32A(hwnd,buffer,sizeof(buffer));
1975 if (buffer[i]<'0' || buffer[i]>'9')
1977 for (k=i+1;k<=m;k++) /* delete bad character */
1979 buffer[i]=buffer[k];
1987 if (value>maxval) /* build a new string */
1989 sprintf(buffer,"%d",maxval);
1994 editpos=SendMessage16(hwnd,EM_GETSEL16,0,0);
1995 SetWindowText32A(hwnd,buffer);
1996 SendMessage16(hwnd,EM_SETSEL16,0,editpos);
2003 /***********************************************************************
2004 * CC_PaintSelectedColor [internal]
2006 static void CC_PaintSelectedColor(HWND16 hDlg,COLORREF cr)
2011 HWND32 hwnd=GetDlgItem32(hDlg,0x2c5);
2012 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
2015 GetClientRect16 (hwnd, &rect) ;
2016 hBrush = CreateSolidBrush32(cr);
2019 hBrush = SelectObject32 (hdc, hBrush) ;
2020 Rectangle32(hdc, rect.left,rect.top,rect.right/2,rect.bottom);
2021 DeleteObject32 (SelectObject32 (hdc,hBrush)) ;
2022 hBrush=CreateSolidBrush32(GetNearestColor32(hdc,cr));
2025 hBrush= SelectObject32 (hdc, hBrush) ;
2026 Rectangle32( hdc, rect.right/2-1,rect.top,rect.right,rect.bottom);
2027 DeleteObject32( SelectObject32 (hdc, hBrush)) ;
2030 ReleaseDC32(hwnd,hdc);
2034 /***********************************************************************
2035 * CC_PaintTriangle [internal]
2037 static void CC_PaintTriangle(HWND16 hDlg,int y)
2041 int w=GetDialogBaseUnits();
2046 HWND16 hwnd=GetDlgItem32(hDlg,0x2be);
2047 struct CCPRIVATE *lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2049 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
2051 GetClientRect16(hwnd,&rect);
2055 points[0].y=rect.top;
2056 points[0].x=rect.right; /* | /| */
2057 ClientToScreen16(hwnd,points); /* | / | */
2058 ScreenToClient16(hDlg,points); /* |< | */
2059 oben=points[0].y; /* | \ | */
2061 temp=(long)height*(long)y;
2062 points[0].y=oben+height -temp/(long)MAXVERT;
2063 points[1].y=points[0].y+w;
2064 points[2].y=points[0].y-w;
2065 points[2].x=points[1].x=points[0].x + w;
2067 if (lpp->old3angle.left)
2068 FillRect16(hDC,&lpp->old3angle,GetStockObject32(WHITE_BRUSH));
2069 lpp->old3angle.left =points[0].x;
2070 lpp->old3angle.right =points[1].x+1;
2071 lpp->old3angle.top =points[2].y-1;
2072 lpp->old3angle.bottom=points[1].y+1;
2073 Polygon16(hDC,points,3);
2074 ReleaseDC32(hDlg,hDC);
2079 /***********************************************************************
2080 * CC_PaintCross [internal]
2082 static void CC_PaintCross(HWND16 hDlg,int x,int y)
2085 int w=GetDialogBaseUnits();
2086 HWND16 hwnd=GetDlgItem32(hDlg,0x2c6);
2087 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2092 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
2094 GetClientRect16(hwnd,&rect);
2096 SelectClipRgn32(hDC,CreateRectRgnIndirect16(&rect));
2097 hPen=CreatePen32(PS_SOLID,2,0);
2098 hPen=SelectObject32(hDC,hPen);
2099 point.x=((long)rect.right*(long)x)/(long)MAXHORI;
2100 point.y=rect.bottom-((long)rect.bottom*(long)y)/(long)MAXVERT;
2101 if (lpp->oldcross.left!=lpp->oldcross.right)
2102 BitBlt32(hDC,lpp->oldcross.left,lpp->oldcross.top,
2103 lpp->oldcross.right-lpp->oldcross.left,
2104 lpp->oldcross.bottom-lpp->oldcross.top,
2105 lpp->hdcMem,lpp->oldcross.left,lpp->oldcross.top,SRCCOPY);
2106 lpp->oldcross.left =point.x-w-1;
2107 lpp->oldcross.right =point.x+w+1;
2108 lpp->oldcross.top =point.y-w-1;
2109 lpp->oldcross.bottom=point.y+w+1;
2111 MoveTo(hDC,point.x-w,point.y);
2112 LineTo32(hDC,point.x+w,point.y);
2113 MoveTo(hDC,point.x,point.y-w);
2114 LineTo32(hDC,point.x,point.y+w);
2115 DeleteObject32(SelectObject32(hDC,hPen));
2116 ReleaseDC32(hwnd,hDC);
2125 /***********************************************************************
2126 * CC_PrepareColorGraph [internal]
2128 static void CC_PrepareColorGraph(HWND16 hDlg)
2130 int sdif,hdif,xdif,ydif,r,g,b,hue,sat;
2131 HWND32 hwnd=GetDlgItem32(hDlg,0x2c6);
2132 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2136 HCURSOR16 hcursor=SetCursor16(LoadCursor16(0,IDC_WAIT16));
2138 GetClientRect16(hwnd,&client);
2140 lpp->hdcMem = CreateCompatibleDC32(hdc);
2141 lpp->hbmMem = CreateCompatibleBitmap32(hdc,client.right,client.bottom);
2142 SelectObject32(lpp->hdcMem,lpp->hbmMem);
2144 xdif=client.right /XSTEPS;
2145 ydif=client.bottom/YSTEPS+1;
2148 for(rect.left=hue=0;hue<239+hdif;hue+=hdif)
2150 rect.right=rect.left+xdif;
2151 rect.bottom=client.bottom;
2152 for(sat=0;sat<240+sdif;sat+=sdif)
2154 rect.top=rect.bottom-ydif;
2155 r=CC_HSLtoRGB('R',hue,sat,120);
2156 g=CC_HSLtoRGB('G',hue,sat,120);
2157 b=CC_HSLtoRGB('B',hue,sat,120);
2158 hbrush=CreateSolidBrush32(RGB(r,g,b));
2159 FillRect16(lpp->hdcMem,&rect,hbrush);
2160 DeleteObject32(hbrush);
2161 rect.bottom=rect.top;
2163 rect.left=rect.right;
2165 ReleaseDC32(hwnd,hdc);
2166 SetCursor16(hcursor);
2169 /***********************************************************************
2170 * CC_PaintColorGraph [internal]
2172 static void CC_PaintColorGraph(HWND16 hDlg)
2174 HWND32 hwnd=GetDlgItem32(hDlg,0x2c6);
2175 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2178 if (IsWindowVisible32(hwnd)) /* if full size */
2181 CC_PrepareColorGraph(hDlg); /* should not be necessary */
2184 GetClientRect16(hwnd,&rect);
2186 BitBlt32(hDC,0,0,rect.right,rect.bottom,lpp->hdcMem,0,0,SRCCOPY);
2188 WARN(commdlg,"choose color: hdcMem is not defined\n");
2189 ReleaseDC32(hwnd,hDC);
2192 /***********************************************************************
2193 * CC_PaintLumBar [internal]
2195 static void CC_PaintLumBar(HWND16 hDlg,int hue,int sat)
2197 HWND32 hwnd=GetDlgItem32(hDlg,0x2be);
2199 int lum,ldif,ydif,r,g,b;
2203 if (IsWindowVisible32(hwnd))
2206 GetClientRect16(hwnd,&client);
2210 ydif=client.bottom/YSTEPS+1;
2211 for(lum=0;lum<240+ldif;lum+=ldif)
2213 rect.top=MAX(0,rect.bottom-ydif);
2214 r=CC_HSLtoRGB('R',hue,sat,lum);
2215 g=CC_HSLtoRGB('G',hue,sat,lum);
2216 b=CC_HSLtoRGB('B',hue,sat,lum);
2217 hbrush=CreateSolidBrush32(RGB(r,g,b));
2218 FillRect16(hDC,&rect,hbrush);
2219 DeleteObject32(hbrush);
2220 rect.bottom=rect.top;
2222 GetClientRect16(hwnd,&rect);
2223 FrameRect16(hDC,&rect,GetStockObject32(BLACK_BRUSH));
2224 ReleaseDC32(hwnd,hDC);
2228 /***********************************************************************
2229 * CC_EditSetRGB [internal]
2231 static void CC_EditSetRGB(HWND16 hDlg,COLORREF cr)
2234 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2235 int r=GetRValue(cr);
2236 int g=GetGValue(cr);
2237 int b=GetBValue(cr);
2238 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
2241 sprintf(buffer,"%d",r);
2242 SetWindowText32A(GetDlgItem32(hDlg,0x2c2),buffer);
2243 sprintf(buffer,"%d",g);
2244 SetWindowText32A(GetDlgItem32(hDlg,0x2c3),buffer);
2245 sprintf(buffer,"%d",b);
2246 SetWindowText32A(GetDlgItem32(hDlg,0x2c4),buffer);
2247 lpp->updating=FALSE;
2251 /***********************************************************************
2252 * CC_EditSetHSL [internal]
2254 static void CC_EditSetHSL(HWND16 hDlg,int h,int s,int l)
2257 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2259 if (IsWindowVisible32(GetDlgItem32(hDlg,0x2c6))) /* if full size */
2262 sprintf(buffer,"%d",h);
2263 SetWindowText32A(GetDlgItem32(hDlg,0x2bf),buffer);
2264 sprintf(buffer,"%d",s);
2265 SetWindowText32A(GetDlgItem32(hDlg,0x2c0),buffer);
2266 sprintf(buffer,"%d",l);
2267 SetWindowText32A(GetDlgItem32(hDlg,0x2c1),buffer);
2268 lpp->updating=FALSE;
2270 CC_PaintLumBar(hDlg,h,s);
2273 /***********************************************************************
2274 * CC_SwitchToFullSize [internal]
2276 static void CC_SwitchToFullSize(HWND16 hDlg,COLORREF result,LPRECT16 lprect)
2279 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2281 EnableWindow32(GetDlgItem32(hDlg,0x2cf),FALSE);
2282 CC_PrepareColorGraph(hDlg);
2283 for (i=0x2bf;i<0x2c5;i++)
2284 EnableWindow32(GetDlgItem32(hDlg,i),TRUE);
2285 for (i=0x2d3;i<0x2d9;i++)
2286 EnableWindow32(GetDlgItem32(hDlg,i),TRUE);
2287 EnableWindow32(GetDlgItem32(hDlg,0x2c9),TRUE);
2288 EnableWindow32(GetDlgItem32(hDlg,0x2c8),TRUE);
2291 SetWindowPos32(hDlg,0,0,0,lprect->right-lprect->left,
2292 lprect->bottom-lprect->top, SWP_NOMOVE|SWP_NOZORDER);
2294 ShowWindow32(GetDlgItem32(hDlg,0x2c6),SW_SHOW);
2295 ShowWindow32(GetDlgItem32(hDlg,0x2be),SW_SHOW);
2296 ShowWindow32(GetDlgItem32(hDlg,0x2c5),SW_SHOW);
2298 CC_EditSetRGB(hDlg,result);
2299 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
2302 /***********************************************************************
2303 * CC_PaintPredefColorArray [internal]
2305 static void CC_PaintPredefColorArray(HWND16 hDlg,int rows,int cols)
2307 HWND32 hwnd=GetDlgItem32(hDlg,0x2d0);
2313 GetClientRect16(hwnd,&rect);
2315 dy=rect.bottom/rows;
2319 GetClientRect16 (hwnd, &rect) ;
2321 for (j=0;j<rows;j++)
2323 for (i=0;i<cols;i++)
2325 hBrush = CreateSolidBrush32(predefcolors[j][i]);
2328 hBrush = SelectObject32 (hdc, hBrush) ;
2329 Rectangle32(hdc, rect.left, rect.top,
2330 rect.left+dx-DISTANCE, rect.top+dy-DISTANCE);
2331 rect.left=rect.left+dx;
2332 DeleteObject32( SelectObject32 (hdc, hBrush)) ;
2335 rect.top=rect.top+dy;
2338 ReleaseDC32(hwnd,hdc);
2339 /* FIXME: draw_a_focus_rect */
2341 /***********************************************************************
2342 * CC_PaintUserColorArray [internal]
2344 static void CC_PaintUserColorArray(HWND16 hDlg,int rows,int cols,COLORREF* lpcr)
2346 HWND32 hwnd=GetDlgItem32(hDlg,0x2d1);
2352 GetClientRect16(hwnd,&rect);
2355 dy=rect.bottom/rows;
2361 for (j=0;j<rows;j++)
2363 for (i=0;i<cols;i++)
2365 hBrush = CreateSolidBrush32(lpcr[i+j*cols]);
2368 hBrush = SelectObject32 (hdc, hBrush) ;
2369 Rectangle32( hdc, rect.left, rect.top,
2370 rect.left+dx-DISTANCE, rect.top+dy-DISTANCE);
2371 rect.left=rect.left+dx;
2372 DeleteObject32( SelectObject32 (hdc, hBrush)) ;
2375 rect.top=rect.top+dy;
2378 ReleaseDC32(hwnd,hdc);
2380 /* FIXME: draw_a_focus_rect */
2385 /***********************************************************************
2386 * CC_HookCallChk [internal]
2388 static BOOL32 CC_HookCallChk(LPCHOOSECOLOR16 lpcc)
2391 if(lpcc->Flags & CC_ENABLEHOOK)
2397 /***********************************************************************
2398 * CC_WMInitDialog [internal]
2400 static LONG CC_WMInitDialog(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2406 struct CCPRIVATE * lpp;
2408 TRACE(commdlg,"WM_INITDIALOG lParam=%08lX\n", lParam);
2409 lpp=calloc(1,sizeof(struct CCPRIVATE));
2410 lpp->lpcc=(LPCHOOSECOLOR16)lParam;
2411 if (lpp->lpcc->lStructSize != sizeof(CHOOSECOLOR16))
2413 EndDialog32 (hDlg, 0) ;
2416 SetWindowLong32A(hDlg, DWL_USER, (LONG)lpp);
2418 if (!(lpp->lpcc->Flags & CC_SHOWHELP))
2419 ShowWindow32(GetDlgItem32(hDlg,0x40e),SW_HIDE);
2420 lpp->msetrgb=RegisterWindowMessage32A( SETRGBSTRING );
2422 cpos=MAKELONG(5,7); /* init */
2423 if (lpp->lpcc->Flags & CC_RGBINIT)
2427 if (predefcolors[i][j]==lpp->lpcc->rgbResult)
2434 /* FIXME: Draw_a_focus_rect & set_init_values */
2436 GetWindowRect16(hDlg,&lpp->fullsize);
2437 if (lpp->lpcc->Flags & CC_FULLOPEN || lpp->lpcc->Flags & CC_PREVENTFULLOPEN)
2439 hwnd=GetDlgItem32(hDlg,0x2cf);
2440 EnableWindow32(hwnd,FALSE);
2442 if (!(lpp->lpcc->Flags & CC_FULLOPEN) || lpp->lpcc->Flags & CC_PREVENTFULLOPEN)
2445 res=rect.bottom-rect.top;
2446 hwnd=GetDlgItem32(hDlg,0x2c6); /* cut at left border */
2448 ClientToScreen16(hwnd,&point);
2449 ScreenToClient16(hDlg,&point);
2450 GetClientRect16(hDlg,&rect);
2451 point.x+=GetSystemMetrics32(SM_CXDLGFRAME);
2452 SetWindowPos32(hDlg,0,0,0,point.x,res,SWP_NOMOVE|SWP_NOZORDER);
2454 ShowWindow32(GetDlgItem32(hDlg,0x2c6),SW_HIDE);
2455 ShowWindow32(GetDlgItem32(hDlg,0x2c5),SW_HIDE);
2458 CC_SwitchToFullSize(hDlg,lpp->lpcc->rgbResult,NULL);
2460 for (i=0x2bf;i<0x2c5;i++)
2461 SendMessage16(GetDlgItem32(hDlg,i),EM_LIMITTEXT16,3,0); /* max 3 digits: xyz */
2462 if (CC_HookCallChk(lpp->lpcc))
2463 res=CallWindowProc16(lpp->lpcc->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
2467 /***********************************************************************
2468 * CC_WMCommand [internal]
2470 static LRESULT CC_WMCommand(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2476 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2477 TRACE(commdlg,"CC_WMCommand wParam=%x lParam=%lx\n",wParam,lParam);
2480 case 0x2c2: /* edit notify RGB */
2483 if (HIWORD(lParam)==EN_UPDATE && !lpp->updating)
2485 i=CC_CheckDigitsInEdit(LOWORD(lParam),255);
2486 r=GetRValue(lpp->lpcc->rgbResult);
2487 g=GetGValue(lpp->lpcc->rgbResult);
2488 b=GetBValue(lpp->lpcc->rgbResult);
2492 case 0x2c2:if ((xx=(i!=r))) r=i;break;
2493 case 0x2c3:if ((xx=(i!=g))) g=i;break;
2494 case 0x2c4:if ((xx=(i!=b))) b=i;break;
2496 if (xx) /* something has changed */
2498 lpp->lpcc->rgbResult=RGB(r,g,b);
2499 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2500 lpp->h=CC_RGBtoHSL('H',r,g,b);
2501 lpp->s=CC_RGBtoHSL('S',r,g,b);
2502 lpp->l=CC_RGBtoHSL('L',r,g,b);
2503 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
2504 CC_PaintCross(hDlg,lpp->h,lpp->s);
2505 CC_PaintTriangle(hDlg,lpp->l);
2510 case 0x2bf: /* edit notify HSL */
2513 if (HIWORD(lParam)==EN_UPDATE && !lpp->updating)
2515 i=CC_CheckDigitsInEdit(LOWORD(lParam),wParam==0x2bf?239:240);
2519 case 0x2bf:if ((xx=(i!=lpp->h))) lpp->h=i;break;
2520 case 0x2c0:if ((xx=(i!=lpp->s))) lpp->s=i;break;
2521 case 0x2c1:if ((xx=(i!=lpp->l))) lpp->l=i;break;
2523 if (xx) /* something has changed */
2525 r=CC_HSLtoRGB('R',lpp->h,lpp->s,lpp->l);
2526 g=CC_HSLtoRGB('G',lpp->h,lpp->s,lpp->l);
2527 b=CC_HSLtoRGB('B',lpp->h,lpp->s,lpp->l);
2528 lpp->lpcc->rgbResult=RGB(r,g,b);
2529 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2530 CC_EditSetRGB(hDlg,lpp->lpcc->rgbResult);
2531 CC_PaintCross(hDlg,lpp->h,lpp->s);
2532 CC_PaintTriangle(hDlg,lpp->l);
2538 CC_SwitchToFullSize(hDlg,lpp->lpcc->rgbResult,&lpp->fullsize);
2539 InvalidateRect32( hDlg, NULL, TRUE );
2540 SetFocus32(GetDlgItem32(hDlg,0x2bf));
2543 case 0x2c8: /* add colors ... column by column */
2544 cr=PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors);
2545 cr[(lpp->nextuserdef%2)*8 + lpp->nextuserdef/2]=lpp->lpcc->rgbResult;
2546 if (++lpp->nextuserdef==16)
2548 CC_PaintUserColorArray(hDlg,2,8,PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors));
2551 case 0x2c9: /* resulting color */
2553 lpp->lpcc->rgbResult=GetNearestColor32(hdc,lpp->lpcc->rgbResult);
2554 ReleaseDC32(hDlg,hdc);
2555 CC_EditSetRGB(hDlg,lpp->lpcc->rgbResult);
2556 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2557 r=GetRValue(lpp->lpcc->rgbResult);
2558 g=GetGValue(lpp->lpcc->rgbResult);
2559 b=GetBValue(lpp->lpcc->rgbResult);
2560 lpp->h=CC_RGBtoHSL('H',r,g,b);
2561 lpp->s=CC_RGBtoHSL('S',r,g,b);
2562 lpp->l=CC_RGBtoHSL('L',r,g,b);
2563 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
2564 CC_PaintCross(hDlg,lpp->h,lpp->s);
2565 CC_PaintTriangle(hDlg,lpp->l);
2568 case 0x40e: /* Help! */ /* The Beatles, 1965 ;-) */
2569 i=RegisterWindowMessage32A( HELPMSGSTRING );
2570 if (lpp->lpcc->hwndOwner)
2571 SendMessage16(lpp->lpcc->hwndOwner,i,0,(LPARAM)lpp->lpcc);
2572 if (CC_HookCallChk(lpp->lpcc))
2573 CallWindowProc16(lpp->lpcc->lpfnHook,hDlg,
2574 WM_COMMAND,psh15,(LPARAM)lpp->lpcc);
2578 cokmsg=RegisterWindowMessage32A( COLOROKSTRING );
2579 if (lpp->lpcc->hwndOwner)
2580 if (SendMessage16(lpp->lpcc->hwndOwner,cokmsg,0,(LPARAM)lpp->lpcc))
2581 break; /* do NOT close */
2583 EndDialog32 (hDlg, 1) ;
2587 EndDialog32 (hDlg, 0) ;
2594 /***********************************************************************
2595 * CC_WMPaint [internal]
2597 static LRESULT CC_WMPaint(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2599 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2600 /* we have to paint dialog children except text and buttons */
2602 CC_PaintPredefColorArray(hDlg,6,8);
2603 CC_PaintUserColorArray(hDlg,2,8,PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors));
2604 CC_PaintColorGraph(hDlg);
2605 CC_PaintLumBar(hDlg,lpp->h,lpp->s);
2606 CC_PaintCross(hDlg,lpp->h,lpp->s);
2607 CC_PaintTriangle(hDlg,lpp->l);
2608 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2610 /* special necessary for Wine */
2611 ValidateRect32(GetDlgItem32(hDlg,0x2d0),NULL);
2612 ValidateRect32(GetDlgItem32(hDlg,0x2d1),NULL);
2613 ValidateRect32(GetDlgItem32(hDlg,0x2c6),NULL);
2614 ValidateRect32(GetDlgItem32(hDlg,0x2be),NULL);
2615 ValidateRect32(GetDlgItem32(hDlg,0x2c5),NULL);
2616 /* hope we can remove it later -->FIXME */
2621 /***********************************************************************
2622 * CC_WMLButtonDown [internal]
2624 static LRESULT CC_WMLButtonDown(HWND16 hDlg, WPARAM16 wParam, LPARAM lParam)
2626 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2629 if (CC_MouseCheckPredefColorArray(hDlg,0x2d0,6,8,lParam,&lpp->lpcc->rgbResult))
2632 if (CC_MouseCheckUserColorArray(hDlg,0x2d1,2,8,lParam,&lpp->lpcc->rgbResult,
2633 PTR_SEG_TO_LIN(lpp->lpcc->lpCustColors)))
2636 if (CC_MouseCheckColorGraph(hDlg,0x2c6,&lpp->h,&lpp->s,lParam))
2639 if (CC_MouseCheckColorGraph(hDlg,0x2be,NULL,&lpp->l,lParam))
2643 r=CC_HSLtoRGB('R',lpp->h,lpp->s,lpp->l);
2644 g=CC_HSLtoRGB('G',lpp->h,lpp->s,lpp->l);
2645 b=CC_HSLtoRGB('B',lpp->h,lpp->s,lpp->l);
2646 lpp->lpcc->rgbResult=RGB(r,g,b);
2650 r=GetRValue(lpp->lpcc->rgbResult);
2651 g=GetGValue(lpp->lpcc->rgbResult);
2652 b=GetBValue(lpp->lpcc->rgbResult);
2653 lpp->h=CC_RGBtoHSL('H',r,g,b);
2654 lpp->s=CC_RGBtoHSL('S',r,g,b);
2655 lpp->l=CC_RGBtoHSL('L',r,g,b);
2659 CC_EditSetRGB(hDlg,lpp->lpcc->rgbResult);
2660 CC_EditSetHSL(hDlg,lpp->h,lpp->s,lpp->l);
2661 CC_PaintCross(hDlg,lpp->h,lpp->s);
2662 CC_PaintTriangle(hDlg,lpp->l);
2663 CC_PaintSelectedColor(hDlg,lpp->lpcc->rgbResult);
2669 /***********************************************************************
2670 * ColorDlgProc (COMMDLG.8)
2672 LRESULT WINAPI ColorDlgProc(HWND16 hDlg, UINT16 message,
2673 WPARAM16 wParam, LONG lParam)
2676 struct CCPRIVATE * lpp=(struct CCPRIVATE *)GetWindowLong32A(hDlg, DWL_USER);
2677 if (message!=WM_INITDIALOG)
2682 if (CC_HookCallChk(lpp->lpcc))
2683 res=CallWindowProc16(lpp->lpcc->lpfnHook,hDlg,message,wParam,lParam);
2688 /* FIXME: SetRGB message
2689 if (message && message==msetrgb)
2690 return HandleSetRGB(hDlg,lParam);
2696 return CC_WMInitDialog(hDlg,wParam,lParam);
2698 DeleteDC32(lpp->hdcMem);
2699 DeleteObject32(lpp->hbmMem);
2701 SetWindowLong32A(hDlg, DWL_USER, 0L); /* we don't need it anymore */
2704 if (CC_WMCommand(hDlg, wParam, lParam))
2708 CC_WMPaint(hDlg, wParam, lParam);
2710 case WM_LBUTTONDBLCLK:
2711 if (CC_MouseCheckResultWindow(hDlg,lParam))
2714 case WM_MOUSEMOVE: /* FIXME: calculate new hue,sat,lum (if in color graph) */
2716 case WM_LBUTTONUP: /* FIXME: ClipCursor off (if in color graph)*/
2718 case WM_LBUTTONDOWN:/* FIXME: ClipCursor on (if in color graph)*/
2719 if (CC_WMLButtonDown(hDlg, wParam, lParam))
2726 static void CFn_CHOOSEFONT16to32A(LPCHOOSEFONT16 chf16, LPCHOOSEFONT32A chf32a)
2728 chf32a->lStructSize=sizeof(CHOOSEFONT32A);
2729 chf32a->hwndOwner=chf16->hwndOwner;
2730 chf32a->hDC=chf16->hDC;
2731 chf32a->iPointSize=chf16->iPointSize;
2732 chf32a->Flags=chf16->Flags;
2733 chf32a->rgbColors=chf16->rgbColors;
2734 chf32a->lCustData=chf16->lCustData;
2735 chf32a->lpfnHook=NULL;
2736 chf32a->lpTemplateName=PTR_SEG_TO_LIN(chf16->lpTemplateName);
2737 chf32a->hInstance=chf16->hInstance;
2738 chf32a->lpszStyle=PTR_SEG_TO_LIN(chf16->lpszStyle);
2739 chf32a->nFontType=chf16->nFontType;
2740 chf32a->nSizeMax=chf16->nSizeMax;
2741 chf32a->nSizeMin=chf16->nSizeMin;
2742 FONT_LogFont16To32A(PTR_SEG_TO_LIN(chf16->lpLogFont), chf32a->lpLogFont);
2746 /***********************************************************************
2747 * ChooseFont16 (COMMDLG.15)
2749 BOOL16 WINAPI ChooseFont16(LPCHOOSEFONT16 lpChFont)
2752 HANDLE16 hDlgTmpl = 0;
2753 BOOL16 bRet = FALSE, win32Format = FALSE;
2756 CHOOSEFONT32A cf32a;
2758 SEGPTR lpTemplateName;
2760 cf32a.lpLogFont=&lf32a;
2761 CFn_CHOOSEFONT16to32A(lpChFont, &cf32a);
2763 TRACE(commdlg,"ChooseFont\n");
2764 if (!lpChFont) return FALSE;
2766 if (lpChFont->Flags & CF_ENABLETEMPLATEHANDLE)
2768 if (!(template = LockResource16( lpChFont->hInstance )))
2770 CommDlgLastError = CDERR_LOADRESFAILURE;
2774 else if (lpChFont->Flags & CF_ENABLETEMPLATE)
2777 if (!(hResInfo = FindResource16( lpChFont->hInstance,
2778 lpChFont->lpTemplateName,
2781 CommDlgLastError = CDERR_FINDRESFAILURE;
2784 if (!(hDlgTmpl = LoadResource16( lpChFont->hInstance, hResInfo )) ||
2785 !(template = LockResource16( hDlgTmpl )))
2787 CommDlgLastError = CDERR_LOADRESFAILURE;
2793 template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT );
2797 hInst = WIN_GetWindowInstance( lpChFont->hwndOwner );
2799 /* lpTemplateName is not used in the dialog */
2800 lpTemplateName=lpChFont->lpTemplateName;
2801 lpChFont->lpTemplateName=(SEGPTR)&cf32a;
2803 hwndDialog = DIALOG_CreateIndirect( hInst, template, win32Format,
2804 lpChFont->hwndOwner,
2805 (DLGPROC16)MODULE_GetWndProcEntry16("FormatCharDlgProc"),
2806 (DWORD)lpChFont, WIN_PROC_16 );
2807 if (hwndDialog) bRet = DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner);
2808 if (hDlgTmpl) FreeResource16( hDlgTmpl );
2809 lpChFont->lpTemplateName=lpTemplateName;
2810 FONT_LogFont32ATo16(cf32a.lpLogFont,
2811 (LPLOGFONT16)(PTR_SEG_TO_LIN(lpChFont->lpLogFont)));
2816 /***********************************************************************
2817 * ChooseFont32A (COMDLG32.3)
2819 BOOL32 WINAPI ChooseFont32A(LPCHOOSEFONT32A lpChFont)
2823 HINSTANCE32 hInst=WIN_GetWindowInstance( lpChFont->hwndOwner );
2824 LPCVOID template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT );
2825 if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS | CF_ENABLETEMPLATE |
2826 CF_ENABLETEMPLATEHANDLE)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
2827 hwndDialog = DIALOG_CreateIndirect(hInst, template, TRUE, lpChFont->hwndOwner,
2828 (DLGPROC16)FormatCharDlgProc32A, (LPARAM)lpChFont, WIN_PROC_32A );
2829 if (hwndDialog) bRet = DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner);
2833 /***********************************************************************
2834 * ChooseFont32W (COMDLG32.4)
2836 BOOL32 WINAPI ChooseFont32W(LPCHOOSEFONT32W lpChFont)
2840 HINSTANCE32 hInst=WIN_GetWindowInstance( lpChFont->hwndOwner );
2841 CHOOSEFONT32A cf32a;
2843 LPCVOID template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT );
2844 if (lpChFont->Flags & (CF_SELECTSCRIPT | CF_NOVERTFONTS | CF_ENABLETEMPLATE |
2845 CF_ENABLETEMPLATEHANDLE)) FIXME(commdlg, ": unimplemented flag (ignored)\n");
2846 memcpy(&cf32a, lpChFont, sizeof(cf32a));
2847 memcpy(&lf32a, lpChFont->lpLogFont, sizeof(LOGFONT32A));
2848 lstrcpynWtoA(lf32a.lfFaceName, lpChFont->lpLogFont->lfFaceName, LF_FACESIZE);
2849 cf32a.lpLogFont=&lf32a;
2850 cf32a.lpszStyle=HEAP_strdupWtoA(GetProcessHeap(), 0, lpChFont->lpszStyle);
2851 lpChFont->lpTemplateName=(LPWSTR)&cf32a;
2852 hwndDialog=DIALOG_CreateIndirect(hInst, template, TRUE, lpChFont->hwndOwner,
2853 (DLGPROC16)FormatCharDlgProc32W, (LPARAM)lpChFont, WIN_PROC_32W );
2854 if (hwndDialog)bRet=DIALOG_DoDialogBox(hwndDialog, lpChFont->hwndOwner);
2855 HeapFree(GetProcessHeap(), 0, cf32a.lpszStyle);
2856 lpChFont->lpTemplateName=(LPWSTR)cf32a.lpTemplateName;
2857 memcpy(lpChFont->lpLogFont, &lf32a, sizeof(CHOOSEFONT32A));
2858 lstrcpynAtoW(lpChFont->lpLogFont->lfFaceName, lf32a.lfFaceName, LF_FACESIZE);
2863 #define TEXT_EXTRAS 4
2864 #define TEXT_COLORS 16
2866 static const COLORREF textcolors[TEXT_COLORS]=
2868 0x00000000L,0x00000080L,0x00008000L,0x00008080L,
2869 0x00800000L,0x00800080L,0x00808000L,0x00808080L,
2870 0x00c0c0c0L,0x000000ffL,0x0000ff00L,0x0000ffffL,
2871 0x00ff0000L,0x00ff00ffL,0x00ffff00L,0x00FFFFFFL
2874 /***********************************************************************
2875 * CFn_HookCallChk [internal]
2877 static BOOL32 CFn_HookCallChk(LPCHOOSEFONT16 lpcf)
2880 if(lpcf->Flags & CF_ENABLEHOOK)
2886 /***********************************************************************
2887 * CFn_HookCallChk32 [internal]
2889 static BOOL32 CFn_HookCallChk32(LPCHOOSEFONT32A lpcf)
2892 if(lpcf->Flags & CF_ENABLEHOOK)
2899 /*************************************************************************
2900 * AddFontFamily [internal]
2902 static INT32 AddFontFamily(LPLOGFONT32A lplf, UINT32 nFontType,
2903 LPCHOOSEFONT32A lpcf, HWND32 hwnd)
2908 TRACE(commdlg,"font=%s (nFontType=%d)\n", lplf->lfFaceName,nFontType);
2910 if (lpcf->Flags & CF_FIXEDPITCHONLY)
2911 if (!(lplf->lfPitchAndFamily & FIXED_PITCH))
2913 if (lpcf->Flags & CF_ANSIONLY)
2914 if (lplf->lfCharSet != ANSI_CHARSET)
2916 if (lpcf->Flags & CF_TTONLY)
2917 if (!(nFontType & TRUETYPE_FONTTYPE))
2920 i=SendMessage32A(hwnd, CB_ADDSTRING32, 0, (LPARAM)lplf->lfFaceName);
2923 w=(lplf->lfCharSet << 8) | lplf->lfPitchAndFamily;
2924 SendMessage32A(hwnd, CB_SETITEMDATA32, i, MAKELONG(nFontType,w));
2925 return 1 ; /* store some important font information */
2935 LPCHOOSEFONT32A lpcf32a;
2936 } CFn_ENUMSTRUCT, *LPCFn_ENUMSTRUCT;
2938 /*************************************************************************
2939 * FontFamilyEnumProc32 [internal]
2941 INT32 WINAPI FontFamilyEnumProc32(LPENUMLOGFONT32A lpEnumLogFont,
2942 LPNEWTEXTMETRIC32A metrics, UINT32 nFontType, LPARAM lParam)
2945 e=(LPCFn_ENUMSTRUCT)lParam;
2946 return AddFontFamily(&lpEnumLogFont->elfLogFont, nFontType, e->lpcf32a, e->hWnd1);
2949 /***********************************************************************
2950 * FontFamilyEnumProc16 (COMMDLG.19)
2952 INT16 WINAPI FontFamilyEnumProc16( SEGPTR logfont, SEGPTR metrics,
2953 UINT16 nFontType, LPARAM lParam )
2955 HWND16 hwnd=LOWORD(lParam);
2956 HWND16 hDlg=GetParent16(hwnd);
2957 LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLong32A(hDlg, DWL_USER);
2958 LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN( logfont );
2960 FONT_LogFont16To32A(lplf, &lf32a);
2961 return AddFontFamily(&lf32a, nFontType, (LPCHOOSEFONT32A)lpcf->lpTemplateName,
2965 /*************************************************************************
2966 * SetFontStylesToCombo2 [internal]
2968 * Fill font style information into combobox (without using font.c directly)
2970 static int SetFontStylesToCombo2(HWND32 hwnd, HDC32 hdc, LPLOGFONT32A lplf)
2977 static struct FONTSTYLE fontstyles[FSTYLES]={
2978 { 0,FW_NORMAL,"Regular"},{0,FW_BOLD,"Bold"},
2979 { 1,FW_NORMAL,"Italic"}, {1,FW_BOLD,"Bold Italic"}};
2984 for (i=0;i<FSTYLES;i++)
2986 lplf->lfItalic=fontstyles[i].italic;
2987 lplf->lfWeight=fontstyles[i].weight;
2988 hf=CreateFontIndirect32A(lplf);
2989 hf=SelectObject32(hdc,hf);
2990 GetTextMetrics16(hdc,&tm);
2991 hf=SelectObject32(hdc,hf);
2994 if (tm.tmWeight==fontstyles[i].weight &&
2995 tm.tmItalic==fontstyles[i].italic) /* font successful created ? */
2997 char *str = SEGPTR_STRDUP(fontstyles[i].stname);
2998 j=SendMessage16(hwnd,CB_ADDSTRING16,0,(LPARAM)SEGPTR_GET(str) );
3000 if (j==CB_ERR) return 1;
3001 j=SendMessage16(hwnd, CB_SETITEMDATA16, j,
3002 MAKELONG(fontstyles[i].weight,fontstyles[i].italic));
3003 if (j==CB_ERR) return 1;
3009 /*************************************************************************
3010 * AddFontSizeToCombo3 [internal]
3012 static int AddFontSizeToCombo3(HWND32 hwnd, UINT32 h, LPCHOOSEFONT32A lpcf)
3017 if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
3018 ((lpcf->Flags & CF_LIMITSIZE) && (h >= lpcf->nSizeMin) && (h <= lpcf->nSizeMax)))
3020 sprintf(buffer, "%2d", h);
3021 j=SendMessage32A(hwnd, CB_FINDSTRINGEXACT32, -1, (LPARAM)buffer);
3024 j=SendMessage32A(hwnd, CB_ADDSTRING32, 0, (LPARAM)buffer);
3025 if (j!=CB_ERR) j = SendMessage32A(hwnd, CB_SETITEMDATA32, j, h);
3026 if (j==CB_ERR) return 1;
3032 /*************************************************************************
3033 * SetFontSizesToCombo3 [internal]
3035 static int SetFontSizesToCombo3(HWND32 hwnd, LPCHOOSEFONT32A lpcf)
3037 static const int sizes[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72,0};
3040 for (i=0; sizes[i]; i++)
3041 if (AddFontSizeToCombo3(hwnd, sizes[i], lpcf)) return 1;
3045 /***********************************************************************
3046 * AddFontStyle [internal]
3048 INT32 AddFontStyle(LPLOGFONT32A lplf, UINT32 nFontType,
3049 LPCHOOSEFONT32A lpcf, HWND32 hcmb2, HWND32 hcmb3, HWND32 hDlg)
3053 TRACE(commdlg,"(nFontType=%d)\n",nFontType);
3054 TRACE(commdlg," %s h=%d w=%d e=%d o=%d wg=%d i=%d u=%d s=%d"
3055 " ch=%d op=%d cp=%d q=%d pf=%xh\n",
3056 lplf->lfFaceName,lplf->lfHeight,lplf->lfWidth,
3057 lplf->lfEscapement,lplf->lfOrientation,
3058 lplf->lfWeight,lplf->lfItalic,lplf->lfUnderline,
3059 lplf->lfStrikeOut,lplf->lfCharSet, lplf->lfOutPrecision,
3060 lplf->lfClipPrecision,lplf->lfQuality, lplf->lfPitchAndFamily);
3061 if (nFontType & RASTER_FONTTYPE)
3063 if (AddFontSizeToCombo3(hcmb3, lplf->lfHeight, lpcf)) return 0;
3064 } else if (SetFontSizesToCombo3(hcmb3, lpcf)) return 0;
3066 if (!SendMessage32A(hcmb2, CB_GETCOUNT32, 0, 0))
3068 HDC32 hdc= (lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC32(hDlg);
3069 i=SetFontStylesToCombo2(hcmb2,hdc,lplf);
3070 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
3071 ReleaseDC32(hDlg,hdc);
3079 /***********************************************************************
3080 * FontStyleEnumProc16 (COMMDLG.18)
3082 INT16 WINAPI FontStyleEnumProc16( SEGPTR logfont, SEGPTR metrics,
3083 UINT16 nFontType, LPARAM lParam )
3085 HWND16 hcmb2=LOWORD(lParam);
3086 HWND16 hcmb3=HIWORD(lParam);
3087 HWND16 hDlg=GetParent16(hcmb3);
3088 LPCHOOSEFONT16 lpcf=(LPCHOOSEFONT16)GetWindowLong32A(hDlg, DWL_USER);
3089 LOGFONT16 *lplf = (LOGFONT16 *)PTR_SEG_TO_LIN(logfont);
3091 FONT_LogFont16To32A(lplf, &lf32a);
3092 return AddFontStyle(&lf32a, nFontType, (LPCHOOSEFONT32A)lpcf->lpTemplateName,
3093 hcmb2, hcmb3, hDlg);
3096 /***********************************************************************
3097 * FontStyleEnumProc32 [internal]
3099 INT32 WINAPI FontStyleEnumProc32( LPENUMLOGFONT32A lpFont,
3100 LPNEWTEXTMETRIC32A metrics, UINT32 nFontType, LPARAM lParam )
3102 LPCFn_ENUMSTRUCT s=(LPCFn_ENUMSTRUCT)lParam;
3103 HWND32 hcmb2=s->hWnd1;
3104 HWND32 hcmb3=s->hWnd2;
3105 HWND32 hDlg=GetParent32(hcmb3);
3106 return AddFontStyle(&lpFont->elfLogFont, nFontType, s->lpcf32a, hcmb2,
3110 /***********************************************************************
3111 * CFn_WMInitDialog [internal]
3113 LRESULT CFn_WMInitDialog(HWND32 hDlg, WPARAM32 wParam, LPARAM lParam,
3114 LPCHOOSEFONT32A lpcf)
3120 HCURSOR32 hcursor=SetCursor32(LoadCursor32A(0,IDC_WAIT32A));
3122 SetWindowLong32A(hDlg, DWL_USER, lParam);
3123 lpxx=lpcf->lpLogFont;
3124 TRACE(commdlg,"WM_INITDIALOG lParam=%08lX\n", lParam);
3126 if (lpcf->lStructSize != sizeof(CHOOSEFONT32A))
3128 ERR(commdlg,"structure size failure !!!\n");
3129 EndDialog32 (hDlg, 0);
3133 hBitmapTT = LoadBitmap32A(0, MAKEINTRESOURCE32A(OBM_TRTYPE));
3135 /* This font will be deleted by WM_COMMAND */
3136 SendDlgItemMessage32A(hDlg,stc6,WM_SETFONT,
3137 CreateFont32A(0, 0, 1, 1, 400, 0, 0, 0, 0, 0, 0, 0, 0, NULL),FALSE);
3139 if (!(lpcf->Flags & CF_SHOWHELP) || !IsWindow32(lpcf->hwndOwner))
3140 ShowWindow32(GetDlgItem32(hDlg,pshHelp),SW_HIDE);
3141 if (!(lpcf->Flags & CF_APPLY))
3142 ShowWindow32(GetDlgItem32(hDlg,psh3),SW_HIDE);
3143 if (lpcf->Flags & CF_EFFECTS)
3145 for (res=1,i=0;res && i<TEXT_COLORS;i++)
3147 /* FIXME: load color name from resource: res=LoadString(...,i+....,buffer,.....); */
3149 strcpy( name, "[color name]" );
3150 j=SendDlgItemMessage32A(hDlg, cmb4, CB_ADDSTRING32, 0, (LPARAM)name);
3151 SendDlgItemMessage32A(hDlg, cmb4, CB_SETITEMDATA16, j, textcolors[j]);
3152 /* look for a fitting value in color combobox */
3153 if (textcolors[j]==lpcf->rgbColors)
3154 SendDlgItemMessage32A(hDlg,cmb4, CB_SETCURSEL32,j,0);
3159 ShowWindow32(GetDlgItem32(hDlg,cmb4),SW_HIDE);
3160 ShowWindow32(GetDlgItem32(hDlg,chx1),SW_HIDE);
3161 ShowWindow32(GetDlgItem32(hDlg,chx2),SW_HIDE);
3162 ShowWindow32(GetDlgItem32(hDlg,grp1),SW_HIDE);
3163 ShowWindow32(GetDlgItem32(hDlg,stc4),SW_HIDE);
3165 hdc= (lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC32(hDlg);
3169 s.hWnd1=GetDlgItem32(hDlg,cmb1);
3171 if (!EnumFontFamilies32A(hdc, NULL, FontFamilyEnumProc32, (LPARAM)&s))
3172 TRACE(commdlg,"EnumFontFamilies returns 0\n");
3173 if (lpcf->Flags & CF_INITTOLOGFONTSTRUCT)
3175 /* look for fitting font name in combobox1 */
3176 j=SendDlgItemMessage32A(hDlg,cmb1,CB_FINDSTRING32,-1,(LONG)lpxx->lfFaceName);
3179 SendDlgItemMessage32A(hDlg, cmb1, CB_SETCURSEL32, j, 0);
3180 SendMessage32A(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
3181 GetDlgItem32(hDlg,cmb1));
3183 /* look for fitting font style in combobox2 */
3184 l=MAKELONG(lpxx->lfWeight > FW_MEDIUM ? FW_BOLD:FW_NORMAL,lpxx->lfItalic !=0);
3185 for (i=0;i<TEXT_EXTRAS;i++)
3187 if (l==SendDlgItemMessage32A(hDlg, cmb2, CB_GETITEMDATA32, i, 0))
3188 SendDlgItemMessage32A(hDlg, cmb2, CB_SETCURSEL32, i, 0);
3191 /* look for fitting font size in combobox3 */
3192 j=SendDlgItemMessage32A(hDlg, cmb3, CB_GETCOUNT32, 0, 0);
3195 if (lpxx->lfHeight==(int)SendDlgItemMessage32A(hDlg,cmb3, CB_GETITEMDATA32,i,0))
3196 SendDlgItemMessage32A(hDlg,cmb3,CB_SETCURSEL32,i,0);
3202 SendDlgItemMessage32A(hDlg,cmb1,CB_SETCURSEL32,0,0);
3203 SendMessage32A(hDlg, WM_COMMAND, MAKEWPARAM(cmb1, CBN_SELCHANGE),
3204 GetDlgItem32(hDlg,cmb1));
3206 if (lpcf->Flags & CF_USESTYLE && lpcf->lpszStyle)
3208 j=SendDlgItemMessage32A(hDlg,cmb2,CB_FINDSTRING32,-1,(LONG)lpcf->lpszStyle);
3211 j=SendDlgItemMessage32A(hDlg,cmb2,CB_SETCURSEL32,j,0);
3212 SendMessage32A(hDlg,WM_COMMAND,cmb2,
3213 MAKELONG(GetDlgItem32(hDlg,cmb2),CBN_SELCHANGE));
3219 WARN(commdlg,"HDC failure !!!\n");
3220 EndDialog32 (hDlg, 0);
3224 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
3225 ReleaseDC32(hDlg,hdc);
3226 SetCursor32(hcursor);
3231 /***********************************************************************
3232 * CFn_WMMeasureItem [internal]
3234 LRESULT CFn_WMMeasureItem(HWND32 hDlg, WPARAM32 wParam, LPARAM lParam)
3237 LPMEASUREITEMSTRUCT32 lpmi=(LPMEASUREITEMSTRUCT32)lParam;
3239 hBitmapTT = LoadBitmap32A(0, MAKEINTRESOURCE32A(OBM_TRTYPE));
3240 GetObject32A( hBitmapTT, sizeof(bm), &bm );
3241 lpmi->itemHeight=bm.bmHeight;
3242 /* FIXME: use MAX of bm.bmHeight and tm.tmHeight .*/
3247 /***********************************************************************
3248 * CFn_WMDrawItem [internal]
3250 LRESULT CFn_WMDrawItem(HWND32 hDlg, WPARAM32 wParam, LPARAM lParam)
3255 COLORREF cr, oldText=0, oldBk=0;
3260 HBITMAP32 hBitmap; /* for later TT usage */
3262 LPDRAWITEMSTRUCT32 lpdi = (LPDRAWITEMSTRUCT32)lParam;
3264 if (lpdi->itemID == 0xFFFF) /* got no items */
3265 DrawFocusRect32(lpdi->hDC, &lpdi->rcItem);
3268 if (lpdi->CtlType == ODT_COMBOBOX)
3270 if (lpdi->itemState ==ODS_SELECTED)
3272 hBrush=GetSysColorBrush32(COLOR_HIGHLIGHT);
3273 oldText=SetTextColor32(lpdi->hDC, GetSysColor32(COLOR_HIGHLIGHTTEXT));
3274 oldBk=SetBkColor32(lpdi->hDC, GetSysColor32(COLOR_HIGHLIGHT));
3277 hBrush = SelectObject32(lpdi->hDC, GetStockObject32(LTGRAY_BRUSH));
3278 SelectObject32(lpdi->hDC, hBrush);
3280 FillRect32(lpdi->hDC, &lpdi->rcItem, hBrush);
3283 return TRUE; /* this should never happen */
3286 switch (lpdi->CtlID)
3288 case cmb1: /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
3289 SendMessage32A(lpdi->hwndItem, CB_GETLBTEXT32, lpdi->itemID,
3291 GetObject32A( hBitmapTT, sizeof(bm), &bm );
3292 TextOut32A(lpdi->hDC, lpdi->rcItem.left + bm.bmWidth + 10,
3293 lpdi->rcItem.top, buffer, lstrlen32A(buffer));
3295 nFontType = SendMessage32A(lpdi->hwndItem, CB_GETITEMDATA32, lpdi->itemID,0L);
3296 /* FIXME: draw bitmap if truetype usage */
3297 if (nFontType&TRUETYPE_FONTTYPE)
3299 hMemDC = CreateCompatibleDC32(lpdi->hDC);
3300 hBitmap = SelectObject32(hMemDC, hBitmapTT);
3301 BitBlt32(lpdi->hDC, lpdi->rcItem.left, lpdi->rcItem.top,
3302 bm.bmWidth, bm.bmHeight, hMemDC, 0, 0, SRCCOPY);
3303 SelectObject32(hMemDC, hBitmap);
3309 case cmb3: /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
3310 SendMessage32A(lpdi->hwndItem, CB_GETLBTEXT32, lpdi->itemID,
3312 TextOut32A(lpdi->hDC, lpdi->rcItem.left,
3313 lpdi->rcItem.top, buffer, lstrlen32A(buffer));
3316 case cmb4: /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
3317 SendMessage32A(lpdi->hwndItem, CB_GETLBTEXT32, lpdi->itemID,
3319 TextOut32A(lpdi->hDC, lpdi->rcItem.left + 25+5,
3320 lpdi->rcItem.top, buffer, lstrlen32A(buffer));
3321 cr = SendMessage32A(lpdi->hwndItem, CB_GETITEMDATA32, lpdi->itemID,0L);
3322 hBrush = CreateSolidBrush32(cr);
3325 hBrush = SelectObject32 (lpdi->hDC, hBrush) ;
3326 rect.right=rect.left+25;
3330 Rectangle32( lpdi->hDC, rect.left, rect.top,
3331 rect.right, rect.bottom );
3332 DeleteObject32( SelectObject32 (lpdi->hDC, hBrush)) ;
3338 default: return TRUE; /* this should never happen */
3340 if (lpdi->itemState == ODS_SELECTED)
3342 SetTextColor32(lpdi->hDC, oldText);
3343 SetBkColor32(lpdi->hDC, oldBk);
3349 /***********************************************************************
3350 * CFn_WMCtlColor [internal]
3352 LRESULT CFn_WMCtlColorStatic(HWND32 hDlg, WPARAM32 wParam, LPARAM lParam,
3353 LPCHOOSEFONT32A lpcf)
3355 if (lpcf->Flags & CF_EFFECTS)
3356 if (GetDlgCtrlID32(lParam)==stc6)
3358 SetTextColor32((HDC32)wParam, lpcf->rgbColors);
3359 return GetStockObject32(WHITE_BRUSH);
3364 /***********************************************************************
3365 * CFn_WMCommand [internal]
3367 LRESULT CFn_WMCommand(HWND32 hDlg, WPARAM32 wParam, LPARAM lParam,
3368 LPCHOOSEFONT32A lpcf)
3374 LPLOGFONT32A lpxx=lpcf->lpLogFont;
3376 TRACE(commdlg,"WM_COMMAND wParam=%08lX lParam=%08lX\n", (LONG)wParam, lParam);
3377 switch (LOWORD(wParam))
3379 case cmb1:if (HIWORD(wParam)==CBN_SELCHANGE)
3381 hdc=(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC) ? lpcf->hDC : GetDC32(hDlg);
3384 SendDlgItemMessage32A(hDlg, cmb2, CB_RESETCONTENT16, 0, 0);
3385 SendDlgItemMessage32A(hDlg, cmb3, CB_RESETCONTENT16, 0, 0);
3386 i=SendDlgItemMessage32A(hDlg, cmb1, CB_GETCURSEL16, 0, 0);
3389 HCURSOR32 hcursor=SetCursor32(LoadCursor32A(0,IDC_WAIT32A));
3392 SendDlgItemMessage32A(hDlg, cmb1, CB_GETLBTEXT32, i,
3394 TRACE(commdlg,"WM_COMMAND/cmb1 =>%s\n",str);
3395 s.hWnd1=GetDlgItem32(hDlg, cmb2);
3396 s.hWnd2=GetDlgItem32(hDlg, cmb3);
3398 EnumFontFamilies32A(hdc, str, FontStyleEnumProc32, (LPARAM)&s);
3399 SetCursor32(hcursor);
3401 if (!(lpcf->Flags & CF_PRINTERFONTS && lpcf->hDC))
3402 ReleaseDC32(hDlg,hdc);
3406 WARN(commdlg,"HDC failure !!!\n");
3407 EndDialog32 (hDlg, 0);
3414 case cmb3:if (HIWORD(wParam)==CBN_SELCHANGE || HIWORD(wParam)== BN_CLICKED )
3417 TRACE(commdlg,"WM_COMMAND/cmb2,3 =%08lX\n", lParam);
3418 i=SendDlgItemMessage32A(hDlg,cmb1,CB_GETCURSEL32,0,0);
3420 i=GetDlgItemText32A( hDlg, cmb1, str, 256 );
3423 SendDlgItemMessage32A(hDlg,cmb1,CB_GETLBTEXT32,i,
3425 l=SendDlgItemMessage32A(hDlg,cmb1,CB_GETITEMDATA32,i,0);
3427 lpcf->nFontType = LOWORD(l);
3428 /* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */
3429 /* same value reported to the EnumFonts
3430 call back with the extra FONTTYPE_... bits added */
3431 lpxx->lfPitchAndFamily=j&0xff;
3432 lpxx->lfCharSet=j>>8;
3434 strcpy(lpxx->lfFaceName,str);
3435 i=SendDlgItemMessage32A(hDlg, cmb2, CB_GETCURSEL32, 0, 0);
3438 l=SendDlgItemMessage32A(hDlg, cmb2, CB_GETITEMDATA32, i, 0);
3439 if (0!=(lpxx->lfItalic=HIWORD(l)))
3440 lpcf->nFontType |= ITALIC_FONTTYPE;
3441 if ((lpxx->lfWeight=LOWORD(l)) > FW_MEDIUM)
3442 lpcf->nFontType |= BOLD_FONTTYPE;
3444 i=SendDlgItemMessage32A(hDlg, cmb3, CB_GETCURSEL32, 0, 0);
3446 lpxx->lfHeight=-LOWORD(SendDlgItemMessage32A(hDlg, cmb3, CB_GETITEMDATA32, i, 0));
3449 lpxx->lfStrikeOut=IsDlgButtonChecked32(hDlg,chx1);
3450 lpxx->lfUnderline=IsDlgButtonChecked32(hDlg,chx2);
3451 lpxx->lfWidth=lpxx->lfOrientation=lpxx->lfEscapement=0;
3452 lpxx->lfOutPrecision=OUT_DEFAULT_PRECIS;
3453 lpxx->lfClipPrecision=CLIP_DEFAULT_PRECIS;
3454 lpxx->lfQuality=DEFAULT_QUALITY;
3455 lpcf->iPointSize= -10*lpxx->lfHeight;
3457 hFont=CreateFontIndirect32A(lpxx);
3460 HFONT32 oldFont=SendDlgItemMessage32A(hDlg, stc6,
3462 SendDlgItemMessage32A(hDlg,stc6,WM_SETFONT,hFont,TRUE);
3463 DeleteObject32(oldFont);
3468 case cmb4:i=SendDlgItemMessage32A(hDlg, cmb4, CB_GETCURSEL32, 0, 0);
3471 lpcf->rgbColors=textcolors[i];
3472 InvalidateRect32( GetDlgItem32(hDlg,stc6), NULL, 0 );
3476 case psh15:i=RegisterWindowMessage32A( HELPMSGSTRING );
3477 if (lpcf->hwndOwner)
3478 SendMessage32A(lpcf->hwndOwner, i, 0, (LPARAM)GetWindowLong32A(hDlg, DWL_USER));
3479 /* if (CFn_HookCallChk(lpcf))
3480 CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/
3483 case IDOK:if ( (!(lpcf->Flags & CF_LIMITSIZE)) ||
3484 ( (lpcf->Flags & CF_LIMITSIZE) &&
3485 (-lpxx->lfHeight >= lpcf->nSizeMin) &&
3486 (-lpxx->lfHeight <= lpcf->nSizeMax)))
3487 EndDialog32(hDlg, TRUE);
3491 sprintf(buffer,"Select a font size between %d and %d points.",
3492 lpcf->nSizeMin,lpcf->nSizeMax);
3493 MessageBox32A(hDlg, buffer, NULL, MB_OK);
3496 case IDCANCEL:EndDialog32(hDlg, FALSE);
3502 static LRESULT CFn_WMDestroy(HWND32 hwnd, WPARAM32 wParam, LPARAM lParam)
3504 DeleteObject32(SendDlgItemMessage32A(hwnd, stc6, WM_GETFONT, 0, 0));
3509 /***********************************************************************
3510 * FormatCharDlgProc16 (COMMDLG.16)
3511 FIXME: 1. some strings are "hardcoded", but it's better load from sysres
3512 2. some CF_.. flags are not supported
3513 3. some TType extensions
3515 LRESULT WINAPI FormatCharDlgProc16(HWND16 hDlg, UINT16 message, WPARAM16 wParam,
3518 LPCHOOSEFONT16 lpcf;
3519 LPCHOOSEFONT32A lpcf32a;
3523 if (message!=WM_INITDIALOG)
3525 lpcf=(LPCHOOSEFONT16)GetWindowLong32A(hDlg, DWL_USER);
3528 if (CFn_HookCallChk(lpcf))
3529 res=CallWindowProc16(lpcf->lpfnHook,hDlg,message,wParam,lParam);
3535 lpcf=(LPCHOOSEFONT16)lParam;
3536 lpcf32a=(LPCHOOSEFONT32A)lpcf->lpTemplateName;
3537 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a))
3539 TRACE(commdlg, "CFn_WMInitDialog returned FALSE\n");
3542 if (CFn_HookCallChk(lpcf))
3543 return CallWindowProc16(lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
3545 WINPROC_MapMsg16To32A(message, wParam, &uMsg32, &wParam32, &lParam);
3546 lpcf32a=(LPCHOOSEFONT32A)lpcf->lpTemplateName;
3549 case WM_MEASUREITEM:
3550 res=CFn_WMMeasureItem(hDlg, wParam32, lParam);
3553 res=CFn_WMDrawItem(hDlg, wParam32, lParam);
3555 case WM_CTLCOLORSTATIC:
3556 res=CFn_WMCtlColorStatic(hDlg, wParam32, lParam, lpcf32a);
3559 res=CFn_WMCommand(hDlg, wParam32, lParam, lpcf32a);
3562 res=CFn_WMDestroy(hDlg, wParam32, lParam);
3564 case WM_CHOOSEFONT_GETLOGFONT:
3565 TRACE(commdlg,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3567 FIXME(commdlg, "current logfont back to caller\n");
3570 WINPROC_UnmapMsg16To32A(hDlg,uMsg32, wParam32, lParam, res);
3574 /***********************************************************************
3575 * FormatCharDlgProc32A [internal]
3577 LRESULT WINAPI FormatCharDlgProc32A(HWND32 hDlg, UINT32 uMsg, WPARAM32 wParam,
3580 LPCHOOSEFONT32A lpcf;
3582 if (uMsg!=WM_INITDIALOG)
3584 lpcf=(LPCHOOSEFONT32A)GetWindowLong32A(hDlg, DWL_USER);
3587 if (CFn_HookCallChk32(lpcf))
3588 res=CallWindowProc32A(lpcf->lpfnHook, hDlg, uMsg, wParam, lParam);
3594 lpcf=(LPCHOOSEFONT32A)lParam;
3595 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf))
3597 TRACE(commdlg, "CFn_WMInitDialog returned FALSE\n");
3600 if (CFn_HookCallChk32(lpcf))
3601 return CallWindowProc32A(lpcf->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
3605 case WM_MEASUREITEM:
3606 return CFn_WMMeasureItem(hDlg, wParam, lParam);
3608 return CFn_WMDrawItem(hDlg, wParam, lParam);
3609 case WM_CTLCOLORSTATIC:
3610 return CFn_WMCtlColorStatic(hDlg, wParam, lParam, lpcf);
3612 return CFn_WMCommand(hDlg, wParam, lParam, lpcf);
3614 return CFn_WMDestroy(hDlg, wParam, lParam);
3615 case WM_CHOOSEFONT_GETLOGFONT:
3616 TRACE(commdlg,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3618 FIXME(commdlg, "current logfont back to caller\n");
3624 /***********************************************************************
3625 * FormatCharDlgProc32W [internal]
3627 LRESULT WINAPI FormatCharDlgProc32W(HWND32 hDlg, UINT32 uMsg, WPARAM32 wParam,
3630 LPCHOOSEFONT32W lpcf32w;
3631 LPCHOOSEFONT32A lpcf32a;
3633 if (uMsg!=WM_INITDIALOG)
3635 lpcf32w=(LPCHOOSEFONT32W)GetWindowLong32A(hDlg, DWL_USER);
3638 if (CFn_HookCallChk32((LPCHOOSEFONT32A)lpcf32w))
3639 res=CallWindowProc32W(lpcf32w->lpfnHook, hDlg, uMsg, wParam, lParam);
3645 lpcf32w=(LPCHOOSEFONT32W)lParam;
3646 lpcf32a=(LPCHOOSEFONT32A)lpcf32w->lpTemplateName;
3647 if (!CFn_WMInitDialog(hDlg, wParam, lParam, lpcf32a))
3649 TRACE(commdlg, "CFn_WMInitDialog returned FALSE\n");
3652 if (CFn_HookCallChk32((LPCHOOSEFONT32A)lpcf32w))
3653 return CallWindowProc32W(lpcf32w->lpfnHook,hDlg,WM_INITDIALOG,wParam,lParam);
3655 lpcf32a=(LPCHOOSEFONT32A)lpcf32w->lpTemplateName;
3658 case WM_MEASUREITEM:
3659 return CFn_WMMeasureItem(hDlg, wParam, lParam);
3661 return CFn_WMDrawItem(hDlg, wParam, lParam);
3662 case WM_CTLCOLORSTATIC:
3663 return CFn_WMCtlColorStatic(hDlg, wParam, lParam, lpcf32a);
3665 return CFn_WMCommand(hDlg, wParam, lParam, lpcf32a);
3667 return CFn_WMDestroy(hDlg, wParam, lParam);
3668 case WM_CHOOSEFONT_GETLOGFONT:
3669 TRACE(commdlg,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3671 FIXME(commdlg, "current logfont back to caller\n");
3678 static BOOL32 Commdlg_GetFileName32A( BOOL16 (CALLBACK *dofunction)(SEGPTR x),
3679 LPOPENFILENAME32A ofn )
3682 LPOPENFILENAME16 ofn16 = SEGPTR_ALLOC(sizeof(OPENFILENAME16));
3684 memset(ofn16,'\0',sizeof(*ofn16));
3685 ofn16->lStructSize = sizeof(*ofn16);
3686 ofn16->hwndOwner = ofn->hwndOwner;
3687 ofn16->hInstance = MapHModuleLS(ofn->hInstance);
3688 if (ofn->lpstrFilter) {
3691 /* filter is a list... title\0ext\0......\0\0 */
3692 s = (LPSTR)ofn->lpstrFilter;
3696 x = (LPSTR)SEGPTR_ALLOC(s-ofn->lpstrFilter);
3697 memcpy(x,ofn->lpstrFilter,s-ofn->lpstrFilter);
3698 ofn16->lpstrFilter = SEGPTR_GET(x);
3700 if (ofn->lpstrCustomFilter) {
3703 /* filter is a list... title\0ext\0......\0\0 */
3704 s = (LPSTR)ofn->lpstrCustomFilter;
3708 x = SEGPTR_ALLOC(s-ofn->lpstrCustomFilter);
3709 memcpy(x,ofn->lpstrCustomFilter,s-ofn->lpstrCustomFilter);
3710 ofn16->lpstrCustomFilter = SEGPTR_GET(x);
3712 ofn16->nMaxCustFilter = ofn->nMaxCustFilter;
3713 ofn16->nFilterIndex = ofn->nFilterIndex;
3715 ofn16->lpstrFile = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFile));
3716 ofn16->nMaxFile = ofn->nMaxFile;
3717 ofn16->nMaxFileTitle = ofn->nMaxFileTitle;
3718 if (ofn16->nMaxFileTitle)
3719 ofn16->lpstrFileTitle = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFileTitle));
3720 if (ofn->lpstrInitialDir)
3721 ofn16->lpstrInitialDir = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrInitialDir));
3722 if (ofn->lpstrTitle)
3723 ofn16->lpstrTitle = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrTitle));
3724 ofn16->Flags = ofn->Flags|OFN_WINE32;
3725 ofn16->nFileOffset = ofn->nFileOffset;
3726 ofn16->nFileExtension = ofn->nFileExtension;
3727 if (ofn->lpstrDefExt)
3728 ofn16->lpstrDefExt = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrDefExt));
3729 ofn16->lCustData = ofn->lCustData;
3730 ofn16->lpfnHook = (WNDPROC16)ofn->lpfnHook;
3732 if (ofn->lpTemplateName)
3733 ofn16->lpTemplateName = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpTemplateName));
3735 ret = dofunction(SEGPTR_GET(ofn16));
3737 ofn->nFileOffset = ofn16->nFileOffset;
3738 ofn->nFileExtension = ofn16->nFileExtension;
3739 if (ofn16->lpstrFilter)
3740 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFilter));
3741 if (ofn16->lpTemplateName)
3742 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpTemplateName));
3743 if (ofn16->lpstrDefExt)
3744 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrDefExt));
3745 if (ofn16->lpstrTitle)
3746 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrTitle));
3747 if (ofn16->lpstrInitialDir)
3748 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrInitialDir));
3749 if (ofn16->lpstrCustomFilter)
3750 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrCustomFilter));
3752 if (ofn16->lpstrFile)
3754 strcpy(ofn->lpstrFile,PTR_SEG_TO_LIN(ofn16->lpstrFile));
3755 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFile));
3758 if (ofn16->lpstrFileTitle)
3760 strcpy(ofn->lpstrFileTitle,PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
3761 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
3767 static BOOL32 Commdlg_GetFileName32W( BOOL16 (CALLBACK *dofunction)(SEGPTR x),
3768 LPOPENFILENAME32W ofn )
3771 LPOPENFILENAME16 ofn16 = SEGPTR_ALLOC(sizeof(OPENFILENAME16));
3773 memset(ofn16,'\0',sizeof(*ofn16));
3774 ofn16->lStructSize = sizeof(*ofn16);
3775 ofn16->hwndOwner = ofn->hwndOwner;
3776 ofn16->hInstance = MapHModuleLS(ofn->hInstance);
3777 if (ofn->lpstrFilter) {
3782 /* filter is a list... title\0ext\0......\0\0 */
3783 s = (LPWSTR)ofn->lpstrFilter;
3785 s = s+lstrlen32W(s)+1;
3787 n = s - ofn->lpstrFilter; /* already divides by 2. ptr magic */
3788 x = y = (LPSTR)SEGPTR_ALLOC(n);
3789 s = (LPWSTR)ofn->lpstrFilter;
3796 ofn16->lpstrFilter = SEGPTR_GET(y);
3798 if (ofn->lpstrCustomFilter) {
3803 /* filter is a list... title\0ext\0......\0\0 */
3804 s = (LPWSTR)ofn->lpstrCustomFilter;
3806 s = s+lstrlen32W(s)+1;
3808 n = s - ofn->lpstrCustomFilter;
3809 x = y = (LPSTR)SEGPTR_ALLOC(n);
3810 s = (LPWSTR)ofn->lpstrCustomFilter;
3817 ofn16->lpstrCustomFilter = SEGPTR_GET(y);
3819 ofn16->nMaxCustFilter = ofn->nMaxCustFilter;
3820 ofn16->nFilterIndex = ofn->nFilterIndex;
3822 ofn16->lpstrFile = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFile));
3823 ofn16->nMaxFile = ofn->nMaxFile;
3824 ofn16->nMaxFileTitle = ofn->nMaxFileTitle;
3825 if (ofn->nMaxFileTitle)
3826 ofn16->lpstrFileTitle = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFileTitle));
3827 if (ofn->lpstrInitialDir)
3828 ofn16->lpstrInitialDir = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrInitialDir));
3829 if (ofn->lpstrTitle)
3830 ofn16->lpstrTitle = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrTitle));
3831 ofn16->Flags = ofn->Flags|OFN_WINE32|OFN_UNICODE;
3832 ofn16->nFileOffset = ofn->nFileOffset;
3833 ofn16->nFileExtension = ofn->nFileExtension;
3834 if (ofn->lpstrDefExt)
3835 ofn16->lpstrDefExt = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrDefExt));
3836 ofn16->lCustData = ofn->lCustData;
3837 ofn16->lpfnHook = (WNDPROC16)ofn->lpfnHook;
3838 if (ofn->lpTemplateName)
3839 ofn16->lpTemplateName = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpTemplateName));
3840 ret = dofunction(SEGPTR_GET(ofn16));
3842 ofn->nFileOffset = ofn16->nFileOffset;
3843 ofn->nFileExtension = ofn16->nFileExtension;
3844 if (ofn16->lpstrFilter)
3845 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFilter));
3846 if (ofn16->lpTemplateName)
3847 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpTemplateName));
3848 if (ofn16->lpstrDefExt)
3849 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrDefExt));
3850 if (ofn16->lpstrTitle)
3851 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrTitle));
3852 if (ofn16->lpstrInitialDir)
3853 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrInitialDir));
3854 if (ofn16->lpstrCustomFilter)
3855 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrCustomFilter));
3857 if (ofn16->lpstrFile) {
3858 lstrcpyAtoW(ofn->lpstrFile,PTR_SEG_TO_LIN(ofn16->lpstrFile));
3859 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFile));
3862 if (ofn16->lpstrFileTitle) {
3863 lstrcpyAtoW(ofn->lpstrFileTitle,PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
3864 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFileTitle));
3870 /***********************************************************************
3871 * GetOpenFileName32A (COMDLG32.10)
3873 BOOL32 WINAPI GetOpenFileName32A( LPOPENFILENAME32A ofn )
3875 BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetOpenFileName16;
3876 return Commdlg_GetFileName32A(dofunction,ofn);
3879 /***********************************************************************
3880 * GetOpenFileName32W (COMDLG32.11)
3882 BOOL32 WINAPI GetOpenFileName32W( LPOPENFILENAME32W ofn )
3884 BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetOpenFileName16;
3885 return Commdlg_GetFileName32W(dofunction,ofn);
3888 /***********************************************************************
3889 * GetSaveFileName32A (COMDLG32.12)
3891 BOOL32 WINAPI GetSaveFileName32A( LPOPENFILENAME32A ofn )
3893 BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetSaveFileName16;
3894 return Commdlg_GetFileName32A(dofunction,ofn);
3897 /***********************************************************************
3898 * GetSaveFileName32W (COMDLG32.13)
3900 BOOL32 WINAPI GetSaveFileName32W( LPOPENFILENAME32W ofn )
3902 BOOL16 (CALLBACK * dofunction)(SEGPTR ofn16) = GetSaveFileName16;
3903 return Commdlg_GetFileName32W(dofunction,ofn);
3906 /***********************************************************************
3907 * ChooseColorA (COMDLG32.1)
3909 BOOL32 WINAPI ChooseColor32A(LPCHOOSECOLOR32A lpChCol )
3914 COLORREF* ccref=SEGPTR_ALLOC(64);
3915 LPCHOOSECOLOR16 lpcc16=SEGPTR_ALLOC(sizeof(CHOOSECOLOR16));
3917 memset(lpcc16,'\0',sizeof(*lpcc16));
3918 lpcc16->lStructSize=sizeof(*lpcc16);
3919 lpcc16->hwndOwner=lpChCol->hwndOwner;
3920 lpcc16->hInstance=MapHModuleLS(lpChCol->hInstance);
3921 lpcc16->rgbResult=lpChCol->rgbResult;
3922 memcpy(ccref,lpChCol->lpCustColors,64);
3923 lpcc16->lpCustColors=(COLORREF*)SEGPTR_GET(ccref);
3924 lpcc16->Flags=lpChCol->Flags;
3925 lpcc16->lCustData=lpChCol->lCustData;
3926 lpcc16->lpfnHook=(WNDPROC16)lpChCol->lpfnHook;
3927 if (lpChCol->lpTemplateName)
3928 str = SEGPTR_STRDUP(lpChCol->lpTemplateName );
3929 lpcc16->lpTemplateName=SEGPTR_GET(str);
3931 ret = ChooseColor16(lpcc16);
3934 memcpy(lpChCol->lpCustColors,ccref,64);
3936 SEGPTR_FREE(lpcc16);
3940 /***********************************************************************
3941 * ChooseColorW (COMDLG32.2)
3943 BOOL32 WINAPI ChooseColor32W(LPCHOOSECOLOR32W lpChCol )
3948 COLORREF* ccref=SEGPTR_ALLOC(64);
3949 LPCHOOSECOLOR16 lpcc16=SEGPTR_ALLOC(sizeof(CHOOSECOLOR16));
3951 memset(lpcc16,'\0',sizeof(*lpcc16));
3952 lpcc16->lStructSize=sizeof(*lpcc16);
3953 lpcc16->hwndOwner=lpChCol->hwndOwner;
3954 lpcc16->hInstance=MapHModuleLS(lpChCol->hInstance);
3955 lpcc16->rgbResult=lpChCol->rgbResult;
3956 memcpy(ccref,lpChCol->lpCustColors,64);
3957 lpcc16->lpCustColors=(COLORREF*)SEGPTR_GET(ccref);
3958 lpcc16->Flags=lpChCol->Flags;
3959 lpcc16->lCustData=lpChCol->lCustData;
3960 lpcc16->lpfnHook=(WNDPROC16)lpChCol->lpfnHook;
3961 if (lpChCol->lpTemplateName)
3962 str = SEGPTR_STRDUP_WtoA(lpChCol->lpTemplateName );
3963 lpcc16->lpTemplateName=SEGPTR_GET(str);
3965 ret = ChooseColor16(lpcc16);
3968 memcpy(lpChCol->lpCustColors,ccref,64);
3970 SEGPTR_FREE(lpcc16);
3974 /***********************************************************************
3975 * PageSetupDlgA (COMDLG32.15)
3977 BOOL32 WINAPI PageSetupDlg32A(LPPAGESETUPDLG32A setupdlg) {
3978 FIXME(commdlg,"(%p), stub!\n",setupdlg);