4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
24 static DWORD CommDlgLastError
= 0;
26 static HBITMAP16 hFolder
= 0;
27 static HBITMAP16 hFolder2
= 0;
28 static HBITMAP16 hFloppy
= 0;
29 static HBITMAP16 hHDisk
= 0;
30 static HBITMAP16 hCDRom
= 0;
31 static HBITMAP16 hBitmapTT
= 0;
32 static const char defaultfilter
[]=" \0\0";
34 /***********************************************************************
35 * FileDlg_Init [internal]
37 static BOOL32
FileDlg_Init()
39 static BOOL32 initialized
= 0;
42 if (!hFolder
) hFolder
= LoadBitmap16(0, MAKEINTRESOURCE16(OBM_FOLDER
));
43 if (!hFolder2
) hFolder2
= LoadBitmap16(0, MAKEINTRESOURCE16(OBM_FOLDER2
));
44 if (!hFloppy
) hFloppy
= LoadBitmap16(0, MAKEINTRESOURCE16(OBM_FLOPPY
));
45 if (!hHDisk
) hHDisk
= LoadBitmap16(0, MAKEINTRESOURCE16(OBM_HDISK
));
46 if (!hCDRom
) hCDRom
= LoadBitmap16(0, MAKEINTRESOURCE16(OBM_CDROM
));
47 if (hFolder
== 0 || hFolder2
== 0 || hFloppy
== 0 ||
48 hHDisk
== 0 || hCDRom
== 0)
50 WARN(commdlg
, "Error loading bitmaps !\nprin");
58 /***********************************************************************
59 * GetOpenFileName (COMMDLG.1)
61 BOOL16 WINAPI
GetOpenFileName16( SEGPTR ofn
)
64 HANDLE32 hDlgTmpl
= 0, hResInfo
;
65 BOOL32 bRet
= FALSE
, win32Format
= FALSE
;
67 LPOPENFILENAME16 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(ofn
);
69 char defaultopen
[]="Open File";
72 if (!lpofn
|| !FileDlg_Init()) return FALSE
;
74 if (lpofn
->Flags
& OFN_WINE32
) {
75 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
)
77 if (!(template = LockResource32( MapHModuleSL(lpofn
->hInstance
))))
79 CommDlgLastError
= CDERR_LOADRESFAILURE
;
83 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
85 if (!(hResInfo
= FindResource32A(MapHModuleSL(lpofn
->hInstance
),
86 PTR_SEG_TO_LIN(lpofn
->lpTemplateName
), RT_DIALOG32A
)))
88 CommDlgLastError
= CDERR_FINDRESFAILURE
;
91 if (!(hDlgTmpl
= LoadResource32( MapHModuleSL(lpofn
->hInstance
),
93 !(template = LockResource32( hDlgTmpl
)))
95 CommDlgLastError
= CDERR_LOADRESFAILURE
;
99 template = SYSRES_GetResPtr( SYSRES_DIALOG_OPEN_FILE
);
103 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
)
105 if (!(template = LockResource16( lpofn
->hInstance
)))
107 CommDlgLastError
= CDERR_LOADRESFAILURE
;
111 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
113 if (!(hResInfo
= FindResource16(lpofn
->hInstance
,
114 lpofn
->lpTemplateName
,
117 CommDlgLastError
= CDERR_FINDRESFAILURE
;
120 if (!(hDlgTmpl
= LoadResource16( lpofn
->hInstance
, hResInfo
)) ||
121 !(template = LockResource16( hDlgTmpl
)))
123 CommDlgLastError
= CDERR_LOADRESFAILURE
;
127 template = SYSRES_GetResPtr( SYSRES_DIALOG_OPEN_FILE
);
132 hInst
= WIN_GetWindowInstance( lpofn
->hwndOwner
);
134 if (!(lpofn
->lpstrFilter
))
136 str
= SEGPTR_ALLOC(sizeof(defaultfilter
));
137 TRACE(commdlg
,"Alloc %p default for Filetype in GetOpenFileName\n",str
);
138 memcpy(str
,defaultfilter
,sizeof(defaultfilter
));
139 lpofn
->lpstrFilter
=SEGPTR_GET(str
);
142 if (!(lpofn
->lpstrTitle
))
144 str1
= SEGPTR_ALLOC(strlen(defaultopen
)+1);
145 TRACE(commdlg
,"Alloc %p default for Title in GetOpenFileName\n",str1
);
146 strcpy(str1
,defaultopen
);
147 lpofn
->lpstrTitle
=SEGPTR_GET(str1
);
150 /* FIXME: doesn't handle win32 format correctly yet */
151 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, win32Format
,
153 (DLGPROC16
)MODULE_GetWndProcEntry16("FileOpenDlgProc"),
155 if (hwndDialog
) bRet
= DIALOG_DoDialogBox( hwndDialog
, lpofn
->hwndOwner
);
159 TRACE(commdlg
,"Freeing %p default for Title in GetOpenFileName\n",str1
);
166 TRACE(commdlg
,"Freeing %p default for Filetype in GetOpenFileName\n",str
);
168 lpofn
->lpstrFilter
=0;
172 if (lpofn
->Flags
& OFN_WINE32
)
173 FreeResource32( hDlgTmpl
);
175 FreeResource16( hDlgTmpl
);
178 TRACE(commdlg
,"return lpstrFile='%s' !\n",
179 (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFile
));
184 /***********************************************************************
185 * GetSaveFileName (COMMDLG.2)
187 BOOL16 WINAPI
GetSaveFileName16( SEGPTR ofn
)
190 HANDLE32 hDlgTmpl
= 0;
191 BOOL32 bRet
= FALSE
, win32Format
= FALSE
;
192 LPOPENFILENAME16 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(ofn
);
195 char defaultsave
[]="Save as";
196 char *str
=0,*str1
=0;
198 if (!lpofn
|| !FileDlg_Init()) return FALSE
;
200 if (lpofn
->Flags
& OFN_WINE32
) {
201 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
)
203 if (!(template = LockResource32( MapHModuleSL(lpofn
->hInstance
))))
205 CommDlgLastError
= CDERR_LOADRESFAILURE
;
209 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
212 if (!(hResInfo
= FindResource32A(MapHModuleSL(lpofn
->hInstance
),
213 PTR_SEG_TO_LIN(lpofn
->lpTemplateName
),
216 CommDlgLastError
= CDERR_FINDRESFAILURE
;
219 if (!(hDlgTmpl
= LoadResource32(MapHModuleSL(lpofn
->hInstance
),
221 !(template = LockResource32(hDlgTmpl
)))
223 CommDlgLastError
= CDERR_LOADRESFAILURE
;
228 template = SYSRES_GetResPtr( SYSRES_DIALOG_SAVE_FILE
);
232 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
)
234 if (!(template = LockResource16( lpofn
->hInstance
)))
236 CommDlgLastError
= CDERR_LOADRESFAILURE
;
240 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
243 if (!(hResInfo
= FindResource16(lpofn
->hInstance
,
244 lpofn
->lpTemplateName
,
247 CommDlgLastError
= CDERR_FINDRESFAILURE
;
250 if (!(hDlgTmpl
= LoadResource16( lpofn
->hInstance
, hResInfo
)) ||
251 !(template = LockResource16( hDlgTmpl
)))
253 CommDlgLastError
= CDERR_LOADRESFAILURE
;
257 template = SYSRES_GetResPtr( SYSRES_DIALOG_SAVE_FILE
);
262 hInst
= WIN_GetWindowInstance( lpofn
->hwndOwner
);
264 if (!(lpofn
->lpstrFilter
))
266 str
= SEGPTR_ALLOC(sizeof(defaultfilter
));
267 TRACE(commdlg
,"Alloc default for Filetype in GetSaveFileName\n");
268 memcpy(str
,defaultfilter
,sizeof(defaultfilter
));
269 lpofn
->lpstrFilter
=SEGPTR_GET(str
);
272 if (!(lpofn
->lpstrTitle
))
274 str1
= SEGPTR_ALLOC(sizeof(defaultsave
)+1);
275 TRACE(commdlg
,"Alloc default for Title in GetSaveFileName\n");
276 strcpy(str1
,defaultsave
);
277 lpofn
->lpstrTitle
=SEGPTR_GET(str1
);
280 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, win32Format
,
282 (DLGPROC16
)MODULE_GetWndProcEntry16("FileSaveDlgProc"),
284 if (hwndDialog
) bRet
= DIALOG_DoDialogBox( hwndDialog
, lpofn
->hwndOwner
);
288 TRACE(commdlg
,"Freeing %p default for Title in GetSaveFileName\n",str1
);
295 TRACE(commdlg
,"Freeing %p default for Filetype in GetSaveFileName\n",str
);
297 lpofn
->lpstrFilter
=0;
301 if (lpofn
->Flags
& OFN_WINE32
)
302 FreeResource32( hDlgTmpl
);
304 FreeResource16( hDlgTmpl
);
307 TRACE(commdlg
, "return lpstrFile='%s' !\n",
308 (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFile
));
312 /***********************************************************************
313 * FILEDLG_StripEditControl [internal]
314 * Strip pathnames off the contents of the edit control.
316 static void FILEDLG_StripEditControl(HWND16 hwnd
)
320 GetDlgItemText32A( hwnd
, edt1
, temp
, sizeof(temp
) );
321 cp
= strrchr(temp
, '\\');
325 cp
= strrchr(temp
, ':');
329 /* FIXME: shouldn't we do something with the result here? ;-) */
332 /***********************************************************************
333 * FILEDLG_ScanDir [internal]
335 static BOOL32
FILEDLG_ScanDir(HWND16 hWnd
, LPSTR newPath
)
342 lstrcpyn32A(buffer
, newPath
, sizeof(buffer
));
344 if (str
[0] && (str
[1] == ':')) {
345 drive
= toupper(str
[0]) - 'A';
347 if (!DRIVE_SetCurrentDrive(drive
))
350 drive
= DRIVE_GetCurrentDrive();
353 if (str
[0] && !DRIVE_Chdir(drive
, str
)) {
357 GetDlgItemText32A(hWnd
, edt1
, buffer
, sizeof(buffer
));
358 if ((hlb
= GetDlgItem32(hWnd
, lst1
)) != 0) {
359 char* scptr
; /* ptr on semi-colon */
360 char* filter
= buffer
;
362 TRACE(commdlg
, "Using filter %s\n", filter
);
363 SendMessage32A(hlb
, LB_RESETCONTENT32
, 0, 0);
365 scptr
= strchr(filter
, ';');
366 if (scptr
) *scptr
= 0;
367 TRACE(commdlg
, "Using file spec %s\n", filter
);
368 if (SendMessage32A(hlb
, LB_DIR32
, 0, (LPARAM
)filter
) == LB_ERR
)
370 if (scptr
) *scptr
= ';';
371 filter
= (scptr
) ? (scptr
+ 1) : 0;
375 strcpy(buffer
, "*.*");
376 return DlgDirList32A(hWnd
, buffer
, lst2
, stc1
, 0x8010);
379 /***********************************************************************
380 * FILEDLG_GetFileType [internal]
383 static LPSTR
FILEDLG_GetFileType(LPSTR cfptr
, LPSTR fptr
, WORD index
)
388 for ( ;(n
= strlen(cfptr
)) != 0; i
++)
393 cfptr
+= strlen(cfptr
) + 1;
396 for ( ;(n
= strlen(fptr
)) != 0; i
++)
401 fptr
+= strlen(fptr
) + 1;
403 return "*.*"; /* FIXME */
406 /***********************************************************************
407 * FILEDLG_WMDrawItem [internal]
409 static LONG
FILEDLG_WMDrawItem(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
,int savedlg
)
411 LPDRAWITEMSTRUCT16 lpdis
= (LPDRAWITEMSTRUCT16
)PTR_SEG_TO_LIN(lParam
);
414 HBITMAP16 hBitmap
, hPrevBitmap
;
418 if (lpdis
->CtlType
== ODT_LISTBOX
&& lpdis
->CtlID
== lst1
)
420 if (!(str
= SEGPTR_ALLOC(512))) return FALSE
;
421 hBrush
= SelectObject32(lpdis
->hDC
, GetStockObject32(LTGRAY_BRUSH
));
422 SelectObject32(lpdis
->hDC
, hBrush
);
423 FillRect16(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
424 SendMessage16(lpdis
->hwndItem
, LB_GETTEXT16
, lpdis
->itemID
,
425 (LPARAM
)SEGPTR_GET(str
));
427 if (savedlg
) /* use _gray_ text in FileSaveDlg */
428 if (!lpdis
->itemState
)
429 SetTextColor32(lpdis
->hDC
,GetSysColor32(COLOR_GRAYTEXT
) );
431 SetTextColor32(lpdis
->hDC
,GetSysColor32(COLOR_WINDOWTEXT
) );
432 /* inversion of gray would be bad readable */
434 TextOut16(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
436 if (lpdis
->itemState
!= 0) {
437 InvertRect16(lpdis
->hDC
, &lpdis
->rcItem
);
443 if (lpdis
->CtlType
== ODT_LISTBOX
&& lpdis
->CtlID
== lst2
)
445 if (!(str
= SEGPTR_ALLOC(512))) return FALSE
;
446 hBrush
= SelectObject32(lpdis
->hDC
, GetStockObject32(LTGRAY_BRUSH
));
447 SelectObject32(lpdis
->hDC
, hBrush
);
448 FillRect16(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
449 SendMessage16(lpdis
->hwndItem
, LB_GETTEXT16
, lpdis
->itemID
,
450 (LPARAM
)SEGPTR_GET(str
));
453 GetObject16( hBitmap
, sizeof(bm
), &bm
);
454 TextOut16(lpdis
->hDC
, lpdis
->rcItem
.left
+ bm
.bmWidth
,
455 lpdis
->rcItem
.top
, str
, strlen(str
));
456 hMemDC
= CreateCompatibleDC32(lpdis
->hDC
);
457 hPrevBitmap
= SelectObject32(hMemDC
, hBitmap
);
458 BitBlt32(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
459 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
460 SelectObject32(hMemDC
, hPrevBitmap
);
462 if (lpdis
->itemState
!= 0) InvertRect16(lpdis
->hDC
, &lpdis
->rcItem
);
466 if (lpdis
->CtlType
== ODT_COMBOBOX
&& lpdis
->CtlID
== cmb2
)
468 if (!(str
= SEGPTR_ALLOC(512))) return FALSE
;
469 hBrush
= SelectObject32(lpdis
->hDC
, GetStockObject32(LTGRAY_BRUSH
));
470 SelectObject32(lpdis
->hDC
, hBrush
);
471 FillRect16(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
472 SendMessage16(lpdis
->hwndItem
, CB_GETLBTEXT16
, lpdis
->itemID
,
473 (LPARAM
)SEGPTR_GET(str
));
474 switch(DRIVE_GetType( str
[2] - 'a' ))
476 case TYPE_FLOPPY
: hBitmap
= hFloppy
; break;
477 case TYPE_CDROM
: hBitmap
= hCDRom
; break;
480 default: hBitmap
= hHDisk
; break;
482 GetObject16( hBitmap
, sizeof(bm
), &bm
);
483 TextOut16(lpdis
->hDC
, lpdis
->rcItem
.left
+ bm
.bmWidth
,
484 lpdis
->rcItem
.top
, str
, strlen(str
));
485 hMemDC
= CreateCompatibleDC32(lpdis
->hDC
);
486 hPrevBitmap
= SelectObject32(hMemDC
, hBitmap
);
487 BitBlt32( lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
488 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
489 SelectObject32(hMemDC
, hPrevBitmap
);
491 if (lpdis
->itemState
!= 0) InvertRect16(lpdis
->hDC
, &lpdis
->rcItem
);
498 /***********************************************************************
499 * FILEDLG_WMMeasureItem [internal]
501 static LONG
FILEDLG_WMMeasureItem(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
)
504 LPMEASUREITEMSTRUCT16 lpmeasure
;
506 GetObject16( hFolder2
, sizeof(bm
), &bm
);
507 lpmeasure
= (LPMEASUREITEMSTRUCT16
)PTR_SEG_TO_LIN(lParam
);
508 lpmeasure
->itemHeight
= bm
.bmHeight
;
512 /***********************************************************************
513 * FILEDLG_HookCallChk [internal]
515 static int FILEDLG_HookCallChk(LPOPENFILENAME16 lpofn
)
518 if (lpofn
->Flags
& OFN_ENABLEHOOK
)
524 /***********************************************************************
525 * FILEDLG_CallWindowProc [internal]
527 * Adapt the structures back for win32 calls so the callee can read lpCustData
529 static BOOL32
FILEDLG_CallWindowProc(LPOPENFILENAME16 lpofn
,HWND32 hwnd
,
530 UINT32 wMsg
,WPARAM32 wParam
,LPARAM lParam
535 needstruct
= (PTR_SEG_TO_LIN(lParam
) == lpofn
);
537 if (!(lpofn
->Flags
& OFN_WINE32
))
538 return (BOOL32
)CallWindowProc16(
539 lpofn
->lpfnHook
,hwnd
,(UINT16
)wMsg
,(WPARAM16
)wParam
,lParam
542 if (lpofn
->Flags
& OFN_UNICODE
) {
544 OPENFILENAME32W ofnw
;
546 /* FIXME: probably needs more converted */
547 ofnw
.lCustData
= lpofn
->lCustData
;
548 return (BOOL32
)CallWindowProc32W(
549 (WNDPROC32
)lpofn
->lpfnHook
,hwnd
,wMsg
,wParam
,(LPARAM
)&ofnw
552 return (BOOL32
)CallWindowProc32W(
553 (WNDPROC32
)lpofn
->lpfnHook
,hwnd
,wMsg
,wParam
,lParam
558 OPENFILENAME32A ofna
;
560 /* FIXME: probably needs more converted */
561 ofna
.lCustData
= lpofn
->lCustData
;
562 return (BOOL32
)CallWindowProc32A(
563 (WNDPROC32
)lpofn
->lpfnHook
,hwnd
,wMsg
,wParam
,(LPARAM
)&ofna
566 return (BOOL32
)CallWindowProc32A(
567 (WNDPROC32
)lpofn
->lpfnHook
,hwnd
,wMsg
,wParam
,lParam
572 /***********************************************************************
573 * FILEDLG_WMInitDialog [internal]
576 static LONG
FILEDLG_WMInitDialog(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
)
579 LPOPENFILENAME16 lpofn
;
581 LPSTR pstr
, old_pstr
;
582 SetWindowLong32A(hWnd
, DWL_USER
, lParam
);
583 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(lParam
);
584 if (lpofn
->lpstrTitle
) SetWindowText16( hWnd
, lpofn
->lpstrTitle
);
585 /* read custom filter information */
586 if (lpofn
->lpstrCustomFilter
)
588 pstr
= (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
);
590 TRACE(commdlg
,"lpstrCustomFilter = %p\n", pstr
);
594 i
= SendDlgItemMessage16(hWnd
, cmb1
, CB_ADDSTRING16
, 0,
595 (LPARAM
)lpofn
->lpstrCustomFilter
+ n
);
596 n
+= strlen(pstr
) + 1;
597 pstr
+= strlen(pstr
) + 1;
598 TRACE(commdlg
,"add str='%s' "
599 "associated to '%s'\n", old_pstr
, pstr
);
600 SendDlgItemMessage16(hWnd
, cmb1
, CB_SETITEMDATA16
, i
, (LPARAM
)pstr
);
601 n
+= strlen(pstr
) + 1;
602 pstr
+= strlen(pstr
) + 1;
605 /* read filter information */
606 if (lpofn
->lpstrFilter
) {
607 pstr
= (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFilter
);
611 i
= SendDlgItemMessage16(hWnd
, cmb1
, CB_ADDSTRING16
, 0,
612 (LPARAM
)lpofn
->lpstrFilter
+ n
);
613 n
+= strlen(pstr
) + 1;
614 pstr
+= strlen(pstr
) + 1;
615 TRACE(commdlg
,"add str='%s' "
616 "associated to '%s'\n", old_pstr
, pstr
);
617 SendDlgItemMessage16(hWnd
, cmb1
, CB_SETITEMDATA16
, i
, (LPARAM
)pstr
);
618 n
+= strlen(pstr
) + 1;
619 pstr
+= strlen(pstr
) + 1;
622 /* set default filter */
623 if (lpofn
->nFilterIndex
== 0 && lpofn
->lpstrCustomFilter
== (SEGPTR
)NULL
)
624 lpofn
->nFilterIndex
= 1;
625 SendDlgItemMessage16(hWnd
, cmb1
, CB_SETCURSEL16
, lpofn
->nFilterIndex
- 1, 0);
626 strncpy(tmpstr
, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
627 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
), lpofn
->nFilterIndex
- 1),511);
629 TRACE(commdlg
,"nFilterIndex = %ld, SetText of edt1 to '%s'\n",
630 lpofn
->nFilterIndex
, tmpstr
);
631 SetDlgItemText32A( hWnd
, edt1
, tmpstr
);
634 DlgDirListComboBox32A(hWnd
, tmpstr
, cmb2
, 0, 0xC000);
635 /* read initial directory */
636 if (PTR_SEG_TO_LIN(lpofn
->lpstrInitialDir
) != NULL
)
638 strncpy(tmpstr
, PTR_SEG_TO_LIN(lpofn
->lpstrInitialDir
), 510);
640 if (strlen(tmpstr
) > 0 && tmpstr
[strlen(tmpstr
)-1] != '\\'
641 && tmpstr
[strlen(tmpstr
)-1] != ':')
646 if (!FILEDLG_ScanDir(hWnd
, tmpstr
)) {
648 if (!FILEDLG_ScanDir(hWnd
, tmpstr
))
649 WARN(commdlg
, "Couldn't read initial directory %s!\n",tmpstr
);
651 /* select current drive in combo 2, omit missing drives */
652 for(i
=0, n
=-1; i
<=DRIVE_GetCurrentDrive(); i
++)
653 if (DRIVE_IsValid(i
)) n
++;
654 SendDlgItemMessage16(hWnd
, cmb2
, CB_SETCURSEL16
, n
, 0);
655 if (!(lpofn
->Flags
& OFN_SHOWHELP
))
656 ShowWindow32(GetDlgItem32(hWnd
, pshHelp
), SW_HIDE
);
657 if (lpofn
->Flags
& OFN_HIDEREADONLY
)
658 ShowWindow32(GetDlgItem32(hWnd
, chx1
), SW_HIDE
);
659 if (FILEDLG_HookCallChk(lpofn
))
660 return (BOOL16
)FILEDLG_CallWindowProc(lpofn
,hWnd
,WM_INITDIALOG
,wParam
,lParam
);
665 /***********************************************************************
666 * FILEDLG_WMCommand [internal]
668 BOOL32 in_update
=FALSE
;
670 static LRESULT
FILEDLG_WMCommand(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
)
673 LPOPENFILENAME16 lpofn
;
675 char tmpstr
[512], tmpstr2
[512];
677 UINT16 control
,notification
;
679 /* Notifications are packaged differently in Win32 */
681 notification
= HIWORD(lParam
);
683 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
686 case lst1
: /* file list */
687 FILEDLG_StripEditControl(hWnd
);
688 if (notification
== LBN_DBLCLK
)
690 lRet
= SendDlgItemMessage16(hWnd
, lst1
, LB_GETCURSEL16
, 0, 0);
691 if (lRet
== LB_ERR
) return TRUE
;
692 if ((pstr
= SEGPTR_ALLOC(512)))
694 SendDlgItemMessage16(hWnd
, lst1
, LB_GETTEXT16
, lRet
,
695 (LPARAM
)SEGPTR_GET(pstr
));
696 SetDlgItemText32A( hWnd
, edt1
, pstr
);
699 if (FILEDLG_HookCallChk(lpofn
))
700 FILEDLG_CallWindowProc(lpofn
,hWnd
,
701 RegisterWindowMessage32A( LBSELCHSTRING
),
702 control
, MAKELONG(lRet
,CD_LBSELCHANGE
));
703 /* FIXME: for OFN_ALLOWMULTISELECT we need CD_LBSELSUB, CD_SELADD, CD_LBSELNOITEMS */
705 case lst2
: /* directory list */
706 FILEDLG_StripEditControl(hWnd
);
707 if (notification
== LBN_DBLCLK
)
709 lRet
= SendDlgItemMessage16(hWnd
, lst2
, LB_GETCURSEL16
, 0, 0);
710 if (lRet
== LB_ERR
) return TRUE
;
711 pstr
= SEGPTR_ALLOC(512);
712 SendDlgItemMessage16(hWnd
, lst2
, LB_GETTEXT16
, lRet
,
713 (LPARAM
)SEGPTR_GET(pstr
));
714 strcpy( tmpstr
, pstr
);
716 if (tmpstr
[0] == '[')
718 tmpstr
[strlen(tmpstr
) - 1] = 0;
719 strcpy(tmpstr
,tmpstr
+1);
721 strcat(tmpstr
, "\\");
725 case cmb1
: /* file type drop list */
726 if (notification
== CBN_SELCHANGE
)
736 case cmb2
: /* disk drop list */
737 FILEDLG_StripEditControl(hWnd
);
738 lRet
= SendDlgItemMessage16(hWnd
, cmb2
, CB_GETCURSEL16
, 0, 0L);
739 if (lRet
== LB_ERR
) return 0;
740 pstr
= SEGPTR_ALLOC(512);
741 SendDlgItemMessage16(hWnd
, cmb2
, CB_GETLBTEXT16
, lRet
,
742 (LPARAM
)SEGPTR_GET(pstr
));
743 sprintf(tmpstr
, "%c:", pstr
[2]);
746 lRet
= SendDlgItemMessage16(hWnd
, cmb1
, CB_GETCURSEL16
, 0, 0);
749 pstr
= (LPSTR
)SendDlgItemMessage16(hWnd
, cmb1
, CB_GETITEMDATA16
, lRet
, 0);
750 TRACE(commdlg
,"Selected filter : %s\n", pstr
);
751 SetDlgItemText32A( hWnd
, edt1
, pstr
);
752 FILEDLG_ScanDir(hWnd
, tmpstr
);
756 ofn2
=*lpofn
; /* for later restoring */
757 GetDlgItemText32A( hWnd
, edt1
, tmpstr
, sizeof(tmpstr
) );
758 pstr
= strrchr(tmpstr
, '\\');
760 pstr
= strrchr(tmpstr
, ':');
761 if (strchr(tmpstr
,'*') != NULL
|| strchr(tmpstr
,'?') != NULL
)
763 /* edit control contains wildcards */
766 strncpy(tmpstr2
, pstr
+1, 511); tmpstr2
[511]=0;
771 strcpy(tmpstr2
, tmpstr
);
774 TRACE(commdlg
,"tmpstr=%s, tmpstr2=%s\n", tmpstr
, tmpstr2
);
775 SetDlgItemText32A( hWnd
, edt1
, tmpstr2
);
776 FILEDLG_ScanDir(hWnd
, tmpstr
);
779 /* no wildcards, we might have a directory or a filename */
780 /* try appending a wildcard and reading the directory */
781 pstr2
= tmpstr
+ strlen(tmpstr
);
782 if (pstr
== NULL
|| *(pstr
+1) != 0)
783 strcat(tmpstr
, "\\");
784 lRet
= SendDlgItemMessage16(hWnd
, cmb1
, CB_GETCURSEL16
, 0, 0);
785 if (lRet
== LB_ERR
) return TRUE
;
786 lpofn
->nFilterIndex
= lRet
+ 1;
787 TRACE(commdlg
,"lpofn->nFilterIndex=%ld\n", lpofn
->nFilterIndex
);
789 FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
790 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
),
791 lRet
), sizeof(tmpstr2
));
792 SetDlgItemText32A( hWnd
, edt1
, tmpstr2
);
794 /* if ScanDir succeeds, we have changed the directory */
795 if (FILEDLG_ScanDir(hWnd
, tmpstr
)) return TRUE
;
796 /* if not, this must be a filename */
800 /* strip off the pathname */
802 SetDlgItemText32A( hWnd
, edt1
, pstr
+ 1 );
803 lstrcpyn32A(tmpstr2
, pstr
+1, sizeof(tmpstr2
) );
804 /* Should we MessageBox() if this fails? */
805 if (!FILEDLG_ScanDir(hWnd
, tmpstr
)) return TRUE
;
806 strcpy(tmpstr
, tmpstr2
);
808 else SetDlgItemText32A( hWnd
, edt1
, tmpstr
);
810 ShowWindow16(hWnd
, SW_HIDE
); /* this should not be necessary ?! (%%%) */
813 int drive
= DRIVE_GetCurrentDrive();
814 tmpstr2
[0] = 'A'+ drive
;
817 strncpy(tmpstr2
+ 3, DRIVE_GetDosCwd(drive
), 507); tmpstr2
[510]=0;
818 if (strlen(tmpstr2
) > 3)
819 strcat(tmpstr2
, "\\");
820 strncat(tmpstr2
, tmpstr
, 511-strlen(tmpstr2
)); tmpstr2
[511]=0;
821 if (lpofn
->lpstrFile
)
822 lstrcpyn32A(PTR_SEG_TO_LIN(lpofn
->lpstrFile
), tmpstr2
,lpofn
->nMaxFile
);
824 lpofn
->nFileOffset
= strrchr(tmpstr2
,'\\') - tmpstr2
+1;
825 lpofn
->nFileExtension
= 0;
826 while(tmpstr2
[lpofn
->nFileExtension
] != '.' && tmpstr2
[lpofn
->nFileExtension
] != '\0')
827 lpofn
->nFileExtension
++;
828 if (lpofn
->nFileExtension
== '\0')
829 lpofn
->nFileExtension
= 0;
831 lpofn
->nFileExtension
++;
835 if (FILEDLG_HookCallChk(lpofn
))
836 FILEDLG_CallWindowProc(lpofn
,hWnd
,
837 RegisterWindowMessage32A( LBSELCHSTRING
),
838 control
, MAKELONG(lRet
,CD_LBSELCHANGE
));
843 if (PTR_SEG_TO_LIN(lpofn
->lpstrFileTitle
) != NULL
)
845 lRet
= SendDlgItemMessage16(hWnd
, lst1
, LB_GETCURSEL16
, 0, 0);
846 SendDlgItemMessage16(hWnd
, lst1
, LB_GETTEXT16
, lRet
,
847 lpofn
->lpstrFileTitle
);
849 if (FILEDLG_HookCallChk(lpofn
))
851 lRet
= (BOOL16
)FILEDLG_CallWindowProc(lpofn
,
852 hWnd
, RegisterWindowMessage32A( FILEOKSTRING
), 0, lParam
);
855 *lpofn
=ofn2
; /* restore old state */
857 ShowWindow16(hWnd
, SW_SHOW
); /* only if above (%%%) SW_HIDE used */
862 EndDialog32(hWnd
, TRUE
);
865 EndDialog32(hWnd
, FALSE
);
872 /***********************************************************************
873 * FileOpenDlgProc (COMMDLG.6)
875 LRESULT WINAPI
FileOpenDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
878 LPOPENFILENAME16 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
880 if (wMsg
!=WM_INITDIALOG
)
881 if (FILEDLG_HookCallChk(lpofn
))
883 LRESULT lRet
=(BOOL16
)FILEDLG_CallWindowProc(lpofn
,hWnd
,wMsg
,wParam
,lParam
);
885 return lRet
; /* else continue message processing */
890 return FILEDLG_WMInitDialog(hWnd
, wParam
, lParam
);
892 return FILEDLG_WMMeasureItem(hWnd
, wParam
, lParam
);
894 return FILEDLG_WMDrawItem(hWnd
, wParam
, lParam
, FALSE
);
896 return FILEDLG_WMCommand(hWnd
, wParam
, lParam
);
899 SetBkColor((HDC16
)wParam
, 0x00C0C0C0);
900 switch (HIWORD(lParam
))
903 SetTextColor((HDC16
)wParam
, 0x00000000);
905 case CTLCOLOR_STATIC
:
906 SetTextColor((HDC16
)wParam
, 0x00000000);
916 /***********************************************************************
917 * FileSaveDlgProc (COMMDLG.7)
919 LRESULT WINAPI
FileSaveDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
922 LPOPENFILENAME16 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
924 if (wMsg
!=WM_INITDIALOG
)
925 if (FILEDLG_HookCallChk(lpofn
))
927 LRESULT lRet
=(BOOL16
)FILEDLG_CallWindowProc(lpofn
,hWnd
,wMsg
,wParam
,lParam
);
929 return lRet
; /* else continue message processing */
933 return FILEDLG_WMInitDialog(hWnd
, wParam
, lParam
);
936 return FILEDLG_WMMeasureItem(hWnd
, wParam
, lParam
);
939 return FILEDLG_WMDrawItem(hWnd
, wParam
, lParam
, TRUE
);
942 return FILEDLG_WMCommand(hWnd
, wParam
, lParam
);
947 SetBkColor((HDC16)wParam, 0x00C0C0C0);
948 switch (HIWORD(lParam))
951 SetTextColor((HDC16)wParam, 0x00000000);
953 case CTLCOLOR_STATIC:
954 SetTextColor((HDC16)wParam, 0x00000000);
964 /***********************************************************************
965 * FindText16 (COMMDLG.11)
967 HWND16 WINAPI
FindText16( SEGPTR find
)
971 LPFINDREPLACE16 lpFind
= (LPFINDREPLACE16
)PTR_SEG_TO_LIN(find
);
974 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
975 * For now, only the standard dialog works.
977 if (lpFind
->Flags
& (FR_ENABLETEMPLATE
| FR_ENABLETEMPLATEHANDLE
|
978 FR_ENABLEHOOK
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
979 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT
);
980 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
981 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
982 (DLGPROC16
)MODULE_GetWndProcEntry16("FindTextDlgProc"),
986 /***********************************************************************
987 * FindText32A (COMMDLG.6)
989 HWND32 WINAPI
FindText32A( LPFINDREPLACE32A lpFind
)
995 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
996 * For now, only the standard dialog works.
998 if (lpFind
->Flags
& (FR_ENABLETEMPLATE
| FR_ENABLETEMPLATEHANDLE
|
999 FR_ENABLEHOOK
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
1000 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT
);
1001 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
1002 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
1003 (DLGPROC16
)FindTextDlgProc32A
, (LPARAM
)lpFind
, WIN_PROC_32A
);
1006 /***********************************************************************
1007 * FindText32W (COMMDLG.7)
1009 HWND32 WINAPI
FindText32W( LPFINDREPLACE32W lpFind
)
1015 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
1016 * For now, only the standard dialog works.
1018 if (lpFind
->Flags
& (FR_ENABLETEMPLATE
| FR_ENABLETEMPLATEHANDLE
|
1019 FR_ENABLEHOOK
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
1020 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT
);
1021 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
1022 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
1023 (DLGPROC16
)FindTextDlgProc32W
, (LPARAM
)lpFind
, WIN_PROC_32W
);
1026 /***********************************************************************
1027 * ReplaceText16 (COMMDLG.12)
1029 HWND16 WINAPI
ReplaceText16( SEGPTR find
)
1033 LPFINDREPLACE16 lpFind
= (LPFINDREPLACE16
)PTR_SEG_TO_LIN(find
);
1036 * FIXME : We should do error checking on the lpFind structure here
1037 * and make CommDlgExtendedError() return the error condition.
1039 if (lpFind
->Flags
& (FR_ENABLETEMPLATE
| FR_ENABLETEMPLATEHANDLE
|
1040 FR_ENABLEHOOK
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
1041 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT
);
1042 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
1043 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
1044 (DLGPROC16
)MODULE_GetWndProcEntry16("ReplaceTextDlgProc"),
1045 find
, WIN_PROC_16
);
1048 /***********************************************************************
1049 * ReplaceText32A (COMDLG32.19)
1051 HWND32 WINAPI
ReplaceText32A( LPFINDREPLACE32A lpFind
)
1057 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
1058 * For now, only the standard dialog works.
1060 if (lpFind
->Flags
& (FR_ENABLETEMPLATE
| FR_ENABLETEMPLATEHANDLE
|
1061 FR_ENABLEHOOK
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
1062 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT
);
1063 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
1064 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
1065 (DLGPROC16
)ReplaceTextDlgProc32A
, (LPARAM
)lpFind
, WIN_PROC_32A
);
1068 /***********************************************************************
1069 * ReplaceText32W (COMDLG32.20)
1071 HWND32 WINAPI
ReplaceText32W( LPFINDREPLACE32W lpFind
)
1077 * FIXME : We should do error checking on the lpFind structure here
1078 * and make CommDlgExtendedError() return the error condition.
1080 if (lpFind
->Flags
& (FR_ENABLETEMPLATE
| FR_ENABLETEMPLATEHANDLE
|
1081 FR_ENABLEHOOK
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
1082 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT
);
1083 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
1084 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
1085 (DLGPROC16
)ReplaceTextDlgProc32W
, (LPARAM
)lpFind
, WIN_PROC_32W
);
1089 /***********************************************************************
1090 * FINDDLG_WMInitDialog [internal]
1092 static LRESULT
FINDDLG_WMInitDialog(HWND32 hWnd
, LPARAM lParam
, LPDWORD lpFlags
,
1093 LPSTR lpstrFindWhat
, BOOL32 fUnicode
)
1095 SetWindowLong32A(hWnd
, DWL_USER
, lParam
);
1096 *lpFlags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_REPLACEALL
| FR_DIALOGTERM
);
1098 * FIXME : If the initial FindWhat string is empty, we should disable the
1099 * FindNext (IDOK) button. Only after typing some text, the button should be
1102 if (fUnicode
) SetDlgItemText32W(hWnd
, edt1
, (LPWSTR
)lpstrFindWhat
);
1103 else SetDlgItemText32A(hWnd
, edt1
, lpstrFindWhat
);
1104 CheckRadioButton32(hWnd
, rad1
, rad2
, (*lpFlags
& FR_DOWN
) ? rad2
: rad1
);
1105 if (*lpFlags
& (FR_HIDEUPDOWN
| FR_NOUPDOWN
)) {
1106 EnableWindow32(GetDlgItem32(hWnd
, rad1
), FALSE
);
1107 EnableWindow32(GetDlgItem32(hWnd
, rad2
), FALSE
);
1109 if (*lpFlags
& FR_HIDEUPDOWN
) {
1110 ShowWindow32(GetDlgItem32(hWnd
, rad1
), SW_HIDE
);
1111 ShowWindow32(GetDlgItem32(hWnd
, rad2
), SW_HIDE
);
1112 ShowWindow32(GetDlgItem32(hWnd
, grp1
), SW_HIDE
);
1114 CheckDlgButton32(hWnd
, chx1
, (*lpFlags
& FR_WHOLEWORD
) ? 1 : 0);
1115 if (*lpFlags
& (FR_HIDEWHOLEWORD
| FR_NOWHOLEWORD
))
1116 EnableWindow32(GetDlgItem32(hWnd
, chx1
), FALSE
);
1117 if (*lpFlags
& FR_HIDEWHOLEWORD
)
1118 ShowWindow32(GetDlgItem32(hWnd
, chx1
), SW_HIDE
);
1119 CheckDlgButton32(hWnd
, chx2
, (*lpFlags
& FR_MATCHCASE
) ? 1 : 0);
1120 if (*lpFlags
& (FR_HIDEMATCHCASE
| FR_NOMATCHCASE
))
1121 EnableWindow32(GetDlgItem32(hWnd
, chx2
), FALSE
);
1122 if (*lpFlags
& FR_HIDEMATCHCASE
)
1123 ShowWindow32(GetDlgItem32(hWnd
, chx2
), SW_HIDE
);
1124 if (!(*lpFlags
& FR_SHOWHELP
)) {
1125 EnableWindow32(GetDlgItem32(hWnd
, pshHelp
), FALSE
);
1126 ShowWindow32(GetDlgItem32(hWnd
, pshHelp
), SW_HIDE
);
1128 ShowWindow32(hWnd
, SW_SHOWNORMAL
);
1133 /***********************************************************************
1134 * FINDDLG_WMCommand [internal]
1136 static LRESULT
FINDDLG_WMCommand(HWND32 hWnd
, WPARAM32 wParam
,
1137 HWND32 hwndOwner
, LPDWORD lpFlags
,
1138 LPSTR lpstrFindWhat
, WORD wFindWhatLen
,
1141 int uFindReplaceMessage
= RegisterWindowMessage32A( FINDMSGSTRING
);
1142 int uHelpMessage
= RegisterWindowMessage32A( HELPMSGSTRING
);
1147 GetDlgItemText32W(hWnd
, edt1
, (LPWSTR
)lpstrFindWhat
, wFindWhatLen
/2);
1148 else GetDlgItemText32A(hWnd
, edt1
, lpstrFindWhat
, wFindWhatLen
);
1149 if (IsDlgButtonChecked32(hWnd
, rad2
))
1150 *lpFlags
|= FR_DOWN
;
1151 else *lpFlags
&= ~FR_DOWN
;
1152 if (IsDlgButtonChecked32(hWnd
, chx1
))
1153 *lpFlags
|= FR_WHOLEWORD
;
1154 else *lpFlags
&= ~FR_WHOLEWORD
;
1155 if (IsDlgButtonChecked32(hWnd
, chx2
))
1156 *lpFlags
|= FR_MATCHCASE
;
1157 else *lpFlags
&= ~FR_MATCHCASE
;
1158 *lpFlags
&= ~(FR_REPLACE
| FR_REPLACEALL
| FR_DIALOGTERM
);
1159 *lpFlags
|= FR_FINDNEXT
;
1160 SendMessage32A(hwndOwner
, uFindReplaceMessage
, 0,
1161 GetWindowLong32A(hWnd
, DWL_USER
) );
1164 *lpFlags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_REPLACEALL
);
1165 *lpFlags
|= FR_DIALOGTERM
;
1166 SendMessage32A(hwndOwner
, uFindReplaceMessage
, 0,
1167 GetWindowLong32A(hWnd
, DWL_USER
) );
1168 DestroyWindow32(hWnd
);
1171 /* FIXME : should lpfr structure be passed as an argument ??? */
1172 SendMessage32A(hwndOwner
, uHelpMessage
, 0, 0);
1179 /***********************************************************************
1180 * FindTextDlgProc16 (COMMDLG.13)
1182 LRESULT WINAPI
FindTextDlgProc16(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
1185 LPFINDREPLACE16 lpfr
;
1188 lpfr
=(LPFINDREPLACE16
)PTR_SEG_TO_LIN(lParam
);
1189 return FINDDLG_WMInitDialog(hWnd
, lParam
, &(lpfr
->Flags
),
1190 PTR_SEG_TO_LIN(lpfr
->lpstrFindWhat
), FALSE
);
1192 lpfr
=(LPFINDREPLACE16
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
1193 return FINDDLG_WMCommand(hWnd
, wParam
, lpfr
->hwndOwner
,
1194 &lpfr
->Flags
, PTR_SEG_TO_LIN(lpfr
->lpstrFindWhat
),
1195 lpfr
->wFindWhatLen
, FALSE
);
1200 /***********************************************************************
1201 * FindTextDlgProc32A
1203 LRESULT WINAPI
FindTextDlgProc32A(HWND32 hWnd
, UINT32 wMsg
, WPARAM32 wParam
,
1206 LPFINDREPLACE32A lpfr
;
1209 lpfr
=(LPFINDREPLACE32A
)lParam
;
1210 return FINDDLG_WMInitDialog(hWnd
, lParam
, &(lpfr
->Flags
),
1211 lpfr
->lpstrFindWhat
, FALSE
);
1213 lpfr
=(LPFINDREPLACE32A
)GetWindowLong32A(hWnd
, DWL_USER
);
1214 return FINDDLG_WMCommand(hWnd
, wParam
, lpfr
->hwndOwner
,
1215 &lpfr
->Flags
, lpfr
->lpstrFindWhat
, lpfr
->wFindWhatLen
,
1221 /***********************************************************************
1222 * FindTextDlgProc32W
1224 LRESULT WINAPI
FindTextDlgProc32W(HWND32 hWnd
, UINT32 wMsg
, WPARAM32 wParam
,
1227 LPFINDREPLACE32W lpfr
;
1230 lpfr
=(LPFINDREPLACE32W
)lParam
;
1231 return FINDDLG_WMInitDialog(hWnd
, lParam
, &(lpfr
->Flags
),
1232 (LPSTR
)lpfr
->lpstrFindWhat
, TRUE
);
1234 lpfr
=(LPFINDREPLACE32W
)GetWindowLong32A(hWnd
, DWL_USER
);
1235 return FINDDLG_WMCommand(hWnd
, wParam
, lpfr
->hwndOwner
,
1236 &lpfr
->Flags
, (LPSTR
)lpfr
->lpstrFindWhat
, lpfr
->wFindWhatLen
,
1243 /***********************************************************************
1244 * REPLACEDLG_WMInitDialog [internal]
1246 static LRESULT
REPLACEDLG_WMInitDialog(HWND32 hWnd
, LPARAM lParam
,
1247 LPDWORD lpFlags
, LPSTR lpstrFindWhat
,
1248 LPSTR lpstrReplaceWith
, BOOL32 fUnicode
)
1250 SetWindowLong32A(hWnd
, DWL_USER
, lParam
);
1251 *lpFlags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_REPLACEALL
| FR_DIALOGTERM
);
1253 * FIXME : If the initial FindWhat string is empty, we should disable the FinNext /
1254 * Replace / ReplaceAll buttons. Only after typing some text, the buttons should be
1259 SetDlgItemText32W(hWnd
, edt1
, (LPWSTR
)lpstrFindWhat
);
1260 SetDlgItemText32W(hWnd
, edt2
, (LPWSTR
)lpstrReplaceWith
);
1263 SetDlgItemText32A(hWnd
, edt1
, lpstrFindWhat
);
1264 SetDlgItemText32A(hWnd
, edt2
, lpstrReplaceWith
);
1266 CheckDlgButton32(hWnd
, chx1
, (*lpFlags
& FR_WHOLEWORD
) ? 1 : 0);
1267 if (*lpFlags
& (FR_HIDEWHOLEWORD
| FR_NOWHOLEWORD
))
1268 EnableWindow32(GetDlgItem32(hWnd
, chx1
), FALSE
);
1269 if (*lpFlags
& FR_HIDEWHOLEWORD
)
1270 ShowWindow32(GetDlgItem32(hWnd
, chx1
), SW_HIDE
);
1271 CheckDlgButton32(hWnd
, chx2
, (*lpFlags
& FR_MATCHCASE
) ? 1 : 0);
1272 if (*lpFlags
& (FR_HIDEMATCHCASE
| FR_NOMATCHCASE
))
1273 EnableWindow32(GetDlgItem32(hWnd
, chx2
), FALSE
);
1274 if (*lpFlags
& FR_HIDEMATCHCASE
)
1275 ShowWindow32(GetDlgItem32(hWnd
, chx2
), SW_HIDE
);
1276 if (!(*lpFlags
& FR_SHOWHELP
)) {
1277 EnableWindow32(GetDlgItem32(hWnd
, pshHelp
), FALSE
);
1278 ShowWindow32(GetDlgItem32(hWnd
, pshHelp
), SW_HIDE
);
1280 ShowWindow32(hWnd
, SW_SHOWNORMAL
);
1285 /***********************************************************************
1286 * REPLACEDLG_WMCommand [internal]
1288 static LRESULT
REPLACEDLG_WMCommand(HWND32 hWnd
, WPARAM16 wParam
,
1289 HWND32 hwndOwner
, LPDWORD lpFlags
,
1290 LPSTR lpstrFindWhat
, WORD wFindWhatLen
,
1291 LPSTR lpstrReplaceWith
, WORD wReplaceWithLen
,
1294 int uFindReplaceMessage
= RegisterWindowMessage32A( FINDMSGSTRING
);
1295 int uHelpMessage
= RegisterWindowMessage32A( HELPMSGSTRING
);
1301 GetDlgItemText32W(hWnd
, edt1
, (LPWSTR
)lpstrFindWhat
, wFindWhatLen
/2);
1302 GetDlgItemText32W(hWnd
, edt2
, (LPWSTR
)lpstrReplaceWith
, wReplaceWithLen
/2);
1305 GetDlgItemText32A(hWnd
, edt1
, lpstrFindWhat
, wFindWhatLen
);
1306 GetDlgItemText32A(hWnd
, edt2
, lpstrReplaceWith
, wReplaceWithLen
);
1308 if (IsDlgButtonChecked32(hWnd
, chx1
))
1309 *lpFlags
|= FR_WHOLEWORD
;
1310 else *lpFlags
&= ~FR_WHOLEWORD
;
1311 if (IsDlgButtonChecked32(hWnd
, chx2
))
1312 *lpFlags
|= FR_MATCHCASE
;
1313 else *lpFlags
&= ~FR_MATCHCASE
;
1314 *lpFlags
&= ~(FR_REPLACE
| FR_REPLACEALL
| FR_DIALOGTERM
);
1315 *lpFlags
|= FR_FINDNEXT
;
1316 SendMessage32A(hwndOwner
, uFindReplaceMessage
, 0,
1317 GetWindowLong32A(hWnd
, DWL_USER
) );
1320 *lpFlags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_REPLACEALL
);
1321 *lpFlags
|= FR_DIALOGTERM
;
1322 SendMessage32A(hwndOwner
, uFindReplaceMessage
, 0,
1323 GetWindowLong32A(hWnd
, DWL_USER
) );
1324 DestroyWindow32(hWnd
);
1329 GetDlgItemText32W(hWnd
, edt1
, (LPWSTR
)lpstrFindWhat
, wFindWhatLen
/2);
1330 GetDlgItemText32W(hWnd
, edt2
, (LPWSTR
)lpstrReplaceWith
, wReplaceWithLen
/2);
1333 GetDlgItemText32A(hWnd
, edt1
, lpstrFindWhat
, wFindWhatLen
);
1334 GetDlgItemText32A(hWnd
, edt2
, lpstrReplaceWith
, wReplaceWithLen
);
1336 if (IsDlgButtonChecked32(hWnd
, chx1
))
1337 *lpFlags
|= FR_WHOLEWORD
;
1338 else *lpFlags
&= ~FR_WHOLEWORD
;
1339 if (IsDlgButtonChecked32(hWnd
, chx2
))
1340 *lpFlags
|= FR_MATCHCASE
;
1341 else *lpFlags
&= ~FR_MATCHCASE
;
1342 *lpFlags
&= ~(FR_FINDNEXT
| FR_REPLACEALL
| FR_DIALOGTERM
);
1343 *lpFlags
|= FR_REPLACE
;
1344 SendMessage32A(hwndOwner
, uFindReplaceMessage
, 0,
1345 GetWindowLong32A(hWnd
, DWL_USER
) );
1350 GetDlgItemText32W(hWnd
, edt1
, (LPWSTR
)lpstrFindWhat
, wFindWhatLen
/2);
1351 GetDlgItemText32W(hWnd
, edt2
, (LPWSTR
)lpstrReplaceWith
, wReplaceWithLen
/2);
1354 GetDlgItemText32A(hWnd
, edt1
, lpstrFindWhat
, wFindWhatLen
);
1355 GetDlgItemText32A(hWnd
, edt2
, lpstrReplaceWith
, wReplaceWithLen
);
1357 if (IsDlgButtonChecked32(hWnd
, chx1
))
1358 *lpFlags
|= FR_WHOLEWORD
;
1359 else *lpFlags
&= ~FR_WHOLEWORD
;
1360 if (IsDlgButtonChecked32(hWnd
, chx2
))
1361 *lpFlags
|= FR_MATCHCASE
;
1362 else *lpFlags
&= ~FR_MATCHCASE
;
1363 *lpFlags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_DIALOGTERM
);
1364 *lpFlags
|= FR_REPLACEALL
;
1365 SendMessage32A(hwndOwner
, uFindReplaceMessage
, 0,
1366 GetWindowLong32A(hWnd
, DWL_USER
) );
1369 /* FIXME : should lpfr structure be passed as an argument ??? */
1370 SendMessage32A(hwndOwner
, uHelpMessage
, 0, 0);
1377 /***********************************************************************
1378 * ReplaceTextDlgProc16 (COMMDLG.14)
1380 LRESULT WINAPI
ReplaceTextDlgProc16(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
1383 LPFINDREPLACE16 lpfr
;
1386 lpfr
=(LPFINDREPLACE16
)PTR_SEG_TO_LIN(lParam
);
1387 return REPLACEDLG_WMInitDialog(hWnd
, lParam
, &lpfr
->Flags
,
1388 PTR_SEG_TO_LIN(lpfr
->lpstrFindWhat
),
1389 PTR_SEG_TO_LIN(lpfr
->lpstrReplaceWith
), FALSE
);
1391 lpfr
=(LPFINDREPLACE16
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
1392 return REPLACEDLG_WMCommand(hWnd
, wParam
, lpfr
->hwndOwner
,
1393 &lpfr
->Flags
, PTR_SEG_TO_LIN(lpfr
->lpstrFindWhat
),
1394 lpfr
->wFindWhatLen
, PTR_SEG_TO_LIN(lpfr
->lpstrReplaceWith
),
1395 lpfr
->wReplaceWithLen
, FALSE
);
1400 /***********************************************************************
1401 * ReplaceTextDlgProc32A
1403 LRESULT WINAPI
ReplaceTextDlgProc32A(HWND32 hWnd
, UINT32 wMsg
, WPARAM32 wParam
,
1406 LPFINDREPLACE32A lpfr
;
1409 lpfr
=(LPFINDREPLACE32A
)lParam
;
1410 return REPLACEDLG_WMInitDialog(hWnd
, lParam
, &lpfr
->Flags
,
1411 lpfr
->lpstrFindWhat
, lpfr
->lpstrReplaceWith
, FALSE
);
1413 lpfr
=(LPFINDREPLACE32A
)GetWindowLong32A(hWnd
, DWL_USER
);
1414 return REPLACEDLG_WMCommand(hWnd
, wParam
, lpfr
->hwndOwner
,
1415 &lpfr
->Flags
, lpfr
->lpstrFindWhat
, lpfr
->wFindWhatLen
,
1416 lpfr
->lpstrReplaceWith
, lpfr
->wReplaceWithLen
, FALSE
);
1421 /***********************************************************************
1422 * ReplaceTextDlgProc32W
1424 LRESULT WINAPI
ReplaceTextDlgProc32W(HWND32 hWnd
, UINT32 wMsg
, WPARAM32 wParam
,
1427 LPFINDREPLACE32W lpfr
;
1430 lpfr
=(LPFINDREPLACE32W
)lParam
;
1431 return REPLACEDLG_WMInitDialog(hWnd
, lParam
, &lpfr
->Flags
,
1432 (LPSTR
)lpfr
->lpstrFindWhat
, (LPSTR
)lpfr
->lpstrReplaceWith
,
1435 lpfr
=(LPFINDREPLACE32W
)GetWindowLong32A(hWnd
, DWL_USER
);
1436 return REPLACEDLG_WMCommand(hWnd
, wParam
, lpfr
->hwndOwner
,
1437 &lpfr
->Flags
, (LPSTR
)lpfr
->lpstrFindWhat
, lpfr
->wFindWhatLen
,
1438 (LPSTR
)lpfr
->lpstrReplaceWith
, lpfr
->wReplaceWithLen
, TRUE
);
1444 /***********************************************************************
1445 * PrintDlg16 (COMMDLG.20)
1447 BOOL16 WINAPI
PrintDlg16( SEGPTR printdlg
)
1450 BOOL16 bRet
= FALSE
;
1453 LPPRINTDLG16 lpPrint
= (LPPRINTDLG16
)PTR_SEG_TO_LIN(printdlg
);
1455 TRACE(commdlg
,"(%p) -- Flags=%08lX\n", lpPrint
, lpPrint
->Flags
);
1457 if (lpPrint
->Flags
& PD_RETURNDEFAULT
)
1458 /* FIXME: should fill lpPrint->hDevMode and lpPrint->hDevNames here */
1461 if (lpPrint
->Flags
& PD_PRINTSETUP
)
1462 template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT_SETUP
);
1464 template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT
);
1466 hInst
= WIN_GetWindowInstance( lpPrint
->hwndOwner
);
1467 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, TRUE
,
1469 (DLGPROC16
)((lpPrint
->Flags
& PD_PRINTSETUP
) ?
1470 MODULE_GetWndProcEntry16("PrintSetupDlgProc") :
1471 MODULE_GetWndProcEntry16("PrintDlgProc")),
1472 printdlg
, WIN_PROC_16
);
1473 if (hwndDialog
) bRet
= DIALOG_DoDialogBox( hwndDialog
, lpPrint
->hwndOwner
);
1478 /***********************************************************************
1479 * PrintDlg32A (COMDLG32.17)
1481 BOOL32 WINAPI
PrintDlg32A( LPPRINTDLG32A printdlg
)
1483 FIXME(commdlg
, "(%p): stub\n",printdlg
);
1484 /* Altough returning FALSE is theoricaly the right thing
1485 * most programs check for a printer at startup, and if
1486 * none is found popup PrintDlg32A(), if it fails the program
1487 * terminates; by returning TRUE the programs can still run
1488 * as long as no printer related stuff is used
1494 /***********************************************************************
1495 * PrintDlg32W (COMDLG32.18)
1497 BOOL32 WINAPI
PrintDlg32W( LPPRINTDLG32W printdlg
)
1499 FIXME(commdlg
, "empty stub\n" );
1504 /***********************************************************************
1505 * PrintDlgProc (COMMDLG.21)
1507 LRESULT WINAPI
PrintDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
1513 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
1514 ShowWindow16(hWnd
, SW_SHOWNORMAL
);
1520 EndDialog32(hWnd
, TRUE
);
1523 EndDialog32(hWnd
, FALSE
);
1532 /***********************************************************************
1533 * PrintSetupDlgProc (COMMDLG.22)
1535 LRESULT WINAPI
PrintSetupDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
1541 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
1542 ShowWindow16(hWnd
, SW_SHOWNORMAL
);
1547 EndDialog32(hWnd
, TRUE
);
1550 EndDialog32(hWnd
, FALSE
);
1559 /***********************************************************************
1560 * CommDlgExtendedError (COMMDLG.26)
1562 DWORD WINAPI
CommDlgExtendedError(void)
1564 return CommDlgLastError
;
1567 /***********************************************************************
1568 * GetFileTitleA (COMDLG32.8)
1570 short WINAPI
GetFileTitle32A(LPCSTR lpFile
, LPSTR lpTitle
, UINT32 cbBuf
)
1573 TRACE(commdlg
,"(%p %p %d); \n", lpFile
, lpTitle
, cbBuf
);
1574 if (lpFile
== NULL
|| lpTitle
== NULL
)
1576 len
= strlen(lpFile
);
1579 if (strpbrk(lpFile
, "*[]"))
1582 if (lpFile
[len
] == '/' || lpFile
[len
] == '\\' || lpFile
[len
] == ':')
1584 for (i
= len
; i
>= 0; i
--)
1585 if (lpFile
[i
] == '/' || lpFile
[i
] == '\\' || lpFile
[i
] == ':')
1590 TRACE(commdlg
,"---> '%s' \n", &lpFile
[i
]);
1592 len
= strlen(lpFile
+i
)+1;
1596 strncpy(lpTitle
, &lpFile
[i
], len
);
1601 /***********************************************************************
1602 * GetFileTitleA (COMDLG32.8)
1604 short WINAPI
GetFileTitle32W(LPCWSTR lpFile
, LPWSTR lpTitle
, UINT32 cbBuf
)
1606 LPSTR file
= HEAP_strdupWtoA(GetProcessHeap(),0,lpFile
);
1607 LPSTR title
= HeapAlloc(GetProcessHeap(),0,cbBuf
);
1610 ret
= GetFileTitle32A(file
,title
,cbBuf
);
1612 lstrcpynAtoW(lpTitle
,title
,cbBuf
);
1613 HeapFree(GetProcessHeap(),0,file
);
1614 HeapFree(GetProcessHeap(),0,title
);
1617 /***********************************************************************
1618 * GetFileTitle (COMMDLG.27)
1620 short WINAPI
GetFileTitle16(LPCSTR lpFile
, LPSTR lpTitle
, UINT16 cbBuf
)
1622 return GetFileTitle32A(lpFile
,lpTitle
,cbBuf
);
1626 /* ------------------------ Choose Color Dialog --------------------------- */
1628 /***********************************************************************
1629 * ChooseColor (COMMDLG.5)
1631 BOOL16 WINAPI
ChooseColor16(LPCHOOSECOLOR16 lpChCol
)
1634 HANDLE16 hDlgTmpl
= 0;
1635 BOOL16 bRet
= FALSE
, win32Format
= FALSE
;
1639 TRACE(commdlg
,"ChooseColor\n");
1640 if (!lpChCol
) return FALSE
;
1642 if (lpChCol
->Flags
& CC_ENABLETEMPLATEHANDLE
)
1644 if (!(template = LockResource16( lpChCol
->hInstance
)))
1646 CommDlgLastError
= CDERR_LOADRESFAILURE
;
1650 else if (lpChCol
->Flags
& CC_ENABLETEMPLATE
)
1653 if (!(hResInfo
= FindResource16(lpChCol
->hInstance
,
1654 lpChCol
->lpTemplateName
,
1657 CommDlgLastError
= CDERR_FINDRESFAILURE
;
1660 if (!(hDlgTmpl
= LoadResource16( lpChCol
->hInstance
, hResInfo
)) ||
1661 !(template = LockResource16( hDlgTmpl
)))
1663 CommDlgLastError
= CDERR_LOADRESFAILURE
;
1669 template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_COLOR
);
1673 hInst
= WIN_GetWindowInstance( lpChCol
->hwndOwner
);
1674 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, win32Format
,
1676 (DLGPROC16
)MODULE_GetWndProcEntry16("ColorDlgProc"),
1677 (DWORD
)lpChCol
, WIN_PROC_16
);
1678 if (hwndDialog
) bRet
= DIALOG_DoDialogBox( hwndDialog
, lpChCol
->hwndOwner
);
1679 if (hDlgTmpl
) FreeResource16( hDlgTmpl
);
1684 static const COLORREF predefcolors
[6][8]=
1686 { 0x008080FFL
, 0x0080FFFFL
, 0x0080FF80L
, 0x0080FF00L
,
1687 0x00FFFF80L
, 0x00FF8000L
, 0x00C080FFL
, 0x00FF80FFL
},
1688 { 0x000000FFL
, 0x0000FFFFL
, 0x0000FF80L
, 0x0040FF00L
,
1689 0x00FFFF00L
, 0x00C08000L
, 0x00C08080L
, 0x00FF00FFL
},
1691 { 0x00404080L
, 0x004080FFL
, 0x0000FF00L
, 0x00808000L
,
1692 0x00804000L
, 0x00FF8080L
, 0x00400080L
, 0x008000FFL
},
1693 { 0x00000080L
, 0x000080FFL
, 0x00008000L
, 0x00408000L
,
1694 0x00FF0000L
, 0x00A00000L
, 0x00800080L
, 0x00FF0080L
},
1696 { 0x00000040L
, 0x00004080L
, 0x00004000L
, 0x00404000L
,
1697 0x00800000L
, 0x00400000L
, 0x00400040L
, 0x00800040L
},
1698 { 0x00000000L
, 0x00008080L
, 0x00408080L
, 0x00808080L
,
1699 0x00808040L
, 0x00C0C0C0L
, 0x00400040L
, 0x00FFFFFFL
},
1704 LPCHOOSECOLOR16 lpcc
; /* points to public known data structure */
1705 int nextuserdef
; /* next free place in user defined color array */
1706 HDC16 hdcMem
; /* color graph used for BitBlt() */
1707 HBITMAP16 hbmMem
; /* color graph bitmap */
1708 RECT16 fullsize
; /* original dialog window size */
1709 UINT16 msetrgb
; /* # of SETRGBSTRING message (today not used) */
1710 RECT16 old3angle
; /* last position of l-marker */
1711 RECT16 oldcross
; /* last position of color/satuation marker */
1712 BOOL32 updating
; /* to prevent recursive WM_COMMAND/EN_UPDATE procesing */
1715 int l
; /* for temporary storing of hue,sat,lum */
1718 /***********************************************************************
1719 * CC_HSLtoRGB [internal]
1721 static int CC_HSLtoRGB(char c
,int hue
,int sat
,int lum
)
1728 case 'R':if (hue
>80) hue
-=80; else hue
+=160; break;
1729 case 'G':if (hue
>160) hue
-=160; else hue
+=80; break;
1734 maxrgb
=(256*MIN(120,lum
))/120; /* 0 .. 256 */
1740 res
=(hue
-80)* maxrgb
; /* 0...10240 */
1741 res
/=40; /* 0...256 */
1748 res
=(240-hue
)* maxrgb
;
1751 res
=res
-maxrgb
/2; /* -128...128 */
1754 res
=maxrgb
/2 + (sat
*res
) /240; /* 0..256 */
1757 if (lum
>120 && res
<256)
1758 res
+=((lum
-120) * (256-res
))/120;
1760 return MIN(res
,255);
1763 /***********************************************************************
1764 * CC_RGBtoHSL [internal]
1766 static int CC_RGBtoHSL(char c
,int r
,int g
,int b
)
1768 WORD maxi
,mini
,mmsum
,mmdif
,result
=0;
1782 case 'L':mmsum
*=120; /* 0...61200=(255+255)*120 */
1783 result
=mmsum
/255; /* 0...240 */
1786 case 'S':if (!mmsum
)
1789 if (!mini
|| maxi
==255)
1793 result
=mmdif
*240; /* 0...61200=255*240 */
1794 result
/= (mmsum
>255 ? mmsum
=510-mmsum
: mmsum
); /* 0..255 */
1798 case 'H':if (!mmdif
)
1804 iresult
=40*(g
-b
); /* -10200 ... 10200 */
1805 iresult
/=(int)mmdif
; /* -40 .. 40 */
1807 iresult
+=240; /* 0..40 and 200..240 */
1813 iresult
/=(int)mmdif
;
1814 iresult
+=80; /* 40 .. 120 */
1820 iresult
/=(int)mmdif
;
1821 iresult
+=160; /* 120 .. 200 */
1827 return result
; /* is this integer arithmetic precise enough ? */
1832 /***********************************************************************
1833 * CC_MouseCheckPredefColorArray [internal]
1835 static int CC_MouseCheckPredefColorArray(HWND16 hDlg
,int dlgitem
,int rows
,int cols
,
1836 LPARAM lParam
,COLORREF
*cr
)
1839 POINT16 point
= MAKEPOINT16(lParam
);
1843 ClientToScreen16(hDlg
,&point
);
1844 hwnd
=GetDlgItem32(hDlg
,dlgitem
);
1845 GetWindowRect16(hwnd
,&rect
);
1846 if (PtInRect16(&rect
,point
))
1848 dx
=(rect
.right
-rect
.left
)/cols
;
1849 dy
=(rect
.bottom
-rect
.top
)/rows
;
1850 ScreenToClient16(hwnd
,&point
);
1852 if (point
.x
% dx
< (dx
-DISTANCE
) && point
.y
% dy
< (dy
-DISTANCE
))
1856 *cr
=predefcolors
[y
][x
];
1857 /* FIXME: Draw_a_Focus_Rect() */
1864 /***********************************************************************
1865 * CC_MouseCheckUserColorArray [internal]
1867 static int CC_MouseCheckUserColorArray(HWND16 hDlg
,int dlgitem
,int rows
,int cols
,
1868 LPARAM lParam
,COLORREF
*cr
,COLORREF
*crarr
)
1871 POINT16 point
= MAKEPOINT16(lParam
);
1875 ClientToScreen16(hDlg
,&point
);
1876 hwnd
=GetDlgItem32(hDlg
,dlgitem
);
1877 GetWindowRect16(hwnd
,&rect
);
1878 if (PtInRect16(&rect
,point
))
1880 dx
=(rect
.right
-rect
.left
)/cols
;
1881 dy
=(rect
.bottom
-rect
.top
)/rows
;
1882 ScreenToClient16(hwnd
,&point
);
1884 if (point
.x
% dx
< (dx
-DISTANCE
) && point
.y
% dy
< (dy
-DISTANCE
))
1888 *cr
=crarr
[x
+cols
*y
];
1889 /* FIXME: Draw_a_Focus_Rect() */
1899 /* 240 ^...... ^^ 240
1906 /***********************************************************************
1907 * CC_MouseCheckColorGraph [internal]
1909 static int CC_MouseCheckColorGraph(HWND16 hDlg
,int dlgitem
,int *hori
,int *vert
,LPARAM lParam
)
1912 POINT16 point
= MAKEPOINT16(lParam
);
1916 ClientToScreen16(hDlg
,&point
);
1917 hwnd
=GetDlgItem32(hDlg
,dlgitem
);
1918 GetWindowRect16(hwnd
,&rect
);
1919 if (PtInRect16(&rect
,point
))
1921 GetClientRect16(hwnd
,&rect
);
1922 ScreenToClient16(hwnd
,&point
);
1924 x
=(long)point
.x
*MAXHORI
;
1926 y
=(long)(rect
.bottom
-point
.y
)*MAXVERT
;
1938 /***********************************************************************
1939 * CC_MouseCheckResultWindow [internal]
1941 static int CC_MouseCheckResultWindow(HWND16 hDlg
,LPARAM lParam
)
1944 POINT16 point
= MAKEPOINT16(lParam
);
1947 ClientToScreen16(hDlg
,&point
);
1948 hwnd
=GetDlgItem32(hDlg
,0x2c5);
1949 GetWindowRect16(hwnd
,&rect
);
1950 if (PtInRect16(&rect
,point
))
1952 PostMessage16(hDlg
,WM_COMMAND
,0x2c9,0);
1958 /***********************************************************************
1959 * CC_CheckDigitsInEdit [internal]
1961 static int CC_CheckDigitsInEdit(HWND16 hwnd
,int maxval
)
1963 int i
,k
,m
,result
,value
;
1966 GetWindowText32A(hwnd
,buffer
,sizeof(buffer
));
1971 if (buffer
[i
]<'0' || buffer
[i
]>'9')
1973 for (k
=i
+1;k
<=m
;k
++) /* delete bad character */
1975 buffer
[i
]=buffer
[k
];
1983 if (value
>maxval
) /* build a new string */
1985 sprintf(buffer
,"%d",maxval
);
1990 editpos
=SendMessage16(hwnd
,EM_GETSEL16
,0,0);
1991 SetWindowText32A(hwnd
,buffer
);
1992 SendMessage16(hwnd
,EM_SETSEL16
,0,editpos
);
1999 /***********************************************************************
2000 * CC_PaintSelectedColor [internal]
2002 static void CC_PaintSelectedColor(HWND16 hDlg
,COLORREF cr
)
2007 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2c5);
2008 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
2011 GetClientRect16 (hwnd
, &rect
) ;
2012 hBrush
= CreateSolidBrush32(cr
);
2015 hBrush
= SelectObject32 (hdc
, hBrush
) ;
2016 Rectangle32(hdc
, rect
.left
,rect
.top
,rect
.right
/2,rect
.bottom
);
2017 DeleteObject32 (SelectObject32 (hdc
,hBrush
)) ;
2018 hBrush
=CreateSolidBrush32(GetNearestColor32(hdc
,cr
));
2021 hBrush
= SelectObject32 (hdc
, hBrush
) ;
2022 Rectangle32( hdc
, rect
.right
/2-1,rect
.top
,rect
.right
,rect
.bottom
);
2023 DeleteObject32( SelectObject32 (hdc
, hBrush
)) ;
2026 ReleaseDC32(hwnd
,hdc
);
2030 /***********************************************************************
2031 * CC_PaintTriangle [internal]
2033 static void CC_PaintTriangle(HWND16 hDlg
,int y
)
2037 int w
=GetDialogBaseUnits();
2042 HWND16 hwnd
=GetDlgItem32(hDlg
,0x2be);
2043 struct CCPRIVATE
*lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2045 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
2047 GetClientRect16(hwnd
,&rect
);
2051 points
[0].y
=rect
.top
;
2052 points
[0].x
=rect
.right
; /* | /| */
2053 ClientToScreen16(hwnd
,points
); /* | / | */
2054 ScreenToClient16(hDlg
,points
); /* |< | */
2055 oben
=points
[0].y
; /* | \ | */
2057 temp
=(long)height
*(long)y
;
2058 points
[0].y
=oben
+height
-temp
/(long)MAXVERT
;
2059 points
[1].y
=points
[0].y
+w
;
2060 points
[2].y
=points
[0].y
-w
;
2061 points
[2].x
=points
[1].x
=points
[0].x
+ w
;
2063 if (lpp
->old3angle
.left
)
2064 FillRect16(hDC
,&lpp
->old3angle
,GetStockObject32(WHITE_BRUSH
));
2065 lpp
->old3angle
.left
=points
[0].x
;
2066 lpp
->old3angle
.right
=points
[1].x
+1;
2067 lpp
->old3angle
.top
=points
[2].y
-1;
2068 lpp
->old3angle
.bottom
=points
[1].y
+1;
2069 Polygon16(hDC
,points
,3);
2070 ReleaseDC32(hDlg
,hDC
);
2075 /***********************************************************************
2076 * CC_PaintCross [internal]
2078 static void CC_PaintCross(HWND16 hDlg
,int x
,int y
)
2081 int w
=GetDialogBaseUnits();
2082 HWND16 hwnd
=GetDlgItem32(hDlg
,0x2c6);
2083 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2088 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
2090 GetClientRect16(hwnd
,&rect
);
2092 SelectClipRgn32(hDC
,CreateRectRgnIndirect16(&rect
));
2093 hPen
=CreatePen32(PS_SOLID
,2,0);
2094 hPen
=SelectObject32(hDC
,hPen
);
2095 point
.x
=((long)rect
.right
*(long)x
)/(long)MAXHORI
;
2096 point
.y
=rect
.bottom
-((long)rect
.bottom
*(long)y
)/(long)MAXVERT
;
2097 if (lpp
->oldcross
.left
!=lpp
->oldcross
.right
)
2098 BitBlt32(hDC
,lpp
->oldcross
.left
,lpp
->oldcross
.top
,
2099 lpp
->oldcross
.right
-lpp
->oldcross
.left
,
2100 lpp
->oldcross
.bottom
-lpp
->oldcross
.top
,
2101 lpp
->hdcMem
,lpp
->oldcross
.left
,lpp
->oldcross
.top
,SRCCOPY
);
2102 lpp
->oldcross
.left
=point
.x
-w
-1;
2103 lpp
->oldcross
.right
=point
.x
+w
+1;
2104 lpp
->oldcross
.top
=point
.y
-w
-1;
2105 lpp
->oldcross
.bottom
=point
.y
+w
+1;
2107 MoveTo(hDC
,point
.x
-w
,point
.y
);
2108 LineTo32(hDC
,point
.x
+w
,point
.y
);
2109 MoveTo(hDC
,point
.x
,point
.y
-w
);
2110 LineTo32(hDC
,point
.x
,point
.y
+w
);
2111 DeleteObject32(SelectObject32(hDC
,hPen
));
2112 ReleaseDC32(hwnd
,hDC
);
2121 /***********************************************************************
2122 * CC_PrepareColorGraph [internal]
2124 static void CC_PrepareColorGraph(HWND16 hDlg
)
2126 int sdif
,hdif
,xdif
,ydif
,r
,g
,b
,hue
,sat
;
2127 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2c6);
2128 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2132 HCURSOR16 hcursor
=SetCursor16(LoadCursor16(0,IDC_WAIT16
));
2134 GetClientRect16(hwnd
,&client
);
2136 lpp
->hdcMem
= CreateCompatibleDC32(hdc
);
2137 lpp
->hbmMem
= CreateCompatibleBitmap32(hdc
,client
.right
,client
.bottom
);
2138 SelectObject32(lpp
->hdcMem
,lpp
->hbmMem
);
2140 xdif
=client
.right
/XSTEPS
;
2141 ydif
=client
.bottom
/YSTEPS
+1;
2144 for(rect
.left
=hue
=0;hue
<239+hdif
;hue
+=hdif
)
2146 rect
.right
=rect
.left
+xdif
;
2147 rect
.bottom
=client
.bottom
;
2148 for(sat
=0;sat
<240+sdif
;sat
+=sdif
)
2150 rect
.top
=rect
.bottom
-ydif
;
2151 r
=CC_HSLtoRGB('R',hue
,sat
,120);
2152 g
=CC_HSLtoRGB('G',hue
,sat
,120);
2153 b
=CC_HSLtoRGB('B',hue
,sat
,120);
2154 hbrush
=CreateSolidBrush32(RGB(r
,g
,b
));
2155 FillRect16(lpp
->hdcMem
,&rect
,hbrush
);
2156 DeleteObject32(hbrush
);
2157 rect
.bottom
=rect
.top
;
2159 rect
.left
=rect
.right
;
2161 ReleaseDC32(hwnd
,hdc
);
2162 SetCursor16(hcursor
);
2165 /***********************************************************************
2166 * CC_PaintColorGraph [internal]
2168 static void CC_PaintColorGraph(HWND16 hDlg
)
2170 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2c6);
2171 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2174 if (IsWindowVisible32(hwnd
)) /* if full size */
2177 CC_PrepareColorGraph(hDlg
); /* should not be necessary */
2180 GetClientRect16(hwnd
,&rect
);
2182 BitBlt32(hDC
,0,0,rect
.right
,rect
.bottom
,lpp
->hdcMem
,0,0,SRCCOPY
);
2184 WARN(commdlg
,"choose color: hdcMem is not defined\n");
2185 ReleaseDC32(hwnd
,hDC
);
2188 /***********************************************************************
2189 * CC_PaintLumBar [internal]
2191 static void CC_PaintLumBar(HWND16 hDlg
,int hue
,int sat
)
2193 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2be);
2195 int lum
,ldif
,ydif
,r
,g
,b
;
2199 if (IsWindowVisible32(hwnd
))
2202 GetClientRect16(hwnd
,&client
);
2206 ydif
=client
.bottom
/YSTEPS
+1;
2207 for(lum
=0;lum
<240+ldif
;lum
+=ldif
)
2209 rect
.top
=MAX(0,rect
.bottom
-ydif
);
2210 r
=CC_HSLtoRGB('R',hue
,sat
,lum
);
2211 g
=CC_HSLtoRGB('G',hue
,sat
,lum
);
2212 b
=CC_HSLtoRGB('B',hue
,sat
,lum
);
2213 hbrush
=CreateSolidBrush32(RGB(r
,g
,b
));
2214 FillRect16(hDC
,&rect
,hbrush
);
2215 DeleteObject32(hbrush
);
2216 rect
.bottom
=rect
.top
;
2218 GetClientRect16(hwnd
,&rect
);
2219 FrameRect16(hDC
,&rect
,GetStockObject32(BLACK_BRUSH
));
2220 ReleaseDC32(hwnd
,hDC
);
2224 /***********************************************************************
2225 * CC_EditSetRGB [internal]
2227 static void CC_EditSetRGB(HWND16 hDlg
,COLORREF cr
)
2230 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2231 int r
=GetRValue(cr
);
2232 int g
=GetGValue(cr
);
2233 int b
=GetBValue(cr
);
2234 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
2237 sprintf(buffer
,"%d",r
);
2238 SetWindowText32A(GetDlgItem32(hDlg
,0x2c2),buffer
);
2239 sprintf(buffer
,"%d",g
);
2240 SetWindowText32A(GetDlgItem32(hDlg
,0x2c3),buffer
);
2241 sprintf(buffer
,"%d",b
);
2242 SetWindowText32A(GetDlgItem32(hDlg
,0x2c4),buffer
);
2243 lpp
->updating
=FALSE
;
2247 /***********************************************************************
2248 * CC_EditSetHSL [internal]
2250 static void CC_EditSetHSL(HWND16 hDlg
,int h
,int s
,int l
)
2253 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2255 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
2258 sprintf(buffer
,"%d",h
);
2259 SetWindowText32A(GetDlgItem32(hDlg
,0x2bf),buffer
);
2260 sprintf(buffer
,"%d",s
);
2261 SetWindowText32A(GetDlgItem32(hDlg
,0x2c0),buffer
);
2262 sprintf(buffer
,"%d",l
);
2263 SetWindowText32A(GetDlgItem32(hDlg
,0x2c1),buffer
);
2264 lpp
->updating
=FALSE
;
2266 CC_PaintLumBar(hDlg
,h
,s
);
2269 /***********************************************************************
2270 * CC_SwitchToFullSize [internal]
2272 static void CC_SwitchToFullSize(HWND16 hDlg
,COLORREF result
,LPRECT16 lprect
)
2275 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2277 EnableWindow32(GetDlgItem32(hDlg
,0x2cf),FALSE
);
2278 CC_PrepareColorGraph(hDlg
);
2279 for (i
=0x2bf;i
<0x2c5;i
++)
2280 EnableWindow32(GetDlgItem32(hDlg
,i
),TRUE
);
2281 for (i
=0x2d3;i
<0x2d9;i
++)
2282 EnableWindow32(GetDlgItem32(hDlg
,i
),TRUE
);
2283 EnableWindow32(GetDlgItem32(hDlg
,0x2c9),TRUE
);
2284 EnableWindow32(GetDlgItem32(hDlg
,0x2c8),TRUE
);
2287 SetWindowPos32(hDlg
,NULL
,0,0,lprect
->right
-lprect
->left
,
2288 lprect
->bottom
-lprect
->top
, SWP_NOMOVE
|SWP_NOZORDER
);
2290 ShowWindow32(GetDlgItem32(hDlg
,0x2c6),SW_SHOW
);
2291 ShowWindow32(GetDlgItem32(hDlg
,0x2be),SW_SHOW
);
2292 ShowWindow32(GetDlgItem32(hDlg
,0x2c5),SW_SHOW
);
2294 CC_EditSetRGB(hDlg
,result
);
2295 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
2298 /***********************************************************************
2299 * CC_PaintPredefColorArray [internal]
2301 static void CC_PaintPredefColorArray(HWND16 hDlg
,int rows
,int cols
)
2303 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2d0);
2309 GetClientRect16(hwnd
,&rect
);
2311 dy
=rect
.bottom
/rows
;
2315 GetClientRect16 (hwnd
, &rect
) ;
2317 for (j
=0;j
<rows
;j
++)
2319 for (i
=0;i
<cols
;i
++)
2321 hBrush
= CreateSolidBrush32(predefcolors
[j
][i
]);
2324 hBrush
= SelectObject32 (hdc
, hBrush
) ;
2325 Rectangle32(hdc
, rect
.left
, rect
.top
,
2326 rect
.left
+dx
-DISTANCE
, rect
.top
+dy
-DISTANCE
);
2327 rect
.left
=rect
.left
+dx
;
2328 DeleteObject32( SelectObject32 (hdc
, hBrush
)) ;
2331 rect
.top
=rect
.top
+dy
;
2334 ReleaseDC32(hwnd
,hdc
);
2335 /* FIXME: draw_a_focus_rect */
2337 /***********************************************************************
2338 * CC_PaintUserColorArray [internal]
2340 static void CC_PaintUserColorArray(HWND16 hDlg
,int rows
,int cols
,COLORREF
* lpcr
)
2342 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2d1);
2348 GetClientRect16(hwnd
,&rect
);
2351 dy
=rect
.bottom
/rows
;
2357 for (j
=0;j
<rows
;j
++)
2359 for (i
=0;i
<cols
;i
++)
2361 hBrush
= CreateSolidBrush32(lpcr
[i
+j
*cols
]);
2364 hBrush
= SelectObject32 (hdc
, hBrush
) ;
2365 Rectangle32( hdc
, rect
.left
, rect
.top
,
2366 rect
.left
+dx
-DISTANCE
, rect
.top
+dy
-DISTANCE
);
2367 rect
.left
=rect
.left
+dx
;
2368 DeleteObject32( SelectObject32 (hdc
, hBrush
)) ;
2371 rect
.top
=rect
.top
+dy
;
2374 ReleaseDC32(hwnd
,hdc
);
2376 /* FIXME: draw_a_focus_rect */
2381 /***********************************************************************
2382 * CC_HookCallChk [internal]
2384 static BOOL32
CC_HookCallChk(LPCHOOSECOLOR16 lpcc
)
2387 if(lpcc
->Flags
& CC_ENABLEHOOK
)
2393 /***********************************************************************
2394 * CC_WMInitDialog [internal]
2396 static LONG
CC_WMInitDialog(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2402 struct CCPRIVATE
* lpp
;
2404 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
2405 lpp
=calloc(1,sizeof(struct CCPRIVATE
));
2406 lpp
->lpcc
=(LPCHOOSECOLOR16
)lParam
;
2407 if (lpp
->lpcc
->lStructSize
!= sizeof(CHOOSECOLOR16
))
2409 EndDialog32 (hDlg
, 0) ;
2412 SetWindowLong32A(hDlg
, DWL_USER
, (LONG
)lpp
);
2414 if (!(lpp
->lpcc
->Flags
& CC_SHOWHELP
))
2415 ShowWindow32(GetDlgItem32(hDlg
,0x40e),SW_HIDE
);
2416 lpp
->msetrgb
=RegisterWindowMessage32A( SETRGBSTRING
);
2418 cpos
=MAKELONG(5,7); /* init */
2419 if (lpp
->lpcc
->Flags
& CC_RGBINIT
)
2423 if (predefcolors
[i
][j
]==lpp
->lpcc
->rgbResult
)
2430 /* FIXME: Draw_a_focus_rect & set_init_values */
2432 GetWindowRect16(hDlg
,&lpp
->fullsize
);
2433 if (lpp
->lpcc
->Flags
& CC_FULLOPEN
|| lpp
->lpcc
->Flags
& CC_PREVENTFULLOPEN
)
2435 hwnd
=GetDlgItem32(hDlg
,0x2cf);
2436 EnableWindow32(hwnd
,FALSE
);
2438 if (!(lpp
->lpcc
->Flags
& CC_FULLOPEN
) || lpp
->lpcc
->Flags
& CC_PREVENTFULLOPEN
)
2441 res
=rect
.bottom
-rect
.top
;
2442 hwnd
=GetDlgItem32(hDlg
,0x2c6); /* cut at left border */
2444 ClientToScreen16(hwnd
,&point
);
2445 ScreenToClient16(hDlg
,&point
);
2446 GetClientRect16(hDlg
,&rect
);
2447 point
.x
+=GetSystemMetrics32(SM_CXDLGFRAME
);
2448 SetWindowPos32(hDlg
,NULL
,0,0,point
.x
,res
,SWP_NOMOVE
|SWP_NOZORDER
);
2450 ShowWindow32(GetDlgItem32(hDlg
,0x2c6),SW_HIDE
);
2451 ShowWindow32(GetDlgItem32(hDlg
,0x2c5),SW_HIDE
);
2454 CC_SwitchToFullSize(hDlg
,lpp
->lpcc
->rgbResult
,NULL
);
2456 for (i
=0x2bf;i
<0x2c5;i
++)
2457 SendMessage16(GetDlgItem32(hDlg
,i
),EM_LIMITTEXT16
,3,0); /* max 3 digits: xyz */
2458 if (CC_HookCallChk(lpp
->lpcc
))
2459 res
=CallWindowProc16(lpp
->lpcc
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
2463 /***********************************************************************
2464 * CC_WMCommand [internal]
2466 static LRESULT
CC_WMCommand(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2472 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2473 TRACE(commdlg
,"CC_WMCommand wParam=%x lParam=%lx\n",wParam
,lParam
);
2476 case 0x2c2: /* edit notify RGB */
2479 if (HIWORD(lParam
)==EN_UPDATE
&& !lpp
->updating
)
2481 i
=CC_CheckDigitsInEdit(LOWORD(lParam
),255);
2482 r
=GetRValue(lpp
->lpcc
->rgbResult
);
2483 g
=GetGValue(lpp
->lpcc
->rgbResult
);
2484 b
=GetBValue(lpp
->lpcc
->rgbResult
);
2488 case 0x2c2:if ((xx
=(i
!=r
))) r
=i
;break;
2489 case 0x2c3:if ((xx
=(i
!=g
))) g
=i
;break;
2490 case 0x2c4:if ((xx
=(i
!=b
))) b
=i
;break;
2492 if (xx
) /* something has changed */
2494 lpp
->lpcc
->rgbResult
=RGB(r
,g
,b
);
2495 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2496 lpp
->h
=CC_RGBtoHSL('H',r
,g
,b
);
2497 lpp
->s
=CC_RGBtoHSL('S',r
,g
,b
);
2498 lpp
->l
=CC_RGBtoHSL('L',r
,g
,b
);
2499 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
2500 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2501 CC_PaintTriangle(hDlg
,lpp
->l
);
2506 case 0x2bf: /* edit notify HSL */
2509 if (HIWORD(lParam
)==EN_UPDATE
&& !lpp
->updating
)
2511 i
=CC_CheckDigitsInEdit(LOWORD(lParam
),wParam
==0x2bf?239:240);
2515 case 0x2bf:if ((xx
=(i
!=lpp
->h
))) lpp
->h
=i
;break;
2516 case 0x2c0:if ((xx
=(i
!=lpp
->s
))) lpp
->s
=i
;break;
2517 case 0x2c1:if ((xx
=(i
!=lpp
->l
))) lpp
->l
=i
;break;
2519 if (xx
) /* something has changed */
2521 r
=CC_HSLtoRGB('R',lpp
->h
,lpp
->s
,lpp
->l
);
2522 g
=CC_HSLtoRGB('G',lpp
->h
,lpp
->s
,lpp
->l
);
2523 b
=CC_HSLtoRGB('B',lpp
->h
,lpp
->s
,lpp
->l
);
2524 lpp
->lpcc
->rgbResult
=RGB(r
,g
,b
);
2525 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2526 CC_EditSetRGB(hDlg
,lpp
->lpcc
->rgbResult
);
2527 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2528 CC_PaintTriangle(hDlg
,lpp
->l
);
2534 CC_SwitchToFullSize(hDlg
,lpp
->lpcc
->rgbResult
,&lpp
->fullsize
);
2535 InvalidateRect32( hDlg
, NULL
, TRUE
);
2536 SetFocus32(GetDlgItem32(hDlg
,0x2bf));
2539 case 0x2c8: /* add colors ... column by column */
2540 cr
=PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
);
2541 cr
[(lpp
->nextuserdef
%2)*8 + lpp
->nextuserdef
/2]=lpp
->lpcc
->rgbResult
;
2542 if (++lpp
->nextuserdef
==16)
2544 CC_PaintUserColorArray(hDlg
,2,8,PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
));
2547 case 0x2c9: /* resulting color */
2549 lpp
->lpcc
->rgbResult
=GetNearestColor32(hdc
,lpp
->lpcc
->rgbResult
);
2550 ReleaseDC32(hDlg
,hdc
);
2551 CC_EditSetRGB(hDlg
,lpp
->lpcc
->rgbResult
);
2552 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2553 r
=GetRValue(lpp
->lpcc
->rgbResult
);
2554 g
=GetGValue(lpp
->lpcc
->rgbResult
);
2555 b
=GetBValue(lpp
->lpcc
->rgbResult
);
2556 lpp
->h
=CC_RGBtoHSL('H',r
,g
,b
);
2557 lpp
->s
=CC_RGBtoHSL('S',r
,g
,b
);
2558 lpp
->l
=CC_RGBtoHSL('L',r
,g
,b
);
2559 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
2560 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2561 CC_PaintTriangle(hDlg
,lpp
->l
);
2564 case 0x40e: /* Help! */ /* The Beatles, 1965 ;-) */
2565 i
=RegisterWindowMessage32A( HELPMSGSTRING
);
2566 if (lpp
->lpcc
->hwndOwner
)
2567 SendMessage16(lpp
->lpcc
->hwndOwner
,i
,0,(LPARAM
)lpp
->lpcc
);
2568 if (CC_HookCallChk(lpp
->lpcc
))
2569 CallWindowProc16(lpp
->lpcc
->lpfnHook
,hDlg
,
2570 WM_COMMAND
,psh15
,(LPARAM
)lpp
->lpcc
);
2574 cokmsg
=RegisterWindowMessage32A( COLOROKSTRING
);
2575 if (lpp
->lpcc
->hwndOwner
)
2576 if (SendMessage16(lpp
->lpcc
->hwndOwner
,cokmsg
,0,(LPARAM
)lpp
->lpcc
))
2577 break; /* do NOT close */
2579 EndDialog32 (hDlg
, 1) ;
2583 EndDialog32 (hDlg
, 0) ;
2590 /***********************************************************************
2591 * CC_WMPaint [internal]
2593 static LRESULT
CC_WMPaint(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2595 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2596 /* we have to paint dialog children except text and buttons */
2598 CC_PaintPredefColorArray(hDlg
,6,8);
2599 CC_PaintUserColorArray(hDlg
,2,8,PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
));
2600 CC_PaintColorGraph(hDlg
);
2601 CC_PaintLumBar(hDlg
,lpp
->h
,lpp
->s
);
2602 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2603 CC_PaintTriangle(hDlg
,lpp
->l
);
2604 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2606 /* special necessary for Wine */
2607 ValidateRect32(GetDlgItem32(hDlg
,0x2d0),NULL
);
2608 ValidateRect32(GetDlgItem32(hDlg
,0x2d1),NULL
);
2609 ValidateRect32(GetDlgItem32(hDlg
,0x2c6),NULL
);
2610 ValidateRect32(GetDlgItem32(hDlg
,0x2be),NULL
);
2611 ValidateRect32(GetDlgItem32(hDlg
,0x2c5),NULL
);
2612 /* hope we can remove it later -->FIXME */
2617 /***********************************************************************
2618 * CC_WMLButtonDown [internal]
2620 static LRESULT
CC_WMLButtonDown(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2622 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2625 if (CC_MouseCheckPredefColorArray(hDlg
,0x2d0,6,8,lParam
,&lpp
->lpcc
->rgbResult
))
2628 if (CC_MouseCheckUserColorArray(hDlg
,0x2d1,2,8,lParam
,&lpp
->lpcc
->rgbResult
,
2629 PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
)))
2632 if (CC_MouseCheckColorGraph(hDlg
,0x2c6,&lpp
->h
,&lpp
->s
,lParam
))
2635 if (CC_MouseCheckColorGraph(hDlg
,0x2be,NULL
,&lpp
->l
,lParam
))
2639 r
=CC_HSLtoRGB('R',lpp
->h
,lpp
->s
,lpp
->l
);
2640 g
=CC_HSLtoRGB('G',lpp
->h
,lpp
->s
,lpp
->l
);
2641 b
=CC_HSLtoRGB('B',lpp
->h
,lpp
->s
,lpp
->l
);
2642 lpp
->lpcc
->rgbResult
=RGB(r
,g
,b
);
2646 r
=GetRValue(lpp
->lpcc
->rgbResult
);
2647 g
=GetGValue(lpp
->lpcc
->rgbResult
);
2648 b
=GetBValue(lpp
->lpcc
->rgbResult
);
2649 lpp
->h
=CC_RGBtoHSL('H',r
,g
,b
);
2650 lpp
->s
=CC_RGBtoHSL('S',r
,g
,b
);
2651 lpp
->l
=CC_RGBtoHSL('L',r
,g
,b
);
2655 CC_EditSetRGB(hDlg
,lpp
->lpcc
->rgbResult
);
2656 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
2657 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2658 CC_PaintTriangle(hDlg
,lpp
->l
);
2659 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2665 /***********************************************************************
2666 * ColorDlgProc (COMMDLG.8)
2668 LRESULT WINAPI
ColorDlgProc(HWND16 hDlg
, UINT16 message
,
2669 WPARAM16 wParam
, LONG lParam
)
2672 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2673 if (message
!=WM_INITDIALOG
)
2678 if (CC_HookCallChk(lpp
->lpcc
))
2679 res
=CallWindowProc16(lpp
->lpcc
->lpfnHook
,hDlg
,message
,wParam
,lParam
);
2684 /* FIXME: SetRGB message
2685 if (message && message==msetrgb)
2686 return HandleSetRGB(hDlg,lParam);
2692 return CC_WMInitDialog(hDlg
,wParam
,lParam
);
2694 DeleteDC32(lpp
->hdcMem
);
2695 DeleteObject32(lpp
->hbmMem
);
2697 SetWindowLong32A(hDlg
, DWL_USER
, 0L); /* we don't need it anymore */
2700 if (CC_WMCommand(hDlg
, wParam
, lParam
))
2704 CC_WMPaint(hDlg
, wParam
, lParam
);
2706 case WM_LBUTTONDBLCLK
:
2707 if (CC_MouseCheckResultWindow(hDlg
,lParam
))
2710 case WM_MOUSEMOVE
: /* FIXME: calculate new hue,sat,lum (if in color graph) */
2712 case WM_LBUTTONUP
: /* FIXME: ClipCursor off (if in color graph)*/
2714 case WM_LBUTTONDOWN
:/* FIXME: ClipCursor on (if in color graph)*/
2715 if (CC_WMLButtonDown(hDlg
, wParam
, lParam
))
2722 static void CFn_CHOOSEFONT16to32A(LPCHOOSEFONT16 chf16
, LPCHOOSEFONT32A chf32a
)
2724 chf32a
->lStructSize
=sizeof(CHOOSEFONT32A
);
2725 chf32a
->hwndOwner
=chf16
->hwndOwner
;
2726 chf32a
->hDC
=chf16
->hDC
;
2727 chf32a
->iPointSize
=chf16
->iPointSize
;
2728 chf32a
->Flags
=chf16
->Flags
;
2729 chf32a
->rgbColors
=chf16
->rgbColors
;
2730 chf32a
->lCustData
=chf16
->lCustData
;
2731 chf32a
->lpfnHook
=NULL
;
2732 chf32a
->lpTemplateName
=PTR_SEG_TO_LIN(chf16
->lpTemplateName
);
2733 chf32a
->hInstance
=chf16
->hInstance
;
2734 chf32a
->lpszStyle
=PTR_SEG_TO_LIN(chf16
->lpszStyle
);
2735 chf32a
->nFontType
=chf16
->nFontType
;
2736 chf32a
->nSizeMax
=chf16
->nSizeMax
;
2737 chf32a
->nSizeMin
=chf16
->nSizeMin
;
2738 FONT_LogFont16To32A(PTR_SEG_TO_LIN(chf16
->lpLogFont
), chf32a
->lpLogFont
);
2742 /***********************************************************************
2743 * ChooseFont16 (COMMDLG.15)
2745 BOOL16 WINAPI
ChooseFont16(LPCHOOSEFONT16 lpChFont
)
2748 HANDLE16 hDlgTmpl
= 0;
2749 BOOL16 bRet
= FALSE
, win32Format
= FALSE
;
2752 CHOOSEFONT32A cf32a
;
2754 SEGPTR lpTemplateName
;
2756 cf32a
.lpLogFont
=&lf32a
;
2757 CFn_CHOOSEFONT16to32A(lpChFont
, &cf32a
);
2759 TRACE(commdlg
,"ChooseFont\n");
2760 if (!lpChFont
) return FALSE
;
2762 if (lpChFont
->Flags
& CF_ENABLETEMPLATEHANDLE
)
2764 if (!(template = LockResource16( lpChFont
->hInstance
)))
2766 CommDlgLastError
= CDERR_LOADRESFAILURE
;
2770 else if (lpChFont
->Flags
& CF_ENABLETEMPLATE
)
2773 if (!(hResInfo
= FindResource16( lpChFont
->hInstance
,
2774 lpChFont
->lpTemplateName
,
2777 CommDlgLastError
= CDERR_FINDRESFAILURE
;
2780 if (!(hDlgTmpl
= LoadResource16( lpChFont
->hInstance
, hResInfo
)) ||
2781 !(template = LockResource16( hDlgTmpl
)))
2783 CommDlgLastError
= CDERR_LOADRESFAILURE
;
2789 template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT
);
2793 hInst
= WIN_GetWindowInstance( lpChFont
->hwndOwner
);
2795 /* lpTemplateName is not used in the dialog */
2796 lpTemplateName
=lpChFont
->lpTemplateName
;
2797 lpChFont
->lpTemplateName
=(SEGPTR
)&cf32a
;
2799 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, win32Format
,
2800 lpChFont
->hwndOwner
,
2801 (DLGPROC16
)MODULE_GetWndProcEntry16("FormatCharDlgProc"),
2802 (DWORD
)lpChFont
, WIN_PROC_16
);
2803 if (hwndDialog
) bRet
= DIALOG_DoDialogBox(hwndDialog
, lpChFont
->hwndOwner
);
2804 if (hDlgTmpl
) FreeResource16( hDlgTmpl
);
2805 lpChFont
->lpTemplateName
=lpTemplateName
;
2806 FONT_LogFont32ATo16(cf32a
.lpLogFont
,
2807 (LPLOGFONT16
)(PTR_SEG_TO_LIN(lpChFont
->lpLogFont
)));
2812 /***********************************************************************
2813 * ChooseFont32A (COMDLG32.3)
2815 BOOL32 WINAPI
ChooseFont32A(LPCHOOSEFONT32A lpChFont
)
2819 HINSTANCE32 hInst
=WIN_GetWindowInstance( lpChFont
->hwndOwner
);
2820 LPCVOID
template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT
);
2821 if (lpChFont
->Flags
& (CF_SELECTSCRIPT
| CF_NOVERTFONTS
| CF_ENABLETEMPLATE
|
2822 CF_ENABLETEMPLATEHANDLE
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
2823 hwndDialog
= DIALOG_CreateIndirect(hInst
, template, TRUE
, lpChFont
->hwndOwner
,
2824 (DLGPROC16
)FormatCharDlgProc32A
, (LPARAM
)lpChFont
, WIN_PROC_32A
);
2825 if (hwndDialog
) bRet
= DIALOG_DoDialogBox(hwndDialog
, lpChFont
->hwndOwner
);
2829 /***********************************************************************
2830 * ChooseFont32W (COMDLG32.4)
2832 BOOL32 WINAPI
ChooseFont32W(LPCHOOSEFONT32W lpChFont
)
2836 HINSTANCE32 hInst
=WIN_GetWindowInstance( lpChFont
->hwndOwner
);
2837 CHOOSEFONT32A cf32a
;
2839 LPCVOID
template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT
);
2840 if (lpChFont
->Flags
& (CF_SELECTSCRIPT
| CF_NOVERTFONTS
| CF_ENABLETEMPLATE
|
2841 CF_ENABLETEMPLATEHANDLE
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
2842 memcpy(&cf32a
, lpChFont
, sizeof(cf32a
));
2843 memcpy(&lf32a
, lpChFont
->lpLogFont
, sizeof(LOGFONT32A
));
2844 lstrcpynWtoA(lf32a
.lfFaceName
, lpChFont
->lpLogFont
->lfFaceName
, LF_FACESIZE
);
2845 cf32a
.lpLogFont
=&lf32a
;
2846 cf32a
.lpszStyle
=HEAP_strdupWtoA(GetProcessHeap(), 0, lpChFont
->lpszStyle
);
2847 lpChFont
->lpTemplateName
=(LPWSTR
)&cf32a
;
2848 hwndDialog
=DIALOG_CreateIndirect(hInst
, template, TRUE
, lpChFont
->hwndOwner
,
2849 (DLGPROC16
)FormatCharDlgProc32W
, (LPARAM
)lpChFont
, WIN_PROC_32W
);
2850 if (hwndDialog
)bRet
=DIALOG_DoDialogBox(hwndDialog
, lpChFont
->hwndOwner
);
2851 HeapFree(GetProcessHeap(), 0, cf32a
.lpszStyle
);
2852 lpChFont
->lpTemplateName
=(LPWSTR
)cf32a
.lpTemplateName
;
2853 memcpy(lpChFont
->lpLogFont
, &lf32a
, sizeof(CHOOSEFONT32A
));
2854 lstrcpynAtoW(lpChFont
->lpLogFont
->lfFaceName
, lf32a
.lfFaceName
, LF_FACESIZE
);
2859 #define TEXT_EXTRAS 4
2860 #define TEXT_COLORS 16
2862 static const COLORREF textcolors
[TEXT_COLORS
]=
2864 0x00000000L
,0x00000080L
,0x00008000L
,0x00008080L
,
2865 0x00800000L
,0x00800080L
,0x00808000L
,0x00808080L
,
2866 0x00c0c0c0L
,0x000000ffL
,0x0000ff00L
,0x0000ffffL
,
2867 0x00ff0000L
,0x00ff00ffL
,0x00ffff00L
,0x00FFFFFFL
2870 /***********************************************************************
2871 * CFn_HookCallChk [internal]
2873 static BOOL32
CFn_HookCallChk(LPCHOOSEFONT16 lpcf
)
2876 if(lpcf
->Flags
& CF_ENABLEHOOK
)
2882 /***********************************************************************
2883 * CFn_HookCallChk32 [internal]
2885 static BOOL32
CFn_HookCallChk32(LPCHOOSEFONT32A lpcf
)
2888 if(lpcf
->Flags
& CF_ENABLEHOOK
)
2895 /*************************************************************************
2896 * AddFontFamily [internal]
2898 static INT32
AddFontFamily(LPLOGFONT32A lplf
, UINT32 nFontType
,
2899 LPCHOOSEFONT32A lpcf
, HWND32 hwnd
)
2904 TRACE(commdlg
,"font=%s (nFontType=%d)\n", lplf
->lfFaceName
,nFontType
);
2906 if (lpcf
->Flags
& CF_FIXEDPITCHONLY
)
2907 if (!(lplf
->lfPitchAndFamily
& FIXED_PITCH
))
2909 if (lpcf
->Flags
& CF_ANSIONLY
)
2910 if (lplf
->lfCharSet
!= ANSI_CHARSET
)
2912 if (lpcf
->Flags
& CF_TTONLY
)
2913 if (!(nFontType
& TRUETYPE_FONTTYPE
))
2916 i
=SendMessage32A(hwnd
, CB_ADDSTRING32
, 0, (LPARAM
)lplf
->lfFaceName
);
2919 w
=(lplf
->lfCharSet
<< 8) | lplf
->lfPitchAndFamily
;
2920 SendMessage32A(hwnd
, CB_SETITEMDATA32
, i
, MAKELONG(nFontType
,w
));
2921 return 1 ; /* store some important font information */
2931 LPCHOOSEFONT32A lpcf32a
;
2932 } CFn_ENUMSTRUCT
, *LPCFn_ENUMSTRUCT
;
2934 /*************************************************************************
2935 * FontFamilyEnumProc32 [internal]
2937 INT32 WINAPI
FontFamilyEnumProc32(LPENUMLOGFONT32A lpEnumLogFont
,
2938 LPNEWTEXTMETRIC32A metrics
, UINT32 nFontType
, LPARAM lParam
)
2941 e
=(LPCFn_ENUMSTRUCT
)lParam
;
2942 return AddFontFamily(&lpEnumLogFont
->elfLogFont
, nFontType
, e
->lpcf32a
, e
->hWnd1
);
2945 /***********************************************************************
2946 * FontFamilyEnumProc16 (COMMDLG.19)
2948 INT16 WINAPI
FontFamilyEnumProc16( SEGPTR logfont
, SEGPTR metrics
,
2949 UINT16 nFontType
, LPARAM lParam
)
2951 HWND16 hwnd
=LOWORD(lParam
);
2952 HWND16 hDlg
=GetParent16(hwnd
);
2953 LPCHOOSEFONT16 lpcf
=(LPCHOOSEFONT16
)GetWindowLong32A(hDlg
, DWL_USER
);
2954 LOGFONT16
*lplf
= (LOGFONT16
*)PTR_SEG_TO_LIN( logfont
);
2956 FONT_LogFont16To32A(lplf
, &lf32a
);
2957 return AddFontFamily(&lf32a
, nFontType
, (LPCHOOSEFONT32A
)lpcf
->lpTemplateName
,
2961 /*************************************************************************
2962 * SetFontStylesToCombo2 [internal]
2964 * Fill font style information into combobox (without using font.c directly)
2966 static int SetFontStylesToCombo2(HWND32 hwnd
, HDC32 hdc
, LPLOGFONT32A lplf
)
2973 static struct FONTSTYLE fontstyles
[FSTYLES
]={
2974 { 0,FW_NORMAL
,"Regular"},{0,FW_BOLD
,"Bold"},
2975 { 1,FW_NORMAL
,"Italic"}, {1,FW_BOLD
,"Bold Italic"}};
2980 for (i
=0;i
<FSTYLES
;i
++)
2982 lplf
->lfItalic
=fontstyles
[i
].italic
;
2983 lplf
->lfWeight
=fontstyles
[i
].weight
;
2984 hf
=CreateFontIndirect32A(lplf
);
2985 hf
=SelectObject32(hdc
,hf
);
2986 GetTextMetrics16(hdc
,&tm
);
2987 hf
=SelectObject32(hdc
,hf
);
2990 if (tm
.tmWeight
==fontstyles
[i
].weight
&&
2991 tm
.tmItalic
==fontstyles
[i
].italic
) /* font successful created ? */
2993 char *str
= SEGPTR_STRDUP(fontstyles
[i
].stname
);
2994 j
=SendMessage16(hwnd
,CB_ADDSTRING16
,0,(LPARAM
)SEGPTR_GET(str
) );
2996 if (j
==CB_ERR
) return 1;
2997 j
=SendMessage16(hwnd
, CB_SETITEMDATA16
, j
,
2998 MAKELONG(fontstyles
[i
].weight
,fontstyles
[i
].italic
));
2999 if (j
==CB_ERR
) return 1;
3005 /*************************************************************************
3006 * AddFontSizeToCombo3 [internal]
3008 static int AddFontSizeToCombo3(HWND32 hwnd
, UINT32 h
, LPCHOOSEFONT32A lpcf
)
3013 if ( (!(lpcf
->Flags
& CF_LIMITSIZE
)) ||
3014 ((lpcf
->Flags
& CF_LIMITSIZE
) && (h
>= lpcf
->nSizeMin
) && (h
<= lpcf
->nSizeMax
)))
3016 sprintf(buffer
, "%2d", h
);
3017 j
=SendMessage32A(hwnd
, CB_FINDSTRINGEXACT32
, -1, (LPARAM
)buffer
);
3020 j
=SendMessage32A(hwnd
, CB_ADDSTRING32
, 0, (LPARAM
)buffer
);
3021 if (j
!=CB_ERR
) j
= SendMessage32A(hwnd
, CB_SETITEMDATA32
, j
, h
);
3022 if (j
==CB_ERR
) return 1;
3028 /*************************************************************************
3029 * SetFontSizesToCombo3 [internal]
3031 static int SetFontSizesToCombo3(HWND32 hwnd
, LPCHOOSEFONT32A lpcf
)
3033 static const int sizes
[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72,0};
3036 for (i
=0; sizes
[i
]; i
++)
3037 if (AddFontSizeToCombo3(hwnd
, sizes
[i
], lpcf
)) return 1;
3041 /***********************************************************************
3042 * AddFontStyle [internal]
3044 INT32
AddFontStyle(LPLOGFONT32A lplf
, UINT32 nFontType
,
3045 LPCHOOSEFONT32A lpcf
, HWND32 hcmb2
, HWND32 hcmb3
, HWND32 hDlg
)
3049 TRACE(commdlg
,"(nFontType=%d)\n",nFontType
);
3050 TRACE(commdlg
," %s h=%d w=%d e=%d o=%d wg=%d i=%d u=%d s=%d"
3051 " ch=%d op=%d cp=%d q=%d pf=%xh\n",
3052 lplf
->lfFaceName
,lplf
->lfHeight
,lplf
->lfWidth
,
3053 lplf
->lfEscapement
,lplf
->lfOrientation
,
3054 lplf
->lfWeight
,lplf
->lfItalic
,lplf
->lfUnderline
,
3055 lplf
->lfStrikeOut
,lplf
->lfCharSet
, lplf
->lfOutPrecision
,
3056 lplf
->lfClipPrecision
,lplf
->lfQuality
, lplf
->lfPitchAndFamily
);
3057 if (nFontType
& RASTER_FONTTYPE
)
3059 if (AddFontSizeToCombo3(hcmb3
, lplf
->lfHeight
, lpcf
)) return 0;
3060 } else if (SetFontSizesToCombo3(hcmb3
, lpcf
)) return 0;
3062 if (!SendMessage32A(hcmb2
, CB_GETCOUNT32
, 0, 0))
3064 HDC32 hdc
= (lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
) ? lpcf
->hDC
: GetDC32(hDlg
);
3065 i
=SetFontStylesToCombo2(hcmb2
,hdc
,lplf
);
3066 if (!(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
))
3067 ReleaseDC32(hDlg
,hdc
);
3075 /***********************************************************************
3076 * FontStyleEnumProc16 (COMMDLG.18)
3078 INT16 WINAPI
FontStyleEnumProc16( SEGPTR logfont
, SEGPTR metrics
,
3079 UINT16 nFontType
, LPARAM lParam
)
3081 HWND16 hcmb2
=LOWORD(lParam
);
3082 HWND16 hcmb3
=HIWORD(lParam
);
3083 HWND16 hDlg
=GetParent16(hcmb3
);
3084 LPCHOOSEFONT16 lpcf
=(LPCHOOSEFONT16
)GetWindowLong32A(hDlg
, DWL_USER
);
3085 LOGFONT16
*lplf
= (LOGFONT16
*)PTR_SEG_TO_LIN(logfont
);
3087 FONT_LogFont16To32A(lplf
, &lf32a
);
3088 return AddFontStyle(&lf32a
, nFontType
, (LPCHOOSEFONT32A
)lpcf
->lpTemplateName
,
3089 hcmb2
, hcmb3
, hDlg
);
3092 /***********************************************************************
3093 * FontStyleEnumProc32 [internal]
3095 INT32 WINAPI
FontStyleEnumProc32( LPENUMLOGFONT32A lpFont
,
3096 LPNEWTEXTMETRIC32A metrics
, UINT32 nFontType
, LPARAM lParam
)
3098 LPCFn_ENUMSTRUCT s
=(LPCFn_ENUMSTRUCT
)lParam
;
3099 HWND32 hcmb2
=s
->hWnd1
;
3100 HWND32 hcmb3
=s
->hWnd2
;
3101 HWND32 hDlg
=GetParent32(hcmb3
);
3102 return AddFontStyle(&lpFont
->elfLogFont
, nFontType
, s
->lpcf32a
, hcmb2
,
3106 /***********************************************************************
3107 * CFn_WMInitDialog [internal]
3109 LRESULT
CFn_WMInitDialog(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
,
3110 LPCHOOSEFONT32A lpcf
)
3116 HCURSOR32 hcursor
=SetCursor32(LoadCursor32A(0,IDC_WAIT32A
));
3118 SetWindowLong32A(hDlg
, DWL_USER
, lParam
);
3119 lpxx
=lpcf
->lpLogFont
;
3120 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
3122 if (lpcf
->lStructSize
!= sizeof(CHOOSEFONT32A
))
3124 ERR(commdlg
,"structure size failure !!!\n");
3125 EndDialog32 (hDlg
, 0);
3129 hBitmapTT
= LoadBitmap32A(0, MAKEINTRESOURCE32A(OBM_TRTYPE
));
3131 /* This font will be deleted by WM_COMMAND */
3132 SendDlgItemMessage32A(hDlg
,stc6
,WM_SETFONT
,
3133 CreateFont32A(0, 0, 1, 1, 400, 0, 0, 0, 0, 0, 0, 0, 0, NULL
),FALSE
);
3135 if (!(lpcf
->Flags
& CF_SHOWHELP
) || !IsWindow32(lpcf
->hwndOwner
))
3136 ShowWindow32(GetDlgItem32(hDlg
,pshHelp
),SW_HIDE
);
3137 if (!(lpcf
->Flags
& CF_APPLY
))
3138 ShowWindow32(GetDlgItem32(hDlg
,psh3
),SW_HIDE
);
3139 if (lpcf
->Flags
& CF_EFFECTS
)
3141 for (res
=1,i
=0;res
&& i
<TEXT_COLORS
;i
++)
3143 /* FIXME: load color name from resource: res=LoadString(...,i+....,buffer,.....); */
3145 strcpy( name
, "[color name]" );
3146 j
=SendDlgItemMessage32A(hDlg
, cmb4
, CB_ADDSTRING32
, 0, (LPARAM
)name
);
3147 SendDlgItemMessage32A(hDlg
, cmb4
, CB_SETITEMDATA16
, j
, textcolors
[j
]);
3148 /* look for a fitting value in color combobox */
3149 if (textcolors
[j
]==lpcf
->rgbColors
)
3150 SendDlgItemMessage32A(hDlg
,cmb4
, CB_SETCURSEL32
,j
,0);
3155 ShowWindow32(GetDlgItem32(hDlg
,cmb4
),SW_HIDE
);
3156 ShowWindow32(GetDlgItem32(hDlg
,chx1
),SW_HIDE
);
3157 ShowWindow32(GetDlgItem32(hDlg
,chx2
),SW_HIDE
);
3158 ShowWindow32(GetDlgItem32(hDlg
,grp1
),SW_HIDE
);
3159 ShowWindow32(GetDlgItem32(hDlg
,stc4
),SW_HIDE
);
3161 hdc
= (lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
) ? lpcf
->hDC
: GetDC32(hDlg
);
3165 s
.hWnd1
=GetDlgItem32(hDlg
,cmb1
);
3167 if (!EnumFontFamilies32A(hdc
, NULL
, FontFamilyEnumProc32
, (LPARAM
)&s
))
3168 TRACE(commdlg
,"EnumFontFamilies returns 0\n");
3169 if (lpcf
->Flags
& CF_INITTOLOGFONTSTRUCT
)
3171 /* look for fitting font name in combobox1 */
3172 j
=SendDlgItemMessage32A(hDlg
,cmb1
,CB_FINDSTRING32
,-1,(LONG
)lpxx
->lfFaceName
);
3175 SendDlgItemMessage32A(hDlg
, cmb1
, CB_SETCURSEL32
, j
, 0);
3176 SendMessage32A(hDlg
, WM_COMMAND
, MAKEWPARAM(cmb1
, CBN_SELCHANGE
),
3177 GetDlgItem32(hDlg
,cmb1
));
3179 /* look for fitting font style in combobox2 */
3180 l
=MAKELONG(lpxx
->lfWeight
> FW_MEDIUM
? FW_BOLD
:FW_NORMAL
,lpxx
->lfItalic
!=0);
3181 for (i
=0;i
<TEXT_EXTRAS
;i
++)
3183 if (l
==SendDlgItemMessage32A(hDlg
, cmb2
, CB_GETITEMDATA32
, i
, 0))
3184 SendDlgItemMessage32A(hDlg
, cmb2
, CB_SETCURSEL32
, i
, 0);
3187 /* look for fitting font size in combobox3 */
3188 j
=SendDlgItemMessage32A(hDlg
, cmb3
, CB_GETCOUNT32
, 0, 0);
3191 if (lpxx
->lfHeight
==(int)SendDlgItemMessage32A(hDlg
,cmb3
, CB_GETITEMDATA32
,i
,0))
3192 SendDlgItemMessage32A(hDlg
,cmb3
,CB_SETCURSEL32
,i
,0);
3198 SendDlgItemMessage32A(hDlg
,cmb1
,CB_SETCURSEL32
,0,0);
3199 SendMessage32A(hDlg
, WM_COMMAND
, MAKEWPARAM(cmb1
, CBN_SELCHANGE
),
3200 GetDlgItem32(hDlg
,cmb1
));
3202 if (lpcf
->Flags
& CF_USESTYLE
&& lpcf
->lpszStyle
)
3204 j
=SendDlgItemMessage32A(hDlg
,cmb2
,CB_FINDSTRING32
,-1,(LONG
)lpcf
->lpszStyle
);
3207 j
=SendDlgItemMessage32A(hDlg
,cmb2
,CB_SETCURSEL32
,j
,0);
3208 SendMessage32A(hDlg
,WM_COMMAND
,cmb2
,
3209 MAKELONG(GetDlgItem32(hDlg
,cmb2
),CBN_SELCHANGE
));
3215 WARN(commdlg
,"HDC failure !!!\n");
3216 EndDialog32 (hDlg
, 0);
3220 if (!(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
))
3221 ReleaseDC32(hDlg
,hdc
);
3222 SetCursor32(hcursor
);
3227 /***********************************************************************
3228 * CFn_WMMeasureItem [internal]
3230 LRESULT
CFn_WMMeasureItem(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
)
3233 LPMEASUREITEMSTRUCT32 lpmi
=(LPMEASUREITEMSTRUCT32
)lParam
;
3235 hBitmapTT
= LoadBitmap32A(0, MAKEINTRESOURCE32A(OBM_TRTYPE
));
3236 GetObject32A( hBitmapTT
, sizeof(bm
), &bm
);
3237 lpmi
->itemHeight
=bm
.bmHeight
;
3238 /* FIXME: use MAX of bm.bmHeight and tm.tmHeight .*/
3243 /***********************************************************************
3244 * CFn_WMDrawItem [internal]
3246 LRESULT
CFn_WMDrawItem(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
)
3251 COLORREF cr
, oldText
=0, oldBk
=0;
3256 HBITMAP32 hBitmap
; /* for later TT usage */
3258 LPDRAWITEMSTRUCT32 lpdi
= (LPDRAWITEMSTRUCT32
)lParam
;
3260 if (lpdi
->itemID
== 0xFFFF) /* got no items */
3261 DrawFocusRect32(lpdi
->hDC
, &lpdi
->rcItem
);
3264 if (lpdi
->CtlType
== ODT_COMBOBOX
)
3266 if (lpdi
->itemState
==ODS_SELECTED
)
3268 hBrush
=GetSysColorBrush32(COLOR_HIGHLIGHT
);
3269 oldText
=SetTextColor32(lpdi
->hDC
, GetSysColor32(COLOR_HIGHLIGHTTEXT
));
3270 oldBk
=SetBkColor32(lpdi
->hDC
, GetSysColor32(COLOR_HIGHLIGHT
));
3273 hBrush
= SelectObject32(lpdi
->hDC
, GetStockObject32(LTGRAY_BRUSH
));
3274 SelectObject32(lpdi
->hDC
, hBrush
);
3276 FillRect32(lpdi
->hDC
, &lpdi
->rcItem
, hBrush
);
3279 return TRUE
; /* this should never happen */
3282 switch (lpdi
->CtlID
)
3284 case cmb1
: /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
3285 SendMessage32A(lpdi
->hwndItem
, CB_GETLBTEXT32
, lpdi
->itemID
,
3287 GetObject32A( hBitmapTT
, sizeof(bm
), &bm
);
3288 TextOut32A(lpdi
->hDC
, lpdi
->rcItem
.left
+ bm
.bmWidth
+ 10,
3289 lpdi
->rcItem
.top
, buffer
, lstrlen32A(buffer
));
3291 nFontType
= SendMessage32A(lpdi
->hwndItem
, CB_GETITEMDATA32
, lpdi
->itemID
,0L);
3292 /* FIXME: draw bitmap if truetype usage */
3293 if (nFontType
&TRUETYPE_FONTTYPE
)
3295 hMemDC
= CreateCompatibleDC32(lpdi
->hDC
);
3296 hBitmap
= SelectObject32(hMemDC
, hBitmapTT
);
3297 BitBlt32(lpdi
->hDC
, lpdi
->rcItem
.left
, lpdi
->rcItem
.top
,
3298 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
3299 SelectObject32(hMemDC
, hBitmap
);
3305 case cmb3
: /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
3306 SendMessage32A(lpdi
->hwndItem
, CB_GETLBTEXT32
, lpdi
->itemID
,
3308 TextOut32A(lpdi
->hDC
, lpdi
->rcItem
.left
,
3309 lpdi
->rcItem
.top
, buffer
, lstrlen32A(buffer
));
3312 case cmb4
: /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
3313 SendMessage32A(lpdi
->hwndItem
, CB_GETLBTEXT32
, lpdi
->itemID
,
3315 TextOut32A(lpdi
->hDC
, lpdi
->rcItem
.left
+ 25+5,
3316 lpdi
->rcItem
.top
, buffer
, lstrlen32A(buffer
));
3317 cr
= SendMessage32A(lpdi
->hwndItem
, CB_GETITEMDATA32
, lpdi
->itemID
,0L);
3318 hBrush
= CreateSolidBrush32(cr
);
3321 hBrush
= SelectObject32 (lpdi
->hDC
, hBrush
) ;
3322 rect
.right
=rect
.left
+25;
3326 Rectangle32( lpdi
->hDC
, rect
.left
, rect
.top
,
3327 rect
.right
, rect
.bottom
);
3328 DeleteObject32( SelectObject32 (lpdi
->hDC
, hBrush
)) ;
3334 default: return TRUE
; /* this should never happen */
3336 if (lpdi
->itemState
== ODS_SELECTED
)
3338 SetTextColor32(lpdi
->hDC
, oldText
);
3339 SetBkColor32(lpdi
->hDC
, oldBk
);
3345 /***********************************************************************
3346 * CFn_WMCtlColor [internal]
3348 LRESULT
CFn_WMCtlColorStatic(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
,
3349 LPCHOOSEFONT32A lpcf
)
3351 if (lpcf
->Flags
& CF_EFFECTS
)
3352 if (GetDlgCtrlID32(lParam
)==stc6
)
3354 SetTextColor32((HDC32
)wParam
, lpcf
->rgbColors
);
3355 return GetStockObject32(WHITE_BRUSH
);
3360 /***********************************************************************
3361 * CFn_WMCommand [internal]
3363 LRESULT
CFn_WMCommand(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
,
3364 LPCHOOSEFONT32A lpcf
)
3370 LPLOGFONT32A lpxx
=lpcf
->lpLogFont
;
3372 TRACE(commdlg
,"WM_COMMAND wParam=%08lX lParam=%08lX\n", (LONG
)wParam
, lParam
);
3373 switch (LOWORD(wParam
))
3375 case cmb1
:if (HIWORD(wParam
)==CBN_SELCHANGE
)
3377 hdc
=(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
) ? lpcf
->hDC
: GetDC32(hDlg
);
3380 SendDlgItemMessage32A(hDlg
, cmb2
, CB_RESETCONTENT16
, 0, 0);
3381 SendDlgItemMessage32A(hDlg
, cmb3
, CB_RESETCONTENT16
, 0, 0);
3382 i
=SendDlgItemMessage32A(hDlg
, cmb1
, CB_GETCURSEL16
, 0, 0);
3385 HCURSOR32 hcursor
=SetCursor32(LoadCursor32A(0,IDC_WAIT32A
));
3388 SendDlgItemMessage32A(hDlg
, cmb1
, CB_GETLBTEXT32
, i
,
3390 TRACE(commdlg
,"WM_COMMAND/cmb1 =>%s\n",str
);
3391 s
.hWnd1
=GetDlgItem32(hDlg
, cmb2
);
3392 s
.hWnd2
=GetDlgItem32(hDlg
, cmb3
);
3394 EnumFontFamilies32A(hdc
, str
, FontStyleEnumProc32
, (LPARAM
)&s
);
3395 SetCursor32(hcursor
);
3397 if (!(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
))
3398 ReleaseDC32(hDlg
,hdc
);
3402 WARN(commdlg
,"HDC failure !!!\n");
3403 EndDialog32 (hDlg
, 0);
3410 case cmb3
:if (HIWORD(wParam
)==CBN_SELCHANGE
|| HIWORD(wParam
)== BN_CLICKED
)
3413 TRACE(commdlg
,"WM_COMMAND/cmb2,3 =%08lX\n", lParam
);
3414 i
=SendDlgItemMessage32A(hDlg
,cmb1
,CB_GETCURSEL32
,0,0);
3416 i
=GetDlgItemText32A( hDlg
, cmb1
, str
, 256 );
3419 SendDlgItemMessage32A(hDlg
,cmb1
,CB_GETLBTEXT32
,i
,
3421 l
=SendDlgItemMessage32A(hDlg
,cmb1
,CB_GETITEMDATA32
,i
,0);
3423 lpcf
->nFontType
= LOWORD(l
);
3424 /* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */
3425 /* same value reported to the EnumFonts
3426 call back with the extra FONTTYPE_... bits added */
3427 lpxx
->lfPitchAndFamily
=j
&0xff;
3428 lpxx
->lfCharSet
=j
>>8;
3430 strcpy(lpxx
->lfFaceName
,str
);
3431 i
=SendDlgItemMessage32A(hDlg
, cmb2
, CB_GETCURSEL32
, 0, 0);
3434 l
=SendDlgItemMessage32A(hDlg
, cmb2
, CB_GETITEMDATA32
, i
, 0);
3435 if (0!=(lpxx
->lfItalic
=HIWORD(l
)))
3436 lpcf
->nFontType
|= ITALIC_FONTTYPE
;
3437 if ((lpxx
->lfWeight
=LOWORD(l
)) > FW_MEDIUM
)
3438 lpcf
->nFontType
|= BOLD_FONTTYPE
;
3440 i
=SendDlgItemMessage32A(hDlg
, cmb3
, CB_GETCURSEL32
, 0, 0);
3442 lpxx
->lfHeight
=-LOWORD(SendDlgItemMessage32A(hDlg
, cmb3
, CB_GETITEMDATA32
, i
, 0));
3445 lpxx
->lfStrikeOut
=IsDlgButtonChecked32(hDlg
,chx1
);
3446 lpxx
->lfUnderline
=IsDlgButtonChecked32(hDlg
,chx2
);
3447 lpxx
->lfWidth
=lpxx
->lfOrientation
=lpxx
->lfEscapement
=0;
3448 lpxx
->lfOutPrecision
=OUT_DEFAULT_PRECIS
;
3449 lpxx
->lfClipPrecision
=CLIP_DEFAULT_PRECIS
;
3450 lpxx
->lfQuality
=DEFAULT_QUALITY
;
3451 lpcf
->iPointSize
= -10*lpxx
->lfHeight
;
3453 hFont
=CreateFontIndirect32A(lpxx
);
3456 HFONT32 oldFont
=SendDlgItemMessage32A(hDlg
, stc6
,
3458 SendDlgItemMessage32A(hDlg
,stc6
,WM_SETFONT
,hFont
,TRUE
);
3459 DeleteObject32(oldFont
);
3464 case cmb4
:i
=SendDlgItemMessage32A(hDlg
, cmb4
, CB_GETCURSEL32
, 0, 0);
3467 lpcf
->rgbColors
=textcolors
[i
];
3468 InvalidateRect32( GetDlgItem32(hDlg
,stc6
), NULL
, 0 );
3472 case psh15
:i
=RegisterWindowMessage32A( HELPMSGSTRING
);
3473 if (lpcf
->hwndOwner
)
3474 SendMessage32A(lpcf
->hwndOwner
, i
, 0, (LPARAM
)GetWindowLong32A(hDlg
, DWL_USER
));
3475 /* if (CFn_HookCallChk(lpcf))
3476 CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/
3479 case IDOK
:if ( (!(lpcf
->Flags
& CF_LIMITSIZE
)) ||
3480 ( (lpcf
->Flags
& CF_LIMITSIZE
) &&
3481 (-lpxx
->lfHeight
>= lpcf
->nSizeMin
) &&
3482 (-lpxx
->lfHeight
<= lpcf
->nSizeMax
)))
3483 EndDialog32(hDlg
, TRUE
);
3487 sprintf(buffer
,"Select a font size between %d and %d points.",
3488 lpcf
->nSizeMin
,lpcf
->nSizeMax
);
3489 MessageBox32A(hDlg
, buffer
, NULL
, MB_OK
);
3492 case IDCANCEL
:EndDialog32(hDlg
, FALSE
);
3498 static LRESULT
CFn_WMDestroy(HWND32 hwnd
, WPARAM32 wParam
, LPARAM lParam
)
3500 DeleteObject32(SendDlgItemMessage32A(hwnd
, stc6
, WM_GETFONT
, 0, 0));
3505 /***********************************************************************
3506 * FormatCharDlgProc16 (COMMDLG.16)
3507 FIXME: 1. some strings are "hardcoded", but it's better load from sysres
3508 2. some CF_.. flags are not supported
3509 3. some TType extensions
3511 LRESULT WINAPI
FormatCharDlgProc16(HWND16 hDlg
, UINT16 message
, WPARAM16 wParam
,
3514 LPCHOOSEFONT16 lpcf
;
3515 LPCHOOSEFONT32A lpcf32a
;
3519 if (message
!=WM_INITDIALOG
)
3521 lpcf
=(LPCHOOSEFONT16
)GetWindowLong32A(hDlg
, DWL_USER
);
3524 if (CFn_HookCallChk(lpcf
))
3525 res
=CallWindowProc16(lpcf
->lpfnHook
,hDlg
,message
,wParam
,lParam
);
3531 lpcf
=(LPCHOOSEFONT16
)lParam
;
3532 lpcf32a
=(LPCHOOSEFONT32A
)lpcf
->lpTemplateName
;
3533 if (!CFn_WMInitDialog(hDlg
, wParam
, lParam
, lpcf32a
))
3535 TRACE(commdlg
, "CFn_WMInitDialog returned FALSE\n");
3538 if (CFn_HookCallChk(lpcf
))
3539 return CallWindowProc16(lpcf
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
3541 WINPROC_MapMsg16To32A(message
, wParam
, &uMsg32
, &wParam32
, &lParam
);
3542 lpcf32a
=(LPCHOOSEFONT32A
)lpcf
->lpTemplateName
;
3545 case WM_MEASUREITEM
:
3546 res
=CFn_WMMeasureItem(hDlg
, wParam32
, lParam
);
3549 res
=CFn_WMDrawItem(hDlg
, wParam32
, lParam
);
3551 case WM_CTLCOLORSTATIC
:
3552 res
=CFn_WMCtlColorStatic(hDlg
, wParam32
, lParam
, lpcf32a
);
3555 res
=CFn_WMCommand(hDlg
, wParam32
, lParam
, lpcf32a
);
3558 res
=CFn_WMDestroy(hDlg
, wParam32
, lParam
);
3560 case WM_CHOOSEFONT_GETLOGFONT
:
3561 TRACE(commdlg
,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3563 FIXME(commdlg
, "current logfont back to caller\n");
3566 WINPROC_UnmapMsg16To32A(uMsg32
, wParam32
, lParam
, res
);
3570 /***********************************************************************
3571 * FormatCharDlgProc32A [internal]
3573 LRESULT WINAPI
FormatCharDlgProc32A(HWND32 hDlg
, UINT32 uMsg
, WPARAM32 wParam
,
3576 LPCHOOSEFONT32A lpcf
;
3578 if (uMsg
!=WM_INITDIALOG
)
3580 lpcf
=(LPCHOOSEFONT32A
)GetWindowLong32A(hDlg
, DWL_USER
);
3583 if (CFn_HookCallChk32(lpcf
))
3584 res
=CallWindowProc32A(lpcf
->lpfnHook
, hDlg
, uMsg
, wParam
, lParam
);
3590 lpcf
=(LPCHOOSEFONT32A
)lParam
;
3591 if (!CFn_WMInitDialog(hDlg
, wParam
, lParam
, lpcf
))
3593 TRACE(commdlg
, "CFn_WMInitDialog returned FALSE\n");
3596 if (CFn_HookCallChk32(lpcf
))
3597 return CallWindowProc32A(lpcf
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
3601 case WM_MEASUREITEM
:
3602 return CFn_WMMeasureItem(hDlg
, wParam
, lParam
);
3604 return CFn_WMDrawItem(hDlg
, wParam
, lParam
);
3605 case WM_CTLCOLORSTATIC
:
3606 return CFn_WMCtlColorStatic(hDlg
, wParam
, lParam
, lpcf
);
3608 return CFn_WMCommand(hDlg
, wParam
, lParam
, lpcf
);
3610 return CFn_WMDestroy(hDlg
, wParam
, lParam
);
3611 case WM_CHOOSEFONT_GETLOGFONT
:
3612 TRACE(commdlg
,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3614 FIXME(commdlg
, "current logfont back to caller\n");
3620 /***********************************************************************
3621 * FormatCharDlgProc32W [internal]
3623 LRESULT WINAPI
FormatCharDlgProc32W(HWND32 hDlg
, UINT32 uMsg
, WPARAM32 wParam
,
3626 LPCHOOSEFONT32W lpcf32w
;
3627 LPCHOOSEFONT32A lpcf32a
;
3629 if (uMsg
!=WM_INITDIALOG
)
3631 lpcf32w
=(LPCHOOSEFONT32W
)GetWindowLong32A(hDlg
, DWL_USER
);
3634 if (CFn_HookCallChk32((LPCHOOSEFONT32A
)lpcf32w
))
3635 res
=CallWindowProc32W(lpcf32w
->lpfnHook
, hDlg
, uMsg
, wParam
, lParam
);
3641 lpcf32w
=(LPCHOOSEFONT32W
)lParam
;
3642 lpcf32a
=(LPCHOOSEFONT32A
)lpcf32w
->lpTemplateName
;
3643 if (!CFn_WMInitDialog(hDlg
, wParam
, lParam
, lpcf32a
))
3645 TRACE(commdlg
, "CFn_WMInitDialog returned FALSE\n");
3648 if (CFn_HookCallChk32((LPCHOOSEFONT32A
)lpcf32w
))
3649 return CallWindowProc32W(lpcf32w
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
3651 lpcf32a
=(LPCHOOSEFONT32A
)lpcf32w
->lpTemplateName
;
3654 case WM_MEASUREITEM
:
3655 return CFn_WMMeasureItem(hDlg
, wParam
, lParam
);
3657 return CFn_WMDrawItem(hDlg
, wParam
, lParam
);
3658 case WM_CTLCOLORSTATIC
:
3659 return CFn_WMCtlColorStatic(hDlg
, wParam
, lParam
, lpcf32a
);
3661 return CFn_WMCommand(hDlg
, wParam
, lParam
, lpcf32a
);
3663 return CFn_WMDestroy(hDlg
, wParam
, lParam
);
3664 case WM_CHOOSEFONT_GETLOGFONT
:
3665 TRACE(commdlg
,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3667 FIXME(commdlg
, "current logfont back to caller\n");
3674 static BOOL32
Commdlg_GetFileName32A( BOOL16 (CALLBACK
*dofunction
)(SEGPTR x
),
3675 LPOPENFILENAME32A ofn
)
3678 LPOPENFILENAME16 ofn16
= SEGPTR_ALLOC(sizeof(OPENFILENAME16
));
3680 memset(ofn16
,'\0',sizeof(*ofn16
));
3681 ofn16
->lStructSize
= sizeof(*ofn16
);
3682 ofn16
->hwndOwner
= ofn
->hwndOwner
;
3683 ofn16
->hInstance
= MapHModuleLS(ofn
->hInstance
);
3684 if (ofn
->lpstrFilter
) {
3687 /* filter is a list... title\0ext\0......\0\0 */
3688 s
= (LPSTR
)ofn
->lpstrFilter
;
3692 x
= (LPSTR
)SEGPTR_ALLOC(s
-ofn
->lpstrFilter
);
3693 memcpy(x
,ofn
->lpstrFilter
,s
-ofn
->lpstrFilter
);
3694 ofn16
->lpstrFilter
= SEGPTR_GET(x
);
3696 if (ofn
->lpstrCustomFilter
) {
3699 /* filter is a list... title\0ext\0......\0\0 */
3700 s
= (LPSTR
)ofn
->lpstrCustomFilter
;
3704 x
= SEGPTR_ALLOC(s
-ofn
->lpstrCustomFilter
);
3705 memcpy(x
,ofn
->lpstrCustomFilter
,s
-ofn
->lpstrCustomFilter
);
3706 ofn16
->lpstrCustomFilter
= SEGPTR_GET(x
);
3708 ofn16
->nMaxCustFilter
= ofn
->nMaxCustFilter
;
3709 ofn16
->nFilterIndex
= ofn
->nFilterIndex
;
3711 ofn16
->lpstrFile
= SEGPTR_GET(SEGPTR_ALLOC(ofn
->nMaxFile
));
3712 ofn16
->nMaxFile
= ofn
->nMaxFile
;
3713 ofn16
->nMaxFileTitle
= ofn
->nMaxFileTitle
;
3714 if (ofn16
->nMaxFileTitle
)
3715 ofn16
->lpstrFileTitle
= SEGPTR_GET(SEGPTR_ALLOC(ofn
->nMaxFileTitle
));
3716 if (ofn
->lpstrInitialDir
)
3717 ofn16
->lpstrInitialDir
= SEGPTR_GET(SEGPTR_STRDUP(ofn
->lpstrInitialDir
));
3718 if (ofn
->lpstrTitle
)
3719 ofn16
->lpstrTitle
= SEGPTR_GET(SEGPTR_STRDUP(ofn
->lpstrTitle
));
3720 ofn16
->Flags
= ofn
->Flags
|OFN_WINE32
;
3721 ofn16
->nFileOffset
= ofn
->nFileOffset
;
3722 ofn16
->nFileExtension
= ofn
->nFileExtension
;
3723 if (ofn
->lpstrDefExt
)
3724 ofn16
->lpstrDefExt
= SEGPTR_GET(SEGPTR_STRDUP(ofn
->lpstrDefExt
));
3725 ofn16
->lCustData
= ofn
->lCustData
;
3726 ofn16
->lpfnHook
= (WNDPROC16
)ofn
->lpfnHook
;
3728 if (ofn
->lpTemplateName
)
3729 ofn16
->lpTemplateName
= SEGPTR_GET(SEGPTR_STRDUP(ofn
->lpTemplateName
));
3731 ret
= dofunction(SEGPTR_GET(ofn16
));
3733 ofn
->nFileOffset
= ofn16
->nFileOffset
;
3734 ofn
->nFileExtension
= ofn16
->nFileExtension
;
3735 if (ofn16
->lpstrFilter
)
3736 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFilter
));
3737 if (ofn16
->lpTemplateName
)
3738 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpTemplateName
));
3739 if (ofn16
->lpstrDefExt
)
3740 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrDefExt
));
3741 if (ofn16
->lpstrTitle
)
3742 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrTitle
));
3743 if (ofn16
->lpstrInitialDir
)
3744 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrInitialDir
));
3745 if (ofn16
->lpstrCustomFilter
)
3746 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrCustomFilter
));
3748 if (ofn16
->lpstrFile
)
3750 strcpy(ofn
->lpstrFile
,PTR_SEG_TO_LIN(ofn16
->lpstrFile
));
3751 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFile
));
3754 if (ofn16
->lpstrFileTitle
)
3756 strcpy(ofn
->lpstrFileTitle
,PTR_SEG_TO_LIN(ofn16
->lpstrFileTitle
));
3757 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFileTitle
));
3763 static BOOL32
Commdlg_GetFileName32W( BOOL16 (CALLBACK
*dofunction
)(SEGPTR x
),
3764 LPOPENFILENAME32W ofn
)
3767 LPOPENFILENAME16 ofn16
= SEGPTR_ALLOC(sizeof(OPENFILENAME16
));
3769 memset(ofn16
,'\0',sizeof(*ofn16
));
3770 ofn16
->lStructSize
= sizeof(*ofn16
);
3771 ofn16
->hwndOwner
= ofn
->hwndOwner
;
3772 ofn16
->hInstance
= MapHModuleLS(ofn
->hInstance
);
3773 if (ofn
->lpstrFilter
) {
3778 /* filter is a list... title\0ext\0......\0\0 */
3779 s
= (LPWSTR
)ofn
->lpstrFilter
;
3781 s
= s
+lstrlen32W(s
)+1;
3783 n
= s
- ofn
->lpstrFilter
; /* already divides by 2. ptr magic */
3784 x
= y
= (LPSTR
)SEGPTR_ALLOC(n
);
3785 s
= (LPWSTR
)ofn
->lpstrFilter
;
3792 ofn16
->lpstrFilter
= SEGPTR_GET(y
);
3794 if (ofn
->lpstrCustomFilter
) {
3799 /* filter is a list... title\0ext\0......\0\0 */
3800 s
= (LPWSTR
)ofn
->lpstrCustomFilter
;
3802 s
= s
+lstrlen32W(s
)+1;
3804 n
= s
- ofn
->lpstrCustomFilter
;
3805 x
= y
= (LPSTR
)SEGPTR_ALLOC(n
);
3806 s
= (LPWSTR
)ofn
->lpstrCustomFilter
;
3813 ofn16
->lpstrCustomFilter
= SEGPTR_GET(y
);
3815 ofn16
->nMaxCustFilter
= ofn
->nMaxCustFilter
;
3816 ofn16
->nFilterIndex
= ofn
->nFilterIndex
;
3818 ofn16
->lpstrFile
= SEGPTR_GET(SEGPTR_ALLOC(ofn
->nMaxFile
));
3819 ofn16
->nMaxFile
= ofn
->nMaxFile
;
3820 ofn16
->nMaxFileTitle
= ofn
->nMaxFileTitle
;
3821 if (ofn
->nMaxFileTitle
)
3822 ofn16
->lpstrFileTitle
= SEGPTR_GET(SEGPTR_ALLOC(ofn
->nMaxFileTitle
));
3823 if (ofn
->lpstrInitialDir
)
3824 ofn16
->lpstrInitialDir
= SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn
->lpstrInitialDir
));
3825 if (ofn
->lpstrTitle
)
3826 ofn16
->lpstrTitle
= SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn
->lpstrTitle
));
3827 ofn16
->Flags
= ofn
->Flags
|OFN_WINE32
|OFN_UNICODE
;
3828 ofn16
->nFileOffset
= ofn
->nFileOffset
;
3829 ofn16
->nFileExtension
= ofn
->nFileExtension
;
3830 if (ofn
->lpstrDefExt
)
3831 ofn16
->lpstrDefExt
= SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn
->lpstrDefExt
));
3832 ofn16
->lCustData
= ofn
->lCustData
;
3833 ofn16
->lpfnHook
= (WNDPROC16
)ofn
->lpfnHook
;
3834 if (ofn
->lpTemplateName
)
3835 ofn16
->lpTemplateName
= SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn
->lpTemplateName
));
3836 ret
= dofunction(SEGPTR_GET(ofn16
));
3838 ofn
->nFileOffset
= ofn16
->nFileOffset
;
3839 ofn
->nFileExtension
= ofn16
->nFileExtension
;
3840 if (ofn16
->lpstrFilter
)
3841 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFilter
));
3842 if (ofn16
->lpTemplateName
)
3843 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpTemplateName
));
3844 if (ofn16
->lpstrDefExt
)
3845 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrDefExt
));
3846 if (ofn16
->lpstrTitle
)
3847 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrTitle
));
3848 if (ofn16
->lpstrInitialDir
)
3849 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrInitialDir
));
3850 if (ofn16
->lpstrCustomFilter
)
3851 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrCustomFilter
));
3853 if (ofn16
->lpstrFile
) {
3854 lstrcpyAtoW(ofn
->lpstrFile
,PTR_SEG_TO_LIN(ofn16
->lpstrFile
));
3855 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFile
));
3858 if (ofn16
->lpstrFileTitle
) {
3859 lstrcpyAtoW(ofn
->lpstrFileTitle
,PTR_SEG_TO_LIN(ofn16
->lpstrFileTitle
));
3860 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFileTitle
));
3866 /***********************************************************************
3867 * GetOpenFileName32A (COMDLG32.10)
3869 BOOL32 WINAPI
GetOpenFileName32A( LPOPENFILENAME32A ofn
)
3871 BOOL16 (CALLBACK
* dofunction
)(SEGPTR ofn16
) = GetOpenFileName16
;
3872 return Commdlg_GetFileName32A(dofunction
,ofn
);
3875 /***********************************************************************
3876 * GetOpenFileName32W (COMDLG32.11)
3878 BOOL32 WINAPI
GetOpenFileName32W( LPOPENFILENAME32W ofn
)
3880 BOOL16 (CALLBACK
* dofunction
)(SEGPTR ofn16
) = GetOpenFileName16
;
3881 return Commdlg_GetFileName32W(dofunction
,ofn
);
3884 /***********************************************************************
3885 * GetSaveFileName32A (COMDLG32.12)
3887 BOOL32 WINAPI
GetSaveFileName32A( LPOPENFILENAME32A ofn
)
3889 BOOL16 (CALLBACK
* dofunction
)(SEGPTR ofn16
) = GetSaveFileName16
;
3890 return Commdlg_GetFileName32A(dofunction
,ofn
);
3893 /***********************************************************************
3894 * GetSaveFileName32W (COMDLG32.13)
3896 BOOL32 WINAPI
GetSaveFileName32W( LPOPENFILENAME32W ofn
)
3898 BOOL16 (CALLBACK
* dofunction
)(SEGPTR ofn16
) = GetSaveFileName16
;
3899 return Commdlg_GetFileName32W(dofunction
,ofn
);
3902 /***********************************************************************
3903 * ChooseColorA (COMDLG32.1)
3905 BOOL32 WINAPI
ChooseColor32A(LPCHOOSECOLOR32A lpChCol
)
3910 COLORREF
* ccref
=SEGPTR_ALLOC(64);
3911 LPCHOOSECOLOR16 lpcc16
=SEGPTR_ALLOC(sizeof(CHOOSECOLOR16
));
3913 memset(lpcc16
,'\0',sizeof(*lpcc16
));
3914 lpcc16
->lStructSize
=sizeof(*lpcc16
);
3915 lpcc16
->hwndOwner
=lpChCol
->hwndOwner
;
3916 lpcc16
->hInstance
=MapHModuleLS(lpChCol
->hInstance
);
3917 lpcc16
->rgbResult
=lpChCol
->rgbResult
;
3918 memcpy(ccref
,lpChCol
->lpCustColors
,64);
3919 lpcc16
->lpCustColors
=(COLORREF
*)SEGPTR_GET(ccref
);
3920 lpcc16
->Flags
=lpChCol
->Flags
;
3921 lpcc16
->lCustData
=lpChCol
->lCustData
;
3922 lpcc16
->lpfnHook
=(WNDPROC16
)lpChCol
->lpfnHook
;
3923 if (lpChCol
->lpTemplateName
)
3924 str
= SEGPTR_STRDUP(lpChCol
->lpTemplateName
);
3925 lpcc16
->lpTemplateName
=SEGPTR_GET(str
);
3927 ret
= ChooseColor16(lpcc16
);
3930 memcpy(lpChCol
->lpCustColors
,ccref
,64);
3932 SEGPTR_FREE(lpcc16
);
3936 /***********************************************************************
3937 * ChooseColorW (COMDLG32.2)
3939 BOOL32 WINAPI
ChooseColor32W(LPCHOOSECOLOR32W lpChCol
)
3944 COLORREF
* ccref
=SEGPTR_ALLOC(64);
3945 LPCHOOSECOLOR16 lpcc16
=SEGPTR_ALLOC(sizeof(CHOOSECOLOR16
));
3947 memset(lpcc16
,'\0',sizeof(*lpcc16
));
3948 lpcc16
->lStructSize
=sizeof(*lpcc16
);
3949 lpcc16
->hwndOwner
=lpChCol
->hwndOwner
;
3950 lpcc16
->hInstance
=MapHModuleLS(lpChCol
->hInstance
);
3951 lpcc16
->rgbResult
=lpChCol
->rgbResult
;
3952 memcpy(ccref
,lpChCol
->lpCustColors
,64);
3953 lpcc16
->lpCustColors
=(COLORREF
*)SEGPTR_GET(ccref
);
3954 lpcc16
->Flags
=lpChCol
->Flags
;
3955 lpcc16
->lCustData
=lpChCol
->lCustData
;
3956 lpcc16
->lpfnHook
=(WNDPROC16
)lpChCol
->lpfnHook
;
3957 if (lpChCol
->lpTemplateName
)
3958 str
= SEGPTR_STRDUP_WtoA(lpChCol
->lpTemplateName
);
3959 lpcc16
->lpTemplateName
=SEGPTR_GET(str
);
3961 ret
= ChooseColor16(lpcc16
);
3964 memcpy(lpChCol
->lpCustColors
,ccref
,64);
3966 SEGPTR_FREE(lpcc16
);
3970 /***********************************************************************
3971 * PageSetupDlgA (COMDLG32.15)
3973 BOOL32 WINAPI
PageSetupDlg32A(LPPAGESETUPDLG32A setupdlg
) {
3974 FIXME(commdlg
,"(%p), stub!\n",setupdlg
);