4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
24 static DWORD CommDlgLastError
= 0;
26 static HBITMAP16 hFolder
= 0;
27 static HBITMAP16 hFolder2
= 0;
28 static HBITMAP16 hFloppy
= 0;
29 static HBITMAP16 hHDisk
= 0;
30 static HBITMAP16 hCDRom
= 0;
31 static HBITMAP16 hBitmapTT
= 0;
32 static const char defaultfilter
[]=" \0\0";
34 /***********************************************************************
35 * FileDlg_Init [internal]
37 static BOOL32
FileDlg_Init(void)
39 static BOOL32 initialized
= 0;
42 if (!hFolder
) hFolder
= LoadBitmap16(0, MAKEINTRESOURCE16(OBM_FOLDER
));
43 if (!hFolder2
) hFolder2
= LoadBitmap16(0, MAKEINTRESOURCE16(OBM_FOLDER2
));
44 if (!hFloppy
) hFloppy
= LoadBitmap16(0, MAKEINTRESOURCE16(OBM_FLOPPY
));
45 if (!hHDisk
) hHDisk
= LoadBitmap16(0, MAKEINTRESOURCE16(OBM_HDISK
));
46 if (!hCDRom
) hCDRom
= LoadBitmap16(0, MAKEINTRESOURCE16(OBM_CDROM
));
47 if (hFolder
== 0 || hFolder2
== 0 || hFloppy
== 0 ||
48 hHDisk
== 0 || hCDRom
== 0)
50 WARN(commdlg
, "Error loading bitmaps !\nprin");
58 /***********************************************************************
59 * GetOpenFileName (COMMDLG.1)
61 BOOL16 WINAPI
GetOpenFileName16( SEGPTR ofn
)
64 HANDLE32 hDlgTmpl
= 0, hResInfo
;
65 BOOL32 bRet
= FALSE
, win32Format
= FALSE
;
67 LPOPENFILENAME16 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(ofn
);
69 char defaultopen
[]="Open File";
72 if (!lpofn
|| !FileDlg_Init()) return FALSE
;
74 if (lpofn
->Flags
& OFN_WINE32
) {
75 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
)
77 if (!(template = LockResource32( MapHModuleSL(lpofn
->hInstance
))))
79 CommDlgLastError
= CDERR_LOADRESFAILURE
;
83 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
85 if (!(hResInfo
= FindResource32A(MapHModuleSL(lpofn
->hInstance
),
86 PTR_SEG_TO_LIN(lpofn
->lpTemplateName
), RT_DIALOG32A
)))
88 CommDlgLastError
= CDERR_FINDRESFAILURE
;
91 if (!(hDlgTmpl
= LoadResource32( MapHModuleSL(lpofn
->hInstance
),
93 !(template = LockResource32( hDlgTmpl
)))
95 CommDlgLastError
= CDERR_LOADRESFAILURE
;
99 template = SYSRES_GetResPtr( SYSRES_DIALOG_OPEN_FILE
);
103 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
)
105 if (!(template = LockResource16( lpofn
->hInstance
)))
107 CommDlgLastError
= CDERR_LOADRESFAILURE
;
111 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
113 if (!(hResInfo
= FindResource16(lpofn
->hInstance
,
114 lpofn
->lpTemplateName
,
117 CommDlgLastError
= CDERR_FINDRESFAILURE
;
120 if (!(hDlgTmpl
= LoadResource16( lpofn
->hInstance
, hResInfo
)) ||
121 !(template = LockResource16( hDlgTmpl
)))
123 CommDlgLastError
= CDERR_LOADRESFAILURE
;
127 template = SYSRES_GetResPtr( SYSRES_DIALOG_OPEN_FILE
);
132 hInst
= WIN_GetWindowInstance( lpofn
->hwndOwner
);
134 if (!(lpofn
->lpstrFilter
))
136 str
= SEGPTR_ALLOC(sizeof(defaultfilter
));
137 TRACE(commdlg
,"Alloc %p default for Filetype in GetOpenFileName\n",str
);
138 memcpy(str
,defaultfilter
,sizeof(defaultfilter
));
139 lpofn
->lpstrFilter
=SEGPTR_GET(str
);
142 if (!(lpofn
->lpstrTitle
))
144 str1
= SEGPTR_ALLOC(strlen(defaultopen
)+1);
145 TRACE(commdlg
,"Alloc %p default for Title in GetOpenFileName\n",str1
);
146 strcpy(str1
,defaultopen
);
147 lpofn
->lpstrTitle
=SEGPTR_GET(str1
);
150 /* FIXME: doesn't handle win32 format correctly yet */
151 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, win32Format
,
153 (DLGPROC16
)MODULE_GetWndProcEntry16("FileOpenDlgProc"),
155 if (hwndDialog
) bRet
= DIALOG_DoDialogBox( hwndDialog
, lpofn
->hwndOwner
);
159 TRACE(commdlg
,"Freeing %p default for Title in GetOpenFileName\n",str1
);
166 TRACE(commdlg
,"Freeing %p default for Filetype in GetOpenFileName\n",str
);
168 lpofn
->lpstrFilter
=0;
172 if (lpofn
->Flags
& OFN_WINE32
)
173 FreeResource32( hDlgTmpl
);
175 FreeResource16( hDlgTmpl
);
178 TRACE(commdlg
,"return lpstrFile='%s' !\n",
179 (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFile
));
184 /***********************************************************************
185 * GetSaveFileName (COMMDLG.2)
187 BOOL16 WINAPI
GetSaveFileName16( SEGPTR ofn
)
190 HANDLE32 hDlgTmpl
= 0;
191 BOOL32 bRet
= FALSE
, win32Format
= FALSE
;
192 LPOPENFILENAME16 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(ofn
);
195 char defaultsave
[]="Save as";
196 char *str
=0,*str1
=0;
198 if (!lpofn
|| !FileDlg_Init()) return FALSE
;
200 if (lpofn
->Flags
& OFN_WINE32
) {
201 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
)
203 if (!(template = LockResource32( MapHModuleSL(lpofn
->hInstance
))))
205 CommDlgLastError
= CDERR_LOADRESFAILURE
;
209 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
212 if (!(hResInfo
= FindResource32A(MapHModuleSL(lpofn
->hInstance
),
213 PTR_SEG_TO_LIN(lpofn
->lpTemplateName
),
216 CommDlgLastError
= CDERR_FINDRESFAILURE
;
219 if (!(hDlgTmpl
= LoadResource32(MapHModuleSL(lpofn
->hInstance
),
221 !(template = LockResource32(hDlgTmpl
)))
223 CommDlgLastError
= CDERR_LOADRESFAILURE
;
228 template = SYSRES_GetResPtr( SYSRES_DIALOG_SAVE_FILE
);
232 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
)
234 if (!(template = LockResource16( lpofn
->hInstance
)))
236 CommDlgLastError
= CDERR_LOADRESFAILURE
;
240 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
243 if (!(hResInfo
= FindResource16(lpofn
->hInstance
,
244 lpofn
->lpTemplateName
,
247 CommDlgLastError
= CDERR_FINDRESFAILURE
;
250 if (!(hDlgTmpl
= LoadResource16( lpofn
->hInstance
, hResInfo
)) ||
251 !(template = LockResource16( hDlgTmpl
)))
253 CommDlgLastError
= CDERR_LOADRESFAILURE
;
257 template = SYSRES_GetResPtr( SYSRES_DIALOG_SAVE_FILE
);
262 hInst
= WIN_GetWindowInstance( lpofn
->hwndOwner
);
264 if (!(lpofn
->lpstrFilter
))
266 str
= SEGPTR_ALLOC(sizeof(defaultfilter
));
267 TRACE(commdlg
,"Alloc default for Filetype in GetSaveFileName\n");
268 memcpy(str
,defaultfilter
,sizeof(defaultfilter
));
269 lpofn
->lpstrFilter
=SEGPTR_GET(str
);
272 if (!(lpofn
->lpstrTitle
))
274 str1
= SEGPTR_ALLOC(sizeof(defaultsave
)+1);
275 TRACE(commdlg
,"Alloc default for Title in GetSaveFileName\n");
276 strcpy(str1
,defaultsave
);
277 lpofn
->lpstrTitle
=SEGPTR_GET(str1
);
280 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, win32Format
,
282 (DLGPROC16
)MODULE_GetWndProcEntry16("FileSaveDlgProc"),
284 if (hwndDialog
) bRet
= DIALOG_DoDialogBox( hwndDialog
, lpofn
->hwndOwner
);
288 TRACE(commdlg
,"Freeing %p default for Title in GetSaveFileName\n",str1
);
295 TRACE(commdlg
,"Freeing %p default for Filetype in GetSaveFileName\n",str
);
297 lpofn
->lpstrFilter
=0;
301 if (lpofn
->Flags
& OFN_WINE32
)
302 FreeResource32( hDlgTmpl
);
304 FreeResource16( hDlgTmpl
);
307 TRACE(commdlg
, "return lpstrFile='%s' !\n",
308 (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFile
));
312 /***********************************************************************
313 * FILEDLG_StripEditControl [internal]
314 * Strip pathnames off the contents of the edit control.
316 static void FILEDLG_StripEditControl(HWND16 hwnd
)
320 GetDlgItemText32A( hwnd
, edt1
, temp
, sizeof(temp
) );
321 cp
= strrchr(temp
, '\\');
325 cp
= strrchr(temp
, ':');
329 /* FIXME: shouldn't we do something with the result here? ;-) */
332 /***********************************************************************
333 * FILEDLG_ScanDir [internal]
335 static BOOL32
FILEDLG_ScanDir(HWND16 hWnd
, LPSTR newPath
)
342 lstrcpyn32A(buffer
, newPath
, sizeof(buffer
));
344 if (str
[0] && (str
[1] == ':')) {
345 drive
= toupper(str
[0]) - 'A';
347 if (!DRIVE_SetCurrentDrive(drive
))
350 drive
= DRIVE_GetCurrentDrive();
353 if (str
[0] && !DRIVE_Chdir(drive
, str
)) {
357 GetDlgItemText32A(hWnd
, edt1
, buffer
, sizeof(buffer
));
358 if ((hlb
= GetDlgItem32(hWnd
, lst1
)) != 0) {
359 char* scptr
; /* ptr on semi-colon */
360 char* filter
= buffer
;
362 TRACE(commdlg
, "Using filter %s\n", filter
);
363 SendMessage32A(hlb
, LB_RESETCONTENT32
, 0, 0);
365 scptr
= strchr(filter
, ';');
366 if (scptr
) *scptr
= 0;
367 TRACE(commdlg
, "Using file spec %s\n", filter
);
368 if (SendMessage32A(hlb
, LB_DIR32
, 0, (LPARAM
)filter
) == LB_ERR
)
370 if (scptr
) *scptr
= ';';
371 filter
= (scptr
) ? (scptr
+ 1) : 0;
375 strcpy(buffer
, "*.*");
376 return DlgDirList32A(hWnd
, buffer
, lst2
, stc1
, 0x8010);
379 /***********************************************************************
380 * FILEDLG_GetFileType [internal]
383 static LPSTR
FILEDLG_GetFileType(LPSTR cfptr
, LPSTR fptr
, WORD index
)
388 for ( ;(n
= strlen(cfptr
)) != 0; i
++)
393 cfptr
+= strlen(cfptr
) + 1;
396 for ( ;(n
= strlen(fptr
)) != 0; i
++)
401 fptr
+= strlen(fptr
) + 1;
403 return "*.*"; /* FIXME */
406 /***********************************************************************
407 * FILEDLG_WMDrawItem [internal]
409 static LONG
FILEDLG_WMDrawItem(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
,int savedlg
)
411 LPDRAWITEMSTRUCT16 lpdis
= (LPDRAWITEMSTRUCT16
)PTR_SEG_TO_LIN(lParam
);
414 HBITMAP16 hBitmap
, hPrevBitmap
;
418 if (lpdis
->CtlType
== ODT_LISTBOX
&& lpdis
->CtlID
== lst1
)
420 if (!(str
= SEGPTR_ALLOC(512))) return FALSE
;
421 hBrush
= SelectObject32(lpdis
->hDC
, GetStockObject32(LTGRAY_BRUSH
));
422 SelectObject32(lpdis
->hDC
, hBrush
);
423 FillRect16(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
424 SendMessage16(lpdis
->hwndItem
, LB_GETTEXT16
, lpdis
->itemID
,
425 (LPARAM
)SEGPTR_GET(str
));
427 if (savedlg
) /* use _gray_ text in FileSaveDlg */
429 if (!lpdis
->itemState
)
430 SetTextColor32(lpdis
->hDC
,GetSysColor32(COLOR_GRAYTEXT
) );
432 SetTextColor32(lpdis
->hDC
,GetSysColor32(COLOR_WINDOWTEXT
) );
433 /* inversion of gray would be bad readable */
436 TextOut16(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
438 if (lpdis
->itemState
!= 0) {
439 InvertRect16(lpdis
->hDC
, &lpdis
->rcItem
);
445 if (lpdis
->CtlType
== ODT_LISTBOX
&& lpdis
->CtlID
== lst2
)
447 if (!(str
= SEGPTR_ALLOC(512))) return FALSE
;
448 hBrush
= SelectObject32(lpdis
->hDC
, GetStockObject32(LTGRAY_BRUSH
));
449 SelectObject32(lpdis
->hDC
, hBrush
);
450 FillRect16(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
451 SendMessage16(lpdis
->hwndItem
, LB_GETTEXT16
, lpdis
->itemID
,
452 (LPARAM
)SEGPTR_GET(str
));
455 GetObject16( hBitmap
, sizeof(bm
), &bm
);
456 TextOut16(lpdis
->hDC
, lpdis
->rcItem
.left
+ bm
.bmWidth
,
457 lpdis
->rcItem
.top
, str
, strlen(str
));
458 hMemDC
= CreateCompatibleDC32(lpdis
->hDC
);
459 hPrevBitmap
= SelectObject32(hMemDC
, hBitmap
);
460 BitBlt32(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
461 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
462 SelectObject32(hMemDC
, hPrevBitmap
);
464 if (lpdis
->itemState
!= 0) InvertRect16(lpdis
->hDC
, &lpdis
->rcItem
);
468 if (lpdis
->CtlType
== ODT_COMBOBOX
&& lpdis
->CtlID
== cmb2
)
470 if (!(str
= SEGPTR_ALLOC(512))) return FALSE
;
471 hBrush
= SelectObject32(lpdis
->hDC
, GetStockObject32(LTGRAY_BRUSH
));
472 SelectObject32(lpdis
->hDC
, hBrush
);
473 FillRect16(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
474 SendMessage16(lpdis
->hwndItem
, CB_GETLBTEXT16
, lpdis
->itemID
,
475 (LPARAM
)SEGPTR_GET(str
));
476 switch(DRIVE_GetType( str
[2] - 'a' ))
478 case TYPE_FLOPPY
: hBitmap
= hFloppy
; break;
479 case TYPE_CDROM
: hBitmap
= hCDRom
; break;
482 default: hBitmap
= hHDisk
; break;
484 GetObject16( hBitmap
, sizeof(bm
), &bm
);
485 TextOut16(lpdis
->hDC
, lpdis
->rcItem
.left
+ bm
.bmWidth
,
486 lpdis
->rcItem
.top
, str
, strlen(str
));
487 hMemDC
= CreateCompatibleDC32(lpdis
->hDC
);
488 hPrevBitmap
= SelectObject32(hMemDC
, hBitmap
);
489 BitBlt32( lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
490 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
491 SelectObject32(hMemDC
, hPrevBitmap
);
493 if (lpdis
->itemState
!= 0) InvertRect16(lpdis
->hDC
, &lpdis
->rcItem
);
500 /***********************************************************************
501 * FILEDLG_WMMeasureItem [internal]
503 static LONG
FILEDLG_WMMeasureItem(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
)
506 LPMEASUREITEMSTRUCT16 lpmeasure
;
508 GetObject16( hFolder2
, sizeof(bm
), &bm
);
509 lpmeasure
= (LPMEASUREITEMSTRUCT16
)PTR_SEG_TO_LIN(lParam
);
510 lpmeasure
->itemHeight
= bm
.bmHeight
;
514 /***********************************************************************
515 * FILEDLG_HookCallChk [internal]
517 static int FILEDLG_HookCallChk(LPOPENFILENAME16 lpofn
)
520 if (lpofn
->Flags
& OFN_ENABLEHOOK
)
526 /***********************************************************************
527 * FILEDLG_CallWindowProc [internal]
529 * Adapt the structures back for win32 calls so the callee can read lpCustData
531 static BOOL32
FILEDLG_CallWindowProc(LPOPENFILENAME16 lpofn
,HWND32 hwnd
,
532 UINT32 wMsg
,WPARAM32 wParam
,LPARAM lParam
536 BOOL32 result
= FALSE
;
537 WINDOWPROCTYPE ProcType
; /* Type of Hook Function to be called. */
539 /* TRUE if lParam points to the OPENFILENAME16 Structure */
540 needstruct
= (PTR_SEG_TO_LIN(lParam
) == lpofn
);
542 ProcType
= (lpofn
->Flags
& OFN_WINE32
)
543 ? (lpofn
->Flags
& OFN_UNICODE
) /* 32-Bit call to GetOpenFileName */
544 ? WIN_PROC_32W
: WIN_PROC_32A
545 : WIN_PROC_16
; /* 16-Bit call to GetOpenFileName */
547 if (!(lpofn
->Flags
& OFN_WINE32
))
548 /* Call to 16-Bit Hooking function... No Problem at all. */
549 return (BOOL32
)CallWindowProc16(
550 lpofn
->lpfnHook
,hwnd
,(UINT16
)wMsg
,(WPARAM16
)wParam
,lParam
555 /* Parameter lParam points to lpofn... Convert Structure Data... */
556 if (lpofn
->Flags
& OFN_UNICODE
)
558 OPENFILENAME32W ofnw
;
560 /* FIXME: probably needs more converted */
561 ofnw
.lCustData
= lpofn
->lCustData
;
562 return (BOOL32
)CallWindowProc32W(
563 (WNDPROC32
)lpofn
->lpfnHook
,hwnd
,wMsg
,wParam
,(LPARAM
)&ofnw
566 else /* ! |OFN_UNICODE */
568 OPENFILENAME32A ofna
;
570 /* FIXME: probably needs more converted */
571 ofna
.lCustData
= lpofn
->lCustData
;
572 return (BOOL32
)CallWindowProc32A(
573 (WNDPROC32
)lpofn
->lpfnHook
,hwnd
,wMsg
,wParam
,(LPARAM
)&ofna
577 else /* ! needstruct */
579 HWINDOWPROC hWindowProc
=NULL
;
581 if (WINPROC_SetProc(&hWindowProc
, lpofn
->lpfnHook
, ProcType
, WIN_PROC_WINDOW
))
583 /* Call Window Procedure converting 16-Bit Type Parameters to 32-Bit Type Parameters */
584 result
= CallWindowProc16( (WNDPROC16
)hWindowProc
,
585 hwnd
, wMsg
, wParam
, lParam
);
587 result
= LOWORD(result
);
589 WINPROC_FreeProc( hWindowProc
, WIN_PROC_WINDOW
);
598 /***********************************************************************
599 * FILEDLG_WMInitDialog [internal]
602 static LONG
FILEDLG_WMInitDialog(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
)
605 LPOPENFILENAME16 lpofn
;
607 LPSTR pstr
, old_pstr
;
608 SetWindowLong32A(hWnd
, DWL_USER
, lParam
);
609 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(lParam
);
610 if (lpofn
->lpstrTitle
) SetWindowText16( hWnd
, lpofn
->lpstrTitle
);
611 /* read custom filter information */
612 if (lpofn
->lpstrCustomFilter
)
614 pstr
= (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
);
616 TRACE(commdlg
,"lpstrCustomFilter = %p\n", pstr
);
620 i
= SendDlgItemMessage16(hWnd
, cmb1
, CB_ADDSTRING16
, 0,
621 (LPARAM
)lpofn
->lpstrCustomFilter
+ n
);
622 n
+= strlen(pstr
) + 1;
623 pstr
+= strlen(pstr
) + 1;
624 TRACE(commdlg
,"add str='%s' "
625 "associated to '%s'\n", old_pstr
, pstr
);
626 SendDlgItemMessage16(hWnd
, cmb1
, CB_SETITEMDATA16
, i
, (LPARAM
)pstr
);
627 n
+= strlen(pstr
) + 1;
628 pstr
+= strlen(pstr
) + 1;
631 /* read filter information */
632 if (lpofn
->lpstrFilter
) {
633 pstr
= (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFilter
);
637 i
= SendDlgItemMessage16(hWnd
, cmb1
, CB_ADDSTRING16
, 0,
638 (LPARAM
)lpofn
->lpstrFilter
+ n
);
639 n
+= strlen(pstr
) + 1;
640 pstr
+= strlen(pstr
) + 1;
641 TRACE(commdlg
,"add str='%s' "
642 "associated to '%s'\n", old_pstr
, pstr
);
643 SendDlgItemMessage16(hWnd
, cmb1
, CB_SETITEMDATA16
, i
, (LPARAM
)pstr
);
644 n
+= strlen(pstr
) + 1;
645 pstr
+= strlen(pstr
) + 1;
648 /* set default filter */
649 if (lpofn
->nFilterIndex
== 0 && lpofn
->lpstrCustomFilter
== (SEGPTR
)NULL
)
650 lpofn
->nFilterIndex
= 1;
651 SendDlgItemMessage16(hWnd
, cmb1
, CB_SETCURSEL16
, lpofn
->nFilterIndex
- 1, 0);
652 strncpy(tmpstr
, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
653 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
), lpofn
->nFilterIndex
- 1),511);
655 TRACE(commdlg
,"nFilterIndex = %ld, SetText of edt1 to '%s'\n",
656 lpofn
->nFilterIndex
, tmpstr
);
657 SetDlgItemText32A( hWnd
, edt1
, tmpstr
);
660 DlgDirListComboBox32A(hWnd
, tmpstr
, cmb2
, 0, 0xC000);
661 /* read initial directory */
662 if (PTR_SEG_TO_LIN(lpofn
->lpstrInitialDir
) != NULL
)
664 strncpy(tmpstr
, PTR_SEG_TO_LIN(lpofn
->lpstrInitialDir
), 510);
666 if (strlen(tmpstr
) > 0 && tmpstr
[strlen(tmpstr
)-1] != '\\'
667 && tmpstr
[strlen(tmpstr
)-1] != ':')
672 if (!FILEDLG_ScanDir(hWnd
, tmpstr
)) {
674 if (!FILEDLG_ScanDir(hWnd
, tmpstr
))
675 WARN(commdlg
, "Couldn't read initial directory %s!\n",tmpstr
);
677 /* select current drive in combo 2, omit missing drives */
678 for(i
=0, n
=-1; i
<=DRIVE_GetCurrentDrive(); i
++)
679 if (DRIVE_IsValid(i
)) n
++;
680 SendDlgItemMessage16(hWnd
, cmb2
, CB_SETCURSEL16
, n
, 0);
681 if (!(lpofn
->Flags
& OFN_SHOWHELP
))
682 ShowWindow32(GetDlgItem32(hWnd
, pshHelp
), SW_HIDE
);
683 if (lpofn
->Flags
& OFN_HIDEREADONLY
)
684 ShowWindow32(GetDlgItem32(hWnd
, chx1
), SW_HIDE
);
685 if (FILEDLG_HookCallChk(lpofn
))
686 return (BOOL16
)FILEDLG_CallWindowProc(lpofn
,hWnd
,WM_INITDIALOG
,wParam
,lParam
);
691 /***********************************************************************
692 * FILEDLG_WMCommand [internal]
694 BOOL32 in_update
=FALSE
;
696 static LRESULT
FILEDLG_WMCommand(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
)
699 LPOPENFILENAME16 lpofn
;
701 char tmpstr
[512], tmpstr2
[512];
703 UINT16 control
,notification
;
705 /* Notifications are packaged differently in Win32 */
707 notification
= HIWORD(lParam
);
709 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
712 case lst1
: /* file list */
713 FILEDLG_StripEditControl(hWnd
);
714 if (notification
== LBN_DBLCLK
)
716 lRet
= SendDlgItemMessage16(hWnd
, lst1
, LB_GETCURSEL16
, 0, 0);
717 if (lRet
== LB_ERR
) return TRUE
;
718 if ((pstr
= SEGPTR_ALLOC(512)))
720 SendDlgItemMessage16(hWnd
, lst1
, LB_GETTEXT16
, lRet
,
721 (LPARAM
)SEGPTR_GET(pstr
));
722 SetDlgItemText32A( hWnd
, edt1
, pstr
);
725 if (FILEDLG_HookCallChk(lpofn
))
726 FILEDLG_CallWindowProc(lpofn
,hWnd
,
727 RegisterWindowMessage32A( LBSELCHSTRING
),
728 control
, MAKELONG(lRet
,CD_LBSELCHANGE
));
729 /* FIXME: for OFN_ALLOWMULTISELECT we need CD_LBSELSUB, CD_SELADD, CD_LBSELNOITEMS */
731 case lst2
: /* directory list */
732 FILEDLG_StripEditControl(hWnd
);
733 if (notification
== LBN_DBLCLK
)
735 lRet
= SendDlgItemMessage16(hWnd
, lst2
, LB_GETCURSEL16
, 0, 0);
736 if (lRet
== LB_ERR
) return TRUE
;
737 pstr
= SEGPTR_ALLOC(512);
738 SendDlgItemMessage16(hWnd
, lst2
, LB_GETTEXT16
, lRet
,
739 (LPARAM
)SEGPTR_GET(pstr
));
740 strcpy( tmpstr
, pstr
);
742 if (tmpstr
[0] == '[')
744 tmpstr
[strlen(tmpstr
) - 1] = 0;
745 strcpy(tmpstr
,tmpstr
+1);
747 strcat(tmpstr
, "\\");
751 case cmb1
: /* file type drop list */
752 if (notification
== CBN_SELCHANGE
)
762 case cmb2
: /* disk drop list */
763 FILEDLG_StripEditControl(hWnd
);
764 lRet
= SendDlgItemMessage16(hWnd
, cmb2
, CB_GETCURSEL16
, 0, 0L);
765 if (lRet
== LB_ERR
) return 0;
766 pstr
= SEGPTR_ALLOC(512);
767 SendDlgItemMessage16(hWnd
, cmb2
, CB_GETLBTEXT16
, lRet
,
768 (LPARAM
)SEGPTR_GET(pstr
));
769 sprintf(tmpstr
, "%c:", pstr
[2]);
772 lRet
= SendDlgItemMessage16(hWnd
, cmb1
, CB_GETCURSEL16
, 0, 0);
775 pstr
= (LPSTR
)SendDlgItemMessage16(hWnd
, cmb1
, CB_GETITEMDATA16
, lRet
, 0);
776 TRACE(commdlg
,"Selected filter : %s\n", pstr
);
777 SetDlgItemText32A( hWnd
, edt1
, pstr
);
778 FILEDLG_ScanDir(hWnd
, tmpstr
);
782 ofn2
=*lpofn
; /* for later restoring */
783 GetDlgItemText32A( hWnd
, edt1
, tmpstr
, sizeof(tmpstr
) );
784 pstr
= strrchr(tmpstr
, '\\');
786 pstr
= strrchr(tmpstr
, ':');
787 if (strchr(tmpstr
,'*') != NULL
|| strchr(tmpstr
,'?') != NULL
)
789 /* edit control contains wildcards */
792 strncpy(tmpstr2
, pstr
+1, 511); tmpstr2
[511]=0;
797 strcpy(tmpstr2
, tmpstr
);
800 TRACE(commdlg
,"tmpstr=%s, tmpstr2=%s\n", tmpstr
, tmpstr2
);
801 SetDlgItemText32A( hWnd
, edt1
, tmpstr2
);
802 FILEDLG_ScanDir(hWnd
, tmpstr
);
805 /* no wildcards, we might have a directory or a filename */
806 /* try appending a wildcard and reading the directory */
807 pstr2
= tmpstr
+ strlen(tmpstr
);
808 if (pstr
== NULL
|| *(pstr
+1) != 0)
809 strcat(tmpstr
, "\\");
810 lRet
= SendDlgItemMessage16(hWnd
, cmb1
, CB_GETCURSEL16
, 0, 0);
811 if (lRet
== LB_ERR
) return TRUE
;
812 lpofn
->nFilterIndex
= lRet
+ 1;
813 TRACE(commdlg
,"lpofn->nFilterIndex=%ld\n", lpofn
->nFilterIndex
);
815 FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
816 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
),
817 lRet
), sizeof(tmpstr2
));
818 SetDlgItemText32A( hWnd
, edt1
, tmpstr2
);
820 /* if ScanDir succeeds, we have changed the directory */
821 if (FILEDLG_ScanDir(hWnd
, tmpstr
)) return TRUE
;
822 /* if not, this must be a filename */
826 /* strip off the pathname */
828 SetDlgItemText32A( hWnd
, edt1
, pstr
+ 1 );
829 lstrcpyn32A(tmpstr2
, pstr
+1, sizeof(tmpstr2
) );
830 /* Should we MessageBox() if this fails? */
831 if (!FILEDLG_ScanDir(hWnd
, tmpstr
)) return TRUE
;
832 strcpy(tmpstr
, tmpstr2
);
834 else SetDlgItemText32A( hWnd
, edt1
, tmpstr
);
836 ShowWindow16(hWnd
, SW_HIDE
); /* this should not be necessary ?! (%%%) */
839 int drive
= DRIVE_GetCurrentDrive();
840 tmpstr2
[0] = 'A'+ drive
;
843 strncpy(tmpstr2
+ 3, DRIVE_GetDosCwd(drive
), 507); tmpstr2
[510]=0;
844 if (strlen(tmpstr2
) > 3)
845 strcat(tmpstr2
, "\\");
846 strncat(tmpstr2
, tmpstr
, 511-strlen(tmpstr2
)); tmpstr2
[511]=0;
847 if (lpofn
->lpstrFile
)
848 lstrcpyn32A(PTR_SEG_TO_LIN(lpofn
->lpstrFile
), tmpstr2
,lpofn
->nMaxFile
);
850 lpofn
->nFileOffset
= strrchr(tmpstr2
,'\\') - tmpstr2
+1;
851 lpofn
->nFileExtension
= 0;
852 while(tmpstr2
[lpofn
->nFileExtension
] != '.' && tmpstr2
[lpofn
->nFileExtension
] != '\0')
853 lpofn
->nFileExtension
++;
854 if (tmpstr2
[lpofn
->nFileExtension
] == '\0')
855 lpofn
->nFileExtension
= 0;
857 lpofn
->nFileExtension
++;
861 if (FILEDLG_HookCallChk(lpofn
))
862 FILEDLG_CallWindowProc(lpofn
,hWnd
,
863 RegisterWindowMessage32A( LBSELCHSTRING
),
864 control
, MAKELONG(lRet
,CD_LBSELCHANGE
));
869 if (PTR_SEG_TO_LIN(lpofn
->lpstrFileTitle
) != NULL
)
871 lRet
= SendDlgItemMessage16(hWnd
, lst1
, LB_GETCURSEL16
, 0, 0);
872 SendDlgItemMessage16(hWnd
, lst1
, LB_GETTEXT16
, lRet
,
873 lpofn
->lpstrFileTitle
);
875 if (FILEDLG_HookCallChk(lpofn
))
877 lRet
= (BOOL16
)FILEDLG_CallWindowProc(lpofn
,
878 hWnd
, RegisterWindowMessage32A( FILEOKSTRING
), 0, lParam
);
881 *lpofn
=ofn2
; /* restore old state */
883 ShowWindow16(hWnd
, SW_SHOW
); /* only if above (%%%) SW_HIDE used */
888 EndDialog32(hWnd
, TRUE
);
891 EndDialog32(hWnd
, FALSE
);
898 /***********************************************************************
899 * FileOpenDlgProc (COMMDLG.6)
901 LRESULT WINAPI
FileOpenDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
904 LPOPENFILENAME16 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
906 if (wMsg
!=WM_INITDIALOG
)
907 if (FILEDLG_HookCallChk(lpofn
))
909 LRESULT lRet
=(BOOL16
)FILEDLG_CallWindowProc(lpofn
,hWnd
,wMsg
,wParam
,lParam
);
911 return lRet
; /* else continue message processing */
916 return FILEDLG_WMInitDialog(hWnd
, wParam
, lParam
);
918 return FILEDLG_WMMeasureItem(hWnd
, wParam
, lParam
);
920 return FILEDLG_WMDrawItem(hWnd
, wParam
, lParam
, FALSE
);
922 return FILEDLG_WMCommand(hWnd
, wParam
, lParam
);
925 SetBkColor((HDC16
)wParam
, 0x00C0C0C0);
926 switch (HIWORD(lParam
))
929 SetTextColor((HDC16
)wParam
, 0x00000000);
931 case CTLCOLOR_STATIC
:
932 SetTextColor((HDC16
)wParam
, 0x00000000);
942 /***********************************************************************
943 * FileSaveDlgProc (COMMDLG.7)
945 LRESULT WINAPI
FileSaveDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
948 LPOPENFILENAME16 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
950 if (wMsg
!=WM_INITDIALOG
)
951 if (FILEDLG_HookCallChk(lpofn
))
953 LRESULT lRet
=(BOOL16
)FILEDLG_CallWindowProc(lpofn
,hWnd
,wMsg
,wParam
,lParam
);
955 return lRet
; /* else continue message processing */
959 return FILEDLG_WMInitDialog(hWnd
, wParam
, lParam
);
962 return FILEDLG_WMMeasureItem(hWnd
, wParam
, lParam
);
965 return FILEDLG_WMDrawItem(hWnd
, wParam
, lParam
, TRUE
);
968 return FILEDLG_WMCommand(hWnd
, wParam
, lParam
);
973 SetBkColor((HDC16)wParam, 0x00C0C0C0);
974 switch (HIWORD(lParam))
977 SetTextColor((HDC16)wParam, 0x00000000);
979 case CTLCOLOR_STATIC:
980 SetTextColor((HDC16)wParam, 0x00000000);
990 /***********************************************************************
991 * FindText16 (COMMDLG.11)
993 HWND16 WINAPI
FindText16( SEGPTR find
)
997 LPFINDREPLACE16 lpFind
= (LPFINDREPLACE16
)PTR_SEG_TO_LIN(find
);
1000 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
1001 * For now, only the standard dialog works.
1003 if (lpFind
->Flags
& (FR_ENABLETEMPLATE
| FR_ENABLETEMPLATEHANDLE
|
1004 FR_ENABLEHOOK
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
1005 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT
);
1006 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
1007 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
1008 (DLGPROC16
)MODULE_GetWndProcEntry16("FindTextDlgProc"),
1009 find
, WIN_PROC_16
);
1012 /***********************************************************************
1013 * FindText32A (COMMDLG.6)
1015 HWND32 WINAPI
FindText32A( LPFINDREPLACE32A lpFind
)
1021 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
1022 * For now, only the standard dialog works.
1024 if (lpFind
->Flags
& (FR_ENABLETEMPLATE
| FR_ENABLETEMPLATEHANDLE
|
1025 FR_ENABLEHOOK
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
1026 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT
);
1027 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
1028 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
1029 (DLGPROC16
)FindTextDlgProc32A
, (LPARAM
)lpFind
, WIN_PROC_32A
);
1032 /***********************************************************************
1033 * FindText32W (COMMDLG.7)
1035 HWND32 WINAPI
FindText32W( LPFINDREPLACE32W lpFind
)
1041 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
1042 * For now, only the standard dialog works.
1044 if (lpFind
->Flags
& (FR_ENABLETEMPLATE
| FR_ENABLETEMPLATEHANDLE
|
1045 FR_ENABLEHOOK
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
1046 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT
);
1047 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
1048 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
1049 (DLGPROC16
)FindTextDlgProc32W
, (LPARAM
)lpFind
, WIN_PROC_32W
);
1052 /***********************************************************************
1053 * ReplaceText16 (COMMDLG.12)
1055 HWND16 WINAPI
ReplaceText16( SEGPTR find
)
1059 LPFINDREPLACE16 lpFind
= (LPFINDREPLACE16
)PTR_SEG_TO_LIN(find
);
1062 * FIXME : We should do error checking on the lpFind structure here
1063 * and make CommDlgExtendedError() return the error condition.
1065 if (lpFind
->Flags
& (FR_ENABLETEMPLATE
| FR_ENABLETEMPLATEHANDLE
|
1066 FR_ENABLEHOOK
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
1067 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT
);
1068 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
1069 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
1070 (DLGPROC16
)MODULE_GetWndProcEntry16("ReplaceTextDlgProc"),
1071 find
, WIN_PROC_16
);
1074 /***********************************************************************
1075 * ReplaceText32A (COMDLG32.19)
1077 HWND32 WINAPI
ReplaceText32A( LPFINDREPLACE32A lpFind
)
1083 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
1084 * For now, only the standard dialog works.
1086 if (lpFind
->Flags
& (FR_ENABLETEMPLATE
| FR_ENABLETEMPLATEHANDLE
|
1087 FR_ENABLEHOOK
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
1088 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT
);
1089 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
1090 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
1091 (DLGPROC16
)ReplaceTextDlgProc32A
, (LPARAM
)lpFind
, WIN_PROC_32A
);
1094 /***********************************************************************
1095 * ReplaceText32W (COMDLG32.20)
1097 HWND32 WINAPI
ReplaceText32W( LPFINDREPLACE32W lpFind
)
1103 * FIXME : We should do error checking on the lpFind structure here
1104 * and make CommDlgExtendedError() return the error condition.
1106 if (lpFind
->Flags
& (FR_ENABLETEMPLATE
| FR_ENABLETEMPLATEHANDLE
|
1107 FR_ENABLEHOOK
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
1108 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT
);
1109 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
1110 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
1111 (DLGPROC16
)ReplaceTextDlgProc32W
, (LPARAM
)lpFind
, WIN_PROC_32W
);
1115 /***********************************************************************
1116 * FINDDLG_WMInitDialog [internal]
1118 static LRESULT
FINDDLG_WMInitDialog(HWND32 hWnd
, LPARAM lParam
, LPDWORD lpFlags
,
1119 LPSTR lpstrFindWhat
, BOOL32 fUnicode
)
1121 SetWindowLong32A(hWnd
, DWL_USER
, lParam
);
1122 *lpFlags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_REPLACEALL
| FR_DIALOGTERM
);
1124 * FIXME : If the initial FindWhat string is empty, we should disable the
1125 * FindNext (IDOK) button. Only after typing some text, the button should be
1128 if (fUnicode
) SetDlgItemText32W(hWnd
, edt1
, (LPWSTR
)lpstrFindWhat
);
1129 else SetDlgItemText32A(hWnd
, edt1
, lpstrFindWhat
);
1130 CheckRadioButton32(hWnd
, rad1
, rad2
, (*lpFlags
& FR_DOWN
) ? rad2
: rad1
);
1131 if (*lpFlags
& (FR_HIDEUPDOWN
| FR_NOUPDOWN
)) {
1132 EnableWindow32(GetDlgItem32(hWnd
, rad1
), FALSE
);
1133 EnableWindow32(GetDlgItem32(hWnd
, rad2
), FALSE
);
1135 if (*lpFlags
& FR_HIDEUPDOWN
) {
1136 ShowWindow32(GetDlgItem32(hWnd
, rad1
), SW_HIDE
);
1137 ShowWindow32(GetDlgItem32(hWnd
, rad2
), SW_HIDE
);
1138 ShowWindow32(GetDlgItem32(hWnd
, grp1
), SW_HIDE
);
1140 CheckDlgButton32(hWnd
, chx1
, (*lpFlags
& FR_WHOLEWORD
) ? 1 : 0);
1141 if (*lpFlags
& (FR_HIDEWHOLEWORD
| FR_NOWHOLEWORD
))
1142 EnableWindow32(GetDlgItem32(hWnd
, chx1
), FALSE
);
1143 if (*lpFlags
& FR_HIDEWHOLEWORD
)
1144 ShowWindow32(GetDlgItem32(hWnd
, chx1
), SW_HIDE
);
1145 CheckDlgButton32(hWnd
, chx2
, (*lpFlags
& FR_MATCHCASE
) ? 1 : 0);
1146 if (*lpFlags
& (FR_HIDEMATCHCASE
| FR_NOMATCHCASE
))
1147 EnableWindow32(GetDlgItem32(hWnd
, chx2
), FALSE
);
1148 if (*lpFlags
& FR_HIDEMATCHCASE
)
1149 ShowWindow32(GetDlgItem32(hWnd
, chx2
), SW_HIDE
);
1150 if (!(*lpFlags
& FR_SHOWHELP
)) {
1151 EnableWindow32(GetDlgItem32(hWnd
, pshHelp
), FALSE
);
1152 ShowWindow32(GetDlgItem32(hWnd
, pshHelp
), SW_HIDE
);
1154 ShowWindow32(hWnd
, SW_SHOWNORMAL
);
1159 /***********************************************************************
1160 * FINDDLG_WMCommand [internal]
1162 static LRESULT
FINDDLG_WMCommand(HWND32 hWnd
, WPARAM32 wParam
,
1163 HWND32 hwndOwner
, LPDWORD lpFlags
,
1164 LPSTR lpstrFindWhat
, WORD wFindWhatLen
,
1167 int uFindReplaceMessage
= RegisterWindowMessage32A( FINDMSGSTRING
);
1168 int uHelpMessage
= RegisterWindowMessage32A( HELPMSGSTRING
);
1173 GetDlgItemText32W(hWnd
, edt1
, (LPWSTR
)lpstrFindWhat
, wFindWhatLen
/2);
1174 else GetDlgItemText32A(hWnd
, edt1
, lpstrFindWhat
, wFindWhatLen
);
1175 if (IsDlgButtonChecked32(hWnd
, rad2
))
1176 *lpFlags
|= FR_DOWN
;
1177 else *lpFlags
&= ~FR_DOWN
;
1178 if (IsDlgButtonChecked32(hWnd
, chx1
))
1179 *lpFlags
|= FR_WHOLEWORD
;
1180 else *lpFlags
&= ~FR_WHOLEWORD
;
1181 if (IsDlgButtonChecked32(hWnd
, chx2
))
1182 *lpFlags
|= FR_MATCHCASE
;
1183 else *lpFlags
&= ~FR_MATCHCASE
;
1184 *lpFlags
&= ~(FR_REPLACE
| FR_REPLACEALL
| FR_DIALOGTERM
);
1185 *lpFlags
|= FR_FINDNEXT
;
1186 SendMessage32A(hwndOwner
, uFindReplaceMessage
, 0,
1187 GetWindowLong32A(hWnd
, DWL_USER
) );
1190 *lpFlags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_REPLACEALL
);
1191 *lpFlags
|= FR_DIALOGTERM
;
1192 SendMessage32A(hwndOwner
, uFindReplaceMessage
, 0,
1193 GetWindowLong32A(hWnd
, DWL_USER
) );
1194 DestroyWindow32(hWnd
);
1197 /* FIXME : should lpfr structure be passed as an argument ??? */
1198 SendMessage32A(hwndOwner
, uHelpMessage
, 0, 0);
1205 /***********************************************************************
1206 * FindTextDlgProc16 (COMMDLG.13)
1208 LRESULT WINAPI
FindTextDlgProc16(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
1211 LPFINDREPLACE16 lpfr
;
1214 lpfr
=(LPFINDREPLACE16
)PTR_SEG_TO_LIN(lParam
);
1215 return FINDDLG_WMInitDialog(hWnd
, lParam
, &(lpfr
->Flags
),
1216 PTR_SEG_TO_LIN(lpfr
->lpstrFindWhat
), FALSE
);
1218 lpfr
=(LPFINDREPLACE16
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
1219 return FINDDLG_WMCommand(hWnd
, wParam
, lpfr
->hwndOwner
,
1220 &lpfr
->Flags
, PTR_SEG_TO_LIN(lpfr
->lpstrFindWhat
),
1221 lpfr
->wFindWhatLen
, FALSE
);
1226 /***********************************************************************
1227 * FindTextDlgProc32A
1229 LRESULT WINAPI
FindTextDlgProc32A(HWND32 hWnd
, UINT32 wMsg
, WPARAM32 wParam
,
1232 LPFINDREPLACE32A lpfr
;
1235 lpfr
=(LPFINDREPLACE32A
)lParam
;
1236 return FINDDLG_WMInitDialog(hWnd
, lParam
, &(lpfr
->Flags
),
1237 lpfr
->lpstrFindWhat
, FALSE
);
1239 lpfr
=(LPFINDREPLACE32A
)GetWindowLong32A(hWnd
, DWL_USER
);
1240 return FINDDLG_WMCommand(hWnd
, wParam
, lpfr
->hwndOwner
,
1241 &lpfr
->Flags
, lpfr
->lpstrFindWhat
, lpfr
->wFindWhatLen
,
1247 /***********************************************************************
1248 * FindTextDlgProc32W
1250 LRESULT WINAPI
FindTextDlgProc32W(HWND32 hWnd
, UINT32 wMsg
, WPARAM32 wParam
,
1253 LPFINDREPLACE32W lpfr
;
1256 lpfr
=(LPFINDREPLACE32W
)lParam
;
1257 return FINDDLG_WMInitDialog(hWnd
, lParam
, &(lpfr
->Flags
),
1258 (LPSTR
)lpfr
->lpstrFindWhat
, TRUE
);
1260 lpfr
=(LPFINDREPLACE32W
)GetWindowLong32A(hWnd
, DWL_USER
);
1261 return FINDDLG_WMCommand(hWnd
, wParam
, lpfr
->hwndOwner
,
1262 &lpfr
->Flags
, (LPSTR
)lpfr
->lpstrFindWhat
, lpfr
->wFindWhatLen
,
1269 /***********************************************************************
1270 * REPLACEDLG_WMInitDialog [internal]
1272 static LRESULT
REPLACEDLG_WMInitDialog(HWND32 hWnd
, LPARAM lParam
,
1273 LPDWORD lpFlags
, LPSTR lpstrFindWhat
,
1274 LPSTR lpstrReplaceWith
, BOOL32 fUnicode
)
1276 SetWindowLong32A(hWnd
, DWL_USER
, lParam
);
1277 *lpFlags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_REPLACEALL
| FR_DIALOGTERM
);
1279 * FIXME : If the initial FindWhat string is empty, we should disable the FinNext /
1280 * Replace / ReplaceAll buttons. Only after typing some text, the buttons should be
1285 SetDlgItemText32W(hWnd
, edt1
, (LPWSTR
)lpstrFindWhat
);
1286 SetDlgItemText32W(hWnd
, edt2
, (LPWSTR
)lpstrReplaceWith
);
1289 SetDlgItemText32A(hWnd
, edt1
, lpstrFindWhat
);
1290 SetDlgItemText32A(hWnd
, edt2
, lpstrReplaceWith
);
1292 CheckDlgButton32(hWnd
, chx1
, (*lpFlags
& FR_WHOLEWORD
) ? 1 : 0);
1293 if (*lpFlags
& (FR_HIDEWHOLEWORD
| FR_NOWHOLEWORD
))
1294 EnableWindow32(GetDlgItem32(hWnd
, chx1
), FALSE
);
1295 if (*lpFlags
& FR_HIDEWHOLEWORD
)
1296 ShowWindow32(GetDlgItem32(hWnd
, chx1
), SW_HIDE
);
1297 CheckDlgButton32(hWnd
, chx2
, (*lpFlags
& FR_MATCHCASE
) ? 1 : 0);
1298 if (*lpFlags
& (FR_HIDEMATCHCASE
| FR_NOMATCHCASE
))
1299 EnableWindow32(GetDlgItem32(hWnd
, chx2
), FALSE
);
1300 if (*lpFlags
& FR_HIDEMATCHCASE
)
1301 ShowWindow32(GetDlgItem32(hWnd
, chx2
), SW_HIDE
);
1302 if (!(*lpFlags
& FR_SHOWHELP
)) {
1303 EnableWindow32(GetDlgItem32(hWnd
, pshHelp
), FALSE
);
1304 ShowWindow32(GetDlgItem32(hWnd
, pshHelp
), SW_HIDE
);
1306 ShowWindow32(hWnd
, SW_SHOWNORMAL
);
1311 /***********************************************************************
1312 * REPLACEDLG_WMCommand [internal]
1314 static LRESULT
REPLACEDLG_WMCommand(HWND32 hWnd
, WPARAM16 wParam
,
1315 HWND32 hwndOwner
, LPDWORD lpFlags
,
1316 LPSTR lpstrFindWhat
, WORD wFindWhatLen
,
1317 LPSTR lpstrReplaceWith
, WORD wReplaceWithLen
,
1320 int uFindReplaceMessage
= RegisterWindowMessage32A( FINDMSGSTRING
);
1321 int uHelpMessage
= RegisterWindowMessage32A( HELPMSGSTRING
);
1327 GetDlgItemText32W(hWnd
, edt1
, (LPWSTR
)lpstrFindWhat
, wFindWhatLen
/2);
1328 GetDlgItemText32W(hWnd
, edt2
, (LPWSTR
)lpstrReplaceWith
, wReplaceWithLen
/2);
1331 GetDlgItemText32A(hWnd
, edt1
, lpstrFindWhat
, wFindWhatLen
);
1332 GetDlgItemText32A(hWnd
, edt2
, lpstrReplaceWith
, wReplaceWithLen
);
1334 if (IsDlgButtonChecked32(hWnd
, chx1
))
1335 *lpFlags
|= FR_WHOLEWORD
;
1336 else *lpFlags
&= ~FR_WHOLEWORD
;
1337 if (IsDlgButtonChecked32(hWnd
, chx2
))
1338 *lpFlags
|= FR_MATCHCASE
;
1339 else *lpFlags
&= ~FR_MATCHCASE
;
1340 *lpFlags
&= ~(FR_REPLACE
| FR_REPLACEALL
| FR_DIALOGTERM
);
1341 *lpFlags
|= FR_FINDNEXT
;
1342 SendMessage32A(hwndOwner
, uFindReplaceMessage
, 0,
1343 GetWindowLong32A(hWnd
, DWL_USER
) );
1346 *lpFlags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_REPLACEALL
);
1347 *lpFlags
|= FR_DIALOGTERM
;
1348 SendMessage32A(hwndOwner
, uFindReplaceMessage
, 0,
1349 GetWindowLong32A(hWnd
, DWL_USER
) );
1350 DestroyWindow32(hWnd
);
1355 GetDlgItemText32W(hWnd
, edt1
, (LPWSTR
)lpstrFindWhat
, wFindWhatLen
/2);
1356 GetDlgItemText32W(hWnd
, edt2
, (LPWSTR
)lpstrReplaceWith
, wReplaceWithLen
/2);
1359 GetDlgItemText32A(hWnd
, edt1
, lpstrFindWhat
, wFindWhatLen
);
1360 GetDlgItemText32A(hWnd
, edt2
, lpstrReplaceWith
, wReplaceWithLen
);
1362 if (IsDlgButtonChecked32(hWnd
, chx1
))
1363 *lpFlags
|= FR_WHOLEWORD
;
1364 else *lpFlags
&= ~FR_WHOLEWORD
;
1365 if (IsDlgButtonChecked32(hWnd
, chx2
))
1366 *lpFlags
|= FR_MATCHCASE
;
1367 else *lpFlags
&= ~FR_MATCHCASE
;
1368 *lpFlags
&= ~(FR_FINDNEXT
| FR_REPLACEALL
| FR_DIALOGTERM
);
1369 *lpFlags
|= FR_REPLACE
;
1370 SendMessage32A(hwndOwner
, uFindReplaceMessage
, 0,
1371 GetWindowLong32A(hWnd
, DWL_USER
) );
1376 GetDlgItemText32W(hWnd
, edt1
, (LPWSTR
)lpstrFindWhat
, wFindWhatLen
/2);
1377 GetDlgItemText32W(hWnd
, edt2
, (LPWSTR
)lpstrReplaceWith
, wReplaceWithLen
/2);
1380 GetDlgItemText32A(hWnd
, edt1
, lpstrFindWhat
, wFindWhatLen
);
1381 GetDlgItemText32A(hWnd
, edt2
, lpstrReplaceWith
, wReplaceWithLen
);
1383 if (IsDlgButtonChecked32(hWnd
, chx1
))
1384 *lpFlags
|= FR_WHOLEWORD
;
1385 else *lpFlags
&= ~FR_WHOLEWORD
;
1386 if (IsDlgButtonChecked32(hWnd
, chx2
))
1387 *lpFlags
|= FR_MATCHCASE
;
1388 else *lpFlags
&= ~FR_MATCHCASE
;
1389 *lpFlags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_DIALOGTERM
);
1390 *lpFlags
|= FR_REPLACEALL
;
1391 SendMessage32A(hwndOwner
, uFindReplaceMessage
, 0,
1392 GetWindowLong32A(hWnd
, DWL_USER
) );
1395 /* FIXME : should lpfr structure be passed as an argument ??? */
1396 SendMessage32A(hwndOwner
, uHelpMessage
, 0, 0);
1403 /***********************************************************************
1404 * ReplaceTextDlgProc16 (COMMDLG.14)
1406 LRESULT WINAPI
ReplaceTextDlgProc16(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
1409 LPFINDREPLACE16 lpfr
;
1412 lpfr
=(LPFINDREPLACE16
)PTR_SEG_TO_LIN(lParam
);
1413 return REPLACEDLG_WMInitDialog(hWnd
, lParam
, &lpfr
->Flags
,
1414 PTR_SEG_TO_LIN(lpfr
->lpstrFindWhat
),
1415 PTR_SEG_TO_LIN(lpfr
->lpstrReplaceWith
), FALSE
);
1417 lpfr
=(LPFINDREPLACE16
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
1418 return REPLACEDLG_WMCommand(hWnd
, wParam
, lpfr
->hwndOwner
,
1419 &lpfr
->Flags
, PTR_SEG_TO_LIN(lpfr
->lpstrFindWhat
),
1420 lpfr
->wFindWhatLen
, PTR_SEG_TO_LIN(lpfr
->lpstrReplaceWith
),
1421 lpfr
->wReplaceWithLen
, FALSE
);
1426 /***********************************************************************
1427 * ReplaceTextDlgProc32A
1429 LRESULT WINAPI
ReplaceTextDlgProc32A(HWND32 hWnd
, UINT32 wMsg
, WPARAM32 wParam
,
1432 LPFINDREPLACE32A lpfr
;
1435 lpfr
=(LPFINDREPLACE32A
)lParam
;
1436 return REPLACEDLG_WMInitDialog(hWnd
, lParam
, &lpfr
->Flags
,
1437 lpfr
->lpstrFindWhat
, lpfr
->lpstrReplaceWith
, FALSE
);
1439 lpfr
=(LPFINDREPLACE32A
)GetWindowLong32A(hWnd
, DWL_USER
);
1440 return REPLACEDLG_WMCommand(hWnd
, wParam
, lpfr
->hwndOwner
,
1441 &lpfr
->Flags
, lpfr
->lpstrFindWhat
, lpfr
->wFindWhatLen
,
1442 lpfr
->lpstrReplaceWith
, lpfr
->wReplaceWithLen
, FALSE
);
1447 /***********************************************************************
1448 * ReplaceTextDlgProc32W
1450 LRESULT WINAPI
ReplaceTextDlgProc32W(HWND32 hWnd
, UINT32 wMsg
, WPARAM32 wParam
,
1453 LPFINDREPLACE32W lpfr
;
1456 lpfr
=(LPFINDREPLACE32W
)lParam
;
1457 return REPLACEDLG_WMInitDialog(hWnd
, lParam
, &lpfr
->Flags
,
1458 (LPSTR
)lpfr
->lpstrFindWhat
, (LPSTR
)lpfr
->lpstrReplaceWith
,
1461 lpfr
=(LPFINDREPLACE32W
)GetWindowLong32A(hWnd
, DWL_USER
);
1462 return REPLACEDLG_WMCommand(hWnd
, wParam
, lpfr
->hwndOwner
,
1463 &lpfr
->Flags
, (LPSTR
)lpfr
->lpstrFindWhat
, lpfr
->wFindWhatLen
,
1464 (LPSTR
)lpfr
->lpstrReplaceWith
, lpfr
->wReplaceWithLen
, TRUE
);
1470 /***********************************************************************
1471 * PrintDlg16 (COMMDLG.20)
1473 BOOL16 WINAPI
PrintDlg16( SEGPTR printdlg
)
1476 BOOL16 bRet
= FALSE
;
1479 LPPRINTDLG16 lpPrint
= (LPPRINTDLG16
)PTR_SEG_TO_LIN(printdlg
);
1481 TRACE(commdlg
,"(%p) -- Flags=%08lX\n", lpPrint
, lpPrint
->Flags
);
1483 if (lpPrint
->Flags
& PD_RETURNDEFAULT
)
1484 /* FIXME: should fill lpPrint->hDevMode and lpPrint->hDevNames here */
1487 if (lpPrint
->Flags
& PD_PRINTSETUP
)
1488 template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT_SETUP
);
1490 template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT
);
1492 hInst
= WIN_GetWindowInstance( lpPrint
->hwndOwner
);
1493 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, TRUE
,
1495 (DLGPROC16
)((lpPrint
->Flags
& PD_PRINTSETUP
) ?
1496 MODULE_GetWndProcEntry16("PrintSetupDlgProc") :
1497 MODULE_GetWndProcEntry16("PrintDlgProc")),
1498 printdlg
, WIN_PROC_16
);
1499 if (hwndDialog
) bRet
= DIALOG_DoDialogBox( hwndDialog
, lpPrint
->hwndOwner
);
1504 /***********************************************************************
1505 * PrintDlg32A (COMDLG32.17)
1507 BOOL32 WINAPI
PrintDlg32A( LPPRINTDLG32A printdlg
)
1509 FIXME(commdlg
, "(%p): stub\n",printdlg
);
1510 /* Altough returning FALSE is theoricaly the right thing
1511 * most programs check for a printer at startup, and if
1512 * none is found popup PrintDlg32A(), if it fails the program
1513 * terminates; by returning TRUE the programs can still run
1514 * as long as no printer related stuff is used
1520 /***********************************************************************
1521 * PrintDlg32W (COMDLG32.18)
1523 BOOL32 WINAPI
PrintDlg32W( LPPRINTDLG32W printdlg
)
1525 FIXME(commdlg
, "empty stub\n" );
1530 /***********************************************************************
1531 * PrintDlgProc (COMMDLG.21)
1533 LRESULT WINAPI
PrintDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
1539 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
1540 ShowWindow16(hWnd
, SW_SHOWNORMAL
);
1546 EndDialog32(hWnd
, TRUE
);
1549 EndDialog32(hWnd
, FALSE
);
1558 /***********************************************************************
1559 * PrintSetupDlgProc (COMMDLG.22)
1561 LRESULT WINAPI
PrintSetupDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
1567 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
1568 ShowWindow16(hWnd
, SW_SHOWNORMAL
);
1573 EndDialog32(hWnd
, TRUE
);
1576 EndDialog32(hWnd
, FALSE
);
1585 /***********************************************************************
1586 * CommDlgExtendedError (COMMDLG.26)
1588 DWORD WINAPI
CommDlgExtendedError(void)
1590 return CommDlgLastError
;
1593 /***********************************************************************
1594 * GetFileTitleA (COMDLG32.8)
1596 short WINAPI
GetFileTitle32A(LPCSTR lpFile
, LPSTR lpTitle
, UINT32 cbBuf
)
1599 TRACE(commdlg
,"(%p %p %d); \n", lpFile
, lpTitle
, cbBuf
);
1600 if (lpFile
== NULL
|| lpTitle
== NULL
)
1602 len
= strlen(lpFile
);
1605 if (strpbrk(lpFile
, "*[]"))
1608 if (lpFile
[len
] == '/' || lpFile
[len
] == '\\' || lpFile
[len
] == ':')
1610 for (i
= len
; i
>= 0; i
--)
1611 if (lpFile
[i
] == '/' || lpFile
[i
] == '\\' || lpFile
[i
] == ':')
1618 TRACE(commdlg
,"---> '%s' \n", &lpFile
[i
]);
1620 len
= strlen(lpFile
+i
)+1;
1624 strncpy(lpTitle
, &lpFile
[i
], len
);
1629 /***********************************************************************
1630 * GetFileTitleA (COMDLG32.8)
1632 short WINAPI
GetFileTitle32W(LPCWSTR lpFile
, LPWSTR lpTitle
, UINT32 cbBuf
)
1634 LPSTR file
= HEAP_strdupWtoA(GetProcessHeap(),0,lpFile
);
1635 LPSTR title
= HeapAlloc(GetProcessHeap(),0,cbBuf
);
1638 ret
= GetFileTitle32A(file
,title
,cbBuf
);
1640 lstrcpynAtoW(lpTitle
,title
,cbBuf
);
1641 HeapFree(GetProcessHeap(),0,file
);
1642 HeapFree(GetProcessHeap(),0,title
);
1645 /***********************************************************************
1646 * GetFileTitle (COMMDLG.27)
1648 short WINAPI
GetFileTitle16(LPCSTR lpFile
, LPSTR lpTitle
, UINT16 cbBuf
)
1650 return GetFileTitle32A(lpFile
,lpTitle
,cbBuf
);
1654 /* ------------------------ Choose Color Dialog --------------------------- */
1656 /***********************************************************************
1657 * ChooseColor (COMMDLG.5)
1659 BOOL16 WINAPI
ChooseColor16(LPCHOOSECOLOR16 lpChCol
)
1662 HANDLE16 hDlgTmpl
= 0;
1663 BOOL16 bRet
= FALSE
, win32Format
= FALSE
;
1667 TRACE(commdlg
,"ChooseColor\n");
1668 if (!lpChCol
) return FALSE
;
1670 if (lpChCol
->Flags
& CC_ENABLETEMPLATEHANDLE
)
1672 if (!(template = LockResource16( lpChCol
->hInstance
)))
1674 CommDlgLastError
= CDERR_LOADRESFAILURE
;
1678 else if (lpChCol
->Flags
& CC_ENABLETEMPLATE
)
1681 if (!(hResInfo
= FindResource16(lpChCol
->hInstance
,
1682 lpChCol
->lpTemplateName
,
1685 CommDlgLastError
= CDERR_FINDRESFAILURE
;
1688 if (!(hDlgTmpl
= LoadResource16( lpChCol
->hInstance
, hResInfo
)) ||
1689 !(template = LockResource16( hDlgTmpl
)))
1691 CommDlgLastError
= CDERR_LOADRESFAILURE
;
1697 template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_COLOR
);
1701 hInst
= WIN_GetWindowInstance( lpChCol
->hwndOwner
);
1702 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, win32Format
,
1704 (DLGPROC16
)MODULE_GetWndProcEntry16("ColorDlgProc"),
1705 (DWORD
)lpChCol
, WIN_PROC_16
);
1706 if (hwndDialog
) bRet
= DIALOG_DoDialogBox( hwndDialog
, lpChCol
->hwndOwner
);
1707 if (hDlgTmpl
) FreeResource16( hDlgTmpl
);
1712 static const COLORREF predefcolors
[6][8]=
1714 { 0x008080FFL
, 0x0080FFFFL
, 0x0080FF80L
, 0x0080FF00L
,
1715 0x00FFFF80L
, 0x00FF8000L
, 0x00C080FFL
, 0x00FF80FFL
},
1716 { 0x000000FFL
, 0x0000FFFFL
, 0x0000FF80L
, 0x0040FF00L
,
1717 0x00FFFF00L
, 0x00C08000L
, 0x00C08080L
, 0x00FF00FFL
},
1719 { 0x00404080L
, 0x004080FFL
, 0x0000FF00L
, 0x00808000L
,
1720 0x00804000L
, 0x00FF8080L
, 0x00400080L
, 0x008000FFL
},
1721 { 0x00000080L
, 0x000080FFL
, 0x00008000L
, 0x00408000L
,
1722 0x00FF0000L
, 0x00A00000L
, 0x00800080L
, 0x00FF0080L
},
1724 { 0x00000040L
, 0x00004080L
, 0x00004000L
, 0x00404000L
,
1725 0x00800000L
, 0x00400000L
, 0x00400040L
, 0x00800040L
},
1726 { 0x00000000L
, 0x00008080L
, 0x00408080L
, 0x00808080L
,
1727 0x00808040L
, 0x00C0C0C0L
, 0x00400040L
, 0x00FFFFFFL
},
1732 LPCHOOSECOLOR16 lpcc
; /* points to public known data structure */
1733 int nextuserdef
; /* next free place in user defined color array */
1734 HDC16 hdcMem
; /* color graph used for BitBlt() */
1735 HBITMAP16 hbmMem
; /* color graph bitmap */
1736 RECT16 fullsize
; /* original dialog window size */
1737 UINT16 msetrgb
; /* # of SETRGBSTRING message (today not used) */
1738 RECT16 old3angle
; /* last position of l-marker */
1739 RECT16 oldcross
; /* last position of color/satuation marker */
1740 BOOL32 updating
; /* to prevent recursive WM_COMMAND/EN_UPDATE procesing */
1743 int l
; /* for temporary storing of hue,sat,lum */
1746 /***********************************************************************
1747 * CC_HSLtoRGB [internal]
1749 static int CC_HSLtoRGB(char c
,int hue
,int sat
,int lum
)
1756 case 'R':if (hue
>80) hue
-=80; else hue
+=160; break;
1757 case 'G':if (hue
>160) hue
-=160; else hue
+=80; break;
1762 maxrgb
=(256*MIN(120,lum
))/120; /* 0 .. 256 */
1768 res
=(hue
-80)* maxrgb
; /* 0...10240 */
1769 res
/=40; /* 0...256 */
1776 res
=(240-hue
)* maxrgb
;
1779 res
=res
-maxrgb
/2; /* -128...128 */
1782 res
=maxrgb
/2 + (sat
*res
) /240; /* 0..256 */
1785 if (lum
>120 && res
<256)
1786 res
+=((lum
-120) * (256-res
))/120;
1788 return MIN(res
,255);
1791 /***********************************************************************
1792 * CC_RGBtoHSL [internal]
1794 static int CC_RGBtoHSL(char c
,int r
,int g
,int b
)
1796 WORD maxi
,mini
,mmsum
,mmdif
,result
=0;
1810 case 'L':mmsum
*=120; /* 0...61200=(255+255)*120 */
1811 result
=mmsum
/255; /* 0...240 */
1814 case 'S':if (!mmsum
)
1817 if (!mini
|| maxi
==255)
1821 result
=mmdif
*240; /* 0...61200=255*240 */
1822 result
/= (mmsum
>255 ? mmsum
=510-mmsum
: mmsum
); /* 0..255 */
1826 case 'H':if (!mmdif
)
1832 iresult
=40*(g
-b
); /* -10200 ... 10200 */
1833 iresult
/=(int)mmdif
; /* -40 .. 40 */
1835 iresult
+=240; /* 0..40 and 200..240 */
1841 iresult
/=(int)mmdif
;
1842 iresult
+=80; /* 40 .. 120 */
1848 iresult
/=(int)mmdif
;
1849 iresult
+=160; /* 120 .. 200 */
1855 return result
; /* is this integer arithmetic precise enough ? */
1860 /***********************************************************************
1861 * CC_MouseCheckPredefColorArray [internal]
1863 static int CC_MouseCheckPredefColorArray(HWND16 hDlg
,int dlgitem
,int rows
,int cols
,
1864 LPARAM lParam
,COLORREF
*cr
)
1867 POINT16 point
= MAKEPOINT16(lParam
);
1871 ClientToScreen16(hDlg
,&point
);
1872 hwnd
=GetDlgItem32(hDlg
,dlgitem
);
1873 GetWindowRect16(hwnd
,&rect
);
1874 if (PtInRect16(&rect
,point
))
1876 dx
=(rect
.right
-rect
.left
)/cols
;
1877 dy
=(rect
.bottom
-rect
.top
)/rows
;
1878 ScreenToClient16(hwnd
,&point
);
1880 if (point
.x
% dx
< (dx
-DISTANCE
) && point
.y
% dy
< (dy
-DISTANCE
))
1884 *cr
=predefcolors
[y
][x
];
1885 /* FIXME: Draw_a_Focus_Rect() */
1892 /***********************************************************************
1893 * CC_MouseCheckUserColorArray [internal]
1895 static int CC_MouseCheckUserColorArray(HWND16 hDlg
,int dlgitem
,int rows
,int cols
,
1896 LPARAM lParam
,COLORREF
*cr
,COLORREF
*crarr
)
1899 POINT16 point
= MAKEPOINT16(lParam
);
1903 ClientToScreen16(hDlg
,&point
);
1904 hwnd
=GetDlgItem32(hDlg
,dlgitem
);
1905 GetWindowRect16(hwnd
,&rect
);
1906 if (PtInRect16(&rect
,point
))
1908 dx
=(rect
.right
-rect
.left
)/cols
;
1909 dy
=(rect
.bottom
-rect
.top
)/rows
;
1910 ScreenToClient16(hwnd
,&point
);
1912 if (point
.x
% dx
< (dx
-DISTANCE
) && point
.y
% dy
< (dy
-DISTANCE
))
1916 *cr
=crarr
[x
+cols
*y
];
1917 /* FIXME: Draw_a_Focus_Rect() */
1927 /* 240 ^...... ^^ 240
1934 /***********************************************************************
1935 * CC_MouseCheckColorGraph [internal]
1937 static int CC_MouseCheckColorGraph(HWND16 hDlg
,int dlgitem
,int *hori
,int *vert
,LPARAM lParam
)
1940 POINT16 point
= MAKEPOINT16(lParam
);
1944 ClientToScreen16(hDlg
,&point
);
1945 hwnd
=GetDlgItem32(hDlg
,dlgitem
);
1946 GetWindowRect16(hwnd
,&rect
);
1947 if (PtInRect16(&rect
,point
))
1949 GetClientRect16(hwnd
,&rect
);
1950 ScreenToClient16(hwnd
,&point
);
1952 x
=(long)point
.x
*MAXHORI
;
1954 y
=(long)(rect
.bottom
-point
.y
)*MAXVERT
;
1966 /***********************************************************************
1967 * CC_MouseCheckResultWindow [internal]
1969 static int CC_MouseCheckResultWindow(HWND16 hDlg
,LPARAM lParam
)
1972 POINT16 point
= MAKEPOINT16(lParam
);
1975 ClientToScreen16(hDlg
,&point
);
1976 hwnd
=GetDlgItem32(hDlg
,0x2c5);
1977 GetWindowRect16(hwnd
,&rect
);
1978 if (PtInRect16(&rect
,point
))
1980 PostMessage16(hDlg
,WM_COMMAND
,0x2c9,0);
1986 /***********************************************************************
1987 * CC_CheckDigitsInEdit [internal]
1989 static int CC_CheckDigitsInEdit(HWND16 hwnd
,int maxval
)
1991 int i
,k
,m
,result
,value
;
1994 GetWindowText32A(hwnd
,buffer
,sizeof(buffer
));
1999 if (buffer
[i
]<'0' || buffer
[i
]>'9')
2001 for (k
=i
+1;k
<=m
;k
++) /* delete bad character */
2003 buffer
[i
]=buffer
[k
];
2011 if (value
>maxval
) /* build a new string */
2013 sprintf(buffer
,"%d",maxval
);
2018 editpos
=SendMessage16(hwnd
,EM_GETSEL16
,0,0);
2019 SetWindowText32A(hwnd
,buffer
);
2020 SendMessage16(hwnd
,EM_SETSEL16
,0,editpos
);
2027 /***********************************************************************
2028 * CC_PaintSelectedColor [internal]
2030 static void CC_PaintSelectedColor(HWND16 hDlg
,COLORREF cr
)
2035 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2c5);
2036 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
2039 GetClientRect16 (hwnd
, &rect
) ;
2040 hBrush
= CreateSolidBrush32(cr
);
2043 hBrush
= SelectObject32 (hdc
, hBrush
) ;
2044 Rectangle32(hdc
, rect
.left
,rect
.top
,rect
.right
/2,rect
.bottom
);
2045 DeleteObject32 (SelectObject32 (hdc
,hBrush
)) ;
2046 hBrush
=CreateSolidBrush32(GetNearestColor32(hdc
,cr
));
2049 hBrush
= SelectObject32 (hdc
, hBrush
) ;
2050 Rectangle32( hdc
, rect
.right
/2-1,rect
.top
,rect
.right
,rect
.bottom
);
2051 DeleteObject32( SelectObject32 (hdc
, hBrush
)) ;
2054 ReleaseDC32(hwnd
,hdc
);
2058 /***********************************************************************
2059 * CC_PaintTriangle [internal]
2061 static void CC_PaintTriangle(HWND16 hDlg
,int y
)
2065 int w
=GetDialogBaseUnits();
2070 HWND16 hwnd
=GetDlgItem32(hDlg
,0x2be);
2071 struct CCPRIVATE
*lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2073 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
2075 GetClientRect16(hwnd
,&rect
);
2079 points
[0].y
=rect
.top
;
2080 points
[0].x
=rect
.right
; /* | /| */
2081 ClientToScreen16(hwnd
,points
); /* | / | */
2082 ScreenToClient16(hDlg
,points
); /* |< | */
2083 oben
=points
[0].y
; /* | \ | */
2085 temp
=(long)height
*(long)y
;
2086 points
[0].y
=oben
+height
-temp
/(long)MAXVERT
;
2087 points
[1].y
=points
[0].y
+w
;
2088 points
[2].y
=points
[0].y
-w
;
2089 points
[2].x
=points
[1].x
=points
[0].x
+ w
;
2091 if (lpp
->old3angle
.left
)
2092 FillRect16(hDC
,&lpp
->old3angle
,GetStockObject32(WHITE_BRUSH
));
2093 lpp
->old3angle
.left
=points
[0].x
;
2094 lpp
->old3angle
.right
=points
[1].x
+1;
2095 lpp
->old3angle
.top
=points
[2].y
-1;
2096 lpp
->old3angle
.bottom
=points
[1].y
+1;
2097 Polygon16(hDC
,points
,3);
2098 ReleaseDC32(hDlg
,hDC
);
2103 /***********************************************************************
2104 * CC_PaintCross [internal]
2106 static void CC_PaintCross(HWND16 hDlg
,int x
,int y
)
2109 int w
=GetDialogBaseUnits();
2110 HWND16 hwnd
=GetDlgItem32(hDlg
,0x2c6);
2111 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2116 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
2118 GetClientRect16(hwnd
,&rect
);
2120 SelectClipRgn32(hDC
,CreateRectRgnIndirect16(&rect
));
2121 hPen
=CreatePen32(PS_SOLID
,2,0);
2122 hPen
=SelectObject32(hDC
,hPen
);
2123 point
.x
=((long)rect
.right
*(long)x
)/(long)MAXHORI
;
2124 point
.y
=rect
.bottom
-((long)rect
.bottom
*(long)y
)/(long)MAXVERT
;
2125 if (lpp
->oldcross
.left
!=lpp
->oldcross
.right
)
2126 BitBlt32(hDC
,lpp
->oldcross
.left
,lpp
->oldcross
.top
,
2127 lpp
->oldcross
.right
-lpp
->oldcross
.left
,
2128 lpp
->oldcross
.bottom
-lpp
->oldcross
.top
,
2129 lpp
->hdcMem
,lpp
->oldcross
.left
,lpp
->oldcross
.top
,SRCCOPY
);
2130 lpp
->oldcross
.left
=point
.x
-w
-1;
2131 lpp
->oldcross
.right
=point
.x
+w
+1;
2132 lpp
->oldcross
.top
=point
.y
-w
-1;
2133 lpp
->oldcross
.bottom
=point
.y
+w
+1;
2135 MoveTo(hDC
,point
.x
-w
,point
.y
);
2136 LineTo32(hDC
,point
.x
+w
,point
.y
);
2137 MoveTo(hDC
,point
.x
,point
.y
-w
);
2138 LineTo32(hDC
,point
.x
,point
.y
+w
);
2139 DeleteObject32(SelectObject32(hDC
,hPen
));
2140 ReleaseDC32(hwnd
,hDC
);
2149 /***********************************************************************
2150 * CC_PrepareColorGraph [internal]
2152 static void CC_PrepareColorGraph(HWND16 hDlg
)
2154 int sdif
,hdif
,xdif
,ydif
,r
,g
,b
,hue
,sat
;
2155 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2c6);
2156 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2160 HCURSOR16 hcursor
=SetCursor16(LoadCursor16(0,IDC_WAIT16
));
2162 GetClientRect16(hwnd
,&client
);
2164 lpp
->hdcMem
= CreateCompatibleDC32(hdc
);
2165 lpp
->hbmMem
= CreateCompatibleBitmap32(hdc
,client
.right
,client
.bottom
);
2166 SelectObject32(lpp
->hdcMem
,lpp
->hbmMem
);
2168 xdif
=client
.right
/XSTEPS
;
2169 ydif
=client
.bottom
/YSTEPS
+1;
2172 for(rect
.left
=hue
=0;hue
<239+hdif
;hue
+=hdif
)
2174 rect
.right
=rect
.left
+xdif
;
2175 rect
.bottom
=client
.bottom
;
2176 for(sat
=0;sat
<240+sdif
;sat
+=sdif
)
2178 rect
.top
=rect
.bottom
-ydif
;
2179 r
=CC_HSLtoRGB('R',hue
,sat
,120);
2180 g
=CC_HSLtoRGB('G',hue
,sat
,120);
2181 b
=CC_HSLtoRGB('B',hue
,sat
,120);
2182 hbrush
=CreateSolidBrush32(RGB(r
,g
,b
));
2183 FillRect16(lpp
->hdcMem
,&rect
,hbrush
);
2184 DeleteObject32(hbrush
);
2185 rect
.bottom
=rect
.top
;
2187 rect
.left
=rect
.right
;
2189 ReleaseDC32(hwnd
,hdc
);
2190 SetCursor16(hcursor
);
2193 /***********************************************************************
2194 * CC_PaintColorGraph [internal]
2196 static void CC_PaintColorGraph(HWND16 hDlg
)
2198 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2c6);
2199 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2202 if (IsWindowVisible32(hwnd
)) /* if full size */
2205 CC_PrepareColorGraph(hDlg
); /* should not be necessary */
2208 GetClientRect16(hwnd
,&rect
);
2210 BitBlt32(hDC
,0,0,rect
.right
,rect
.bottom
,lpp
->hdcMem
,0,0,SRCCOPY
);
2212 WARN(commdlg
,"choose color: hdcMem is not defined\n");
2213 ReleaseDC32(hwnd
,hDC
);
2216 /***********************************************************************
2217 * CC_PaintLumBar [internal]
2219 static void CC_PaintLumBar(HWND16 hDlg
,int hue
,int sat
)
2221 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2be);
2223 int lum
,ldif
,ydif
,r
,g
,b
;
2227 if (IsWindowVisible32(hwnd
))
2230 GetClientRect16(hwnd
,&client
);
2234 ydif
=client
.bottom
/YSTEPS
+1;
2235 for(lum
=0;lum
<240+ldif
;lum
+=ldif
)
2237 rect
.top
=MAX(0,rect
.bottom
-ydif
);
2238 r
=CC_HSLtoRGB('R',hue
,sat
,lum
);
2239 g
=CC_HSLtoRGB('G',hue
,sat
,lum
);
2240 b
=CC_HSLtoRGB('B',hue
,sat
,lum
);
2241 hbrush
=CreateSolidBrush32(RGB(r
,g
,b
));
2242 FillRect16(hDC
,&rect
,hbrush
);
2243 DeleteObject32(hbrush
);
2244 rect
.bottom
=rect
.top
;
2246 GetClientRect16(hwnd
,&rect
);
2247 FrameRect16(hDC
,&rect
,GetStockObject32(BLACK_BRUSH
));
2248 ReleaseDC32(hwnd
,hDC
);
2252 /***********************************************************************
2253 * CC_EditSetRGB [internal]
2255 static void CC_EditSetRGB(HWND16 hDlg
,COLORREF cr
)
2258 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2259 int r
=GetRValue(cr
);
2260 int g
=GetGValue(cr
);
2261 int b
=GetBValue(cr
);
2262 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
2265 sprintf(buffer
,"%d",r
);
2266 SetWindowText32A(GetDlgItem32(hDlg
,0x2c2),buffer
);
2267 sprintf(buffer
,"%d",g
);
2268 SetWindowText32A(GetDlgItem32(hDlg
,0x2c3),buffer
);
2269 sprintf(buffer
,"%d",b
);
2270 SetWindowText32A(GetDlgItem32(hDlg
,0x2c4),buffer
);
2271 lpp
->updating
=FALSE
;
2275 /***********************************************************************
2276 * CC_EditSetHSL [internal]
2278 static void CC_EditSetHSL(HWND16 hDlg
,int h
,int s
,int l
)
2281 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2283 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
2286 sprintf(buffer
,"%d",h
);
2287 SetWindowText32A(GetDlgItem32(hDlg
,0x2bf),buffer
);
2288 sprintf(buffer
,"%d",s
);
2289 SetWindowText32A(GetDlgItem32(hDlg
,0x2c0),buffer
);
2290 sprintf(buffer
,"%d",l
);
2291 SetWindowText32A(GetDlgItem32(hDlg
,0x2c1),buffer
);
2292 lpp
->updating
=FALSE
;
2294 CC_PaintLumBar(hDlg
,h
,s
);
2297 /***********************************************************************
2298 * CC_SwitchToFullSize [internal]
2300 static void CC_SwitchToFullSize(HWND16 hDlg
,COLORREF result
,LPRECT16 lprect
)
2303 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2305 EnableWindow32(GetDlgItem32(hDlg
,0x2cf),FALSE
);
2306 CC_PrepareColorGraph(hDlg
);
2307 for (i
=0x2bf;i
<0x2c5;i
++)
2308 EnableWindow32(GetDlgItem32(hDlg
,i
),TRUE
);
2309 for (i
=0x2d3;i
<0x2d9;i
++)
2310 EnableWindow32(GetDlgItem32(hDlg
,i
),TRUE
);
2311 EnableWindow32(GetDlgItem32(hDlg
,0x2c9),TRUE
);
2312 EnableWindow32(GetDlgItem32(hDlg
,0x2c8),TRUE
);
2315 SetWindowPos32(hDlg
,0,0,0,lprect
->right
-lprect
->left
,
2316 lprect
->bottom
-lprect
->top
, SWP_NOMOVE
|SWP_NOZORDER
);
2318 ShowWindow32(GetDlgItem32(hDlg
,0x2c6),SW_SHOW
);
2319 ShowWindow32(GetDlgItem32(hDlg
,0x2be),SW_SHOW
);
2320 ShowWindow32(GetDlgItem32(hDlg
,0x2c5),SW_SHOW
);
2322 CC_EditSetRGB(hDlg
,result
);
2323 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
2326 /***********************************************************************
2327 * CC_PaintPredefColorArray [internal]
2329 static void CC_PaintPredefColorArray(HWND16 hDlg
,int rows
,int cols
)
2331 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2d0);
2337 GetClientRect16(hwnd
,&rect
);
2339 dy
=rect
.bottom
/rows
;
2343 GetClientRect16 (hwnd
, &rect
) ;
2345 for (j
=0;j
<rows
;j
++)
2347 for (i
=0;i
<cols
;i
++)
2349 hBrush
= CreateSolidBrush32(predefcolors
[j
][i
]);
2352 hBrush
= SelectObject32 (hdc
, hBrush
) ;
2353 Rectangle32(hdc
, rect
.left
, rect
.top
,
2354 rect
.left
+dx
-DISTANCE
, rect
.top
+dy
-DISTANCE
);
2355 rect
.left
=rect
.left
+dx
;
2356 DeleteObject32( SelectObject32 (hdc
, hBrush
)) ;
2359 rect
.top
=rect
.top
+dy
;
2362 ReleaseDC32(hwnd
,hdc
);
2363 /* FIXME: draw_a_focus_rect */
2365 /***********************************************************************
2366 * CC_PaintUserColorArray [internal]
2368 static void CC_PaintUserColorArray(HWND16 hDlg
,int rows
,int cols
,COLORREF
* lpcr
)
2370 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2d1);
2376 GetClientRect16(hwnd
,&rect
);
2379 dy
=rect
.bottom
/rows
;
2385 for (j
=0;j
<rows
;j
++)
2387 for (i
=0;i
<cols
;i
++)
2389 hBrush
= CreateSolidBrush32(lpcr
[i
+j
*cols
]);
2392 hBrush
= SelectObject32 (hdc
, hBrush
) ;
2393 Rectangle32( hdc
, rect
.left
, rect
.top
,
2394 rect
.left
+dx
-DISTANCE
, rect
.top
+dy
-DISTANCE
);
2395 rect
.left
=rect
.left
+dx
;
2396 DeleteObject32( SelectObject32 (hdc
, hBrush
)) ;
2399 rect
.top
=rect
.top
+dy
;
2402 ReleaseDC32(hwnd
,hdc
);
2404 /* FIXME: draw_a_focus_rect */
2409 /***********************************************************************
2410 * CC_HookCallChk [internal]
2412 static BOOL32
CC_HookCallChk(LPCHOOSECOLOR16 lpcc
)
2415 if(lpcc
->Flags
& CC_ENABLEHOOK
)
2421 /***********************************************************************
2422 * CC_WMInitDialog [internal]
2424 static LONG
CC_WMInitDialog(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2430 struct CCPRIVATE
* lpp
;
2432 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
2433 lpp
=calloc(1,sizeof(struct CCPRIVATE
));
2434 lpp
->lpcc
=(LPCHOOSECOLOR16
)lParam
;
2435 if (lpp
->lpcc
->lStructSize
!= sizeof(CHOOSECOLOR16
))
2437 EndDialog32 (hDlg
, 0) ;
2440 SetWindowLong32A(hDlg
, DWL_USER
, (LONG
)lpp
);
2442 if (!(lpp
->lpcc
->Flags
& CC_SHOWHELP
))
2443 ShowWindow32(GetDlgItem32(hDlg
,0x40e),SW_HIDE
);
2444 lpp
->msetrgb
=RegisterWindowMessage32A( SETRGBSTRING
);
2446 cpos
=MAKELONG(5,7); /* init */
2447 if (lpp
->lpcc
->Flags
& CC_RGBINIT
)
2451 if (predefcolors
[i
][j
]==lpp
->lpcc
->rgbResult
)
2458 /* FIXME: Draw_a_focus_rect & set_init_values */
2460 GetWindowRect16(hDlg
,&lpp
->fullsize
);
2461 if (lpp
->lpcc
->Flags
& CC_FULLOPEN
|| lpp
->lpcc
->Flags
& CC_PREVENTFULLOPEN
)
2463 hwnd
=GetDlgItem32(hDlg
,0x2cf);
2464 EnableWindow32(hwnd
,FALSE
);
2466 if (!(lpp
->lpcc
->Flags
& CC_FULLOPEN
) || lpp
->lpcc
->Flags
& CC_PREVENTFULLOPEN
)
2469 res
=rect
.bottom
-rect
.top
;
2470 hwnd
=GetDlgItem32(hDlg
,0x2c6); /* cut at left border */
2472 ClientToScreen16(hwnd
,&point
);
2473 ScreenToClient16(hDlg
,&point
);
2474 GetClientRect16(hDlg
,&rect
);
2475 point
.x
+=GetSystemMetrics32(SM_CXDLGFRAME
);
2476 SetWindowPos32(hDlg
,0,0,0,point
.x
,res
,SWP_NOMOVE
|SWP_NOZORDER
);
2478 ShowWindow32(GetDlgItem32(hDlg
,0x2c6),SW_HIDE
);
2479 ShowWindow32(GetDlgItem32(hDlg
,0x2c5),SW_HIDE
);
2482 CC_SwitchToFullSize(hDlg
,lpp
->lpcc
->rgbResult
,NULL
);
2484 for (i
=0x2bf;i
<0x2c5;i
++)
2485 SendMessage16(GetDlgItem32(hDlg
,i
),EM_LIMITTEXT16
,3,0); /* max 3 digits: xyz */
2486 if (CC_HookCallChk(lpp
->lpcc
))
2487 res
=CallWindowProc16(lpp
->lpcc
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
2491 /***********************************************************************
2492 * CC_WMCommand [internal]
2494 static LRESULT
CC_WMCommand(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2500 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2501 TRACE(commdlg
,"CC_WMCommand wParam=%x lParam=%lx\n",wParam
,lParam
);
2504 case 0x2c2: /* edit notify RGB */
2507 if (HIWORD(lParam
)==EN_UPDATE
&& !lpp
->updating
)
2509 i
=CC_CheckDigitsInEdit(LOWORD(lParam
),255);
2510 r
=GetRValue(lpp
->lpcc
->rgbResult
);
2511 g
=GetGValue(lpp
->lpcc
->rgbResult
);
2512 b
=GetBValue(lpp
->lpcc
->rgbResult
);
2516 case 0x2c2:if ((xx
=(i
!=r
))) r
=i
;break;
2517 case 0x2c3:if ((xx
=(i
!=g
))) g
=i
;break;
2518 case 0x2c4:if ((xx
=(i
!=b
))) b
=i
;break;
2520 if (xx
) /* something has changed */
2522 lpp
->lpcc
->rgbResult
=RGB(r
,g
,b
);
2523 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2524 lpp
->h
=CC_RGBtoHSL('H',r
,g
,b
);
2525 lpp
->s
=CC_RGBtoHSL('S',r
,g
,b
);
2526 lpp
->l
=CC_RGBtoHSL('L',r
,g
,b
);
2527 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
2528 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2529 CC_PaintTriangle(hDlg
,lpp
->l
);
2534 case 0x2bf: /* edit notify HSL */
2537 if (HIWORD(lParam
)==EN_UPDATE
&& !lpp
->updating
)
2539 i
=CC_CheckDigitsInEdit(LOWORD(lParam
),wParam
==0x2bf?239:240);
2543 case 0x2bf:if ((xx
=(i
!=lpp
->h
))) lpp
->h
=i
;break;
2544 case 0x2c0:if ((xx
=(i
!=lpp
->s
))) lpp
->s
=i
;break;
2545 case 0x2c1:if ((xx
=(i
!=lpp
->l
))) lpp
->l
=i
;break;
2547 if (xx
) /* something has changed */
2549 r
=CC_HSLtoRGB('R',lpp
->h
,lpp
->s
,lpp
->l
);
2550 g
=CC_HSLtoRGB('G',lpp
->h
,lpp
->s
,lpp
->l
);
2551 b
=CC_HSLtoRGB('B',lpp
->h
,lpp
->s
,lpp
->l
);
2552 lpp
->lpcc
->rgbResult
=RGB(r
,g
,b
);
2553 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2554 CC_EditSetRGB(hDlg
,lpp
->lpcc
->rgbResult
);
2555 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2556 CC_PaintTriangle(hDlg
,lpp
->l
);
2562 CC_SwitchToFullSize(hDlg
,lpp
->lpcc
->rgbResult
,&lpp
->fullsize
);
2563 InvalidateRect32( hDlg
, NULL
, TRUE
);
2564 SetFocus32(GetDlgItem32(hDlg
,0x2bf));
2567 case 0x2c8: /* add colors ... column by column */
2568 cr
=PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
);
2569 cr
[(lpp
->nextuserdef
%2)*8 + lpp
->nextuserdef
/2]=lpp
->lpcc
->rgbResult
;
2570 if (++lpp
->nextuserdef
==16)
2572 CC_PaintUserColorArray(hDlg
,2,8,PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
));
2575 case 0x2c9: /* resulting color */
2577 lpp
->lpcc
->rgbResult
=GetNearestColor32(hdc
,lpp
->lpcc
->rgbResult
);
2578 ReleaseDC32(hDlg
,hdc
);
2579 CC_EditSetRGB(hDlg
,lpp
->lpcc
->rgbResult
);
2580 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2581 r
=GetRValue(lpp
->lpcc
->rgbResult
);
2582 g
=GetGValue(lpp
->lpcc
->rgbResult
);
2583 b
=GetBValue(lpp
->lpcc
->rgbResult
);
2584 lpp
->h
=CC_RGBtoHSL('H',r
,g
,b
);
2585 lpp
->s
=CC_RGBtoHSL('S',r
,g
,b
);
2586 lpp
->l
=CC_RGBtoHSL('L',r
,g
,b
);
2587 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
2588 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2589 CC_PaintTriangle(hDlg
,lpp
->l
);
2592 case 0x40e: /* Help! */ /* The Beatles, 1965 ;-) */
2593 i
=RegisterWindowMessage32A( HELPMSGSTRING
);
2594 if (lpp
->lpcc
->hwndOwner
)
2595 SendMessage16(lpp
->lpcc
->hwndOwner
,i
,0,(LPARAM
)lpp
->lpcc
);
2596 if (CC_HookCallChk(lpp
->lpcc
))
2597 CallWindowProc16(lpp
->lpcc
->lpfnHook
,hDlg
,
2598 WM_COMMAND
,psh15
,(LPARAM
)lpp
->lpcc
);
2602 cokmsg
=RegisterWindowMessage32A( COLOROKSTRING
);
2603 if (lpp
->lpcc
->hwndOwner
)
2604 if (SendMessage16(lpp
->lpcc
->hwndOwner
,cokmsg
,0,(LPARAM
)lpp
->lpcc
))
2605 break; /* do NOT close */
2607 EndDialog32 (hDlg
, 1) ;
2611 EndDialog32 (hDlg
, 0) ;
2618 /***********************************************************************
2619 * CC_WMPaint [internal]
2621 static LRESULT
CC_WMPaint(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2623 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2624 /* we have to paint dialog children except text and buttons */
2626 CC_PaintPredefColorArray(hDlg
,6,8);
2627 CC_PaintUserColorArray(hDlg
,2,8,PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
));
2628 CC_PaintColorGraph(hDlg
);
2629 CC_PaintLumBar(hDlg
,lpp
->h
,lpp
->s
);
2630 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2631 CC_PaintTriangle(hDlg
,lpp
->l
);
2632 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2634 /* special necessary for Wine */
2635 ValidateRect32(GetDlgItem32(hDlg
,0x2d0),NULL
);
2636 ValidateRect32(GetDlgItem32(hDlg
,0x2d1),NULL
);
2637 ValidateRect32(GetDlgItem32(hDlg
,0x2c6),NULL
);
2638 ValidateRect32(GetDlgItem32(hDlg
,0x2be),NULL
);
2639 ValidateRect32(GetDlgItem32(hDlg
,0x2c5),NULL
);
2640 /* hope we can remove it later -->FIXME */
2645 /***********************************************************************
2646 * CC_WMLButtonDown [internal]
2648 static LRESULT
CC_WMLButtonDown(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2650 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2653 if (CC_MouseCheckPredefColorArray(hDlg
,0x2d0,6,8,lParam
,&lpp
->lpcc
->rgbResult
))
2656 if (CC_MouseCheckUserColorArray(hDlg
,0x2d1,2,8,lParam
,&lpp
->lpcc
->rgbResult
,
2657 PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
)))
2660 if (CC_MouseCheckColorGraph(hDlg
,0x2c6,&lpp
->h
,&lpp
->s
,lParam
))
2663 if (CC_MouseCheckColorGraph(hDlg
,0x2be,NULL
,&lpp
->l
,lParam
))
2667 r
=CC_HSLtoRGB('R',lpp
->h
,lpp
->s
,lpp
->l
);
2668 g
=CC_HSLtoRGB('G',lpp
->h
,lpp
->s
,lpp
->l
);
2669 b
=CC_HSLtoRGB('B',lpp
->h
,lpp
->s
,lpp
->l
);
2670 lpp
->lpcc
->rgbResult
=RGB(r
,g
,b
);
2674 r
=GetRValue(lpp
->lpcc
->rgbResult
);
2675 g
=GetGValue(lpp
->lpcc
->rgbResult
);
2676 b
=GetBValue(lpp
->lpcc
->rgbResult
);
2677 lpp
->h
=CC_RGBtoHSL('H',r
,g
,b
);
2678 lpp
->s
=CC_RGBtoHSL('S',r
,g
,b
);
2679 lpp
->l
=CC_RGBtoHSL('L',r
,g
,b
);
2683 CC_EditSetRGB(hDlg
,lpp
->lpcc
->rgbResult
);
2684 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
2685 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2686 CC_PaintTriangle(hDlg
,lpp
->l
);
2687 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2693 /***********************************************************************
2694 * ColorDlgProc (COMMDLG.8)
2696 LRESULT WINAPI
ColorDlgProc(HWND16 hDlg
, UINT16 message
,
2697 WPARAM16 wParam
, LONG lParam
)
2700 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2701 if (message
!=WM_INITDIALOG
)
2706 if (CC_HookCallChk(lpp
->lpcc
))
2707 res
=CallWindowProc16(lpp
->lpcc
->lpfnHook
,hDlg
,message
,wParam
,lParam
);
2712 /* FIXME: SetRGB message
2713 if (message && message==msetrgb)
2714 return HandleSetRGB(hDlg,lParam);
2720 return CC_WMInitDialog(hDlg
,wParam
,lParam
);
2722 DeleteDC32(lpp
->hdcMem
);
2723 DeleteObject32(lpp
->hbmMem
);
2725 SetWindowLong32A(hDlg
, DWL_USER
, 0L); /* we don't need it anymore */
2728 if (CC_WMCommand(hDlg
, wParam
, lParam
))
2732 CC_WMPaint(hDlg
, wParam
, lParam
);
2734 case WM_LBUTTONDBLCLK
:
2735 if (CC_MouseCheckResultWindow(hDlg
,lParam
))
2738 case WM_MOUSEMOVE
: /* FIXME: calculate new hue,sat,lum (if in color graph) */
2740 case WM_LBUTTONUP
: /* FIXME: ClipCursor off (if in color graph)*/
2742 case WM_LBUTTONDOWN
:/* FIXME: ClipCursor on (if in color graph)*/
2743 if (CC_WMLButtonDown(hDlg
, wParam
, lParam
))
2750 static void CFn_CHOOSEFONT16to32A(LPCHOOSEFONT16 chf16
, LPCHOOSEFONT32A chf32a
)
2752 chf32a
->lStructSize
=sizeof(CHOOSEFONT32A
);
2753 chf32a
->hwndOwner
=chf16
->hwndOwner
;
2754 chf32a
->hDC
=chf16
->hDC
;
2755 chf32a
->iPointSize
=chf16
->iPointSize
;
2756 chf32a
->Flags
=chf16
->Flags
;
2757 chf32a
->rgbColors
=chf16
->rgbColors
;
2758 chf32a
->lCustData
=chf16
->lCustData
;
2759 chf32a
->lpfnHook
=NULL
;
2760 chf32a
->lpTemplateName
=PTR_SEG_TO_LIN(chf16
->lpTemplateName
);
2761 chf32a
->hInstance
=chf16
->hInstance
;
2762 chf32a
->lpszStyle
=PTR_SEG_TO_LIN(chf16
->lpszStyle
);
2763 chf32a
->nFontType
=chf16
->nFontType
;
2764 chf32a
->nSizeMax
=chf16
->nSizeMax
;
2765 chf32a
->nSizeMin
=chf16
->nSizeMin
;
2766 FONT_LogFont16To32A(PTR_SEG_TO_LIN(chf16
->lpLogFont
), chf32a
->lpLogFont
);
2770 /***********************************************************************
2771 * ChooseFont16 (COMMDLG.15)
2773 BOOL16 WINAPI
ChooseFont16(LPCHOOSEFONT16 lpChFont
)
2776 HANDLE16 hDlgTmpl
= 0;
2777 BOOL16 bRet
= FALSE
, win32Format
= FALSE
;
2780 CHOOSEFONT32A cf32a
;
2782 SEGPTR lpTemplateName
;
2784 cf32a
.lpLogFont
=&lf32a
;
2785 CFn_CHOOSEFONT16to32A(lpChFont
, &cf32a
);
2787 TRACE(commdlg
,"ChooseFont\n");
2788 if (!lpChFont
) return FALSE
;
2790 if (lpChFont
->Flags
& CF_ENABLETEMPLATEHANDLE
)
2792 if (!(template = LockResource16( lpChFont
->hInstance
)))
2794 CommDlgLastError
= CDERR_LOADRESFAILURE
;
2798 else if (lpChFont
->Flags
& CF_ENABLETEMPLATE
)
2801 if (!(hResInfo
= FindResource16( lpChFont
->hInstance
,
2802 lpChFont
->lpTemplateName
,
2805 CommDlgLastError
= CDERR_FINDRESFAILURE
;
2808 if (!(hDlgTmpl
= LoadResource16( lpChFont
->hInstance
, hResInfo
)) ||
2809 !(template = LockResource16( hDlgTmpl
)))
2811 CommDlgLastError
= CDERR_LOADRESFAILURE
;
2817 template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT
);
2821 hInst
= WIN_GetWindowInstance( lpChFont
->hwndOwner
);
2823 /* lpTemplateName is not used in the dialog */
2824 lpTemplateName
=lpChFont
->lpTemplateName
;
2825 lpChFont
->lpTemplateName
=(SEGPTR
)&cf32a
;
2827 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, win32Format
,
2828 lpChFont
->hwndOwner
,
2829 (DLGPROC16
)MODULE_GetWndProcEntry16("FormatCharDlgProc"),
2830 (DWORD
)lpChFont
, WIN_PROC_16
);
2831 if (hwndDialog
) bRet
= DIALOG_DoDialogBox(hwndDialog
, lpChFont
->hwndOwner
);
2832 if (hDlgTmpl
) FreeResource16( hDlgTmpl
);
2833 lpChFont
->lpTemplateName
=lpTemplateName
;
2834 FONT_LogFont32ATo16(cf32a
.lpLogFont
,
2835 (LPLOGFONT16
)(PTR_SEG_TO_LIN(lpChFont
->lpLogFont
)));
2840 /***********************************************************************
2841 * ChooseFont32A (COMDLG32.3)
2843 BOOL32 WINAPI
ChooseFont32A(LPCHOOSEFONT32A lpChFont
)
2847 HINSTANCE32 hInst
=WIN_GetWindowInstance( lpChFont
->hwndOwner
);
2848 LPCVOID
template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT
);
2849 if (lpChFont
->Flags
& (CF_SELECTSCRIPT
| CF_NOVERTFONTS
| CF_ENABLETEMPLATE
|
2850 CF_ENABLETEMPLATEHANDLE
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
2851 hwndDialog
= DIALOG_CreateIndirect(hInst
, template, TRUE
, lpChFont
->hwndOwner
,
2852 (DLGPROC16
)FormatCharDlgProc32A
, (LPARAM
)lpChFont
, WIN_PROC_32A
);
2853 if (hwndDialog
) bRet
= DIALOG_DoDialogBox(hwndDialog
, lpChFont
->hwndOwner
);
2857 /***********************************************************************
2858 * ChooseFont32W (COMDLG32.4)
2860 BOOL32 WINAPI
ChooseFont32W(LPCHOOSEFONT32W lpChFont
)
2864 HINSTANCE32 hInst
=WIN_GetWindowInstance( lpChFont
->hwndOwner
);
2865 CHOOSEFONT32A cf32a
;
2867 LPCVOID
template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT
);
2868 if (lpChFont
->Flags
& (CF_SELECTSCRIPT
| CF_NOVERTFONTS
| CF_ENABLETEMPLATE
|
2869 CF_ENABLETEMPLATEHANDLE
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
2870 memcpy(&cf32a
, lpChFont
, sizeof(cf32a
));
2871 memcpy(&lf32a
, lpChFont
->lpLogFont
, sizeof(LOGFONT32A
));
2872 lstrcpynWtoA(lf32a
.lfFaceName
, lpChFont
->lpLogFont
->lfFaceName
, LF_FACESIZE
);
2873 cf32a
.lpLogFont
=&lf32a
;
2874 cf32a
.lpszStyle
=HEAP_strdupWtoA(GetProcessHeap(), 0, lpChFont
->lpszStyle
);
2875 lpChFont
->lpTemplateName
=(LPWSTR
)&cf32a
;
2876 hwndDialog
=DIALOG_CreateIndirect(hInst
, template, TRUE
, lpChFont
->hwndOwner
,
2877 (DLGPROC16
)FormatCharDlgProc32W
, (LPARAM
)lpChFont
, WIN_PROC_32W
);
2878 if (hwndDialog
)bRet
=DIALOG_DoDialogBox(hwndDialog
, lpChFont
->hwndOwner
);
2879 HeapFree(GetProcessHeap(), 0, cf32a
.lpszStyle
);
2880 lpChFont
->lpTemplateName
=(LPWSTR
)cf32a
.lpTemplateName
;
2881 memcpy(lpChFont
->lpLogFont
, &lf32a
, sizeof(CHOOSEFONT32A
));
2882 lstrcpynAtoW(lpChFont
->lpLogFont
->lfFaceName
, lf32a
.lfFaceName
, LF_FACESIZE
);
2887 #define TEXT_EXTRAS 4
2888 #define TEXT_COLORS 16
2890 static const COLORREF textcolors
[TEXT_COLORS
]=
2892 0x00000000L
,0x00000080L
,0x00008000L
,0x00008080L
,
2893 0x00800000L
,0x00800080L
,0x00808000L
,0x00808080L
,
2894 0x00c0c0c0L
,0x000000ffL
,0x0000ff00L
,0x0000ffffL
,
2895 0x00ff0000L
,0x00ff00ffL
,0x00ffff00L
,0x00FFFFFFL
2898 /***********************************************************************
2899 * CFn_HookCallChk [internal]
2901 static BOOL32
CFn_HookCallChk(LPCHOOSEFONT16 lpcf
)
2904 if(lpcf
->Flags
& CF_ENABLEHOOK
)
2910 /***********************************************************************
2911 * CFn_HookCallChk32 [internal]
2913 static BOOL32
CFn_HookCallChk32(LPCHOOSEFONT32A lpcf
)
2916 if(lpcf
->Flags
& CF_ENABLEHOOK
)
2923 /*************************************************************************
2924 * AddFontFamily [internal]
2926 static INT32
AddFontFamily(LPLOGFONT32A lplf
, UINT32 nFontType
,
2927 LPCHOOSEFONT32A lpcf
, HWND32 hwnd
)
2932 TRACE(commdlg
,"font=%s (nFontType=%d)\n", lplf
->lfFaceName
,nFontType
);
2934 if (lpcf
->Flags
& CF_FIXEDPITCHONLY
)
2935 if (!(lplf
->lfPitchAndFamily
& FIXED_PITCH
))
2937 if (lpcf
->Flags
& CF_ANSIONLY
)
2938 if (lplf
->lfCharSet
!= ANSI_CHARSET
)
2940 if (lpcf
->Flags
& CF_TTONLY
)
2941 if (!(nFontType
& TRUETYPE_FONTTYPE
))
2944 i
=SendMessage32A(hwnd
, CB_ADDSTRING32
, 0, (LPARAM
)lplf
->lfFaceName
);
2947 w
=(lplf
->lfCharSet
<< 8) | lplf
->lfPitchAndFamily
;
2948 SendMessage32A(hwnd
, CB_SETITEMDATA32
, i
, MAKELONG(nFontType
,w
));
2949 return 1 ; /* store some important font information */
2959 LPCHOOSEFONT32A lpcf32a
;
2960 } CFn_ENUMSTRUCT
, *LPCFn_ENUMSTRUCT
;
2962 /*************************************************************************
2963 * FontFamilyEnumProc32 [internal]
2965 INT32 WINAPI
FontFamilyEnumProc32(LPENUMLOGFONT32A lpEnumLogFont
,
2966 LPNEWTEXTMETRIC32A metrics
, UINT32 nFontType
, LPARAM lParam
)
2969 e
=(LPCFn_ENUMSTRUCT
)lParam
;
2970 return AddFontFamily(&lpEnumLogFont
->elfLogFont
, nFontType
, e
->lpcf32a
, e
->hWnd1
);
2973 /***********************************************************************
2974 * FontFamilyEnumProc16 (COMMDLG.19)
2976 INT16 WINAPI
FontFamilyEnumProc16( SEGPTR logfont
, SEGPTR metrics
,
2977 UINT16 nFontType
, LPARAM lParam
)
2979 HWND16 hwnd
=LOWORD(lParam
);
2980 HWND16 hDlg
=GetParent16(hwnd
);
2981 LPCHOOSEFONT16 lpcf
=(LPCHOOSEFONT16
)GetWindowLong32A(hDlg
, DWL_USER
);
2982 LOGFONT16
*lplf
= (LOGFONT16
*)PTR_SEG_TO_LIN( logfont
);
2984 FONT_LogFont16To32A(lplf
, &lf32a
);
2985 return AddFontFamily(&lf32a
, nFontType
, (LPCHOOSEFONT32A
)lpcf
->lpTemplateName
,
2989 /*************************************************************************
2990 * SetFontStylesToCombo2 [internal]
2992 * Fill font style information into combobox (without using font.c directly)
2994 static int SetFontStylesToCombo2(HWND32 hwnd
, HDC32 hdc
, LPLOGFONT32A lplf
)
3001 static struct FONTSTYLE fontstyles
[FSTYLES
]={
3002 { 0,FW_NORMAL
,"Regular"},{0,FW_BOLD
,"Bold"},
3003 { 1,FW_NORMAL
,"Italic"}, {1,FW_BOLD
,"Bold Italic"}};
3008 for (i
=0;i
<FSTYLES
;i
++)
3010 lplf
->lfItalic
=fontstyles
[i
].italic
;
3011 lplf
->lfWeight
=fontstyles
[i
].weight
;
3012 hf
=CreateFontIndirect32A(lplf
);
3013 hf
=SelectObject32(hdc
,hf
);
3014 GetTextMetrics16(hdc
,&tm
);
3015 hf
=SelectObject32(hdc
,hf
);
3018 if (tm
.tmWeight
==fontstyles
[i
].weight
&&
3019 tm
.tmItalic
==fontstyles
[i
].italic
) /* font successful created ? */
3021 char *str
= SEGPTR_STRDUP(fontstyles
[i
].stname
);
3022 j
=SendMessage16(hwnd
,CB_ADDSTRING16
,0,(LPARAM
)SEGPTR_GET(str
) );
3024 if (j
==CB_ERR
) return 1;
3025 j
=SendMessage16(hwnd
, CB_SETITEMDATA16
, j
,
3026 MAKELONG(fontstyles
[i
].weight
,fontstyles
[i
].italic
));
3027 if (j
==CB_ERR
) return 1;
3033 /*************************************************************************
3034 * AddFontSizeToCombo3 [internal]
3036 static int AddFontSizeToCombo3(HWND32 hwnd
, UINT32 h
, LPCHOOSEFONT32A lpcf
)
3041 if ( (!(lpcf
->Flags
& CF_LIMITSIZE
)) ||
3042 ((lpcf
->Flags
& CF_LIMITSIZE
) && (h
>= lpcf
->nSizeMin
) && (h
<= lpcf
->nSizeMax
)))
3044 sprintf(buffer
, "%2d", h
);
3045 j
=SendMessage32A(hwnd
, CB_FINDSTRINGEXACT32
, -1, (LPARAM
)buffer
);
3048 j
=SendMessage32A(hwnd
, CB_ADDSTRING32
, 0, (LPARAM
)buffer
);
3049 if (j
!=CB_ERR
) j
= SendMessage32A(hwnd
, CB_SETITEMDATA32
, j
, h
);
3050 if (j
==CB_ERR
) return 1;
3056 /*************************************************************************
3057 * SetFontSizesToCombo3 [internal]
3059 static int SetFontSizesToCombo3(HWND32 hwnd
, LPCHOOSEFONT32A lpcf
)
3061 static const int sizes
[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72,0};
3064 for (i
=0; sizes
[i
]; i
++)
3065 if (AddFontSizeToCombo3(hwnd
, sizes
[i
], lpcf
)) return 1;
3069 /***********************************************************************
3070 * AddFontStyle [internal]
3072 INT32
AddFontStyle(LPLOGFONT32A lplf
, UINT32 nFontType
,
3073 LPCHOOSEFONT32A lpcf
, HWND32 hcmb2
, HWND32 hcmb3
, HWND32 hDlg
)
3077 TRACE(commdlg
,"(nFontType=%d)\n",nFontType
);
3078 TRACE(commdlg
," %s h=%d w=%d e=%d o=%d wg=%d i=%d u=%d s=%d"
3079 " ch=%d op=%d cp=%d q=%d pf=%xh\n",
3080 lplf
->lfFaceName
,lplf
->lfHeight
,lplf
->lfWidth
,
3081 lplf
->lfEscapement
,lplf
->lfOrientation
,
3082 lplf
->lfWeight
,lplf
->lfItalic
,lplf
->lfUnderline
,
3083 lplf
->lfStrikeOut
,lplf
->lfCharSet
, lplf
->lfOutPrecision
,
3084 lplf
->lfClipPrecision
,lplf
->lfQuality
, lplf
->lfPitchAndFamily
);
3085 if (nFontType
& RASTER_FONTTYPE
)
3087 if (AddFontSizeToCombo3(hcmb3
, lplf
->lfHeight
, lpcf
)) return 0;
3088 } else if (SetFontSizesToCombo3(hcmb3
, lpcf
)) return 0;
3090 if (!SendMessage32A(hcmb2
, CB_GETCOUNT32
, 0, 0))
3092 HDC32 hdc
= (lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
) ? lpcf
->hDC
: GetDC32(hDlg
);
3093 i
=SetFontStylesToCombo2(hcmb2
,hdc
,lplf
);
3094 if (!(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
))
3095 ReleaseDC32(hDlg
,hdc
);
3103 /***********************************************************************
3104 * FontStyleEnumProc16 (COMMDLG.18)
3106 INT16 WINAPI
FontStyleEnumProc16( SEGPTR logfont
, SEGPTR metrics
,
3107 UINT16 nFontType
, LPARAM lParam
)
3109 HWND16 hcmb2
=LOWORD(lParam
);
3110 HWND16 hcmb3
=HIWORD(lParam
);
3111 HWND16 hDlg
=GetParent16(hcmb3
);
3112 LPCHOOSEFONT16 lpcf
=(LPCHOOSEFONT16
)GetWindowLong32A(hDlg
, DWL_USER
);
3113 LOGFONT16
*lplf
= (LOGFONT16
*)PTR_SEG_TO_LIN(logfont
);
3115 FONT_LogFont16To32A(lplf
, &lf32a
);
3116 return AddFontStyle(&lf32a
, nFontType
, (LPCHOOSEFONT32A
)lpcf
->lpTemplateName
,
3117 hcmb2
, hcmb3
, hDlg
);
3120 /***********************************************************************
3121 * FontStyleEnumProc32 [internal]
3123 INT32 WINAPI
FontStyleEnumProc32( LPENUMLOGFONT32A lpFont
,
3124 LPNEWTEXTMETRIC32A metrics
, UINT32 nFontType
, LPARAM lParam
)
3126 LPCFn_ENUMSTRUCT s
=(LPCFn_ENUMSTRUCT
)lParam
;
3127 HWND32 hcmb2
=s
->hWnd1
;
3128 HWND32 hcmb3
=s
->hWnd2
;
3129 HWND32 hDlg
=GetParent32(hcmb3
);
3130 return AddFontStyle(&lpFont
->elfLogFont
, nFontType
, s
->lpcf32a
, hcmb2
,
3134 /***********************************************************************
3135 * CFn_WMInitDialog [internal]
3137 LRESULT
CFn_WMInitDialog(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
,
3138 LPCHOOSEFONT32A lpcf
)
3144 HCURSOR32 hcursor
=SetCursor32(LoadCursor32A(0,IDC_WAIT32A
));
3146 SetWindowLong32A(hDlg
, DWL_USER
, lParam
);
3147 lpxx
=lpcf
->lpLogFont
;
3148 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
3150 if (lpcf
->lStructSize
!= sizeof(CHOOSEFONT32A
))
3152 ERR(commdlg
,"structure size failure !!!\n");
3153 EndDialog32 (hDlg
, 0);
3157 hBitmapTT
= LoadBitmap32A(0, MAKEINTRESOURCE32A(OBM_TRTYPE
));
3159 /* This font will be deleted by WM_COMMAND */
3160 SendDlgItemMessage32A(hDlg
,stc6
,WM_SETFONT
,
3161 CreateFont32A(0, 0, 1, 1, 400, 0, 0, 0, 0, 0, 0, 0, 0, NULL
),FALSE
);
3163 if (!(lpcf
->Flags
& CF_SHOWHELP
) || !IsWindow32(lpcf
->hwndOwner
))
3164 ShowWindow32(GetDlgItem32(hDlg
,pshHelp
),SW_HIDE
);
3165 if (!(lpcf
->Flags
& CF_APPLY
))
3166 ShowWindow32(GetDlgItem32(hDlg
,psh3
),SW_HIDE
);
3167 if (lpcf
->Flags
& CF_EFFECTS
)
3169 for (res
=1,i
=0;res
&& i
<TEXT_COLORS
;i
++)
3171 /* FIXME: load color name from resource: res=LoadString(...,i+....,buffer,.....); */
3173 strcpy( name
, "[color name]" );
3174 j
=SendDlgItemMessage32A(hDlg
, cmb4
, CB_ADDSTRING32
, 0, (LPARAM
)name
);
3175 SendDlgItemMessage32A(hDlg
, cmb4
, CB_SETITEMDATA16
, j
, textcolors
[j
]);
3176 /* look for a fitting value in color combobox */
3177 if (textcolors
[j
]==lpcf
->rgbColors
)
3178 SendDlgItemMessage32A(hDlg
,cmb4
, CB_SETCURSEL32
,j
,0);
3183 ShowWindow32(GetDlgItem32(hDlg
,cmb4
),SW_HIDE
);
3184 ShowWindow32(GetDlgItem32(hDlg
,chx1
),SW_HIDE
);
3185 ShowWindow32(GetDlgItem32(hDlg
,chx2
),SW_HIDE
);
3186 ShowWindow32(GetDlgItem32(hDlg
,grp1
),SW_HIDE
);
3187 ShowWindow32(GetDlgItem32(hDlg
,stc4
),SW_HIDE
);
3189 hdc
= (lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
) ? lpcf
->hDC
: GetDC32(hDlg
);
3193 s
.hWnd1
=GetDlgItem32(hDlg
,cmb1
);
3195 if (!EnumFontFamilies32A(hdc
, NULL
, FontFamilyEnumProc32
, (LPARAM
)&s
))
3196 TRACE(commdlg
,"EnumFontFamilies returns 0\n");
3197 if (lpcf
->Flags
& CF_INITTOLOGFONTSTRUCT
)
3199 /* look for fitting font name in combobox1 */
3200 j
=SendDlgItemMessage32A(hDlg
,cmb1
,CB_FINDSTRING32
,-1,(LONG
)lpxx
->lfFaceName
);
3203 SendDlgItemMessage32A(hDlg
, cmb1
, CB_SETCURSEL32
, j
, 0);
3204 SendMessage32A(hDlg
, WM_COMMAND
, MAKEWPARAM(cmb1
, CBN_SELCHANGE
),
3205 GetDlgItem32(hDlg
,cmb1
));
3207 /* look for fitting font style in combobox2 */
3208 l
=MAKELONG(lpxx
->lfWeight
> FW_MEDIUM
? FW_BOLD
:FW_NORMAL
,lpxx
->lfItalic
!=0);
3209 for (i
=0;i
<TEXT_EXTRAS
;i
++)
3211 if (l
==SendDlgItemMessage32A(hDlg
, cmb2
, CB_GETITEMDATA32
, i
, 0))
3212 SendDlgItemMessage32A(hDlg
, cmb2
, CB_SETCURSEL32
, i
, 0);
3215 /* look for fitting font size in combobox3 */
3216 j
=SendDlgItemMessage32A(hDlg
, cmb3
, CB_GETCOUNT32
, 0, 0);
3219 if (lpxx
->lfHeight
==(int)SendDlgItemMessage32A(hDlg
,cmb3
, CB_GETITEMDATA32
,i
,0))
3220 SendDlgItemMessage32A(hDlg
,cmb3
,CB_SETCURSEL32
,i
,0);
3226 SendDlgItemMessage32A(hDlg
,cmb1
,CB_SETCURSEL32
,0,0);
3227 SendMessage32A(hDlg
, WM_COMMAND
, MAKEWPARAM(cmb1
, CBN_SELCHANGE
),
3228 GetDlgItem32(hDlg
,cmb1
));
3230 if (lpcf
->Flags
& CF_USESTYLE
&& lpcf
->lpszStyle
)
3232 j
=SendDlgItemMessage32A(hDlg
,cmb2
,CB_FINDSTRING32
,-1,(LONG
)lpcf
->lpszStyle
);
3235 j
=SendDlgItemMessage32A(hDlg
,cmb2
,CB_SETCURSEL32
,j
,0);
3236 SendMessage32A(hDlg
,WM_COMMAND
,cmb2
,
3237 MAKELONG(GetDlgItem32(hDlg
,cmb2
),CBN_SELCHANGE
));
3243 WARN(commdlg
,"HDC failure !!!\n");
3244 EndDialog32 (hDlg
, 0);
3248 if (!(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
))
3249 ReleaseDC32(hDlg
,hdc
);
3250 SetCursor32(hcursor
);
3255 /***********************************************************************
3256 * CFn_WMMeasureItem [internal]
3258 LRESULT
CFn_WMMeasureItem(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
)
3261 LPMEASUREITEMSTRUCT32 lpmi
=(LPMEASUREITEMSTRUCT32
)lParam
;
3263 hBitmapTT
= LoadBitmap32A(0, MAKEINTRESOURCE32A(OBM_TRTYPE
));
3264 GetObject32A( hBitmapTT
, sizeof(bm
), &bm
);
3265 lpmi
->itemHeight
=bm
.bmHeight
;
3266 /* FIXME: use MAX of bm.bmHeight and tm.tmHeight .*/
3271 /***********************************************************************
3272 * CFn_WMDrawItem [internal]
3274 LRESULT
CFn_WMDrawItem(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
)
3279 COLORREF cr
, oldText
=0, oldBk
=0;
3284 HBITMAP32 hBitmap
; /* for later TT usage */
3286 LPDRAWITEMSTRUCT32 lpdi
= (LPDRAWITEMSTRUCT32
)lParam
;
3288 if (lpdi
->itemID
== 0xFFFF) /* got no items */
3289 DrawFocusRect32(lpdi
->hDC
, &lpdi
->rcItem
);
3292 if (lpdi
->CtlType
== ODT_COMBOBOX
)
3294 if (lpdi
->itemState
==ODS_SELECTED
)
3296 hBrush
=GetSysColorBrush32(COLOR_HIGHLIGHT
);
3297 oldText
=SetTextColor32(lpdi
->hDC
, GetSysColor32(COLOR_HIGHLIGHTTEXT
));
3298 oldBk
=SetBkColor32(lpdi
->hDC
, GetSysColor32(COLOR_HIGHLIGHT
));
3301 hBrush
= SelectObject32(lpdi
->hDC
, GetStockObject32(LTGRAY_BRUSH
));
3302 SelectObject32(lpdi
->hDC
, hBrush
);
3304 FillRect32(lpdi
->hDC
, &lpdi
->rcItem
, hBrush
);
3307 return TRUE
; /* this should never happen */
3310 switch (lpdi
->CtlID
)
3312 case cmb1
: /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
3313 SendMessage32A(lpdi
->hwndItem
, CB_GETLBTEXT32
, lpdi
->itemID
,
3315 GetObject32A( hBitmapTT
, sizeof(bm
), &bm
);
3316 TextOut32A(lpdi
->hDC
, lpdi
->rcItem
.left
+ bm
.bmWidth
+ 10,
3317 lpdi
->rcItem
.top
, buffer
, lstrlen32A(buffer
));
3319 nFontType
= SendMessage32A(lpdi
->hwndItem
, CB_GETITEMDATA32
, lpdi
->itemID
,0L);
3320 /* FIXME: draw bitmap if truetype usage */
3321 if (nFontType
&TRUETYPE_FONTTYPE
)
3323 hMemDC
= CreateCompatibleDC32(lpdi
->hDC
);
3324 hBitmap
= SelectObject32(hMemDC
, hBitmapTT
);
3325 BitBlt32(lpdi
->hDC
, lpdi
->rcItem
.left
, lpdi
->rcItem
.top
,
3326 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
3327 SelectObject32(hMemDC
, hBitmap
);
3333 case cmb3
: /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
3334 SendMessage32A(lpdi
->hwndItem
, CB_GETLBTEXT32
, lpdi
->itemID
,
3336 TextOut32A(lpdi
->hDC
, lpdi
->rcItem
.left
,
3337 lpdi
->rcItem
.top
, buffer
, lstrlen32A(buffer
));
3340 case cmb4
: /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
3341 SendMessage32A(lpdi
->hwndItem
, CB_GETLBTEXT32
, lpdi
->itemID
,
3343 TextOut32A(lpdi
->hDC
, lpdi
->rcItem
.left
+ 25+5,
3344 lpdi
->rcItem
.top
, buffer
, lstrlen32A(buffer
));
3345 cr
= SendMessage32A(lpdi
->hwndItem
, CB_GETITEMDATA32
, lpdi
->itemID
,0L);
3346 hBrush
= CreateSolidBrush32(cr
);
3349 hBrush
= SelectObject32 (lpdi
->hDC
, hBrush
) ;
3350 rect
.right
=rect
.left
+25;
3354 Rectangle32( lpdi
->hDC
, rect
.left
, rect
.top
,
3355 rect
.right
, rect
.bottom
);
3356 DeleteObject32( SelectObject32 (lpdi
->hDC
, hBrush
)) ;
3362 default: return TRUE
; /* this should never happen */
3364 if (lpdi
->itemState
== ODS_SELECTED
)
3366 SetTextColor32(lpdi
->hDC
, oldText
);
3367 SetBkColor32(lpdi
->hDC
, oldBk
);
3373 /***********************************************************************
3374 * CFn_WMCtlColor [internal]
3376 LRESULT
CFn_WMCtlColorStatic(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
,
3377 LPCHOOSEFONT32A lpcf
)
3379 if (lpcf
->Flags
& CF_EFFECTS
)
3380 if (GetDlgCtrlID32(lParam
)==stc6
)
3382 SetTextColor32((HDC32
)wParam
, lpcf
->rgbColors
);
3383 return GetStockObject32(WHITE_BRUSH
);
3388 /***********************************************************************
3389 * CFn_WMCommand [internal]
3391 LRESULT
CFn_WMCommand(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
,
3392 LPCHOOSEFONT32A lpcf
)
3398 LPLOGFONT32A lpxx
=lpcf
->lpLogFont
;
3400 TRACE(commdlg
,"WM_COMMAND wParam=%08lX lParam=%08lX\n", (LONG
)wParam
, lParam
);
3401 switch (LOWORD(wParam
))
3403 case cmb1
:if (HIWORD(wParam
)==CBN_SELCHANGE
)
3405 hdc
=(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
) ? lpcf
->hDC
: GetDC32(hDlg
);
3408 SendDlgItemMessage32A(hDlg
, cmb2
, CB_RESETCONTENT16
, 0, 0);
3409 SendDlgItemMessage32A(hDlg
, cmb3
, CB_RESETCONTENT16
, 0, 0);
3410 i
=SendDlgItemMessage32A(hDlg
, cmb1
, CB_GETCURSEL16
, 0, 0);
3413 HCURSOR32 hcursor
=SetCursor32(LoadCursor32A(0,IDC_WAIT32A
));
3416 SendDlgItemMessage32A(hDlg
, cmb1
, CB_GETLBTEXT32
, i
,
3418 TRACE(commdlg
,"WM_COMMAND/cmb1 =>%s\n",str
);
3419 s
.hWnd1
=GetDlgItem32(hDlg
, cmb2
);
3420 s
.hWnd2
=GetDlgItem32(hDlg
, cmb3
);
3422 EnumFontFamilies32A(hdc
, str
, FontStyleEnumProc32
, (LPARAM
)&s
);
3423 SetCursor32(hcursor
);
3425 if (!(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
))
3426 ReleaseDC32(hDlg
,hdc
);
3430 WARN(commdlg
,"HDC failure !!!\n");
3431 EndDialog32 (hDlg
, 0);
3438 case cmb3
:if (HIWORD(wParam
)==CBN_SELCHANGE
|| HIWORD(wParam
)== BN_CLICKED
)
3441 TRACE(commdlg
,"WM_COMMAND/cmb2,3 =%08lX\n", lParam
);
3442 i
=SendDlgItemMessage32A(hDlg
,cmb1
,CB_GETCURSEL32
,0,0);
3444 i
=GetDlgItemText32A( hDlg
, cmb1
, str
, 256 );
3447 SendDlgItemMessage32A(hDlg
,cmb1
,CB_GETLBTEXT32
,i
,
3449 l
=SendDlgItemMessage32A(hDlg
,cmb1
,CB_GETITEMDATA32
,i
,0);
3451 lpcf
->nFontType
= LOWORD(l
);
3452 /* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */
3453 /* same value reported to the EnumFonts
3454 call back with the extra FONTTYPE_... bits added */
3455 lpxx
->lfPitchAndFamily
=j
&0xff;
3456 lpxx
->lfCharSet
=j
>>8;
3458 strcpy(lpxx
->lfFaceName
,str
);
3459 i
=SendDlgItemMessage32A(hDlg
, cmb2
, CB_GETCURSEL32
, 0, 0);
3462 l
=SendDlgItemMessage32A(hDlg
, cmb2
, CB_GETITEMDATA32
, i
, 0);
3463 if (0!=(lpxx
->lfItalic
=HIWORD(l
)))
3464 lpcf
->nFontType
|= ITALIC_FONTTYPE
;
3465 if ((lpxx
->lfWeight
=LOWORD(l
)) > FW_MEDIUM
)
3466 lpcf
->nFontType
|= BOLD_FONTTYPE
;
3468 i
=SendDlgItemMessage32A(hDlg
, cmb3
, CB_GETCURSEL32
, 0, 0);
3470 lpxx
->lfHeight
=-LOWORD(SendDlgItemMessage32A(hDlg
, cmb3
, CB_GETITEMDATA32
, i
, 0));
3473 lpxx
->lfStrikeOut
=IsDlgButtonChecked32(hDlg
,chx1
);
3474 lpxx
->lfUnderline
=IsDlgButtonChecked32(hDlg
,chx2
);
3475 lpxx
->lfWidth
=lpxx
->lfOrientation
=lpxx
->lfEscapement
=0;
3476 lpxx
->lfOutPrecision
=OUT_DEFAULT_PRECIS
;
3477 lpxx
->lfClipPrecision
=CLIP_DEFAULT_PRECIS
;
3478 lpxx
->lfQuality
=DEFAULT_QUALITY
;
3479 lpcf
->iPointSize
= -10*lpxx
->lfHeight
;
3481 hFont
=CreateFontIndirect32A(lpxx
);
3484 HFONT32 oldFont
=SendDlgItemMessage32A(hDlg
, stc6
,
3486 SendDlgItemMessage32A(hDlg
,stc6
,WM_SETFONT
,hFont
,TRUE
);
3487 DeleteObject32(oldFont
);
3492 case cmb4
:i
=SendDlgItemMessage32A(hDlg
, cmb4
, CB_GETCURSEL32
, 0, 0);
3495 lpcf
->rgbColors
=textcolors
[i
];
3496 InvalidateRect32( GetDlgItem32(hDlg
,stc6
), NULL
, 0 );
3500 case psh15
:i
=RegisterWindowMessage32A( HELPMSGSTRING
);
3501 if (lpcf
->hwndOwner
)
3502 SendMessage32A(lpcf
->hwndOwner
, i
, 0, (LPARAM
)GetWindowLong32A(hDlg
, DWL_USER
));
3503 /* if (CFn_HookCallChk(lpcf))
3504 CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/
3507 case IDOK
:if ( (!(lpcf
->Flags
& CF_LIMITSIZE
)) ||
3508 ( (lpcf
->Flags
& CF_LIMITSIZE
) &&
3509 (-lpxx
->lfHeight
>= lpcf
->nSizeMin
) &&
3510 (-lpxx
->lfHeight
<= lpcf
->nSizeMax
)))
3511 EndDialog32(hDlg
, TRUE
);
3515 sprintf(buffer
,"Select a font size between %d and %d points.",
3516 lpcf
->nSizeMin
,lpcf
->nSizeMax
);
3517 MessageBox32A(hDlg
, buffer
, NULL
, MB_OK
);
3520 case IDCANCEL
:EndDialog32(hDlg
, FALSE
);
3526 static LRESULT
CFn_WMDestroy(HWND32 hwnd
, WPARAM32 wParam
, LPARAM lParam
)
3528 DeleteObject32(SendDlgItemMessage32A(hwnd
, stc6
, WM_GETFONT
, 0, 0));
3533 /***********************************************************************
3534 * FormatCharDlgProc16 (COMMDLG.16)
3535 FIXME: 1. some strings are "hardcoded", but it's better load from sysres
3536 2. some CF_.. flags are not supported
3537 3. some TType extensions
3539 LRESULT WINAPI
FormatCharDlgProc16(HWND16 hDlg
, UINT16 message
, WPARAM16 wParam
,
3542 LPCHOOSEFONT16 lpcf
;
3543 LPCHOOSEFONT32A lpcf32a
;
3547 if (message
!=WM_INITDIALOG
)
3549 lpcf
=(LPCHOOSEFONT16
)GetWindowLong32A(hDlg
, DWL_USER
);
3552 if (CFn_HookCallChk(lpcf
))
3553 res
=CallWindowProc16(lpcf
->lpfnHook
,hDlg
,message
,wParam
,lParam
);
3559 lpcf
=(LPCHOOSEFONT16
)lParam
;
3560 lpcf32a
=(LPCHOOSEFONT32A
)lpcf
->lpTemplateName
;
3561 if (!CFn_WMInitDialog(hDlg
, wParam
, lParam
, lpcf32a
))
3563 TRACE(commdlg
, "CFn_WMInitDialog returned FALSE\n");
3566 if (CFn_HookCallChk(lpcf
))
3567 return CallWindowProc16(lpcf
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
3569 WINPROC_MapMsg16To32A(message
, wParam
, &uMsg32
, &wParam32
, &lParam
);
3570 lpcf32a
=(LPCHOOSEFONT32A
)lpcf
->lpTemplateName
;
3573 case WM_MEASUREITEM
:
3574 res
=CFn_WMMeasureItem(hDlg
, wParam32
, lParam
);
3577 res
=CFn_WMDrawItem(hDlg
, wParam32
, lParam
);
3579 case WM_CTLCOLORSTATIC
:
3580 res
=CFn_WMCtlColorStatic(hDlg
, wParam32
, lParam
, lpcf32a
);
3583 res
=CFn_WMCommand(hDlg
, wParam32
, lParam
, lpcf32a
);
3586 res
=CFn_WMDestroy(hDlg
, wParam32
, lParam
);
3588 case WM_CHOOSEFONT_GETLOGFONT
:
3589 TRACE(commdlg
,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3591 FIXME(commdlg
, "current logfont back to caller\n");
3594 WINPROC_UnmapMsg16To32A(hDlg
,uMsg32
, wParam32
, lParam
, res
);
3598 /***********************************************************************
3599 * FormatCharDlgProc32A [internal]
3601 LRESULT WINAPI
FormatCharDlgProc32A(HWND32 hDlg
, UINT32 uMsg
, WPARAM32 wParam
,
3604 LPCHOOSEFONT32A lpcf
;
3606 if (uMsg
!=WM_INITDIALOG
)
3608 lpcf
=(LPCHOOSEFONT32A
)GetWindowLong32A(hDlg
, DWL_USER
);
3611 if (CFn_HookCallChk32(lpcf
))
3612 res
=CallWindowProc32A(lpcf
->lpfnHook
, hDlg
, uMsg
, wParam
, lParam
);
3618 lpcf
=(LPCHOOSEFONT32A
)lParam
;
3619 if (!CFn_WMInitDialog(hDlg
, wParam
, lParam
, lpcf
))
3621 TRACE(commdlg
, "CFn_WMInitDialog returned FALSE\n");
3624 if (CFn_HookCallChk32(lpcf
))
3625 return CallWindowProc32A(lpcf
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
3629 case WM_MEASUREITEM
:
3630 return CFn_WMMeasureItem(hDlg
, wParam
, lParam
);
3632 return CFn_WMDrawItem(hDlg
, wParam
, lParam
);
3633 case WM_CTLCOLORSTATIC
:
3634 return CFn_WMCtlColorStatic(hDlg
, wParam
, lParam
, lpcf
);
3636 return CFn_WMCommand(hDlg
, wParam
, lParam
, lpcf
);
3638 return CFn_WMDestroy(hDlg
, wParam
, lParam
);
3639 case WM_CHOOSEFONT_GETLOGFONT
:
3640 TRACE(commdlg
,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3642 FIXME(commdlg
, "current logfont back to caller\n");
3648 /***********************************************************************
3649 * FormatCharDlgProc32W [internal]
3651 LRESULT WINAPI
FormatCharDlgProc32W(HWND32 hDlg
, UINT32 uMsg
, WPARAM32 wParam
,
3654 LPCHOOSEFONT32W lpcf32w
;
3655 LPCHOOSEFONT32A lpcf32a
;
3657 if (uMsg
!=WM_INITDIALOG
)
3659 lpcf32w
=(LPCHOOSEFONT32W
)GetWindowLong32A(hDlg
, DWL_USER
);
3662 if (CFn_HookCallChk32((LPCHOOSEFONT32A
)lpcf32w
))
3663 res
=CallWindowProc32W(lpcf32w
->lpfnHook
, hDlg
, uMsg
, wParam
, lParam
);
3669 lpcf32w
=(LPCHOOSEFONT32W
)lParam
;
3670 lpcf32a
=(LPCHOOSEFONT32A
)lpcf32w
->lpTemplateName
;
3671 if (!CFn_WMInitDialog(hDlg
, wParam
, lParam
, lpcf32a
))
3673 TRACE(commdlg
, "CFn_WMInitDialog returned FALSE\n");
3676 if (CFn_HookCallChk32((LPCHOOSEFONT32A
)lpcf32w
))
3677 return CallWindowProc32W(lpcf32w
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
3679 lpcf32a
=(LPCHOOSEFONT32A
)lpcf32w
->lpTemplateName
;
3682 case WM_MEASUREITEM
:
3683 return CFn_WMMeasureItem(hDlg
, wParam
, lParam
);
3685 return CFn_WMDrawItem(hDlg
, wParam
, lParam
);
3686 case WM_CTLCOLORSTATIC
:
3687 return CFn_WMCtlColorStatic(hDlg
, wParam
, lParam
, lpcf32a
);
3689 return CFn_WMCommand(hDlg
, wParam
, lParam
, lpcf32a
);
3691 return CFn_WMDestroy(hDlg
, wParam
, lParam
);
3692 case WM_CHOOSEFONT_GETLOGFONT
:
3693 TRACE(commdlg
,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3695 FIXME(commdlg
, "current logfont back to caller\n");
3702 static BOOL32
Commdlg_GetFileName32A( BOOL16 (CALLBACK
*dofunction
)(SEGPTR x
),
3703 LPOPENFILENAME32A ofn
)
3706 LPOPENFILENAME16 ofn16
= SEGPTR_ALLOC(sizeof(OPENFILENAME16
));
3708 memset(ofn16
,'\0',sizeof(*ofn16
));
3709 ofn16
->lStructSize
= sizeof(*ofn16
);
3710 ofn16
->hwndOwner
= ofn
->hwndOwner
;
3711 ofn16
->hInstance
= MapHModuleLS(ofn
->hInstance
);
3712 if (ofn
->lpstrFilter
) {
3715 /* filter is a list... title\0ext\0......\0\0 */
3716 s
= (LPSTR
)ofn
->lpstrFilter
;
3720 x
= (LPSTR
)SEGPTR_ALLOC(s
-ofn
->lpstrFilter
);
3721 memcpy(x
,ofn
->lpstrFilter
,s
-ofn
->lpstrFilter
);
3722 ofn16
->lpstrFilter
= SEGPTR_GET(x
);
3724 if (ofn
->lpstrCustomFilter
) {
3727 /* filter is a list... title\0ext\0......\0\0 */
3728 s
= (LPSTR
)ofn
->lpstrCustomFilter
;
3732 x
= SEGPTR_ALLOC(s
-ofn
->lpstrCustomFilter
);
3733 memcpy(x
,ofn
->lpstrCustomFilter
,s
-ofn
->lpstrCustomFilter
);
3734 ofn16
->lpstrCustomFilter
= SEGPTR_GET(x
);
3736 ofn16
->nMaxCustFilter
= ofn
->nMaxCustFilter
;
3737 ofn16
->nFilterIndex
= ofn
->nFilterIndex
;
3739 ofn16
->lpstrFile
= SEGPTR_GET(SEGPTR_ALLOC(ofn
->nMaxFile
));
3740 ofn16
->nMaxFile
= ofn
->nMaxFile
;
3741 ofn16
->nMaxFileTitle
= ofn
->nMaxFileTitle
;
3742 if (ofn16
->nMaxFileTitle
)
3743 ofn16
->lpstrFileTitle
= SEGPTR_GET(SEGPTR_ALLOC(ofn
->nMaxFileTitle
));
3744 if (ofn
->lpstrInitialDir
)
3745 ofn16
->lpstrInitialDir
= SEGPTR_GET(SEGPTR_STRDUP(ofn
->lpstrInitialDir
));
3746 if (ofn
->lpstrTitle
)
3747 ofn16
->lpstrTitle
= SEGPTR_GET(SEGPTR_STRDUP(ofn
->lpstrTitle
));
3748 ofn16
->Flags
= ofn
->Flags
|OFN_WINE32
;
3749 ofn16
->nFileOffset
= ofn
->nFileOffset
;
3750 ofn16
->nFileExtension
= ofn
->nFileExtension
;
3751 if (ofn
->lpstrDefExt
)
3752 ofn16
->lpstrDefExt
= SEGPTR_GET(SEGPTR_STRDUP(ofn
->lpstrDefExt
));
3753 ofn16
->lCustData
= ofn
->lCustData
;
3754 ofn16
->lpfnHook
= (WNDPROC16
)ofn
->lpfnHook
;
3756 if (ofn
->lpTemplateName
)
3757 ofn16
->lpTemplateName
= SEGPTR_GET(SEGPTR_STRDUP(ofn
->lpTemplateName
));
3759 ret
= dofunction(SEGPTR_GET(ofn16
));
3761 ofn
->nFileOffset
= ofn16
->nFileOffset
;
3762 ofn
->nFileExtension
= ofn16
->nFileExtension
;
3763 if (ofn16
->lpstrFilter
)
3764 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFilter
));
3765 if (ofn16
->lpTemplateName
)
3766 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpTemplateName
));
3767 if (ofn16
->lpstrDefExt
)
3768 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrDefExt
));
3769 if (ofn16
->lpstrTitle
)
3770 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrTitle
));
3771 if (ofn16
->lpstrInitialDir
)
3772 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrInitialDir
));
3773 if (ofn16
->lpstrCustomFilter
)
3774 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrCustomFilter
));
3776 if (ofn16
->lpstrFile
)
3778 strcpy(ofn
->lpstrFile
,PTR_SEG_TO_LIN(ofn16
->lpstrFile
));
3779 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFile
));
3782 if (ofn16
->lpstrFileTitle
)
3784 strcpy(ofn
->lpstrFileTitle
,PTR_SEG_TO_LIN(ofn16
->lpstrFileTitle
));
3785 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFileTitle
));
3791 static BOOL32
Commdlg_GetFileName32W( BOOL16 (CALLBACK
*dofunction
)(SEGPTR x
),
3792 LPOPENFILENAME32W ofn
)
3795 LPOPENFILENAME16 ofn16
= SEGPTR_ALLOC(sizeof(OPENFILENAME16
));
3797 memset(ofn16
,'\0',sizeof(*ofn16
));
3798 ofn16
->lStructSize
= sizeof(*ofn16
);
3799 ofn16
->hwndOwner
= ofn
->hwndOwner
;
3800 ofn16
->hInstance
= MapHModuleLS(ofn
->hInstance
);
3801 if (ofn
->lpstrFilter
) {
3806 /* filter is a list... title\0ext\0......\0\0 */
3807 s
= (LPWSTR
)ofn
->lpstrFilter
;
3809 s
= s
+lstrlen32W(s
)+1;
3811 n
= s
- ofn
->lpstrFilter
; /* already divides by 2. ptr magic */
3812 x
= y
= (LPSTR
)SEGPTR_ALLOC(n
);
3813 s
= (LPWSTR
)ofn
->lpstrFilter
;
3820 ofn16
->lpstrFilter
= SEGPTR_GET(y
);
3822 if (ofn
->lpstrCustomFilter
) {
3827 /* filter is a list... title\0ext\0......\0\0 */
3828 s
= (LPWSTR
)ofn
->lpstrCustomFilter
;
3830 s
= s
+lstrlen32W(s
)+1;
3832 n
= s
- ofn
->lpstrCustomFilter
;
3833 x
= y
= (LPSTR
)SEGPTR_ALLOC(n
);
3834 s
= (LPWSTR
)ofn
->lpstrCustomFilter
;
3841 ofn16
->lpstrCustomFilter
= SEGPTR_GET(y
);
3843 ofn16
->nMaxCustFilter
= ofn
->nMaxCustFilter
;
3844 ofn16
->nFilterIndex
= ofn
->nFilterIndex
;
3846 ofn16
->lpstrFile
= SEGPTR_GET(SEGPTR_ALLOC(ofn
->nMaxFile
));
3847 ofn16
->nMaxFile
= ofn
->nMaxFile
;
3848 ofn16
->nMaxFileTitle
= ofn
->nMaxFileTitle
;
3849 if (ofn
->nMaxFileTitle
)
3850 ofn16
->lpstrFileTitle
= SEGPTR_GET(SEGPTR_ALLOC(ofn
->nMaxFileTitle
));
3851 if (ofn
->lpstrInitialDir
)
3852 ofn16
->lpstrInitialDir
= SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn
->lpstrInitialDir
));
3853 if (ofn
->lpstrTitle
)
3854 ofn16
->lpstrTitle
= SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn
->lpstrTitle
));
3855 ofn16
->Flags
= ofn
->Flags
|OFN_WINE32
|OFN_UNICODE
;
3856 ofn16
->nFileOffset
= ofn
->nFileOffset
;
3857 ofn16
->nFileExtension
= ofn
->nFileExtension
;
3858 if (ofn
->lpstrDefExt
)
3859 ofn16
->lpstrDefExt
= SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn
->lpstrDefExt
));
3860 ofn16
->lCustData
= ofn
->lCustData
;
3861 ofn16
->lpfnHook
= (WNDPROC16
)ofn
->lpfnHook
;
3862 if (ofn
->lpTemplateName
)
3863 ofn16
->lpTemplateName
= SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn
->lpTemplateName
));
3864 ret
= dofunction(SEGPTR_GET(ofn16
));
3866 ofn
->nFileOffset
= ofn16
->nFileOffset
;
3867 ofn
->nFileExtension
= ofn16
->nFileExtension
;
3868 if (ofn16
->lpstrFilter
)
3869 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFilter
));
3870 if (ofn16
->lpTemplateName
)
3871 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpTemplateName
));
3872 if (ofn16
->lpstrDefExt
)
3873 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrDefExt
));
3874 if (ofn16
->lpstrTitle
)
3875 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrTitle
));
3876 if (ofn16
->lpstrInitialDir
)
3877 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrInitialDir
));
3878 if (ofn16
->lpstrCustomFilter
)
3879 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrCustomFilter
));
3881 if (ofn16
->lpstrFile
) {
3882 lstrcpyAtoW(ofn
->lpstrFile
,PTR_SEG_TO_LIN(ofn16
->lpstrFile
));
3883 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFile
));
3886 if (ofn16
->lpstrFileTitle
) {
3887 lstrcpyAtoW(ofn
->lpstrFileTitle
,PTR_SEG_TO_LIN(ofn16
->lpstrFileTitle
));
3888 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFileTitle
));
3894 /***********************************************************************
3895 * GetOpenFileName32A (COMDLG32.10)
3897 BOOL32 WINAPI
GetOpenFileName32A( LPOPENFILENAME32A ofn
)
3899 BOOL16 (CALLBACK
* dofunction
)(SEGPTR ofn16
) = GetOpenFileName16
;
3900 return Commdlg_GetFileName32A(dofunction
,ofn
);
3903 /***********************************************************************
3904 * GetOpenFileName32W (COMDLG32.11)
3906 BOOL32 WINAPI
GetOpenFileName32W( LPOPENFILENAME32W ofn
)
3908 BOOL16 (CALLBACK
* dofunction
)(SEGPTR ofn16
) = GetOpenFileName16
;
3909 return Commdlg_GetFileName32W(dofunction
,ofn
);
3912 /***********************************************************************
3913 * GetSaveFileName32A (COMDLG32.12)
3915 BOOL32 WINAPI
GetSaveFileName32A( LPOPENFILENAME32A ofn
)
3917 BOOL16 (CALLBACK
* dofunction
)(SEGPTR ofn16
) = GetSaveFileName16
;
3918 return Commdlg_GetFileName32A(dofunction
,ofn
);
3921 /***********************************************************************
3922 * GetSaveFileName32W (COMDLG32.13)
3924 BOOL32 WINAPI
GetSaveFileName32W( LPOPENFILENAME32W ofn
)
3926 BOOL16 (CALLBACK
* dofunction
)(SEGPTR ofn16
) = GetSaveFileName16
;
3927 return Commdlg_GetFileName32W(dofunction
,ofn
);
3930 /***********************************************************************
3931 * ChooseColorA (COMDLG32.1)
3933 BOOL32 WINAPI
ChooseColor32A(LPCHOOSECOLOR32A lpChCol
)
3938 COLORREF
* ccref
=SEGPTR_ALLOC(64);
3939 LPCHOOSECOLOR16 lpcc16
=SEGPTR_ALLOC(sizeof(CHOOSECOLOR16
));
3941 memset(lpcc16
,'\0',sizeof(*lpcc16
));
3942 lpcc16
->lStructSize
=sizeof(*lpcc16
);
3943 lpcc16
->hwndOwner
=lpChCol
->hwndOwner
;
3944 lpcc16
->hInstance
=MapHModuleLS(lpChCol
->hInstance
);
3945 lpcc16
->rgbResult
=lpChCol
->rgbResult
;
3946 memcpy(ccref
,lpChCol
->lpCustColors
,64);
3947 lpcc16
->lpCustColors
=(COLORREF
*)SEGPTR_GET(ccref
);
3948 lpcc16
->Flags
=lpChCol
->Flags
;
3949 lpcc16
->lCustData
=lpChCol
->lCustData
;
3950 lpcc16
->lpfnHook
=(WNDPROC16
)lpChCol
->lpfnHook
;
3951 if (lpChCol
->lpTemplateName
)
3952 str
= SEGPTR_STRDUP(lpChCol
->lpTemplateName
);
3953 lpcc16
->lpTemplateName
=SEGPTR_GET(str
);
3955 ret
= ChooseColor16(lpcc16
);
3958 memcpy(lpChCol
->lpCustColors
,ccref
,64);
3960 SEGPTR_FREE(lpcc16
);
3964 /***********************************************************************
3965 * ChooseColorW (COMDLG32.2)
3967 BOOL32 WINAPI
ChooseColor32W(LPCHOOSECOLOR32W lpChCol
)
3972 COLORREF
* ccref
=SEGPTR_ALLOC(64);
3973 LPCHOOSECOLOR16 lpcc16
=SEGPTR_ALLOC(sizeof(CHOOSECOLOR16
));
3975 memset(lpcc16
,'\0',sizeof(*lpcc16
));
3976 lpcc16
->lStructSize
=sizeof(*lpcc16
);
3977 lpcc16
->hwndOwner
=lpChCol
->hwndOwner
;
3978 lpcc16
->hInstance
=MapHModuleLS(lpChCol
->hInstance
);
3979 lpcc16
->rgbResult
=lpChCol
->rgbResult
;
3980 memcpy(ccref
,lpChCol
->lpCustColors
,64);
3981 lpcc16
->lpCustColors
=(COLORREF
*)SEGPTR_GET(ccref
);
3982 lpcc16
->Flags
=lpChCol
->Flags
;
3983 lpcc16
->lCustData
=lpChCol
->lCustData
;
3984 lpcc16
->lpfnHook
=(WNDPROC16
)lpChCol
->lpfnHook
;
3985 if (lpChCol
->lpTemplateName
)
3986 str
= SEGPTR_STRDUP_WtoA(lpChCol
->lpTemplateName
);
3987 lpcc16
->lpTemplateName
=SEGPTR_GET(str
);
3989 ret
= ChooseColor16(lpcc16
);
3992 memcpy(lpChCol
->lpCustColors
,ccref
,64);
3994 SEGPTR_FREE(lpcc16
);
3998 /***********************************************************************
3999 * PageSetupDlgA (COMDLG32.15)
4001 BOOL32 WINAPI
PageSetupDlg32A(LPPAGESETUPDLG32A setupdlg
) {
4002 FIXME(commdlg
,"(%p), stub!\n",setupdlg
);