4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
23 static DWORD CommDlgLastError
= 0;
25 static HBITMAP16 hFolder
= 0;
26 static HBITMAP16 hFolder2
= 0;
27 static HBITMAP16 hFloppy
= 0;
28 static HBITMAP16 hHDisk
= 0;
29 static HBITMAP16 hCDRom
= 0;
30 static HBITMAP16 hBitmapTT
= 0;
31 static const char defaultfilter
[]=" \0\0";
33 /***********************************************************************
34 * FileDlg_Init [internal]
36 static BOOL32
FileDlg_Init()
38 static BOOL32 initialized
= 0;
41 if (!hFolder
) hFolder
= LoadBitmap16(0, MAKEINTRESOURCE16(OBM_FOLDER
));
42 if (!hFolder2
) hFolder2
= LoadBitmap16(0, MAKEINTRESOURCE16(OBM_FOLDER2
));
43 if (!hFloppy
) hFloppy
= LoadBitmap16(0, MAKEINTRESOURCE16(OBM_FLOPPY
));
44 if (!hHDisk
) hHDisk
= LoadBitmap16(0, MAKEINTRESOURCE16(OBM_HDISK
));
45 if (!hCDRom
) hCDRom
= LoadBitmap16(0, MAKEINTRESOURCE16(OBM_CDROM
));
46 if (hFolder
== 0 || hFolder2
== 0 || hFloppy
== 0 ||
47 hHDisk
== 0 || hCDRom
== 0)
49 WARN(commdlg
, "Error loading bitmaps !\nprin");
57 /***********************************************************************
58 * GetOpenFileName (COMMDLG.1)
60 BOOL16 WINAPI
GetOpenFileName16( SEGPTR ofn
)
63 HANDLE32 hDlgTmpl
= 0, hResInfo
;
64 BOOL32 bRet
= FALSE
, win32Format
= FALSE
;
66 LPOPENFILENAME16 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(ofn
);
68 char defaultopen
[]="Open File";
71 if (!lpofn
|| !FileDlg_Init()) return FALSE
;
73 if (lpofn
->Flags
& OFN_WINE32
) {
74 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
)
76 if (!(template = LockResource32( lpofn
->hInstance
)))
78 CommDlgLastError
= CDERR_LOADRESFAILURE
;
82 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
84 if (!(hResInfo
= FindResource32A(lpofn
->hInstance
,
85 PTR_SEG_TO_LIN(lpofn
->lpTemplateName
), RT_DIALOG32A
)))
87 CommDlgLastError
= CDERR_FINDRESFAILURE
;
90 if (!(hDlgTmpl
= LoadResource32( lpofn
->hInstance
, hResInfo
)) ||
91 !(template = LockResource32( hDlgTmpl
)))
93 CommDlgLastError
= CDERR_LOADRESFAILURE
;
97 template = SYSRES_GetResPtr( SYSRES_DIALOG_OPEN_FILE
);
101 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
)
103 if (!(template = LockResource16( lpofn
->hInstance
)))
105 CommDlgLastError
= CDERR_LOADRESFAILURE
;
109 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
111 if (!(hResInfo
= FindResource16(lpofn
->hInstance
,
112 lpofn
->lpTemplateName
,
115 CommDlgLastError
= CDERR_FINDRESFAILURE
;
118 if (!(hDlgTmpl
= LoadResource16( lpofn
->hInstance
, hResInfo
)) ||
119 !(template = LockResource16( hDlgTmpl
)))
121 CommDlgLastError
= CDERR_LOADRESFAILURE
;
125 template = SYSRES_GetResPtr( SYSRES_DIALOG_OPEN_FILE
);
130 hInst
= WIN_GetWindowInstance( lpofn
->hwndOwner
);
132 if (!(lpofn
->lpstrFilter
))
134 str
= SEGPTR_ALLOC(sizeof(defaultfilter
));
135 TRACE(commdlg
,"Alloc %p default for Filetype in GetOpenFileName\n",str
);
136 memcpy(str
,defaultfilter
,sizeof(defaultfilter
));
137 lpofn
->lpstrFilter
=SEGPTR_GET(str
);
140 if (!(lpofn
->lpstrTitle
))
142 str1
= SEGPTR_ALLOC(strlen(defaultopen
)+1);
143 TRACE(commdlg
,"Alloc %p default for Title in GetOpenFileName\n",str1
);
144 strcpy(str1
,defaultopen
);
145 lpofn
->lpstrTitle
=SEGPTR_GET(str1
);
148 /* FIXME: doesn't handle win32 format correctly yet */
149 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, win32Format
,
151 (DLGPROC16
)MODULE_GetWndProcEntry16("FileOpenDlgProc"),
153 if (hwndDialog
) bRet
= DIALOG_DoDialogBox( hwndDialog
, lpofn
->hwndOwner
);
157 TRACE(commdlg
,"Freeing %p default for Title in GetOpenFileName\n",str1
);
164 TRACE(commdlg
,"Freeing %p default for Filetype in GetOpenFileName\n",str
);
166 lpofn
->lpstrFilter
=0;
170 if (lpofn
->Flags
& OFN_WINE32
)
171 FreeResource32( hDlgTmpl
);
173 FreeResource16( hDlgTmpl
);
176 TRACE(commdlg
,"return lpstrFile='%s' !\n",
177 (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFile
));
182 /***********************************************************************
183 * GetSaveFileName (COMMDLG.2)
185 BOOL16 WINAPI
GetSaveFileName16( SEGPTR ofn
)
188 HANDLE32 hDlgTmpl
= 0;
189 BOOL32 bRet
= FALSE
, win32Format
= FALSE
;
190 LPOPENFILENAME16 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(ofn
);
193 char defaultsave
[]="Save as";
194 char *str
=0,*str1
=0;
196 if (!lpofn
|| !FileDlg_Init()) return FALSE
;
198 if (lpofn
->Flags
& OFN_WINE32
) {
199 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
)
201 if (!(template = LockResource32( lpofn
->hInstance
)))
203 CommDlgLastError
= CDERR_LOADRESFAILURE
;
207 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
210 if (!(hResInfo
= FindResource32A(lpofn
->hInstance
,
211 PTR_SEG_TO_LIN(lpofn
->lpTemplateName
),
214 CommDlgLastError
= CDERR_FINDRESFAILURE
;
217 if (!(hDlgTmpl
= LoadResource32(lpofn
->hInstance
,hResInfo
)) ||
218 !(template = LockResource32(hDlgTmpl
)))
220 CommDlgLastError
= CDERR_LOADRESFAILURE
;
225 template = SYSRES_GetResPtr( SYSRES_DIALOG_SAVE_FILE
);
229 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
)
231 if (!(template = LockResource16( lpofn
->hInstance
)))
233 CommDlgLastError
= CDERR_LOADRESFAILURE
;
237 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
240 if (!(hResInfo
= FindResource16(lpofn
->hInstance
,
241 lpofn
->lpTemplateName
,
244 CommDlgLastError
= CDERR_FINDRESFAILURE
;
247 if (!(hDlgTmpl
= LoadResource16( lpofn
->hInstance
, hResInfo
)) ||
248 !(template = LockResource16( hDlgTmpl
)))
250 CommDlgLastError
= CDERR_LOADRESFAILURE
;
254 template = SYSRES_GetResPtr( SYSRES_DIALOG_SAVE_FILE
);
259 hInst
= WIN_GetWindowInstance( lpofn
->hwndOwner
);
261 if (!(lpofn
->lpstrFilter
))
263 str
= SEGPTR_ALLOC(sizeof(defaultfilter
));
264 TRACE(commdlg
,"Alloc default for Filetype in GetSaveFileName\n");
265 memcpy(str
,defaultfilter
,sizeof(defaultfilter
));
266 lpofn
->lpstrFilter
=SEGPTR_GET(str
);
269 if (!(lpofn
->lpstrTitle
))
271 str1
= SEGPTR_ALLOC(sizeof(defaultsave
)+1);
272 TRACE(commdlg
,"Alloc default for Title in GetSaveFileName\n");
273 strcpy(str1
,defaultsave
);
274 lpofn
->lpstrTitle
=SEGPTR_GET(str1
);
277 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, win32Format
,
279 (DLGPROC16
)MODULE_GetWndProcEntry16("FileSaveDlgProc"),
281 if (hwndDialog
) bRet
= DIALOG_DoDialogBox( hwndDialog
, lpofn
->hwndOwner
);
285 TRACE(commdlg
,"Freeing %p default for Title in GetSaveFileName\n",str1
);
292 TRACE(commdlg
,"Freeing %p default for Filetype in GetSaveFileName\n",str
);
294 lpofn
->lpstrFilter
=0;
298 if (lpofn
->Flags
& OFN_WINE32
)
299 FreeResource32( hDlgTmpl
);
301 FreeResource16( hDlgTmpl
);
304 TRACE(commdlg
, "return lpstrFile='%s' !\n",
305 (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFile
));
309 /***********************************************************************
310 * FILEDLG_StripEditControl [internal]
311 * Strip pathnames off the contents of the edit control.
313 static void FILEDLG_StripEditControl(HWND16 hwnd
)
317 GetDlgItemText32A( hwnd
, edt1
, temp
, sizeof(temp
) );
318 cp
= strrchr(temp
, '\\');
322 cp
= strrchr(temp
, ':');
326 /* FIXME: shouldn't we do something with the result here? ;-) */
329 /***********************************************************************
330 * FILEDLG_ScanDir [internal]
332 static BOOL32
FILEDLG_ScanDir(HWND16 hWnd
, LPSTR newPath
)
337 lstrcpyn32A( str
, newPath
, 512 );
339 GetDlgItemText32A( hWnd
, edt1
, str
+ len
, sizeof(str
) - len
);
340 if (!DlgDirList32A( hWnd
, str
, lst1
, 0, 0x0000 )) return FALSE
;
341 strcpy( str
, "*.*" );
342 return DlgDirList32A( hWnd
, str
, lst2
, stc1
, 0x8010 );
345 /***********************************************************************
346 * FILEDLG_GetFileType [internal]
349 static LPSTR
FILEDLG_GetFileType(LPSTR cfptr
, LPSTR fptr
, WORD index
)
354 for ( ;(n
= strlen(cfptr
)) != 0; i
++)
359 cfptr
+= strlen(cfptr
) + 1;
362 for ( ;(n
= strlen(fptr
)) != 0; i
++)
367 fptr
+= strlen(fptr
) + 1;
369 return "*.*"; /* FIXME */
372 /***********************************************************************
373 * FILEDLG_WMDrawItem [internal]
375 static LONG
FILEDLG_WMDrawItem(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
,int savedlg
)
377 LPDRAWITEMSTRUCT16 lpdis
= (LPDRAWITEMSTRUCT16
)PTR_SEG_TO_LIN(lParam
);
380 HBITMAP16 hBitmap
, hPrevBitmap
;
384 if (lpdis
->CtlType
== ODT_LISTBOX
&& lpdis
->CtlID
== lst1
)
386 if (!(str
= SEGPTR_ALLOC(512))) return FALSE
;
387 hBrush
= SelectObject32(lpdis
->hDC
, GetStockObject32(LTGRAY_BRUSH
));
388 SelectObject32(lpdis
->hDC
, hBrush
);
389 FillRect16(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
390 SendMessage16(lpdis
->hwndItem
, LB_GETTEXT16
, lpdis
->itemID
,
391 (LPARAM
)SEGPTR_GET(str
));
393 if (savedlg
) /* use _gray_ text in FileSaveDlg */
394 if (!lpdis
->itemState
)
395 SetTextColor32(lpdis
->hDC
,GetSysColor32(COLOR_GRAYTEXT
) );
397 SetTextColor32(lpdis
->hDC
,GetSysColor32(COLOR_WINDOWTEXT
) );
398 /* inversion of gray would be bad readable */
400 TextOut16(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
402 if (lpdis
->itemState
!= 0) {
403 InvertRect16(lpdis
->hDC
, &lpdis
->rcItem
);
409 if (lpdis
->CtlType
== ODT_LISTBOX
&& lpdis
->CtlID
== lst2
)
411 if (!(str
= SEGPTR_ALLOC(512))) return FALSE
;
412 hBrush
= SelectObject32(lpdis
->hDC
, GetStockObject32(LTGRAY_BRUSH
));
413 SelectObject32(lpdis
->hDC
, hBrush
);
414 FillRect16(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
415 SendMessage16(lpdis
->hwndItem
, LB_GETTEXT16
, lpdis
->itemID
,
416 (LPARAM
)SEGPTR_GET(str
));
419 GetObject16( hBitmap
, sizeof(bm
), &bm
);
420 TextOut16(lpdis
->hDC
, lpdis
->rcItem
.left
+ bm
.bmWidth
,
421 lpdis
->rcItem
.top
, str
, strlen(str
));
422 hMemDC
= CreateCompatibleDC32(lpdis
->hDC
);
423 hPrevBitmap
= SelectObject32(hMemDC
, hBitmap
);
424 BitBlt32(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
425 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
426 SelectObject32(hMemDC
, hPrevBitmap
);
428 if (lpdis
->itemState
!= 0) InvertRect16(lpdis
->hDC
, &lpdis
->rcItem
);
432 if (lpdis
->CtlType
== ODT_COMBOBOX
&& lpdis
->CtlID
== cmb2
)
434 if (!(str
= SEGPTR_ALLOC(512))) return FALSE
;
435 hBrush
= SelectObject32(lpdis
->hDC
, GetStockObject32(LTGRAY_BRUSH
));
436 SelectObject32(lpdis
->hDC
, hBrush
);
437 FillRect16(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
438 SendMessage16(lpdis
->hwndItem
, CB_GETLBTEXT16
, lpdis
->itemID
,
439 (LPARAM
)SEGPTR_GET(str
));
440 switch(DRIVE_GetType( str
[2] - 'a' ))
442 case TYPE_FLOPPY
: hBitmap
= hFloppy
; break;
443 case TYPE_CDROM
: hBitmap
= hCDRom
; break;
446 default: hBitmap
= hHDisk
; break;
448 GetObject16( hBitmap
, sizeof(bm
), &bm
);
449 TextOut16(lpdis
->hDC
, lpdis
->rcItem
.left
+ bm
.bmWidth
,
450 lpdis
->rcItem
.top
, str
, strlen(str
));
451 hMemDC
= CreateCompatibleDC32(lpdis
->hDC
);
452 hPrevBitmap
= SelectObject32(hMemDC
, hBitmap
);
453 BitBlt32( lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
454 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
455 SelectObject32(hMemDC
, hPrevBitmap
);
457 if (lpdis
->itemState
!= 0) InvertRect16(lpdis
->hDC
, &lpdis
->rcItem
);
464 /***********************************************************************
465 * FILEDLG_WMMeasureItem [internal]
467 static LONG
FILEDLG_WMMeasureItem(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
)
470 LPMEASUREITEMSTRUCT16 lpmeasure
;
472 GetObject16( hFolder2
, sizeof(bm
), &bm
);
473 lpmeasure
= (LPMEASUREITEMSTRUCT16
)PTR_SEG_TO_LIN(lParam
);
474 lpmeasure
->itemHeight
= bm
.bmHeight
;
478 /***********************************************************************
479 * FILEDLG_HookCallChk [internal]
481 static int FILEDLG_HookCallChk(LPOPENFILENAME16 lpofn
)
484 if (lpofn
->Flags
& OFN_ENABLEHOOK
)
490 /***********************************************************************
491 * FILEDLG_CallWindowProc [internal]
493 * Adapt the structures back for win32 calls so the callee can read lpCustData
495 static BOOL32
FILEDLG_CallWindowProc(LPOPENFILENAME16 lpofn
,HWND32 hwnd
,
496 UINT32 wMsg
,WPARAM32 wParam
,LPARAM lParam
501 needstruct
= (PTR_SEG_TO_LIN(lParam
) == lpofn
);
503 if (!(lpofn
->Flags
& OFN_WINE32
))
504 return (BOOL32
)CallWindowProc16(
505 lpofn
->lpfnHook
,hwnd
,(UINT16
)wMsg
,(WPARAM16
)wParam
,lParam
508 if (lpofn
->Flags
& OFN_UNICODE
) {
510 OPENFILENAME32W ofnw
;
512 /* FIXME: probably needs more converted */
513 ofnw
.lCustData
= lpofn
->lCustData
;
514 return (BOOL32
)CallWindowProc32W(
515 (WNDPROC32
)lpofn
->lpfnHook
,hwnd
,wMsg
,wParam
,(LPARAM
)&ofnw
518 return (BOOL32
)CallWindowProc32W(
519 (WNDPROC32
)lpofn
->lpfnHook
,hwnd
,wMsg
,wParam
,lParam
524 OPENFILENAME32A ofna
;
526 /* FIXME: probably needs more converted */
527 ofna
.lCustData
= lpofn
->lCustData
;
528 return (BOOL32
)CallWindowProc32A(
529 (WNDPROC32
)lpofn
->lpfnHook
,hwnd
,wMsg
,wParam
,(LPARAM
)&ofna
532 return (BOOL32
)CallWindowProc32A(
533 (WNDPROC32
)lpofn
->lpfnHook
,hwnd
,wMsg
,wParam
,lParam
538 /***********************************************************************
539 * FILEDLG_WMInitDialog [internal]
542 static LONG
FILEDLG_WMInitDialog(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
)
545 LPOPENFILENAME16 lpofn
;
547 LPSTR pstr
, old_pstr
;
548 SetWindowLong32A(hWnd
, DWL_USER
, lParam
);
549 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(lParam
);
550 if (lpofn
->lpstrTitle
) SetWindowText16( hWnd
, lpofn
->lpstrTitle
);
551 /* read custom filter information */
552 if (lpofn
->lpstrCustomFilter
)
554 pstr
= (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
);
556 TRACE(commdlg
,"lpstrCustomFilter = %p\n", pstr
);
560 i
= SendDlgItemMessage16(hWnd
, cmb1
, CB_ADDSTRING16
, 0,
561 (LPARAM
)lpofn
->lpstrCustomFilter
+ n
);
562 n
+= strlen(pstr
) + 1;
563 pstr
+= strlen(pstr
) + 1;
564 TRACE(commdlg
,"add str='%s' "
565 "associated to '%s'\n", old_pstr
, pstr
);
566 SendDlgItemMessage16(hWnd
, cmb1
, CB_SETITEMDATA16
, i
, (LPARAM
)pstr
);
567 n
+= strlen(pstr
) + 1;
568 pstr
+= strlen(pstr
) + 1;
571 /* read filter information */
572 if (lpofn
->lpstrFilter
) {
573 pstr
= (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFilter
);
577 i
= SendDlgItemMessage16(hWnd
, cmb1
, CB_ADDSTRING16
, 0,
578 (LPARAM
)lpofn
->lpstrFilter
+ n
);
579 n
+= strlen(pstr
) + 1;
580 pstr
+= strlen(pstr
) + 1;
581 TRACE(commdlg
,"add str='%s' "
582 "associated to '%s'\n", old_pstr
, pstr
);
583 SendDlgItemMessage16(hWnd
, cmb1
, CB_SETITEMDATA16
, i
, (LPARAM
)pstr
);
584 n
+= strlen(pstr
) + 1;
585 pstr
+= strlen(pstr
) + 1;
588 /* set default filter */
589 if (lpofn
->nFilterIndex
== 0 && lpofn
->lpstrCustomFilter
== (SEGPTR
)NULL
)
590 lpofn
->nFilterIndex
= 1;
591 SendDlgItemMessage16(hWnd
, cmb1
, CB_SETCURSEL16
, lpofn
->nFilterIndex
- 1, 0);
592 strncpy(tmpstr
, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
593 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
), lpofn
->nFilterIndex
- 1),511);
595 TRACE(commdlg
,"nFilterIndex = %ld, SetText of edt1 to '%s'\n",
596 lpofn
->nFilterIndex
, tmpstr
);
597 SetDlgItemText32A( hWnd
, edt1
, tmpstr
);
600 DlgDirListComboBox32A(hWnd
, tmpstr
, cmb2
, 0, 0xC000);
601 /* read initial directory */
602 if (PTR_SEG_TO_LIN(lpofn
->lpstrInitialDir
) != NULL
)
604 strncpy(tmpstr
, PTR_SEG_TO_LIN(lpofn
->lpstrInitialDir
), 510);
606 if (strlen(tmpstr
) > 0 && tmpstr
[strlen(tmpstr
)-1] != '\\'
607 && tmpstr
[strlen(tmpstr
)-1] != ':')
612 if (!FILEDLG_ScanDir(hWnd
, tmpstr
)) {
614 if (!FILEDLG_ScanDir(hWnd
, tmpstr
))
615 WARN(commdlg
, "Couldn't read initial directory %s!\n",tmpstr
);
617 /* select current drive in combo 2, omit missing drives */
618 for(i
=0, n
=-1; i
<=DRIVE_GetCurrentDrive(); i
++)
619 if (DRIVE_IsValid(i
)) n
++;
620 SendDlgItemMessage16(hWnd
, cmb2
, CB_SETCURSEL16
, n
, 0);
621 if (!(lpofn
->Flags
& OFN_SHOWHELP
))
622 ShowWindow32(GetDlgItem32(hWnd
, pshHelp
), SW_HIDE
);
623 if (lpofn
->Flags
& OFN_HIDEREADONLY
)
624 ShowWindow32(GetDlgItem32(hWnd
, chx1
), SW_HIDE
);
625 if (FILEDLG_HookCallChk(lpofn
))
626 return (BOOL16
)FILEDLG_CallWindowProc(lpofn
,hWnd
,WM_INITDIALOG
,wParam
,lParam
);
631 /***********************************************************************
632 * FILEDLG_WMCommand [internal]
634 BOOL32 in_update
=FALSE
;
636 static LRESULT
FILEDLG_WMCommand(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
)
639 LPOPENFILENAME16 lpofn
;
641 char tmpstr
[512], tmpstr2
[512];
643 UINT16 control
,notification
;
645 /* Notifications are packaged differently in Win32 */
647 notification
= HIWORD(lParam
);
649 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
652 case lst1
: /* file list */
653 FILEDLG_StripEditControl(hWnd
);
654 if (notification
== LBN_DBLCLK
)
656 lRet
= SendDlgItemMessage16(hWnd
, lst1
, LB_GETCURSEL16
, 0, 0);
657 if (lRet
== LB_ERR
) return TRUE
;
658 if ((pstr
= SEGPTR_ALLOC(512)))
660 SendDlgItemMessage16(hWnd
, lst1
, LB_GETTEXT16
, lRet
,
661 (LPARAM
)SEGPTR_GET(pstr
));
662 SetDlgItemText32A( hWnd
, edt1
, pstr
);
665 if (FILEDLG_HookCallChk(lpofn
))
666 FILEDLG_CallWindowProc(lpofn
,hWnd
,
667 RegisterWindowMessage32A( LBSELCHSTRING
),
668 control
, MAKELONG(lRet
,CD_LBSELCHANGE
));
669 /* FIXME: for OFN_ALLOWMULTISELECT we need CD_LBSELSUB, CD_SELADD, CD_LBSELNOITEMS */
671 case lst2
: /* directory list */
672 FILEDLG_StripEditControl(hWnd
);
673 if (notification
== LBN_DBLCLK
)
675 lRet
= SendDlgItemMessage16(hWnd
, lst2
, LB_GETCURSEL16
, 0, 0);
676 if (lRet
== LB_ERR
) return TRUE
;
677 pstr
= SEGPTR_ALLOC(512);
678 SendDlgItemMessage16(hWnd
, lst2
, LB_GETTEXT16
, lRet
,
679 (LPARAM
)SEGPTR_GET(pstr
));
680 strcpy( tmpstr
, pstr
);
682 if (tmpstr
[0] == '[')
684 tmpstr
[strlen(tmpstr
) - 1] = 0;
685 strcpy(tmpstr
,tmpstr
+1);
687 strcat(tmpstr
, "\\");
691 case cmb1
: /* file type drop list */
692 if (notification
== CBN_SELCHANGE
)
702 case cmb2
: /* disk drop list */
703 FILEDLG_StripEditControl(hWnd
);
704 lRet
= SendDlgItemMessage16(hWnd
, cmb2
, CB_GETCURSEL16
, 0, 0L);
705 if (lRet
== LB_ERR
) return 0;
706 pstr
= SEGPTR_ALLOC(512);
707 SendDlgItemMessage16(hWnd
, cmb2
, CB_GETLBTEXT16
, lRet
,
708 (LPARAM
)SEGPTR_GET(pstr
));
709 sprintf(tmpstr
, "%c:", pstr
[2]);
712 lRet
= SendDlgItemMessage16(hWnd
, cmb1
, CB_GETCURSEL16
, 0, 0);
715 pstr
= (LPSTR
)SendDlgItemMessage16(hWnd
, cmb1
, CB_GETITEMDATA16
, lRet
, 0);
716 TRACE(commdlg
,"Selected filter : %s\n", pstr
);
717 SetDlgItemText32A( hWnd
, edt1
, pstr
);
718 FILEDLG_ScanDir(hWnd
, tmpstr
);
722 ofn2
=*lpofn
; /* for later restoring */
723 GetDlgItemText32A( hWnd
, edt1
, tmpstr
, sizeof(tmpstr
) );
724 pstr
= strrchr(tmpstr
, '\\');
726 pstr
= strrchr(tmpstr
, ':');
727 if (strchr(tmpstr
,'*') != NULL
|| strchr(tmpstr
,'?') != NULL
)
729 /* edit control contains wildcards */
732 strncpy(tmpstr2
, pstr
+1, 511); tmpstr2
[511]=0;
737 strcpy(tmpstr2
, tmpstr
);
740 TRACE(commdlg
,"tmpstr=%s, tmpstr2=%s\n", tmpstr
, tmpstr2
);
741 SetDlgItemText32A( hWnd
, edt1
, tmpstr2
);
742 FILEDLG_ScanDir(hWnd
, tmpstr
);
745 /* no wildcards, we might have a directory or a filename */
746 /* try appending a wildcard and reading the directory */
747 pstr2
= tmpstr
+ strlen(tmpstr
);
748 if (pstr
== NULL
|| *(pstr
+1) != 0)
749 strcat(tmpstr
, "\\");
750 lRet
= SendDlgItemMessage16(hWnd
, cmb1
, CB_GETCURSEL16
, 0, 0);
751 if (lRet
== LB_ERR
) return TRUE
;
752 lpofn
->nFilterIndex
= lRet
+ 1;
753 TRACE(commdlg
,"lpofn->nFilterIndex=%ld\n", lpofn
->nFilterIndex
);
755 FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
756 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
),
757 lRet
), sizeof(tmpstr2
));
758 SetDlgItemText32A( hWnd
, edt1
, tmpstr2
);
760 /* if ScanDir succeeds, we have changed the directory */
761 if (FILEDLG_ScanDir(hWnd
, tmpstr
)) return TRUE
;
762 /* if not, this must be a filename */
766 /* strip off the pathname */
768 SetDlgItemText32A( hWnd
, edt1
, pstr
+ 1 );
769 lstrcpyn32A(tmpstr2
, pstr
+1, sizeof(tmpstr2
) );
770 /* Should we MessageBox() if this fails? */
771 if (!FILEDLG_ScanDir(hWnd
, tmpstr
)) return TRUE
;
772 strcpy(tmpstr
, tmpstr2
);
774 else SetDlgItemText32A( hWnd
, edt1
, tmpstr
);
776 ShowWindow16(hWnd
, SW_HIDE
); /* this should not be necessary ?! (%%%) */
779 int drive
= DRIVE_GetCurrentDrive();
780 tmpstr2
[0] = 'A'+ drive
;
783 strncpy(tmpstr2
+ 3, DRIVE_GetDosCwd(drive
), 507); tmpstr2
[510]=0;
784 if (strlen(tmpstr2
) > 3)
785 strcat(tmpstr2
, "\\");
786 strncat(tmpstr2
, tmpstr
, 511-strlen(tmpstr2
)); tmpstr2
[511]=0;
787 if (lpofn
->lpstrFile
)
788 lstrcpyn32A(PTR_SEG_TO_LIN(lpofn
->lpstrFile
), tmpstr2
,lpofn
->nMaxFile
);
790 lpofn
->nFileOffset
= strrchr(tmpstr2
,'\\') - tmpstr2
+1;
791 lpofn
->nFileExtension
= 0;
792 while(tmpstr2
[lpofn
->nFileExtension
] != '.' && tmpstr2
[lpofn
->nFileExtension
] != '\0')
793 lpofn
->nFileExtension
++;
794 if (lpofn
->nFileExtension
== '\0')
795 lpofn
->nFileExtension
= 0;
797 lpofn
->nFileExtension
++;
801 if (FILEDLG_HookCallChk(lpofn
))
802 FILEDLG_CallWindowProc(lpofn
,hWnd
,
803 RegisterWindowMessage32A( LBSELCHSTRING
),
804 control
, MAKELONG(lRet
,CD_LBSELCHANGE
));
809 if (PTR_SEG_TO_LIN(lpofn
->lpstrFileTitle
) != NULL
)
811 lRet
= SendDlgItemMessage16(hWnd
, lst1
, LB_GETCURSEL16
, 0, 0);
812 SendDlgItemMessage16(hWnd
, lst1
, LB_GETTEXT16
, lRet
,
813 lpofn
->lpstrFileTitle
);
815 if (FILEDLG_HookCallChk(lpofn
))
817 lRet
= (BOOL16
)FILEDLG_CallWindowProc(lpofn
,
818 hWnd
, RegisterWindowMessage32A( FILEOKSTRING
), 0, lParam
);
821 *lpofn
=ofn2
; /* restore old state */
823 ShowWindow16(hWnd
, SW_SHOW
); /* only if above (%%%) SW_HIDE used */
828 EndDialog32(hWnd
, TRUE
);
831 EndDialog32(hWnd
, FALSE
);
838 /***********************************************************************
839 * FileOpenDlgProc (COMMDLG.6)
841 LRESULT WINAPI
FileOpenDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
844 LPOPENFILENAME16 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
846 if (wMsg
!=WM_INITDIALOG
)
847 if (FILEDLG_HookCallChk(lpofn
))
849 LRESULT lRet
=(BOOL16
)FILEDLG_CallWindowProc(lpofn
,hWnd
,wMsg
,wParam
,lParam
);
851 return lRet
; /* else continue message processing */
856 return FILEDLG_WMInitDialog(hWnd
, wParam
, lParam
);
858 return FILEDLG_WMMeasureItem(hWnd
, wParam
, lParam
);
860 return FILEDLG_WMDrawItem(hWnd
, wParam
, lParam
, FALSE
);
862 return FILEDLG_WMCommand(hWnd
, wParam
, lParam
);
865 SetBkColor((HDC16
)wParam
, 0x00C0C0C0);
866 switch (HIWORD(lParam
))
869 SetTextColor((HDC16
)wParam
, 0x00000000);
871 case CTLCOLOR_STATIC
:
872 SetTextColor((HDC16
)wParam
, 0x00000000);
882 /***********************************************************************
883 * FileSaveDlgProc (COMMDLG.7)
885 LRESULT WINAPI
FileSaveDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
888 LPOPENFILENAME16 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
890 if (wMsg
!=WM_INITDIALOG
)
891 if (FILEDLG_HookCallChk(lpofn
))
893 LRESULT lRet
=(BOOL16
)FILEDLG_CallWindowProc(lpofn
,hWnd
,wMsg
,wParam
,lParam
);
895 return lRet
; /* else continue message processing */
899 return FILEDLG_WMInitDialog(hWnd
, wParam
, lParam
);
902 return FILEDLG_WMMeasureItem(hWnd
, wParam
, lParam
);
905 return FILEDLG_WMDrawItem(hWnd
, wParam
, lParam
, TRUE
);
908 return FILEDLG_WMCommand(hWnd
, wParam
, lParam
);
913 SetBkColor((HDC16)wParam, 0x00C0C0C0);
914 switch (HIWORD(lParam))
917 SetTextColor((HDC16)wParam, 0x00000000);
919 case CTLCOLOR_STATIC:
920 SetTextColor((HDC16)wParam, 0x00000000);
930 /***********************************************************************
931 * FindText16 (COMMDLG.11)
933 HWND16 WINAPI
FindText16( SEGPTR find
)
937 LPFINDREPLACE16 lpFind
= (LPFINDREPLACE16
)PTR_SEG_TO_LIN(find
);
940 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
941 * For now, only the standard dialog works.
943 if (lpFind
->Flags
& (FR_ENABLETEMPLATE
| FR_ENABLETEMPLATEHANDLE
|
944 FR_ENABLEHOOK
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
945 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT
);
946 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
947 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
948 (DLGPROC16
)MODULE_GetWndProcEntry16("FindTextDlgProc"),
952 /***********************************************************************
953 * FindText32A (COMMDLG.6)
955 HWND32 WINAPI
FindText32A( LPFINDREPLACE32A lpFind
)
961 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
962 * For now, only the standard dialog works.
964 if (lpFind
->Flags
& (FR_ENABLETEMPLATE
| FR_ENABLETEMPLATEHANDLE
|
965 FR_ENABLEHOOK
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
966 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT
);
967 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
968 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
969 (DLGPROC16
)FindTextDlgProc32A
, (LPARAM
)lpFind
, WIN_PROC_32A
);
972 /***********************************************************************
973 * FindText32W (COMMDLG.7)
975 HWND32 WINAPI
FindText32W( LPFINDREPLACE32W lpFind
)
981 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
982 * For now, only the standard dialog works.
984 if (lpFind
->Flags
& (FR_ENABLETEMPLATE
| FR_ENABLETEMPLATEHANDLE
|
985 FR_ENABLEHOOK
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
986 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT
);
987 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
988 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
989 (DLGPROC16
)FindTextDlgProc32W
, (LPARAM
)lpFind
, WIN_PROC_32W
);
992 /***********************************************************************
993 * ReplaceText16 (COMMDLG.12)
995 HWND16 WINAPI
ReplaceText16( SEGPTR find
)
999 LPFINDREPLACE16 lpFind
= (LPFINDREPLACE16
)PTR_SEG_TO_LIN(find
);
1002 * FIXME : We should do error checking on the lpFind structure here
1003 * and make CommDlgExtendedError() return the error condition.
1005 if (lpFind
->Flags
& (FR_ENABLETEMPLATE
| FR_ENABLETEMPLATEHANDLE
|
1006 FR_ENABLEHOOK
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
1007 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT
);
1008 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
1009 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
1010 (DLGPROC16
)MODULE_GetWndProcEntry16("ReplaceTextDlgProc"),
1011 find
, WIN_PROC_16
);
1014 /***********************************************************************
1015 * ReplaceText32A (COMDLG32.19)
1017 HWND32 WINAPI
ReplaceText32A( LPFINDREPLACE32A lpFind
)
1023 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
1024 * For now, only the standard dialog works.
1026 if (lpFind
->Flags
& (FR_ENABLETEMPLATE
| FR_ENABLETEMPLATEHANDLE
|
1027 FR_ENABLEHOOK
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
1028 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT
);
1029 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
1030 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
1031 (DLGPROC16
)ReplaceTextDlgProc32A
, (LPARAM
)lpFind
, WIN_PROC_32A
);
1034 /***********************************************************************
1035 * ReplaceText32W (COMDLG32.20)
1037 HWND32 WINAPI
ReplaceText32W( LPFINDREPLACE32W lpFind
)
1043 * FIXME : We should do error checking on the lpFind structure here
1044 * and make CommDlgExtendedError() return the error condition.
1046 if (lpFind
->Flags
& (FR_ENABLETEMPLATE
| FR_ENABLETEMPLATEHANDLE
|
1047 FR_ENABLEHOOK
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
1048 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT
);
1049 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
1050 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
1051 (DLGPROC16
)ReplaceTextDlgProc32W
, (LPARAM
)lpFind
, WIN_PROC_32W
);
1055 /***********************************************************************
1056 * FINDDLG_WMInitDialog [internal]
1058 static LRESULT
FINDDLG_WMInitDialog(HWND32 hWnd
, LPARAM lParam
, LPDWORD lpFlags
,
1059 LPSTR lpstrFindWhat
, BOOL32 fUnicode
)
1061 SetWindowLong32A(hWnd
, DWL_USER
, lParam
);
1062 *lpFlags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_REPLACEALL
| FR_DIALOGTERM
);
1064 * FIXME : If the initial FindWhat string is empty, we should disable the
1065 * FindNext (IDOK) button. Only after typing some text, the button should be
1068 if (fUnicode
) SetDlgItemText32W(hWnd
, edt1
, (LPWSTR
)lpstrFindWhat
);
1069 else SetDlgItemText32A(hWnd
, edt1
, lpstrFindWhat
);
1070 CheckRadioButton32(hWnd
, rad1
, rad2
, (*lpFlags
& FR_DOWN
) ? rad2
: rad1
);
1071 if (*lpFlags
& (FR_HIDEUPDOWN
| FR_NOUPDOWN
)) {
1072 EnableWindow32(GetDlgItem32(hWnd
, rad1
), FALSE
);
1073 EnableWindow32(GetDlgItem32(hWnd
, rad2
), FALSE
);
1075 if (*lpFlags
& FR_HIDEUPDOWN
) {
1076 ShowWindow32(GetDlgItem32(hWnd
, rad1
), SW_HIDE
);
1077 ShowWindow32(GetDlgItem32(hWnd
, rad2
), SW_HIDE
);
1078 ShowWindow32(GetDlgItem32(hWnd
, grp1
), SW_HIDE
);
1080 CheckDlgButton32(hWnd
, chx1
, (*lpFlags
& FR_WHOLEWORD
) ? 1 : 0);
1081 if (*lpFlags
& (FR_HIDEWHOLEWORD
| FR_NOWHOLEWORD
))
1082 EnableWindow32(GetDlgItem32(hWnd
, chx1
), FALSE
);
1083 if (*lpFlags
& FR_HIDEWHOLEWORD
)
1084 ShowWindow32(GetDlgItem32(hWnd
, chx1
), SW_HIDE
);
1085 CheckDlgButton32(hWnd
, chx2
, (*lpFlags
& FR_MATCHCASE
) ? 1 : 0);
1086 if (*lpFlags
& (FR_HIDEMATCHCASE
| FR_NOMATCHCASE
))
1087 EnableWindow32(GetDlgItem32(hWnd
, chx2
), FALSE
);
1088 if (*lpFlags
& FR_HIDEMATCHCASE
)
1089 ShowWindow32(GetDlgItem32(hWnd
, chx2
), SW_HIDE
);
1090 if (!(*lpFlags
& FR_SHOWHELP
)) {
1091 EnableWindow32(GetDlgItem32(hWnd
, pshHelp
), FALSE
);
1092 ShowWindow32(GetDlgItem32(hWnd
, pshHelp
), SW_HIDE
);
1094 ShowWindow32(hWnd
, SW_SHOWNORMAL
);
1099 /***********************************************************************
1100 * FINDDLG_WMCommand [internal]
1102 static LRESULT
FINDDLG_WMCommand(HWND32 hWnd
, WPARAM32 wParam
,
1103 HWND32 hwndOwner
, LPDWORD lpFlags
,
1104 LPSTR lpstrFindWhat
, WORD wFindWhatLen
,
1107 int uFindReplaceMessage
= RegisterWindowMessage32A( FINDMSGSTRING
);
1108 int uHelpMessage
= RegisterWindowMessage32A( HELPMSGSTRING
);
1113 GetDlgItemText32W(hWnd
, edt1
, (LPWSTR
)lpstrFindWhat
, wFindWhatLen
/2);
1114 else GetDlgItemText32A(hWnd
, edt1
, lpstrFindWhat
, wFindWhatLen
);
1115 if (IsDlgButtonChecked32(hWnd
, rad2
))
1116 *lpFlags
|= FR_DOWN
;
1117 else *lpFlags
&= ~FR_DOWN
;
1118 if (IsDlgButtonChecked32(hWnd
, chx1
))
1119 *lpFlags
|= FR_WHOLEWORD
;
1120 else *lpFlags
&= ~FR_WHOLEWORD
;
1121 if (IsDlgButtonChecked32(hWnd
, chx2
))
1122 *lpFlags
|= FR_MATCHCASE
;
1123 else *lpFlags
&= ~FR_MATCHCASE
;
1124 *lpFlags
&= ~(FR_REPLACE
| FR_REPLACEALL
| FR_DIALOGTERM
);
1125 *lpFlags
|= FR_FINDNEXT
;
1126 SendMessage32A(hwndOwner
, uFindReplaceMessage
, 0,
1127 GetWindowLong32A(hWnd
, DWL_USER
) );
1130 *lpFlags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_REPLACEALL
);
1131 *lpFlags
|= FR_DIALOGTERM
;
1132 SendMessage32A(hwndOwner
, uFindReplaceMessage
, 0,
1133 GetWindowLong32A(hWnd
, DWL_USER
) );
1134 DestroyWindow32(hWnd
);
1137 /* FIXME : should lpfr structure be passed as an argument ??? */
1138 SendMessage32A(hwndOwner
, uHelpMessage
, 0, 0);
1145 /***********************************************************************
1146 * FindTextDlgProc16 (COMMDLG.13)
1148 LRESULT WINAPI
FindTextDlgProc16(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
1151 LPFINDREPLACE16 lpfr
;
1154 lpfr
=(LPFINDREPLACE16
)PTR_SEG_TO_LIN(lParam
);
1155 return FINDDLG_WMInitDialog(hWnd
, lParam
, &(lpfr
->Flags
),
1156 PTR_SEG_TO_LIN(lpfr
->lpstrFindWhat
), FALSE
);
1158 lpfr
=(LPFINDREPLACE16
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
1159 return FINDDLG_WMCommand(hWnd
, wParam
, lpfr
->hwndOwner
,
1160 &lpfr
->Flags
, PTR_SEG_TO_LIN(lpfr
->lpstrFindWhat
),
1161 lpfr
->wFindWhatLen
, FALSE
);
1166 /***********************************************************************
1167 * FindTextDlgProc32A
1169 LRESULT WINAPI
FindTextDlgProc32A(HWND32 hWnd
, UINT32 wMsg
, WPARAM32 wParam
,
1172 LPFINDREPLACE32A lpfr
;
1175 lpfr
=(LPFINDREPLACE32A
)lParam
;
1176 return FINDDLG_WMInitDialog(hWnd
, lParam
, &(lpfr
->Flags
),
1177 lpfr
->lpstrFindWhat
, FALSE
);
1179 lpfr
=(LPFINDREPLACE32A
)GetWindowLong32A(hWnd
, DWL_USER
);
1180 return FINDDLG_WMCommand(hWnd
, wParam
, lpfr
->hwndOwner
,
1181 &lpfr
->Flags
, lpfr
->lpstrFindWhat
, lpfr
->wFindWhatLen
,
1187 /***********************************************************************
1188 * FindTextDlgProc32W
1190 LRESULT WINAPI
FindTextDlgProc32W(HWND32 hWnd
, UINT32 wMsg
, WPARAM32 wParam
,
1193 LPFINDREPLACE32W lpfr
;
1196 lpfr
=(LPFINDREPLACE32W
)lParam
;
1197 return FINDDLG_WMInitDialog(hWnd
, lParam
, &(lpfr
->Flags
),
1198 (LPSTR
)lpfr
->lpstrFindWhat
, TRUE
);
1200 lpfr
=(LPFINDREPLACE32W
)GetWindowLong32A(hWnd
, DWL_USER
);
1201 return FINDDLG_WMCommand(hWnd
, wParam
, lpfr
->hwndOwner
,
1202 &lpfr
->Flags
, (LPSTR
)lpfr
->lpstrFindWhat
, lpfr
->wFindWhatLen
,
1209 /***********************************************************************
1210 * REPLACEDLG_WMInitDialog [internal]
1212 static LRESULT
REPLACEDLG_WMInitDialog(HWND32 hWnd
, LPARAM lParam
,
1213 LPDWORD lpFlags
, LPSTR lpstrFindWhat
,
1214 LPSTR lpstrReplaceWith
, BOOL32 fUnicode
)
1216 SetWindowLong32A(hWnd
, DWL_USER
, lParam
);
1217 *lpFlags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_REPLACEALL
| FR_DIALOGTERM
);
1219 * FIXME : If the initial FindWhat string is empty, we should disable the FinNext /
1220 * Replace / ReplaceAll buttons. Only after typing some text, the buttons should be
1225 SetDlgItemText32W(hWnd
, edt1
, (LPWSTR
)lpstrFindWhat
);
1226 SetDlgItemText32W(hWnd
, edt2
, (LPWSTR
)lpstrReplaceWith
);
1229 SetDlgItemText32A(hWnd
, edt1
, lpstrFindWhat
);
1230 SetDlgItemText32A(hWnd
, edt2
, lpstrReplaceWith
);
1232 CheckDlgButton32(hWnd
, chx1
, (*lpFlags
& FR_WHOLEWORD
) ? 1 : 0);
1233 if (*lpFlags
& (FR_HIDEWHOLEWORD
| FR_NOWHOLEWORD
))
1234 EnableWindow32(GetDlgItem32(hWnd
, chx1
), FALSE
);
1235 if (*lpFlags
& FR_HIDEWHOLEWORD
)
1236 ShowWindow32(GetDlgItem32(hWnd
, chx1
), SW_HIDE
);
1237 CheckDlgButton32(hWnd
, chx2
, (*lpFlags
& FR_MATCHCASE
) ? 1 : 0);
1238 if (*lpFlags
& (FR_HIDEMATCHCASE
| FR_NOMATCHCASE
))
1239 EnableWindow32(GetDlgItem32(hWnd
, chx2
), FALSE
);
1240 if (*lpFlags
& FR_HIDEMATCHCASE
)
1241 ShowWindow32(GetDlgItem32(hWnd
, chx2
), SW_HIDE
);
1242 if (!(*lpFlags
& FR_SHOWHELP
)) {
1243 EnableWindow32(GetDlgItem32(hWnd
, pshHelp
), FALSE
);
1244 ShowWindow32(GetDlgItem32(hWnd
, pshHelp
), SW_HIDE
);
1246 ShowWindow32(hWnd
, SW_SHOWNORMAL
);
1251 /***********************************************************************
1252 * REPLACEDLG_WMCommand [internal]
1254 static LRESULT
REPLACEDLG_WMCommand(HWND32 hWnd
, WPARAM16 wParam
,
1255 HWND32 hwndOwner
, LPDWORD lpFlags
,
1256 LPSTR lpstrFindWhat
, WORD wFindWhatLen
,
1257 LPSTR lpstrReplaceWith
, WORD wReplaceWithLen
,
1260 int uFindReplaceMessage
= RegisterWindowMessage32A( FINDMSGSTRING
);
1261 int uHelpMessage
= RegisterWindowMessage32A( HELPMSGSTRING
);
1267 GetDlgItemText32W(hWnd
, edt1
, (LPWSTR
)lpstrFindWhat
, wFindWhatLen
/2);
1268 GetDlgItemText32W(hWnd
, edt2
, (LPWSTR
)lpstrReplaceWith
, wReplaceWithLen
/2);
1271 GetDlgItemText32A(hWnd
, edt1
, lpstrFindWhat
, wFindWhatLen
);
1272 GetDlgItemText32A(hWnd
, edt2
, lpstrReplaceWith
, wReplaceWithLen
);
1274 if (IsDlgButtonChecked32(hWnd
, chx1
))
1275 *lpFlags
|= FR_WHOLEWORD
;
1276 else *lpFlags
&= ~FR_WHOLEWORD
;
1277 if (IsDlgButtonChecked32(hWnd
, chx2
))
1278 *lpFlags
|= FR_MATCHCASE
;
1279 else *lpFlags
&= ~FR_MATCHCASE
;
1280 *lpFlags
&= ~(FR_REPLACE
| FR_REPLACEALL
| FR_DIALOGTERM
);
1281 *lpFlags
|= FR_FINDNEXT
;
1282 SendMessage32A(hwndOwner
, uFindReplaceMessage
, 0,
1283 GetWindowLong32A(hWnd
, DWL_USER
) );
1286 *lpFlags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_REPLACEALL
);
1287 *lpFlags
|= FR_DIALOGTERM
;
1288 SendMessage32A(hwndOwner
, uFindReplaceMessage
, 0,
1289 GetWindowLong32A(hWnd
, DWL_USER
) );
1290 DestroyWindow32(hWnd
);
1295 GetDlgItemText32W(hWnd
, edt1
, (LPWSTR
)lpstrFindWhat
, wFindWhatLen
/2);
1296 GetDlgItemText32W(hWnd
, edt2
, (LPWSTR
)lpstrReplaceWith
, wReplaceWithLen
/2);
1299 GetDlgItemText32A(hWnd
, edt1
, lpstrFindWhat
, wFindWhatLen
);
1300 GetDlgItemText32A(hWnd
, edt2
, lpstrReplaceWith
, wReplaceWithLen
);
1302 if (IsDlgButtonChecked32(hWnd
, chx1
))
1303 *lpFlags
|= FR_WHOLEWORD
;
1304 else *lpFlags
&= ~FR_WHOLEWORD
;
1305 if (IsDlgButtonChecked32(hWnd
, chx2
))
1306 *lpFlags
|= FR_MATCHCASE
;
1307 else *lpFlags
&= ~FR_MATCHCASE
;
1308 *lpFlags
&= ~(FR_FINDNEXT
| FR_REPLACEALL
| FR_DIALOGTERM
);
1309 *lpFlags
|= FR_REPLACE
;
1310 SendMessage32A(hwndOwner
, uFindReplaceMessage
, 0,
1311 GetWindowLong32A(hWnd
, DWL_USER
) );
1316 GetDlgItemText32W(hWnd
, edt1
, (LPWSTR
)lpstrFindWhat
, wFindWhatLen
/2);
1317 GetDlgItemText32W(hWnd
, edt2
, (LPWSTR
)lpstrReplaceWith
, wReplaceWithLen
/2);
1320 GetDlgItemText32A(hWnd
, edt1
, lpstrFindWhat
, wFindWhatLen
);
1321 GetDlgItemText32A(hWnd
, edt2
, lpstrReplaceWith
, wReplaceWithLen
);
1323 if (IsDlgButtonChecked32(hWnd
, chx1
))
1324 *lpFlags
|= FR_WHOLEWORD
;
1325 else *lpFlags
&= ~FR_WHOLEWORD
;
1326 if (IsDlgButtonChecked32(hWnd
, chx2
))
1327 *lpFlags
|= FR_MATCHCASE
;
1328 else *lpFlags
&= ~FR_MATCHCASE
;
1329 *lpFlags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_DIALOGTERM
);
1330 *lpFlags
|= FR_REPLACEALL
;
1331 SendMessage32A(hwndOwner
, uFindReplaceMessage
, 0,
1332 GetWindowLong32A(hWnd
, DWL_USER
) );
1335 /* FIXME : should lpfr structure be passed as an argument ??? */
1336 SendMessage32A(hwndOwner
, uHelpMessage
, 0, 0);
1343 /***********************************************************************
1344 * ReplaceTextDlgProc16 (COMMDLG.14)
1346 LRESULT WINAPI
ReplaceTextDlgProc16(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
1349 LPFINDREPLACE16 lpfr
;
1352 lpfr
=(LPFINDREPLACE16
)PTR_SEG_TO_LIN(lParam
);
1353 return REPLACEDLG_WMInitDialog(hWnd
, lParam
, &lpfr
->Flags
,
1354 PTR_SEG_TO_LIN(lpfr
->lpstrFindWhat
),
1355 PTR_SEG_TO_LIN(lpfr
->lpstrReplaceWith
), FALSE
);
1357 lpfr
=(LPFINDREPLACE16
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
1358 return REPLACEDLG_WMCommand(hWnd
, wParam
, lpfr
->hwndOwner
,
1359 &lpfr
->Flags
, PTR_SEG_TO_LIN(lpfr
->lpstrFindWhat
),
1360 lpfr
->wFindWhatLen
, PTR_SEG_TO_LIN(lpfr
->lpstrReplaceWith
),
1361 lpfr
->wReplaceWithLen
, FALSE
);
1366 /***********************************************************************
1367 * ReplaceTextDlgProc32A
1369 LRESULT WINAPI
ReplaceTextDlgProc32A(HWND32 hWnd
, UINT32 wMsg
, WPARAM32 wParam
,
1372 LPFINDREPLACE32A lpfr
;
1375 lpfr
=(LPFINDREPLACE32A
)lParam
;
1376 return REPLACEDLG_WMInitDialog(hWnd
, lParam
, &lpfr
->Flags
,
1377 lpfr
->lpstrFindWhat
, lpfr
->lpstrReplaceWith
, FALSE
);
1379 lpfr
=(LPFINDREPLACE32A
)GetWindowLong32A(hWnd
, DWL_USER
);
1380 return REPLACEDLG_WMCommand(hWnd
, wParam
, lpfr
->hwndOwner
,
1381 &lpfr
->Flags
, lpfr
->lpstrFindWhat
, lpfr
->wFindWhatLen
,
1382 lpfr
->lpstrReplaceWith
, lpfr
->wReplaceWithLen
, FALSE
);
1387 /***********************************************************************
1388 * ReplaceTextDlgProc32W
1390 LRESULT WINAPI
ReplaceTextDlgProc32W(HWND32 hWnd
, UINT32 wMsg
, WPARAM32 wParam
,
1393 LPFINDREPLACE32W lpfr
;
1396 lpfr
=(LPFINDREPLACE32W
)lParam
;
1397 return REPLACEDLG_WMInitDialog(hWnd
, lParam
, &lpfr
->Flags
,
1398 (LPSTR
)lpfr
->lpstrFindWhat
, (LPSTR
)lpfr
->lpstrReplaceWith
,
1401 lpfr
=(LPFINDREPLACE32W
)GetWindowLong32A(hWnd
, DWL_USER
);
1402 return REPLACEDLG_WMCommand(hWnd
, wParam
, lpfr
->hwndOwner
,
1403 &lpfr
->Flags
, (LPSTR
)lpfr
->lpstrFindWhat
, lpfr
->wFindWhatLen
,
1404 (LPSTR
)lpfr
->lpstrReplaceWith
, lpfr
->wReplaceWithLen
, TRUE
);
1410 /***********************************************************************
1411 * PrintDlg16 (COMMDLG.20)
1413 BOOL16 WINAPI
PrintDlg16( SEGPTR printdlg
)
1416 BOOL16 bRet
= FALSE
;
1419 LPPRINTDLG16 lpPrint
= (LPPRINTDLG16
)PTR_SEG_TO_LIN(printdlg
);
1421 TRACE(commdlg
,"(%p) -- Flags=%08lX\n", lpPrint
, lpPrint
->Flags
);
1423 if (lpPrint
->Flags
& PD_RETURNDEFAULT
)
1424 /* FIXME: should fill lpPrint->hDevMode and lpPrint->hDevNames here */
1427 if (lpPrint
->Flags
& PD_PRINTSETUP
)
1428 template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT_SETUP
);
1430 template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT
);
1432 hInst
= WIN_GetWindowInstance( lpPrint
->hwndOwner
);
1433 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, TRUE
,
1435 (DLGPROC16
)((lpPrint
->Flags
& PD_PRINTSETUP
) ?
1436 MODULE_GetWndProcEntry16("PrintSetupDlgProc") :
1437 MODULE_GetWndProcEntry16("PrintDlgProc")),
1438 printdlg
, WIN_PROC_16
);
1439 if (hwndDialog
) bRet
= DIALOG_DoDialogBox( hwndDialog
, lpPrint
->hwndOwner
);
1444 /***********************************************************************
1445 * PrintDlg32A (COMDLG32.17)
1447 BOOL32 WINAPI
PrintDlg32A( LPPRINTDLG32A printdlg
)
1449 FIXME(commdlg
, "empty stub\n" );
1450 /* Altough returning FALSE is theoricaly the right thing
1451 * most programs check for a printer at startup, and if
1452 * none is found popup PrintDlg32A(), if it fails the program
1453 * terminates; by returning TRUE the programs can still run
1454 * as long as no printer related stuff is used
1460 /***********************************************************************
1461 * PrintDlg32W (COMDLG32.18)
1463 BOOL32 WINAPI
PrintDlg32W( LPPRINTDLG32W printdlg
)
1465 FIXME(commdlg
, "empty stub\n" );
1470 /***********************************************************************
1471 * PrintDlgProc (COMMDLG.21)
1473 LRESULT WINAPI
PrintDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
1479 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
1480 ShowWindow16(hWnd
, SW_SHOWNORMAL
);
1486 EndDialog32(hWnd
, TRUE
);
1489 EndDialog32(hWnd
, FALSE
);
1498 /***********************************************************************
1499 * PrintSetupDlgProc (COMMDLG.22)
1501 LRESULT WINAPI
PrintSetupDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
1507 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
1508 ShowWindow16(hWnd
, SW_SHOWNORMAL
);
1513 EndDialog32(hWnd
, TRUE
);
1516 EndDialog32(hWnd
, FALSE
);
1525 /***********************************************************************
1526 * CommDlgExtendedError (COMMDLG.26)
1528 DWORD WINAPI
CommDlgExtendedError(void)
1530 return CommDlgLastError
;
1533 /***********************************************************************
1534 * GetFileTitleA (COMDLG32.8)
1536 short WINAPI
GetFileTitle32A(LPCSTR lpFile
, LPSTR lpTitle
, UINT32 cbBuf
)
1539 TRACE(commdlg
,"(%p %p %d); \n", lpFile
, lpTitle
, cbBuf
);
1540 if (lpFile
== NULL
|| lpTitle
== NULL
)
1542 len
= strlen(lpFile
);
1545 if (strpbrk(lpFile
, "*[]"))
1548 if (lpFile
[len
] == '/' || lpFile
[len
] == '\\' || lpFile
[len
] == ':')
1550 for (i
= len
; i
>= 0; i
--)
1551 if (lpFile
[i
] == '/' || lpFile
[i
] == '\\' || lpFile
[i
] == ':')
1556 TRACE(commdlg
,"---> '%s' \n", &lpFile
[i
]);
1558 len
= strlen(lpFile
+i
)+1;
1562 strncpy(lpTitle
, &lpFile
[i
], len
);
1567 /***********************************************************************
1568 * GetFileTitleA (COMDLG32.8)
1570 short WINAPI
GetFileTitle32W(LPCWSTR lpFile
, LPWSTR lpTitle
, UINT32 cbBuf
)
1572 LPSTR file
= HEAP_strdupWtoA(GetProcessHeap(),0,lpFile
);
1573 LPSTR title
= HeapAlloc(GetProcessHeap(),0,cbBuf
);
1576 ret
= GetFileTitle32A(file
,title
,cbBuf
);
1578 lstrcpynAtoW(lpTitle
,title
,cbBuf
);
1579 HeapFree(GetProcessHeap(),0,file
);
1580 HeapFree(GetProcessHeap(),0,title
);
1583 /***********************************************************************
1584 * GetFileTitle (COMMDLG.27)
1586 short WINAPI
GetFileTitle16(LPCSTR lpFile
, LPSTR lpTitle
, UINT16 cbBuf
)
1588 return GetFileTitle32A(lpFile
,lpTitle
,cbBuf
);
1592 /* ------------------------ Choose Color Dialog --------------------------- */
1594 /***********************************************************************
1595 * ChooseColor (COMMDLG.5)
1597 BOOL16 WINAPI
ChooseColor16(LPCHOOSECOLOR16 lpChCol
)
1600 HANDLE16 hDlgTmpl
= 0;
1601 BOOL16 bRet
= FALSE
, win32Format
= FALSE
;
1605 TRACE(commdlg
,"ChooseColor\n");
1606 if (!lpChCol
) return FALSE
;
1608 if (lpChCol
->Flags
& CC_ENABLETEMPLATEHANDLE
)
1610 if (!(template = LockResource16( lpChCol
->hInstance
)))
1612 CommDlgLastError
= CDERR_LOADRESFAILURE
;
1616 else if (lpChCol
->Flags
& CC_ENABLETEMPLATE
)
1619 if (!(hResInfo
= FindResource16(lpChCol
->hInstance
,
1620 lpChCol
->lpTemplateName
,
1623 CommDlgLastError
= CDERR_FINDRESFAILURE
;
1626 if (!(hDlgTmpl
= LoadResource16( lpChCol
->hInstance
, hResInfo
)) ||
1627 !(template = LockResource16( hDlgTmpl
)))
1629 CommDlgLastError
= CDERR_LOADRESFAILURE
;
1635 template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_COLOR
);
1639 hInst
= WIN_GetWindowInstance( lpChCol
->hwndOwner
);
1640 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, win32Format
,
1642 (DLGPROC16
)MODULE_GetWndProcEntry16("ColorDlgProc"),
1643 (DWORD
)lpChCol
, WIN_PROC_16
);
1644 if (hwndDialog
) bRet
= DIALOG_DoDialogBox( hwndDialog
, lpChCol
->hwndOwner
);
1645 if (hDlgTmpl
) FreeResource16( hDlgTmpl
);
1650 static const COLORREF predefcolors
[6][8]=
1652 { 0x008080FFL
, 0x0080FFFFL
, 0x0080FF80L
, 0x0080FF00L
,
1653 0x00FFFF80L
, 0x00FF8000L
, 0x00C080FFL
, 0x00FF80FFL
},
1654 { 0x000000FFL
, 0x0000FFFFL
, 0x0000FF80L
, 0x0040FF00L
,
1655 0x00FFFF00L
, 0x00C08000L
, 0x00C08080L
, 0x00FF00FFL
},
1657 { 0x00404080L
, 0x004080FFL
, 0x0000FF00L
, 0x00808000L
,
1658 0x00804000L
, 0x00FF8080L
, 0x00400080L
, 0x008000FFL
},
1659 { 0x00000080L
, 0x000080FFL
, 0x00008000L
, 0x00408000L
,
1660 0x00FF0000L
, 0x00A00000L
, 0x00800080L
, 0x00FF0080L
},
1662 { 0x00000040L
, 0x00004080L
, 0x00004000L
, 0x00404000L
,
1663 0x00800000L
, 0x00400000L
, 0x00400040L
, 0x00800040L
},
1664 { 0x00000000L
, 0x00008080L
, 0x00408080L
, 0x00808080L
,
1665 0x00808040L
, 0x00C0C0C0L
, 0x00400040L
, 0x00FFFFFFL
},
1670 LPCHOOSECOLOR16 lpcc
; /* points to public known data structure */
1671 int nextuserdef
; /* next free place in user defined color array */
1672 HDC16 hdcMem
; /* color graph used for BitBlt() */
1673 HBITMAP16 hbmMem
; /* color graph bitmap */
1674 RECT16 fullsize
; /* original dialog window size */
1675 UINT16 msetrgb
; /* # of SETRGBSTRING message (today not used) */
1676 RECT16 old3angle
; /* last position of l-marker */
1677 RECT16 oldcross
; /* last position of color/satuation marker */
1678 BOOL32 updating
; /* to prevent recursive WM_COMMAND/EN_UPDATE procesing */
1681 int l
; /* for temporary storing of hue,sat,lum */
1684 /***********************************************************************
1685 * CC_HSLtoRGB [internal]
1687 static int CC_HSLtoRGB(char c
,int hue
,int sat
,int lum
)
1694 case 'R':if (hue
>80) hue
-=80; else hue
+=160; break;
1695 case 'G':if (hue
>160) hue
-=160; else hue
+=80; break;
1700 maxrgb
=(256*MIN(120,lum
))/120; /* 0 .. 256 */
1706 res
=(hue
-80)* maxrgb
; /* 0...10240 */
1707 res
/=40; /* 0...256 */
1714 res
=(240-hue
)* maxrgb
;
1717 res
=res
-maxrgb
/2; /* -128...128 */
1720 res
=maxrgb
/2 + (sat
*res
) /240; /* 0..256 */
1723 if (lum
>120 && res
<256)
1724 res
+=((lum
-120) * (256-res
))/120;
1726 return MIN(res
,255);
1729 /***********************************************************************
1730 * CC_RGBtoHSL [internal]
1732 static int CC_RGBtoHSL(char c
,int r
,int g
,int b
)
1734 WORD maxi
,mini
,mmsum
,mmdif
,result
=0;
1748 case 'L':mmsum
*=120; /* 0...61200=(255+255)*120 */
1749 result
=mmsum
/255; /* 0...240 */
1752 case 'S':if (!mmsum
)
1755 if (!mini
|| maxi
==255)
1759 result
=mmdif
*240; /* 0...61200=255*240 */
1760 result
/= (mmsum
>255 ? mmsum
=510-mmsum
: mmsum
); /* 0..255 */
1764 case 'H':if (!mmdif
)
1770 iresult
=40*(g
-b
); /* -10200 ... 10200 */
1771 iresult
/=(int)mmdif
; /* -40 .. 40 */
1773 iresult
+=240; /* 0..40 and 200..240 */
1779 iresult
/=(int)mmdif
;
1780 iresult
+=80; /* 40 .. 120 */
1786 iresult
/=(int)mmdif
;
1787 iresult
+=160; /* 120 .. 200 */
1793 return result
; /* is this integer arithmetic precise enough ? */
1798 /***********************************************************************
1799 * CC_MouseCheckPredefColorArray [internal]
1801 static int CC_MouseCheckPredefColorArray(HWND16 hDlg
,int dlgitem
,int rows
,int cols
,
1802 LPARAM lParam
,COLORREF
*cr
)
1805 POINT16 point
= MAKEPOINT16(lParam
);
1809 ClientToScreen16(hDlg
,&point
);
1810 hwnd
=GetDlgItem32(hDlg
,dlgitem
);
1811 GetWindowRect16(hwnd
,&rect
);
1812 if (PtInRect16(&rect
,point
))
1814 dx
=(rect
.right
-rect
.left
)/cols
;
1815 dy
=(rect
.bottom
-rect
.top
)/rows
;
1816 ScreenToClient16(hwnd
,&point
);
1818 if (point
.x
% dx
< (dx
-DISTANCE
) && point
.y
% dy
< (dy
-DISTANCE
))
1822 *cr
=predefcolors
[y
][x
];
1823 /* FIXME: Draw_a_Focus_Rect() */
1830 /***********************************************************************
1831 * CC_MouseCheckUserColorArray [internal]
1833 static int CC_MouseCheckUserColorArray(HWND16 hDlg
,int dlgitem
,int rows
,int cols
,
1834 LPARAM lParam
,COLORREF
*cr
,COLORREF
*crarr
)
1837 POINT16 point
= MAKEPOINT16(lParam
);
1841 ClientToScreen16(hDlg
,&point
);
1842 hwnd
=GetDlgItem32(hDlg
,dlgitem
);
1843 GetWindowRect16(hwnd
,&rect
);
1844 if (PtInRect16(&rect
,point
))
1846 dx
=(rect
.right
-rect
.left
)/cols
;
1847 dy
=(rect
.bottom
-rect
.top
)/rows
;
1848 ScreenToClient16(hwnd
,&point
);
1850 if (point
.x
% dx
< (dx
-DISTANCE
) && point
.y
% dy
< (dy
-DISTANCE
))
1854 *cr
=crarr
[x
+cols
*y
];
1855 /* FIXME: Draw_a_Focus_Rect() */
1865 /* 240 ^...... ^^ 240
1872 /***********************************************************************
1873 * CC_MouseCheckColorGraph [internal]
1875 static int CC_MouseCheckColorGraph(HWND16 hDlg
,int dlgitem
,int *hori
,int *vert
,LPARAM lParam
)
1878 POINT16 point
= MAKEPOINT16(lParam
);
1882 ClientToScreen16(hDlg
,&point
);
1883 hwnd
=GetDlgItem32(hDlg
,dlgitem
);
1884 GetWindowRect16(hwnd
,&rect
);
1885 if (PtInRect16(&rect
,point
))
1887 GetClientRect16(hwnd
,&rect
);
1888 ScreenToClient16(hwnd
,&point
);
1890 x
=(long)point
.x
*MAXHORI
;
1892 y
=(long)(rect
.bottom
-point
.y
)*MAXVERT
;
1904 /***********************************************************************
1905 * CC_MouseCheckResultWindow [internal]
1907 static int CC_MouseCheckResultWindow(HWND16 hDlg
,LPARAM lParam
)
1910 POINT16 point
= MAKEPOINT16(lParam
);
1913 ClientToScreen16(hDlg
,&point
);
1914 hwnd
=GetDlgItem32(hDlg
,0x2c5);
1915 GetWindowRect16(hwnd
,&rect
);
1916 if (PtInRect16(&rect
,point
))
1918 PostMessage16(hDlg
,WM_COMMAND
,0x2c9,0);
1924 /***********************************************************************
1925 * CC_CheckDigitsInEdit [internal]
1927 static int CC_CheckDigitsInEdit(HWND16 hwnd
,int maxval
)
1929 int i
,k
,m
,result
,value
;
1932 GetWindowText32A(hwnd
,buffer
,sizeof(buffer
));
1937 if (buffer
[i
]<'0' || buffer
[i
]>'9')
1939 for (k
=i
+1;k
<=m
;k
++) /* delete bad character */
1941 buffer
[i
]=buffer
[k
];
1949 if (value
>maxval
) /* build a new string */
1951 sprintf(buffer
,"%d",maxval
);
1956 editpos
=SendMessage16(hwnd
,EM_GETSEL16
,0,0);
1957 SetWindowText32A(hwnd
,buffer
);
1958 SendMessage16(hwnd
,EM_SETSEL16
,0,editpos
);
1965 /***********************************************************************
1966 * CC_PaintSelectedColor [internal]
1968 static void CC_PaintSelectedColor(HWND16 hDlg
,COLORREF cr
)
1973 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2c5);
1974 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
1977 GetClientRect16 (hwnd
, &rect
) ;
1978 hBrush
= CreateSolidBrush32(cr
);
1981 hBrush
= SelectObject32 (hdc
, hBrush
) ;
1982 Rectangle32(hdc
, rect
.left
,rect
.top
,rect
.right
/2,rect
.bottom
);
1983 DeleteObject32 (SelectObject32 (hdc
,hBrush
)) ;
1984 hBrush
=CreateSolidBrush32(GetNearestColor32(hdc
,cr
));
1987 hBrush
= SelectObject32 (hdc
, hBrush
) ;
1988 Rectangle32( hdc
, rect
.right
/2-1,rect
.top
,rect
.right
,rect
.bottom
);
1989 DeleteObject32( SelectObject32 (hdc
, hBrush
)) ;
1992 ReleaseDC32(hwnd
,hdc
);
1996 /***********************************************************************
1997 * CC_PaintTriangle [internal]
1999 static void CC_PaintTriangle(HWND16 hDlg
,int y
)
2003 int w
=GetDialogBaseUnits();
2008 HWND16 hwnd
=GetDlgItem32(hDlg
,0x2be);
2009 struct CCPRIVATE
*lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2011 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
2013 GetClientRect16(hwnd
,&rect
);
2017 points
[0].y
=rect
.top
;
2018 points
[0].x
=rect
.right
; /* | /| */
2019 ClientToScreen16(hwnd
,points
); /* | / | */
2020 ScreenToClient16(hDlg
,points
); /* |< | */
2021 oben
=points
[0].y
; /* | \ | */
2023 temp
=(long)height
*(long)y
;
2024 points
[0].y
=oben
+height
-temp
/(long)MAXVERT
;
2025 points
[1].y
=points
[0].y
+w
;
2026 points
[2].y
=points
[0].y
-w
;
2027 points
[2].x
=points
[1].x
=points
[0].x
+ w
;
2029 if (lpp
->old3angle
.left
)
2030 FillRect16(hDC
,&lpp
->old3angle
,GetStockObject32(WHITE_BRUSH
));
2031 lpp
->old3angle
.left
=points
[0].x
;
2032 lpp
->old3angle
.right
=points
[1].x
+1;
2033 lpp
->old3angle
.top
=points
[2].y
-1;
2034 lpp
->old3angle
.bottom
=points
[1].y
+1;
2035 Polygon16(hDC
,points
,3);
2036 ReleaseDC32(hDlg
,hDC
);
2041 /***********************************************************************
2042 * CC_PaintCross [internal]
2044 static void CC_PaintCross(HWND16 hDlg
,int x
,int y
)
2047 int w
=GetDialogBaseUnits();
2048 HWND16 hwnd
=GetDlgItem32(hDlg
,0x2c6);
2049 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2054 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
2056 GetClientRect16(hwnd
,&rect
);
2058 SelectClipRgn32(hDC
,CreateRectRgnIndirect16(&rect
));
2059 hPen
=CreatePen32(PS_SOLID
,2,0);
2060 hPen
=SelectObject32(hDC
,hPen
);
2061 point
.x
=((long)rect
.right
*(long)x
)/(long)MAXHORI
;
2062 point
.y
=rect
.bottom
-((long)rect
.bottom
*(long)y
)/(long)MAXVERT
;
2063 if (lpp
->oldcross
.left
!=lpp
->oldcross
.right
)
2064 BitBlt32(hDC
,lpp
->oldcross
.left
,lpp
->oldcross
.top
,
2065 lpp
->oldcross
.right
-lpp
->oldcross
.left
,
2066 lpp
->oldcross
.bottom
-lpp
->oldcross
.top
,
2067 lpp
->hdcMem
,lpp
->oldcross
.left
,lpp
->oldcross
.top
,SRCCOPY
);
2068 lpp
->oldcross
.left
=point
.x
-w
-1;
2069 lpp
->oldcross
.right
=point
.x
+w
+1;
2070 lpp
->oldcross
.top
=point
.y
-w
-1;
2071 lpp
->oldcross
.bottom
=point
.y
+w
+1;
2073 MoveTo(hDC
,point
.x
-w
,point
.y
);
2074 LineTo32(hDC
,point
.x
+w
,point
.y
);
2075 MoveTo(hDC
,point
.x
,point
.y
-w
);
2076 LineTo32(hDC
,point
.x
,point
.y
+w
);
2077 DeleteObject32(SelectObject32(hDC
,hPen
));
2078 ReleaseDC32(hwnd
,hDC
);
2087 /***********************************************************************
2088 * CC_PrepareColorGraph [internal]
2090 static void CC_PrepareColorGraph(HWND16 hDlg
)
2092 int sdif
,hdif
,xdif
,ydif
,r
,g
,b
,hue
,sat
;
2093 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2c6);
2094 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2098 HCURSOR16 hcursor
=SetCursor16(LoadCursor16(0,IDC_WAIT16
));
2100 GetClientRect16(hwnd
,&client
);
2102 lpp
->hdcMem
= CreateCompatibleDC32(hdc
);
2103 lpp
->hbmMem
= CreateCompatibleBitmap32(hdc
,client
.right
,client
.bottom
);
2104 SelectObject32(lpp
->hdcMem
,lpp
->hbmMem
);
2106 xdif
=client
.right
/XSTEPS
;
2107 ydif
=client
.bottom
/YSTEPS
+1;
2110 for(rect
.left
=hue
=0;hue
<239+hdif
;hue
+=hdif
)
2112 rect
.right
=rect
.left
+xdif
;
2113 rect
.bottom
=client
.bottom
;
2114 for(sat
=0;sat
<240+sdif
;sat
+=sdif
)
2116 rect
.top
=rect
.bottom
-ydif
;
2117 r
=CC_HSLtoRGB('R',hue
,sat
,120);
2118 g
=CC_HSLtoRGB('G',hue
,sat
,120);
2119 b
=CC_HSLtoRGB('B',hue
,sat
,120);
2120 hbrush
=CreateSolidBrush32(RGB(r
,g
,b
));
2121 FillRect16(lpp
->hdcMem
,&rect
,hbrush
);
2122 DeleteObject32(hbrush
);
2123 rect
.bottom
=rect
.top
;
2125 rect
.left
=rect
.right
;
2127 ReleaseDC32(hwnd
,hdc
);
2128 SetCursor16(hcursor
);
2131 /***********************************************************************
2132 * CC_PaintColorGraph [internal]
2134 static void CC_PaintColorGraph(HWND16 hDlg
)
2136 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2c6);
2137 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2140 if (IsWindowVisible32(hwnd
)) /* if full size */
2143 CC_PrepareColorGraph(hDlg
); /* should not be necessary */
2146 GetClientRect16(hwnd
,&rect
);
2148 BitBlt32(hDC
,0,0,rect
.right
,rect
.bottom
,lpp
->hdcMem
,0,0,SRCCOPY
);
2150 WARN(commdlg
,"choose color: hdcMem is not defined\n");
2151 ReleaseDC32(hwnd
,hDC
);
2154 /***********************************************************************
2155 * CC_PaintLumBar [internal]
2157 static void CC_PaintLumBar(HWND16 hDlg
,int hue
,int sat
)
2159 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2be);
2161 int lum
,ldif
,ydif
,r
,g
,b
;
2165 if (IsWindowVisible32(hwnd
))
2168 GetClientRect16(hwnd
,&client
);
2172 ydif
=client
.bottom
/YSTEPS
+1;
2173 for(lum
=0;lum
<240+ldif
;lum
+=ldif
)
2175 rect
.top
=MAX(0,rect
.bottom
-ydif
);
2176 r
=CC_HSLtoRGB('R',hue
,sat
,lum
);
2177 g
=CC_HSLtoRGB('G',hue
,sat
,lum
);
2178 b
=CC_HSLtoRGB('B',hue
,sat
,lum
);
2179 hbrush
=CreateSolidBrush32(RGB(r
,g
,b
));
2180 FillRect16(hDC
,&rect
,hbrush
);
2181 DeleteObject32(hbrush
);
2182 rect
.bottom
=rect
.top
;
2184 GetClientRect16(hwnd
,&rect
);
2185 FrameRect16(hDC
,&rect
,GetStockObject32(BLACK_BRUSH
));
2186 ReleaseDC32(hwnd
,hDC
);
2190 /***********************************************************************
2191 * CC_EditSetRGB [internal]
2193 static void CC_EditSetRGB(HWND16 hDlg
,COLORREF cr
)
2196 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2197 int r
=GetRValue(cr
);
2198 int g
=GetGValue(cr
);
2199 int b
=GetBValue(cr
);
2200 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
2203 sprintf(buffer
,"%d",r
);
2204 SetWindowText32A(GetDlgItem32(hDlg
,0x2c2),buffer
);
2205 sprintf(buffer
,"%d",g
);
2206 SetWindowText32A(GetDlgItem32(hDlg
,0x2c3),buffer
);
2207 sprintf(buffer
,"%d",b
);
2208 SetWindowText32A(GetDlgItem32(hDlg
,0x2c4),buffer
);
2209 lpp
->updating
=FALSE
;
2213 /***********************************************************************
2214 * CC_EditSetHSL [internal]
2216 static void CC_EditSetHSL(HWND16 hDlg
,int h
,int s
,int l
)
2219 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2221 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
2224 sprintf(buffer
,"%d",h
);
2225 SetWindowText32A(GetDlgItem32(hDlg
,0x2bf),buffer
);
2226 sprintf(buffer
,"%d",s
);
2227 SetWindowText32A(GetDlgItem32(hDlg
,0x2c0),buffer
);
2228 sprintf(buffer
,"%d",l
);
2229 SetWindowText32A(GetDlgItem32(hDlg
,0x2c1),buffer
);
2230 lpp
->updating
=FALSE
;
2232 CC_PaintLumBar(hDlg
,h
,s
);
2235 /***********************************************************************
2236 * CC_SwitchToFullSize [internal]
2238 static void CC_SwitchToFullSize(HWND16 hDlg
,COLORREF result
,LPRECT16 lprect
)
2241 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2243 EnableWindow32(GetDlgItem32(hDlg
,0x2cf),FALSE
);
2244 CC_PrepareColorGraph(hDlg
);
2245 for (i
=0x2bf;i
<0x2c5;i
++)
2246 EnableWindow32(GetDlgItem32(hDlg
,i
),TRUE
);
2247 for (i
=0x2d3;i
<0x2d9;i
++)
2248 EnableWindow32(GetDlgItem32(hDlg
,i
),TRUE
);
2249 EnableWindow32(GetDlgItem32(hDlg
,0x2c9),TRUE
);
2250 EnableWindow32(GetDlgItem32(hDlg
,0x2c8),TRUE
);
2253 SetWindowPos32(hDlg
,NULL
,0,0,lprect
->right
-lprect
->left
,
2254 lprect
->bottom
-lprect
->top
, SWP_NOMOVE
|SWP_NOZORDER
);
2256 ShowWindow32(GetDlgItem32(hDlg
,0x2c6),SW_SHOW
);
2257 ShowWindow32(GetDlgItem32(hDlg
,0x2be),SW_SHOW
);
2258 ShowWindow32(GetDlgItem32(hDlg
,0x2c5),SW_SHOW
);
2260 CC_EditSetRGB(hDlg
,result
);
2261 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
2264 /***********************************************************************
2265 * CC_PaintPredefColorArray [internal]
2267 static void CC_PaintPredefColorArray(HWND16 hDlg
,int rows
,int cols
)
2269 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2d0);
2275 GetClientRect16(hwnd
,&rect
);
2277 dy
=rect
.bottom
/rows
;
2281 GetClientRect16 (hwnd
, &rect
) ;
2283 for (j
=0;j
<rows
;j
++)
2285 for (i
=0;i
<cols
;i
++)
2287 hBrush
= CreateSolidBrush32(predefcolors
[j
][i
]);
2290 hBrush
= SelectObject32 (hdc
, hBrush
) ;
2291 Rectangle32(hdc
, rect
.left
, rect
.top
,
2292 rect
.left
+dx
-DISTANCE
, rect
.top
+dy
-DISTANCE
);
2293 rect
.left
=rect
.left
+dx
;
2294 DeleteObject32( SelectObject32 (hdc
, hBrush
)) ;
2297 rect
.top
=rect
.top
+dy
;
2300 ReleaseDC32(hwnd
,hdc
);
2301 /* FIXME: draw_a_focus_rect */
2303 /***********************************************************************
2304 * CC_PaintUserColorArray [internal]
2306 static void CC_PaintUserColorArray(HWND16 hDlg
,int rows
,int cols
,COLORREF
* lpcr
)
2308 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2d1);
2314 GetClientRect16(hwnd
,&rect
);
2317 dy
=rect
.bottom
/rows
;
2323 for (j
=0;j
<rows
;j
++)
2325 for (i
=0;i
<cols
;i
++)
2327 hBrush
= CreateSolidBrush32(lpcr
[i
+j
*cols
]);
2330 hBrush
= SelectObject32 (hdc
, hBrush
) ;
2331 Rectangle32( hdc
, rect
.left
, rect
.top
,
2332 rect
.left
+dx
-DISTANCE
, rect
.top
+dy
-DISTANCE
);
2333 rect
.left
=rect
.left
+dx
;
2334 DeleteObject32( SelectObject32 (hdc
, hBrush
)) ;
2337 rect
.top
=rect
.top
+dy
;
2340 ReleaseDC32(hwnd
,hdc
);
2342 /* FIXME: draw_a_focus_rect */
2347 /***********************************************************************
2348 * CC_HookCallChk [internal]
2350 static BOOL32
CC_HookCallChk(LPCHOOSECOLOR16 lpcc
)
2353 if(lpcc
->Flags
& CC_ENABLEHOOK
)
2359 /***********************************************************************
2360 * CC_WMInitDialog [internal]
2362 static LONG
CC_WMInitDialog(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2368 struct CCPRIVATE
* lpp
;
2370 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
2371 lpp
=calloc(1,sizeof(struct CCPRIVATE
));
2372 lpp
->lpcc
=(LPCHOOSECOLOR16
)lParam
;
2373 if (lpp
->lpcc
->lStructSize
!= sizeof(CHOOSECOLOR16
))
2375 EndDialog32 (hDlg
, 0) ;
2378 SetWindowLong32A(hDlg
, DWL_USER
, (LONG
)lpp
);
2380 if (!(lpp
->lpcc
->Flags
& CC_SHOWHELP
))
2381 ShowWindow32(GetDlgItem32(hDlg
,0x40e),SW_HIDE
);
2382 lpp
->msetrgb
=RegisterWindowMessage32A( SETRGBSTRING
);
2384 cpos
=MAKELONG(5,7); /* init */
2385 if (lpp
->lpcc
->Flags
& CC_RGBINIT
)
2389 if (predefcolors
[i
][j
]==lpp
->lpcc
->rgbResult
)
2396 /* FIXME: Draw_a_focus_rect & set_init_values */
2398 GetWindowRect16(hDlg
,&lpp
->fullsize
);
2399 if (lpp
->lpcc
->Flags
& CC_FULLOPEN
|| lpp
->lpcc
->Flags
& CC_PREVENTFULLOPEN
)
2401 hwnd
=GetDlgItem32(hDlg
,0x2cf);
2402 EnableWindow32(hwnd
,FALSE
);
2404 if (!(lpp
->lpcc
->Flags
& CC_FULLOPEN
) || lpp
->lpcc
->Flags
& CC_PREVENTFULLOPEN
)
2407 res
=rect
.bottom
-rect
.top
;
2408 hwnd
=GetDlgItem32(hDlg
,0x2c6); /* cut at left border */
2410 ClientToScreen16(hwnd
,&point
);
2411 ScreenToClient16(hDlg
,&point
);
2412 GetClientRect16(hDlg
,&rect
);
2413 point
.x
+=GetSystemMetrics32(SM_CXDLGFRAME
);
2414 SetWindowPos32(hDlg
,NULL
,0,0,point
.x
,res
,SWP_NOMOVE
|SWP_NOZORDER
);
2416 ShowWindow32(GetDlgItem32(hDlg
,0x2c6),SW_HIDE
);
2417 ShowWindow32(GetDlgItem32(hDlg
,0x2c5),SW_HIDE
);
2420 CC_SwitchToFullSize(hDlg
,lpp
->lpcc
->rgbResult
,NULL
);
2422 for (i
=0x2bf;i
<0x2c5;i
++)
2423 SendMessage16(GetDlgItem32(hDlg
,i
),EM_LIMITTEXT16
,3,0); /* max 3 digits: xyz */
2424 if (CC_HookCallChk(lpp
->lpcc
))
2425 res
=CallWindowProc16(lpp
->lpcc
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
2429 /***********************************************************************
2430 * CC_WMCommand [internal]
2432 static LRESULT
CC_WMCommand(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2438 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2439 TRACE(commdlg
,"CC_WMCommand wParam=%x lParam=%lx\n",wParam
,lParam
);
2442 case 0x2c2: /* edit notify RGB */
2445 if (HIWORD(lParam
)==EN_UPDATE
&& !lpp
->updating
)
2447 i
=CC_CheckDigitsInEdit(LOWORD(lParam
),255);
2448 r
=GetRValue(lpp
->lpcc
->rgbResult
);
2449 g
=GetGValue(lpp
->lpcc
->rgbResult
);
2450 b
=GetBValue(lpp
->lpcc
->rgbResult
);
2454 case 0x2c2:if ((xx
=(i
!=r
))) r
=i
;break;
2455 case 0x2c3:if ((xx
=(i
!=g
))) g
=i
;break;
2456 case 0x2c4:if ((xx
=(i
!=b
))) b
=i
;break;
2458 if (xx
) /* something has changed */
2460 lpp
->lpcc
->rgbResult
=RGB(r
,g
,b
);
2461 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2462 lpp
->h
=CC_RGBtoHSL('H',r
,g
,b
);
2463 lpp
->s
=CC_RGBtoHSL('S',r
,g
,b
);
2464 lpp
->l
=CC_RGBtoHSL('L',r
,g
,b
);
2465 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
2466 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2467 CC_PaintTriangle(hDlg
,lpp
->l
);
2472 case 0x2bf: /* edit notify HSL */
2475 if (HIWORD(lParam
)==EN_UPDATE
&& !lpp
->updating
)
2477 i
=CC_CheckDigitsInEdit(LOWORD(lParam
),wParam
==0x2bf?239:240);
2481 case 0x2bf:if ((xx
=(i
!=lpp
->h
))) lpp
->h
=i
;break;
2482 case 0x2c0:if ((xx
=(i
!=lpp
->s
))) lpp
->s
=i
;break;
2483 case 0x2c1:if ((xx
=(i
!=lpp
->l
))) lpp
->l
=i
;break;
2485 if (xx
) /* something has changed */
2487 r
=CC_HSLtoRGB('R',lpp
->h
,lpp
->s
,lpp
->l
);
2488 g
=CC_HSLtoRGB('G',lpp
->h
,lpp
->s
,lpp
->l
);
2489 b
=CC_HSLtoRGB('B',lpp
->h
,lpp
->s
,lpp
->l
);
2490 lpp
->lpcc
->rgbResult
=RGB(r
,g
,b
);
2491 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2492 CC_EditSetRGB(hDlg
,lpp
->lpcc
->rgbResult
);
2493 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2494 CC_PaintTriangle(hDlg
,lpp
->l
);
2500 CC_SwitchToFullSize(hDlg
,lpp
->lpcc
->rgbResult
,&lpp
->fullsize
);
2501 InvalidateRect32( hDlg
, NULL
, TRUE
);
2502 SetFocus32(GetDlgItem32(hDlg
,0x2bf));
2505 case 0x2c8: /* add colors ... column by column */
2506 cr
=PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
);
2507 cr
[(lpp
->nextuserdef
%2)*8 + lpp
->nextuserdef
/2]=lpp
->lpcc
->rgbResult
;
2508 if (++lpp
->nextuserdef
==16)
2510 CC_PaintUserColorArray(hDlg
,2,8,PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
));
2513 case 0x2c9: /* resulting color */
2515 lpp
->lpcc
->rgbResult
=GetNearestColor32(hdc
,lpp
->lpcc
->rgbResult
);
2516 ReleaseDC32(hDlg
,hdc
);
2517 CC_EditSetRGB(hDlg
,lpp
->lpcc
->rgbResult
);
2518 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2519 r
=GetRValue(lpp
->lpcc
->rgbResult
);
2520 g
=GetGValue(lpp
->lpcc
->rgbResult
);
2521 b
=GetBValue(lpp
->lpcc
->rgbResult
);
2522 lpp
->h
=CC_RGBtoHSL('H',r
,g
,b
);
2523 lpp
->s
=CC_RGBtoHSL('S',r
,g
,b
);
2524 lpp
->l
=CC_RGBtoHSL('L',r
,g
,b
);
2525 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
2526 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2527 CC_PaintTriangle(hDlg
,lpp
->l
);
2530 case 0x40e: /* Help! */ /* The Beatles, 1965 ;-) */
2531 i
=RegisterWindowMessage32A( HELPMSGSTRING
);
2532 if (lpp
->lpcc
->hwndOwner
)
2533 SendMessage16(lpp
->lpcc
->hwndOwner
,i
,0,(LPARAM
)lpp
->lpcc
);
2534 if (CC_HookCallChk(lpp
->lpcc
))
2535 CallWindowProc16(lpp
->lpcc
->lpfnHook
,hDlg
,
2536 WM_COMMAND
,psh15
,(LPARAM
)lpp
->lpcc
);
2540 cokmsg
=RegisterWindowMessage32A( COLOROKSTRING
);
2541 if (lpp
->lpcc
->hwndOwner
)
2542 if (SendMessage16(lpp
->lpcc
->hwndOwner
,cokmsg
,0,(LPARAM
)lpp
->lpcc
))
2543 break; /* do NOT close */
2545 EndDialog32 (hDlg
, 1) ;
2549 EndDialog32 (hDlg
, 0) ;
2556 /***********************************************************************
2557 * CC_WMPaint [internal]
2559 static LRESULT
CC_WMPaint(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2561 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2562 /* we have to paint dialog children except text and buttons */
2564 CC_PaintPredefColorArray(hDlg
,6,8);
2565 CC_PaintUserColorArray(hDlg
,2,8,PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
));
2566 CC_PaintColorGraph(hDlg
);
2567 CC_PaintLumBar(hDlg
,lpp
->h
,lpp
->s
);
2568 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2569 CC_PaintTriangle(hDlg
,lpp
->l
);
2570 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2572 /* special necessary for Wine */
2573 ValidateRect32(GetDlgItem32(hDlg
,0x2d0),NULL
);
2574 ValidateRect32(GetDlgItem32(hDlg
,0x2d1),NULL
);
2575 ValidateRect32(GetDlgItem32(hDlg
,0x2c6),NULL
);
2576 ValidateRect32(GetDlgItem32(hDlg
,0x2be),NULL
);
2577 ValidateRect32(GetDlgItem32(hDlg
,0x2c5),NULL
);
2578 /* hope we can remove it later -->FIXME */
2583 /***********************************************************************
2584 * CC_WMLButtonDown [internal]
2586 static LRESULT
CC_WMLButtonDown(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2588 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2591 if (CC_MouseCheckPredefColorArray(hDlg
,0x2d0,6,8,lParam
,&lpp
->lpcc
->rgbResult
))
2594 if (CC_MouseCheckUserColorArray(hDlg
,0x2d1,2,8,lParam
,&lpp
->lpcc
->rgbResult
,
2595 PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
)))
2598 if (CC_MouseCheckColorGraph(hDlg
,0x2c6,&lpp
->h
,&lpp
->s
,lParam
))
2601 if (CC_MouseCheckColorGraph(hDlg
,0x2be,NULL
,&lpp
->l
,lParam
))
2605 r
=CC_HSLtoRGB('R',lpp
->h
,lpp
->s
,lpp
->l
);
2606 g
=CC_HSLtoRGB('G',lpp
->h
,lpp
->s
,lpp
->l
);
2607 b
=CC_HSLtoRGB('B',lpp
->h
,lpp
->s
,lpp
->l
);
2608 lpp
->lpcc
->rgbResult
=RGB(r
,g
,b
);
2612 r
=GetRValue(lpp
->lpcc
->rgbResult
);
2613 g
=GetGValue(lpp
->lpcc
->rgbResult
);
2614 b
=GetBValue(lpp
->lpcc
->rgbResult
);
2615 lpp
->h
=CC_RGBtoHSL('H',r
,g
,b
);
2616 lpp
->s
=CC_RGBtoHSL('S',r
,g
,b
);
2617 lpp
->l
=CC_RGBtoHSL('L',r
,g
,b
);
2621 CC_EditSetRGB(hDlg
,lpp
->lpcc
->rgbResult
);
2622 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
2623 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2624 CC_PaintTriangle(hDlg
,lpp
->l
);
2625 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2631 /***********************************************************************
2632 * ColorDlgProc (COMMDLG.8)
2634 LRESULT WINAPI
ColorDlgProc(HWND16 hDlg
, UINT16 message
,
2635 WPARAM16 wParam
, LONG lParam
)
2638 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2639 if (message
!=WM_INITDIALOG
)
2644 if (CC_HookCallChk(lpp
->lpcc
))
2645 res
=CallWindowProc16(lpp
->lpcc
->lpfnHook
,hDlg
,message
,wParam
,lParam
);
2650 /* FIXME: SetRGB message
2651 if (message && message==msetrgb)
2652 return HandleSetRGB(hDlg,lParam);
2658 return CC_WMInitDialog(hDlg
,wParam
,lParam
);
2660 DeleteDC32(lpp
->hdcMem
);
2661 DeleteObject32(lpp
->hbmMem
);
2663 SetWindowLong32A(hDlg
, DWL_USER
, 0L); /* we don't need it anymore */
2666 if (CC_WMCommand(hDlg
, wParam
, lParam
))
2670 CC_WMPaint(hDlg
, wParam
, lParam
);
2672 case WM_LBUTTONDBLCLK
:
2673 if (CC_MouseCheckResultWindow(hDlg
,lParam
))
2676 case WM_MOUSEMOVE
: /* FIXME: calculate new hue,sat,lum (if in color graph) */
2678 case WM_LBUTTONUP
: /* FIXME: ClipCursor off (if in color graph)*/
2680 case WM_LBUTTONDOWN
:/* FIXME: ClipCursor on (if in color graph)*/
2681 if (CC_WMLButtonDown(hDlg
, wParam
, lParam
))
2688 static void CFn_CHOOSEFONT16to32A(LPCHOOSEFONT16 chf16
, LPCHOOSEFONT32A chf32a
)
2690 chf32a
->lStructSize
=sizeof(CHOOSEFONT32A
);
2691 chf32a
->hwndOwner
=chf16
->hwndOwner
;
2692 chf32a
->hDC
=chf16
->hDC
;
2693 chf32a
->iPointSize
=chf16
->iPointSize
;
2694 chf32a
->Flags
=chf16
->Flags
;
2695 chf32a
->rgbColors
=chf16
->rgbColors
;
2696 chf32a
->lCustData
=chf16
->lCustData
;
2697 chf32a
->lpfnHook
=NULL
;
2698 chf32a
->lpTemplateName
=PTR_SEG_TO_LIN(chf16
->lpTemplateName
);
2699 chf32a
->hInstance
=chf16
->hInstance
;
2700 chf32a
->lpszStyle
=PTR_SEG_TO_LIN(chf16
->lpszStyle
);
2701 chf32a
->nFontType
=chf16
->nFontType
;
2702 chf32a
->nSizeMax
=chf16
->nSizeMax
;
2703 chf32a
->nSizeMin
=chf16
->nSizeMin
;
2704 FONT_LogFont16To32A(PTR_SEG_TO_LIN(chf16
->lpLogFont
), chf32a
->lpLogFont
);
2708 /***********************************************************************
2709 * ChooseFont16 (COMMDLG.15)
2711 BOOL16 WINAPI
ChooseFont16(LPCHOOSEFONT16 lpChFont
)
2714 HANDLE16 hDlgTmpl
= 0;
2715 BOOL16 bRet
= FALSE
, win32Format
= FALSE
;
2718 CHOOSEFONT32A cf32a
;
2720 SEGPTR lpTemplateName
;
2722 cf32a
.lpLogFont
=&lf32a
;
2723 CFn_CHOOSEFONT16to32A(lpChFont
, &cf32a
);
2725 TRACE(commdlg
,"ChooseFont\n");
2726 if (!lpChFont
) return FALSE
;
2728 if (lpChFont
->Flags
& CF_ENABLETEMPLATEHANDLE
)
2730 if (!(template = LockResource16( lpChFont
->hInstance
)))
2732 CommDlgLastError
= CDERR_LOADRESFAILURE
;
2736 else if (lpChFont
->Flags
& CF_ENABLETEMPLATE
)
2739 if (!(hResInfo
= FindResource16( lpChFont
->hInstance
,
2740 lpChFont
->lpTemplateName
,
2743 CommDlgLastError
= CDERR_FINDRESFAILURE
;
2746 if (!(hDlgTmpl
= LoadResource16( lpChFont
->hInstance
, hResInfo
)) ||
2747 !(template = LockResource16( hDlgTmpl
)))
2749 CommDlgLastError
= CDERR_LOADRESFAILURE
;
2755 template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT
);
2759 hInst
= WIN_GetWindowInstance( lpChFont
->hwndOwner
);
2761 /* lpTemplateName is not used in the dialog */
2762 lpTemplateName
=lpChFont
->lpTemplateName
;
2763 lpChFont
->lpTemplateName
=(SEGPTR
)&cf32a
;
2765 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, win32Format
,
2766 lpChFont
->hwndOwner
,
2767 (DLGPROC16
)MODULE_GetWndProcEntry16("FormatCharDlgProc"),
2768 (DWORD
)lpChFont
, WIN_PROC_16
);
2769 if (hwndDialog
) bRet
= DIALOG_DoDialogBox(hwndDialog
, lpChFont
->hwndOwner
);
2770 if (hDlgTmpl
) FreeResource16( hDlgTmpl
);
2771 lpChFont
->lpTemplateName
=lpTemplateName
;
2772 FONT_LogFont32ATo16(cf32a
.lpLogFont
,
2773 (LPLOGFONT16
)(PTR_SEG_TO_LIN(lpChFont
->lpLogFont
)));
2778 /***********************************************************************
2779 * ChooseFont32A (COMDLG32.3)
2781 BOOL32 WINAPI
ChooseFont32A(LPCHOOSEFONT32A lpChFont
)
2785 HINSTANCE32 hInst
=WIN_GetWindowInstance( lpChFont
->hwndOwner
);
2786 LPCVOID
template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT
);
2787 if (lpChFont
->Flags
& (CF_SELECTSCRIPT
| CF_NOVERTFONTS
| CF_ENABLETEMPLATE
|
2788 CF_ENABLETEMPLATEHANDLE
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
2789 hwndDialog
= DIALOG_CreateIndirect(hInst
, template, TRUE
, lpChFont
->hwndOwner
,
2790 (DLGPROC16
)FormatCharDlgProc32A
, (LPARAM
)lpChFont
, WIN_PROC_32A
);
2791 if (hwndDialog
) bRet
= DIALOG_DoDialogBox(hwndDialog
, lpChFont
->hwndOwner
);
2795 /***********************************************************************
2796 * ChooseFont32W (COMDLG32.4)
2798 BOOL32 WINAPI
ChooseFont32W(LPCHOOSEFONT32W lpChFont
)
2802 HINSTANCE32 hInst
=WIN_GetWindowInstance( lpChFont
->hwndOwner
);
2803 CHOOSEFONT32A cf32a
;
2805 LPCVOID
template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT
);
2806 if (lpChFont
->Flags
& (CF_SELECTSCRIPT
| CF_NOVERTFONTS
| CF_ENABLETEMPLATE
|
2807 CF_ENABLETEMPLATEHANDLE
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
2808 memcpy(&cf32a
, lpChFont
, sizeof(cf32a
));
2809 memcpy(&lf32a
, lpChFont
->lpLogFont
, sizeof(LOGFONT32A
));
2810 lstrcpynWtoA(lf32a
.lfFaceName
, lpChFont
->lpLogFont
->lfFaceName
, LF_FACESIZE
);
2811 cf32a
.lpLogFont
=&lf32a
;
2812 cf32a
.lpszStyle
=HEAP_strdupWtoA(GetProcessHeap(), 0, lpChFont
->lpszStyle
);
2813 lpChFont
->lpTemplateName
=(LPWSTR
)&cf32a
;
2814 hwndDialog
=DIALOG_CreateIndirect(hInst
, template, TRUE
, lpChFont
->hwndOwner
,
2815 (DLGPROC16
)FormatCharDlgProc32W
, (LPARAM
)lpChFont
, WIN_PROC_32W
);
2816 if (hwndDialog
)bRet
=DIALOG_DoDialogBox(hwndDialog
, lpChFont
->hwndOwner
);
2817 HeapFree(GetProcessHeap(), 0, cf32a
.lpszStyle
);
2818 lpChFont
->lpTemplateName
=(LPWSTR
)cf32a
.lpTemplateName
;
2819 memcpy(lpChFont
->lpLogFont
, &lf32a
, sizeof(CHOOSEFONT32A
));
2820 lstrcpynAtoW(lpChFont
->lpLogFont
->lfFaceName
, lf32a
.lfFaceName
, LF_FACESIZE
);
2825 #define TEXT_EXTRAS 4
2826 #define TEXT_COLORS 16
2828 static const COLORREF textcolors
[TEXT_COLORS
]=
2830 0x00000000L
,0x00000080L
,0x00008000L
,0x00008080L
,
2831 0x00800000L
,0x00800080L
,0x00808000L
,0x00808080L
,
2832 0x00c0c0c0L
,0x000000ffL
,0x0000ff00L
,0x0000ffffL
,
2833 0x00ff0000L
,0x00ff00ffL
,0x00ffff00L
,0x00FFFFFFL
2836 /***********************************************************************
2837 * CFn_HookCallChk [internal]
2839 static BOOL32
CFn_HookCallChk(LPCHOOSEFONT16 lpcf
)
2842 if(lpcf
->Flags
& CF_ENABLEHOOK
)
2848 /***********************************************************************
2849 * CFn_HookCallChk32 [internal]
2851 static BOOL32
CFn_HookCallChk32(LPCHOOSEFONT32A lpcf
)
2854 if(lpcf
->Flags
& CF_ENABLEHOOK
)
2861 /*************************************************************************
2862 * AddFontFamily [internal]
2864 static INT32
AddFontFamily(LPLOGFONT32A lplf
, UINT32 nFontType
,
2865 LPCHOOSEFONT32A lpcf
, HWND32 hwnd
)
2870 TRACE(commdlg
,"font=%s (nFontType=%d)\n", lplf
->lfFaceName
,nFontType
);
2872 if (lpcf
->Flags
& CF_FIXEDPITCHONLY
)
2873 if (!(lplf
->lfPitchAndFamily
& FIXED_PITCH
))
2875 if (lpcf
->Flags
& CF_ANSIONLY
)
2876 if (lplf
->lfCharSet
!= ANSI_CHARSET
)
2878 if (lpcf
->Flags
& CF_TTONLY
)
2879 if (!(nFontType
& TRUETYPE_FONTTYPE
))
2882 i
=SendMessage32A(hwnd
, CB_ADDSTRING32
, 0, (LPARAM
)lplf
->lfFaceName
);
2885 w
=(lplf
->lfCharSet
<< 8) | lplf
->lfPitchAndFamily
;
2886 SendMessage32A(hwnd
, CB_SETITEMDATA32
, i
, MAKELONG(nFontType
,w
));
2887 return 1 ; /* store some important font information */
2897 LPCHOOSEFONT32A lpcf32a
;
2898 } CFn_ENUMSTRUCT
, *LPCFn_ENUMSTRUCT
;
2900 /*************************************************************************
2901 * FontFamilyEnumProc32 [internal]
2903 INT32 WINAPI
FontFamilyEnumProc32(LPENUMLOGFONT32A lpEnumLogFont
,
2904 LPNEWTEXTMETRIC32A metrics
, UINT32 nFontType
, LPARAM lParam
)
2907 e
=(LPCFn_ENUMSTRUCT
)lParam
;
2908 return AddFontFamily(&lpEnumLogFont
->elfLogFont
, nFontType
, e
->lpcf32a
, e
->hWnd1
);
2911 /***********************************************************************
2912 * FontFamilyEnumProc16 (COMMDLG.19)
2914 INT16 WINAPI
FontFamilyEnumProc16( SEGPTR logfont
, SEGPTR metrics
,
2915 UINT16 nFontType
, LPARAM lParam
)
2917 HWND16 hwnd
=LOWORD(lParam
);
2918 HWND16 hDlg
=GetParent16(hwnd
);
2919 LPCHOOSEFONT16 lpcf
=(LPCHOOSEFONT16
)GetWindowLong32A(hDlg
, DWL_USER
);
2920 LOGFONT16
*lplf
= (LOGFONT16
*)PTR_SEG_TO_LIN( logfont
);
2922 FONT_LogFont16To32A(lplf
, &lf32a
);
2923 return AddFontFamily(&lf32a
, nFontType
, (LPCHOOSEFONT32A
)lpcf
->lpTemplateName
,
2927 /*************************************************************************
2928 * SetFontStylesToCombo2 [internal]
2930 * Fill font style information into combobox (without using font.c directly)
2932 static int SetFontStylesToCombo2(HWND32 hwnd
, HDC32 hdc
, LPLOGFONT32A lplf
)
2939 static struct FONTSTYLE fontstyles
[FSTYLES
]={
2940 { 0,FW_NORMAL
,"Regular"},{0,FW_BOLD
,"Bold"},
2941 { 1,FW_NORMAL
,"Italic"}, {1,FW_BOLD
,"Bold Italic"}};
2946 for (i
=0;i
<FSTYLES
;i
++)
2948 lplf
->lfItalic
=fontstyles
[i
].italic
;
2949 lplf
->lfWeight
=fontstyles
[i
].weight
;
2950 hf
=CreateFontIndirect32A(lplf
);
2951 hf
=SelectObject32(hdc
,hf
);
2952 GetTextMetrics16(hdc
,&tm
);
2953 hf
=SelectObject32(hdc
,hf
);
2956 if (tm
.tmWeight
==fontstyles
[i
].weight
&&
2957 tm
.tmItalic
==fontstyles
[i
].italic
) /* font successful created ? */
2959 char *str
= SEGPTR_STRDUP(fontstyles
[i
].stname
);
2960 j
=SendMessage16(hwnd
,CB_ADDSTRING16
,0,(LPARAM
)SEGPTR_GET(str
) );
2962 if (j
==CB_ERR
) return 1;
2963 j
=SendMessage16(hwnd
, CB_SETITEMDATA16
, j
,
2964 MAKELONG(fontstyles
[i
].weight
,fontstyles
[i
].italic
));
2965 if (j
==CB_ERR
) return 1;
2971 /*************************************************************************
2972 * AddFontSizeToCombo3 [internal]
2974 static int AddFontSizeToCombo3(HWND32 hwnd
, UINT32 h
, LPCHOOSEFONT32A lpcf
)
2979 if ( (!(lpcf
->Flags
& CF_LIMITSIZE
)) ||
2980 ((lpcf
->Flags
& CF_LIMITSIZE
) && (h
>= lpcf
->nSizeMin
) && (h
<= lpcf
->nSizeMax
)))
2982 sprintf(buffer
, "%2d", h
);
2983 j
=SendMessage32A(hwnd
, CB_FINDSTRINGEXACT32
, -1, (LPARAM
)buffer
);
2986 j
=SendMessage32A(hwnd
, CB_ADDSTRING32
, 0, (LPARAM
)buffer
);
2987 if (j
!=CB_ERR
) j
= SendMessage32A(hwnd
, CB_SETITEMDATA32
, j
, h
);
2988 if (j
==CB_ERR
) return 1;
2994 /*************************************************************************
2995 * SetFontSizesToCombo3 [internal]
2997 static int SetFontSizesToCombo3(HWND32 hwnd
, LPCHOOSEFONT32A lpcf
)
2999 static const int sizes
[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72,0};
3002 for (i
=0; sizes
[i
]; i
++)
3003 if (AddFontSizeToCombo3(hwnd
, sizes
[i
], lpcf
)) return 1;
3007 /***********************************************************************
3008 * AddFontStyle [internal]
3010 INT32
AddFontStyle(LPLOGFONT32A lplf
, UINT32 nFontType
,
3011 LPCHOOSEFONT32A lpcf
, HWND32 hcmb2
, HWND32 hcmb3
, HWND32 hDlg
)
3015 TRACE(commdlg
,"(nFontType=%d)\n",nFontType
);
3016 TRACE(commdlg
," %s h=%d w=%d e=%d o=%d wg=%d i=%d u=%d s=%d"
3017 " ch=%d op=%d cp=%d q=%d pf=%xh\n",
3018 lplf
->lfFaceName
,lplf
->lfHeight
,lplf
->lfWidth
,
3019 lplf
->lfEscapement
,lplf
->lfOrientation
,
3020 lplf
->lfWeight
,lplf
->lfItalic
,lplf
->lfUnderline
,
3021 lplf
->lfStrikeOut
,lplf
->lfCharSet
, lplf
->lfOutPrecision
,
3022 lplf
->lfClipPrecision
,lplf
->lfQuality
, lplf
->lfPitchAndFamily
);
3023 if (nFontType
& RASTER_FONTTYPE
)
3025 if (AddFontSizeToCombo3(hcmb3
, lplf
->lfHeight
, lpcf
)) return 0;
3026 } else if (SetFontSizesToCombo3(hcmb3
, lpcf
)) return 0;
3028 if (!SendMessage32A(hcmb2
, CB_GETCOUNT32
, 0, 0))
3030 HDC32 hdc
= (lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
) ? lpcf
->hDC
: GetDC32(hDlg
);
3031 i
=SetFontStylesToCombo2(hcmb2
,hdc
,lplf
);
3032 if (!(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
))
3033 ReleaseDC32(hDlg
,hdc
);
3041 /***********************************************************************
3042 * FontStyleEnumProc16 (COMMDLG.18)
3044 INT16 WINAPI
FontStyleEnumProc16( SEGPTR logfont
, SEGPTR metrics
,
3045 UINT16 nFontType
, LPARAM lParam
)
3047 HWND16 hcmb2
=LOWORD(lParam
);
3048 HWND16 hcmb3
=HIWORD(lParam
);
3049 HWND16 hDlg
=GetParent16(hcmb3
);
3050 LPCHOOSEFONT16 lpcf
=(LPCHOOSEFONT16
)GetWindowLong32A(hDlg
, DWL_USER
);
3051 LOGFONT16
*lplf
= (LOGFONT16
*)PTR_SEG_TO_LIN(logfont
);
3053 FONT_LogFont16To32A(lplf
, &lf32a
);
3054 return AddFontStyle(&lf32a
, nFontType
, (LPCHOOSEFONT32A
)lpcf
->lpTemplateName
,
3055 hcmb2
, hcmb3
, hDlg
);
3058 /***********************************************************************
3059 * FontStyleEnumProc32 [internal]
3061 INT32 WINAPI
FontStyleEnumProc32( LPENUMLOGFONT32A lpFont
,
3062 LPNEWTEXTMETRIC32A metrics
, UINT32 nFontType
, LPARAM lParam
)
3064 LPCFn_ENUMSTRUCT s
=(LPCFn_ENUMSTRUCT
)lParam
;
3065 HWND32 hcmb2
=s
->hWnd1
;
3066 HWND32 hcmb3
=s
->hWnd2
;
3067 HWND32 hDlg
=GetParent32(hcmb3
);
3068 return AddFontStyle(&lpFont
->elfLogFont
, nFontType
, s
->lpcf32a
, hcmb2
,
3072 /***********************************************************************
3073 * CFn_WMInitDialog [internal]
3075 LRESULT
CFn_WMInitDialog(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
,
3076 LPCHOOSEFONT32A lpcf
)
3082 HCURSOR32 hcursor
=SetCursor32(LoadCursor32A(0,IDC_WAIT32A
));
3084 SetWindowLong32A(hDlg
, DWL_USER
, lParam
);
3085 lpxx
=lpcf
->lpLogFont
;
3086 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
3088 if (lpcf
->lStructSize
!= sizeof(CHOOSEFONT32A
))
3090 ERR(commdlg
,"structure size failure !!!\n");
3091 EndDialog32 (hDlg
, 0);
3095 hBitmapTT
= LoadBitmap32A(0, MAKEINTRESOURCE32A(OBM_TRTYPE
));
3097 /* This font will be deleted by WM_COMMAND */
3098 SendDlgItemMessage32A(hDlg
,stc6
,WM_SETFONT
,
3099 CreateFont32A(0, 0, 1, 1, 400, 0, 0, 0, 0, 0, 0, 0, 0, NULL
),FALSE
);
3101 if (!(lpcf
->Flags
& CF_SHOWHELP
) || !IsWindow32(lpcf
->hwndOwner
))
3102 ShowWindow32(GetDlgItem32(hDlg
,pshHelp
),SW_HIDE
);
3103 if (!(lpcf
->Flags
& CF_APPLY
))
3104 ShowWindow32(GetDlgItem32(hDlg
,psh3
),SW_HIDE
);
3105 if (lpcf
->Flags
& CF_EFFECTS
)
3107 for (res
=1,i
=0;res
&& i
<TEXT_COLORS
;i
++)
3109 /* FIXME: load color name from resource: res=LoadString(...,i+....,buffer,.....); */
3111 strcpy( name
, "[color name]" );
3112 j
=SendDlgItemMessage32A(hDlg
, cmb4
, CB_ADDSTRING32
, 0, (LPARAM
)name
);
3113 SendDlgItemMessage32A(hDlg
, cmb4
, CB_SETITEMDATA16
, j
, textcolors
[j
]);
3114 /* look for a fitting value in color combobox */
3115 if (textcolors
[j
]==lpcf
->rgbColors
)
3116 SendDlgItemMessage32A(hDlg
,cmb4
, CB_SETCURSEL32
,j
,0);
3121 ShowWindow32(GetDlgItem32(hDlg
,cmb4
),SW_HIDE
);
3122 ShowWindow32(GetDlgItem32(hDlg
,chx1
),SW_HIDE
);
3123 ShowWindow32(GetDlgItem32(hDlg
,chx2
),SW_HIDE
);
3124 ShowWindow32(GetDlgItem32(hDlg
,grp1
),SW_HIDE
);
3125 ShowWindow32(GetDlgItem32(hDlg
,stc4
),SW_HIDE
);
3127 hdc
= (lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
) ? lpcf
->hDC
: GetDC32(hDlg
);
3131 s
.hWnd1
=GetDlgItem32(hDlg
,cmb1
);
3133 if (!EnumFontFamilies32A(hdc
, NULL
, FontFamilyEnumProc32
, (LPARAM
)&s
))
3134 TRACE(commdlg
,"EnumFontFamilies returns 0\n");
3135 if (lpcf
->Flags
& CF_INITTOLOGFONTSTRUCT
)
3137 /* look for fitting font name in combobox1 */
3138 j
=SendDlgItemMessage32A(hDlg
,cmb1
,CB_FINDSTRING32
,-1,(LONG
)lpxx
->lfFaceName
);
3141 SendDlgItemMessage32A(hDlg
, cmb1
, CB_SETCURSEL32
, j
, 0);
3142 SendMessage32A(hDlg
, WM_COMMAND
, MAKEWPARAM(cmb1
, CBN_SELCHANGE
),
3143 GetDlgItem32(hDlg
,cmb1
));
3145 /* look for fitting font style in combobox2 */
3146 l
=MAKELONG(lpxx
->lfWeight
> FW_MEDIUM
? FW_BOLD
:FW_NORMAL
,lpxx
->lfItalic
!=0);
3147 for (i
=0;i
<TEXT_EXTRAS
;i
++)
3149 if (l
==SendDlgItemMessage32A(hDlg
, cmb2
, CB_GETITEMDATA32
, i
, 0))
3150 SendDlgItemMessage32A(hDlg
, cmb2
, CB_SETCURSEL32
, i
, 0);
3153 /* look for fitting font size in combobox3 */
3154 j
=SendDlgItemMessage32A(hDlg
, cmb3
, CB_GETCOUNT32
, 0, 0);
3157 if (lpxx
->lfHeight
==(int)SendDlgItemMessage32A(hDlg
,cmb3
, CB_GETITEMDATA32
,i
,0))
3158 SendDlgItemMessage32A(hDlg
,cmb3
,CB_SETCURSEL32
,i
,0);
3164 SendDlgItemMessage32A(hDlg
,cmb1
,CB_SETCURSEL32
,0,0);
3165 SendMessage32A(hDlg
, WM_COMMAND
, MAKEWPARAM(cmb1
, CBN_SELCHANGE
),
3166 GetDlgItem32(hDlg
,cmb1
));
3168 if (lpcf
->Flags
& CF_USESTYLE
&& lpcf
->lpszStyle
)
3170 j
=SendDlgItemMessage32A(hDlg
,cmb2
,CB_FINDSTRING32
,-1,(LONG
)lpcf
->lpszStyle
);
3173 j
=SendDlgItemMessage32A(hDlg
,cmb2
,CB_SETCURSEL32
,j
,0);
3174 SendMessage32A(hDlg
,WM_COMMAND
,cmb2
,
3175 MAKELONG(GetDlgItem32(hDlg
,cmb2
),CBN_SELCHANGE
));
3181 WARN(commdlg
,"HDC failure !!!\n");
3182 EndDialog32 (hDlg
, 0);
3186 if (!(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
))
3187 ReleaseDC32(hDlg
,hdc
);
3188 SetCursor32(hcursor
);
3193 /***********************************************************************
3194 * CFn_WMMeasureItem [internal]
3196 LRESULT
CFn_WMMeasureItem(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
)
3199 LPMEASUREITEMSTRUCT32 lpmi
=(LPMEASUREITEMSTRUCT32
)lParam
;
3201 hBitmapTT
= LoadBitmap32A(0, MAKEINTRESOURCE32A(OBM_TRTYPE
));
3202 GetObject32A( hBitmapTT
, sizeof(bm
), &bm
);
3203 lpmi
->itemHeight
=bm
.bmHeight
;
3204 /* FIXME: use MAX of bm.bmHeight and tm.tmHeight .*/
3209 /***********************************************************************
3210 * CFn_WMDrawItem [internal]
3212 LRESULT
CFn_WMDrawItem(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
)
3217 COLORREF cr
, oldText
=0, oldBk
=0;
3222 HBITMAP32 hBitmap
; /* for later TT usage */
3224 LPDRAWITEMSTRUCT32 lpdi
= (LPDRAWITEMSTRUCT32
)lParam
;
3226 if (lpdi
->itemID
== 0xFFFF) /* got no items */
3227 DrawFocusRect32(lpdi
->hDC
, &lpdi
->rcItem
);
3230 if (lpdi
->CtlType
== ODT_COMBOBOX
)
3232 if (lpdi
->itemState
==ODS_SELECTED
)
3234 hBrush
=GetSysColorBrush32(COLOR_HIGHLIGHT
);
3235 oldText
=SetTextColor32(lpdi
->hDC
, GetSysColor32(COLOR_HIGHLIGHTTEXT
));
3236 oldBk
=SetBkColor32(lpdi
->hDC
, GetSysColor32(COLOR_HIGHLIGHT
));
3239 hBrush
= SelectObject32(lpdi
->hDC
, GetStockObject32(LTGRAY_BRUSH
));
3240 SelectObject32(lpdi
->hDC
, hBrush
);
3242 FillRect32(lpdi
->hDC
, &lpdi
->rcItem
, hBrush
);
3245 return TRUE
; /* this should never happen */
3248 switch (lpdi
->CtlID
)
3250 case cmb1
: /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
3251 SendMessage32A(lpdi
->hwndItem
, CB_GETLBTEXT32
, lpdi
->itemID
,
3253 GetObject32A( hBitmapTT
, sizeof(bm
), &bm
);
3254 TextOut32A(lpdi
->hDC
, lpdi
->rcItem
.left
+ bm
.bmWidth
+ 10,
3255 lpdi
->rcItem
.top
, buffer
, lstrlen32A(buffer
));
3257 nFontType
= SendMessage32A(lpdi
->hwndItem
, CB_GETITEMDATA32
, lpdi
->itemID
,0L);
3258 /* FIXME: draw bitmap if truetype usage */
3259 if (nFontType
&TRUETYPE_FONTTYPE
)
3261 hMemDC
= CreateCompatibleDC32(lpdi
->hDC
);
3262 hBitmap
= SelectObject32(hMemDC
, hBitmapTT
);
3263 BitBlt32(lpdi
->hDC
, lpdi
->rcItem
.left
, lpdi
->rcItem
.top
,
3264 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
3265 SelectObject32(hMemDC
, hBitmap
);
3271 case cmb3
: /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
3272 SendMessage32A(lpdi
->hwndItem
, CB_GETLBTEXT32
, lpdi
->itemID
,
3274 TextOut32A(lpdi
->hDC
, lpdi
->rcItem
.left
,
3275 lpdi
->rcItem
.top
, buffer
, lstrlen32A(buffer
));
3278 case cmb4
: /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
3279 SendMessage32A(lpdi
->hwndItem
, CB_GETLBTEXT32
, lpdi
->itemID
,
3281 TextOut32A(lpdi
->hDC
, lpdi
->rcItem
.left
+ 25+5,
3282 lpdi
->rcItem
.top
, buffer
, lstrlen32A(buffer
));
3283 cr
= SendMessage32A(lpdi
->hwndItem
, CB_GETITEMDATA32
, lpdi
->itemID
,0L);
3284 hBrush
= CreateSolidBrush32(cr
);
3287 hBrush
= SelectObject32 (lpdi
->hDC
, hBrush
) ;
3288 rect
.right
=rect
.left
+25;
3292 Rectangle32( lpdi
->hDC
, rect
.left
, rect
.top
,
3293 rect
.right
, rect
.bottom
);
3294 DeleteObject32( SelectObject32 (lpdi
->hDC
, hBrush
)) ;
3300 default: return TRUE
; /* this should never happen */
3302 if (lpdi
->itemState
== ODS_SELECTED
)
3304 SetTextColor32(lpdi
->hDC
, oldText
);
3305 SetBkColor32(lpdi
->hDC
, oldBk
);
3311 /***********************************************************************
3312 * CFn_WMCtlColor [internal]
3314 LRESULT
CFn_WMCtlColorStatic(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
,
3315 LPCHOOSEFONT32A lpcf
)
3317 if (lpcf
->Flags
& CF_EFFECTS
)
3318 if (GetDlgCtrlID32(lParam
)==stc6
)
3320 SetTextColor32((HDC32
)wParam
, lpcf
->rgbColors
);
3321 return GetStockObject32(WHITE_BRUSH
);
3326 /***********************************************************************
3327 * CFn_WMCommand [internal]
3329 LRESULT
CFn_WMCommand(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
,
3330 LPCHOOSEFONT32A lpcf
)
3336 LPLOGFONT32A lpxx
=lpcf
->lpLogFont
;
3338 TRACE(commdlg
,"WM_COMMAND wParam=%08lX lParam=%08lX\n", (LONG
)wParam
, lParam
);
3339 switch (LOWORD(wParam
))
3341 case cmb1
:if (HIWORD(wParam
)==CBN_SELCHANGE
)
3343 hdc
=(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
) ? lpcf
->hDC
: GetDC32(hDlg
);
3346 SendDlgItemMessage32A(hDlg
, cmb2
, CB_RESETCONTENT16
, 0, 0);
3347 SendDlgItemMessage32A(hDlg
, cmb3
, CB_RESETCONTENT16
, 0, 0);
3348 i
=SendDlgItemMessage32A(hDlg
, cmb1
, CB_GETCURSEL16
, 0, 0);
3351 HCURSOR32 hcursor
=SetCursor32(LoadCursor32A(0,IDC_WAIT32A
));
3354 SendDlgItemMessage32A(hDlg
, cmb1
, CB_GETLBTEXT32
, i
,
3356 TRACE(commdlg
,"WM_COMMAND/cmb1 =>%s\n",str
);
3357 s
.hWnd1
=GetDlgItem32(hDlg
, cmb2
);
3358 s
.hWnd2
=GetDlgItem32(hDlg
, cmb3
);
3360 EnumFontFamilies32A(hdc
, str
, FontStyleEnumProc32
, (LPARAM
)&s
);
3361 SetCursor32(hcursor
);
3363 if (!(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
))
3364 ReleaseDC32(hDlg
,hdc
);
3368 WARN(commdlg
,"HDC failure !!!\n");
3369 EndDialog32 (hDlg
, 0);
3376 case cmb3
:if (HIWORD(wParam
)==CBN_SELCHANGE
|| HIWORD(wParam
)== BN_CLICKED
)
3379 TRACE(commdlg
,"WM_COMMAND/cmb2,3 =%08lX\n", lParam
);
3380 i
=SendDlgItemMessage32A(hDlg
,cmb1
,CB_GETCURSEL32
,0,0);
3382 i
=GetDlgItemText32A( hDlg
, cmb1
, str
, 256 );
3385 SendDlgItemMessage32A(hDlg
,cmb1
,CB_GETLBTEXT32
,i
,
3387 l
=SendDlgItemMessage32A(hDlg
,cmb1
,CB_GETITEMDATA32
,i
,0);
3389 lpcf
->nFontType
= LOWORD(l
);
3390 /* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */
3391 /* same value reported to the EnumFonts
3392 call back with the extra FONTTYPE_... bits added */
3393 lpxx
->lfPitchAndFamily
=j
&0xff;
3394 lpxx
->lfCharSet
=j
>>8;
3396 strcpy(lpxx
->lfFaceName
,str
);
3397 i
=SendDlgItemMessage32A(hDlg
, cmb2
, CB_GETCURSEL32
, 0, 0);
3400 l
=SendDlgItemMessage32A(hDlg
, cmb2
, CB_GETITEMDATA32
, i
, 0);
3401 if (0!=(lpxx
->lfItalic
=HIWORD(l
)))
3402 lpcf
->nFontType
|= ITALIC_FONTTYPE
;
3403 if ((lpxx
->lfWeight
=LOWORD(l
)) > FW_MEDIUM
)
3404 lpcf
->nFontType
|= BOLD_FONTTYPE
;
3406 i
=SendDlgItemMessage32A(hDlg
, cmb3
, CB_GETCURSEL32
, 0, 0);
3408 lpxx
->lfHeight
=-LOWORD(SendDlgItemMessage32A(hDlg
, cmb3
, CB_GETITEMDATA32
, i
, 0));
3411 lpxx
->lfStrikeOut
=IsDlgButtonChecked32(hDlg
,chx1
);
3412 lpxx
->lfUnderline
=IsDlgButtonChecked32(hDlg
,chx2
);
3413 lpxx
->lfWidth
=lpxx
->lfOrientation
=lpxx
->lfEscapement
=0;
3414 lpxx
->lfOutPrecision
=OUT_DEFAULT_PRECIS
;
3415 lpxx
->lfClipPrecision
=CLIP_DEFAULT_PRECIS
;
3416 lpxx
->lfQuality
=DEFAULT_QUALITY
;
3417 lpcf
->iPointSize
= -10*lpxx
->lfHeight
;
3419 hFont
=CreateFontIndirect32A(lpxx
);
3422 HFONT32 oldFont
=SendDlgItemMessage32A(hDlg
, stc6
,
3424 SendDlgItemMessage32A(hDlg
,stc6
,WM_SETFONT
,hFont
,TRUE
);
3425 DeleteObject32(oldFont
);
3430 case cmb4
:i
=SendDlgItemMessage32A(hDlg
, cmb4
, CB_GETCURSEL32
, 0, 0);
3433 lpcf
->rgbColors
=textcolors
[i
];
3434 InvalidateRect32( GetDlgItem32(hDlg
,stc6
), NULL
, 0 );
3438 case psh15
:i
=RegisterWindowMessage32A( HELPMSGSTRING
);
3439 if (lpcf
->hwndOwner
)
3440 SendMessage32A(lpcf
->hwndOwner
, i
, 0, (LPARAM
)GetWindowLong32A(hDlg
, DWL_USER
));
3441 /* if (CFn_HookCallChk(lpcf))
3442 CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/
3445 case IDOK
:if ( (!(lpcf
->Flags
& CF_LIMITSIZE
)) ||
3446 ( (lpcf
->Flags
& CF_LIMITSIZE
) &&
3447 (-lpxx
->lfHeight
>= lpcf
->nSizeMin
) &&
3448 (-lpxx
->lfHeight
<= lpcf
->nSizeMax
)))
3449 EndDialog32(hDlg
, TRUE
);
3453 sprintf(buffer
,"Select a font size between %d and %d points.",
3454 lpcf
->nSizeMin
,lpcf
->nSizeMax
);
3455 MessageBox32A(hDlg
, buffer
, NULL
, MB_OK
);
3458 case IDCANCEL
:EndDialog32(hDlg
, FALSE
);
3464 static LRESULT
CFn_WMDestroy(HWND32 hwnd
, WPARAM32 wParam
, LPARAM lParam
)
3466 DeleteObject32(SendDlgItemMessage32A(hwnd
, stc6
, WM_GETFONT
, 0, 0));
3471 /***********************************************************************
3472 * FormatCharDlgProc16 (COMMDLG.16)
3473 FIXME: 1. some strings are "hardcoded", but it's better load from sysres
3474 2. some CF_.. flags are not supported
3475 3. some TType extensions
3477 LRESULT WINAPI
FormatCharDlgProc16(HWND16 hDlg
, UINT16 message
, WPARAM16 wParam
,
3480 LPCHOOSEFONT16 lpcf
;
3481 LPCHOOSEFONT32A lpcf32a
;
3485 if (message
!=WM_INITDIALOG
)
3487 lpcf
=(LPCHOOSEFONT16
)GetWindowLong32A(hDlg
, DWL_USER
);
3490 if (CFn_HookCallChk(lpcf
))
3491 res
=CallWindowProc16(lpcf
->lpfnHook
,hDlg
,message
,wParam
,lParam
);
3497 lpcf
=(LPCHOOSEFONT16
)lParam
;
3498 lpcf32a
=(LPCHOOSEFONT32A
)lpcf
->lpTemplateName
;
3499 if (!CFn_WMInitDialog(hDlg
, wParam
, lParam
, lpcf32a
))
3501 TRACE(commdlg
, "CFn_WMInitDialog returned FALSE\n");
3504 if (CFn_HookCallChk(lpcf
))
3505 return CallWindowProc16(lpcf
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
3507 WINPROC_MapMsg16To32A(message
, wParam
, &uMsg32
, &wParam32
, &lParam
);
3508 lpcf32a
=(LPCHOOSEFONT32A
)lpcf
->lpTemplateName
;
3511 case WM_MEASUREITEM
:
3512 res
=CFn_WMMeasureItem(hDlg
, wParam32
, lParam
);
3515 res
=CFn_WMDrawItem(hDlg
, wParam32
, lParam
);
3517 case WM_CTLCOLORSTATIC
:
3518 res
=CFn_WMCtlColorStatic(hDlg
, wParam32
, lParam
, lpcf32a
);
3521 res
=CFn_WMCommand(hDlg
, wParam32
, lParam
, lpcf32a
);
3524 res
=CFn_WMDestroy(hDlg
, wParam32
, lParam
);
3526 case WM_CHOOSEFONT_GETLOGFONT
:
3527 TRACE(commdlg
,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3529 FIXME(commdlg
, "current logfont back to caller\n");
3532 WINPROC_UnmapMsg16To32A(uMsg32
, wParam32
, lParam
, res
);
3536 /***********************************************************************
3537 * FormatCharDlgProc32A [internal]
3539 LRESULT WINAPI
FormatCharDlgProc32A(HWND32 hDlg
, UINT32 uMsg
, WPARAM32 wParam
,
3542 LPCHOOSEFONT32A lpcf
;
3544 if (uMsg
!=WM_INITDIALOG
)
3546 lpcf
=(LPCHOOSEFONT32A
)GetWindowLong32A(hDlg
, DWL_USER
);
3549 if (CFn_HookCallChk32(lpcf
))
3550 res
=CallWindowProc32A(lpcf
->lpfnHook
, hDlg
, uMsg
, wParam
, lParam
);
3556 lpcf
=(LPCHOOSEFONT32A
)lParam
;
3557 if (!CFn_WMInitDialog(hDlg
, wParam
, lParam
, lpcf
))
3559 TRACE(commdlg
, "CFn_WMInitDialog returned FALSE\n");
3562 if (CFn_HookCallChk32(lpcf
))
3563 return CallWindowProc32A(lpcf
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
3567 case WM_MEASUREITEM
:
3568 return CFn_WMMeasureItem(hDlg
, wParam
, lParam
);
3570 return CFn_WMDrawItem(hDlg
, wParam
, lParam
);
3571 case WM_CTLCOLORSTATIC
:
3572 return CFn_WMCtlColorStatic(hDlg
, wParam
, lParam
, lpcf
);
3574 return CFn_WMCommand(hDlg
, wParam
, lParam
, lpcf
);
3576 return CFn_WMDestroy(hDlg
, wParam
, lParam
);
3577 case WM_CHOOSEFONT_GETLOGFONT
:
3578 TRACE(commdlg
,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3580 FIXME(commdlg
, "current logfont back to caller\n");
3586 /***********************************************************************
3587 * FormatCharDlgProc32W [internal]
3589 LRESULT WINAPI
FormatCharDlgProc32W(HWND32 hDlg
, UINT32 uMsg
, WPARAM32 wParam
,
3592 LPCHOOSEFONT32W lpcf32w
;
3593 LPCHOOSEFONT32A lpcf32a
;
3595 if (uMsg
!=WM_INITDIALOG
)
3597 lpcf32w
=(LPCHOOSEFONT32W
)GetWindowLong32A(hDlg
, DWL_USER
);
3600 if (CFn_HookCallChk32((LPCHOOSEFONT32A
)lpcf32w
))
3601 res
=CallWindowProc32W(lpcf32w
->lpfnHook
, hDlg
, uMsg
, wParam
, lParam
);
3607 lpcf32w
=(LPCHOOSEFONT32W
)lParam
;
3608 lpcf32a
=(LPCHOOSEFONT32A
)lpcf32w
->lpTemplateName
;
3609 if (!CFn_WMInitDialog(hDlg
, wParam
, lParam
, lpcf32a
))
3611 TRACE(commdlg
, "CFn_WMInitDialog returned FALSE\n");
3614 if (CFn_HookCallChk32((LPCHOOSEFONT32A
)lpcf32w
))
3615 return CallWindowProc32W(lpcf32w
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
3617 lpcf32a
=(LPCHOOSEFONT32A
)lpcf32w
->lpTemplateName
;
3620 case WM_MEASUREITEM
:
3621 return CFn_WMMeasureItem(hDlg
, wParam
, lParam
);
3623 return CFn_WMDrawItem(hDlg
, wParam
, lParam
);
3624 case WM_CTLCOLORSTATIC
:
3625 return CFn_WMCtlColorStatic(hDlg
, wParam
, lParam
, lpcf32a
);
3627 return CFn_WMCommand(hDlg
, wParam
, lParam
, lpcf32a
);
3629 return CFn_WMDestroy(hDlg
, wParam
, lParam
);
3630 case WM_CHOOSEFONT_GETLOGFONT
:
3631 TRACE(commdlg
,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3633 FIXME(commdlg
, "current logfont back to caller\n");
3640 static BOOL32
Commdlg_GetFileName32A( BOOL16 (CALLBACK
*dofunction
)(SEGPTR x
),
3641 LPOPENFILENAME32A ofn
)
3644 LPOPENFILENAME16 ofn16
= SEGPTR_ALLOC(sizeof(OPENFILENAME16
));
3646 memset(ofn16
,'\0',sizeof(*ofn16
));
3647 ofn16
->lStructSize
= sizeof(*ofn16
);
3648 ofn16
->hwndOwner
= ofn
->hwndOwner
;
3649 /* FIXME: OPENFILENAME16 got only 16 bit for HINSTANCE... */
3650 ofn16
->hInstance
= 0;
3651 if (ofn
->lpstrFilter
) {
3654 /* filter is a list... title\0ext\0......\0\0 */
3655 s
= (LPSTR
)ofn
->lpstrFilter
;
3659 x
= (LPSTR
)SEGPTR_ALLOC(s
-ofn
->lpstrFilter
);
3660 memcpy(x
,ofn
->lpstrFilter
,s
-ofn
->lpstrFilter
);
3661 ofn16
->lpstrFilter
= SEGPTR_GET(x
);
3663 if (ofn
->lpstrCustomFilter
) {
3666 /* filter is a list... title\0ext\0......\0\0 */
3667 s
= (LPSTR
)ofn
->lpstrCustomFilter
;
3671 x
= SEGPTR_ALLOC(s
-ofn
->lpstrCustomFilter
);
3672 memcpy(x
,ofn
->lpstrCustomFilter
,s
-ofn
->lpstrCustomFilter
);
3673 ofn16
->lpstrCustomFilter
= SEGPTR_GET(x
);
3675 ofn16
->nMaxCustFilter
= ofn
->nMaxCustFilter
;
3676 ofn16
->nFilterIndex
= ofn
->nFilterIndex
;
3678 ofn16
->lpstrFile
= SEGPTR_GET(SEGPTR_ALLOC(ofn
->nMaxFile
));
3679 ofn16
->nMaxFile
= ofn
->nMaxFile
;
3680 ofn16
->nMaxFileTitle
= ofn
->nMaxFileTitle
;
3681 if (ofn16
->nMaxFileTitle
)
3682 ofn16
->lpstrFileTitle
= SEGPTR_GET(SEGPTR_ALLOC(ofn
->nMaxFileTitle
));
3683 if (ofn
->lpstrInitialDir
)
3684 ofn16
->lpstrInitialDir
= SEGPTR_GET(SEGPTR_STRDUP(ofn
->lpstrInitialDir
));
3685 if (ofn
->lpstrTitle
)
3686 ofn16
->lpstrTitle
= SEGPTR_GET(SEGPTR_STRDUP(ofn
->lpstrTitle
));
3687 ofn16
->Flags
= ofn
->Flags
|OFN_WINE32
;
3688 ofn16
->nFileOffset
= ofn
->nFileOffset
;
3689 ofn16
->nFileExtension
= ofn
->nFileExtension
;
3690 if (ofn
->lpstrDefExt
)
3691 ofn16
->lpstrDefExt
= SEGPTR_GET(SEGPTR_STRDUP(ofn
->lpstrDefExt
));
3692 ofn16
->lCustData
= ofn
->lCustData
;
3693 ofn16
->lpfnHook
= (WNDPROC16
)ofn
->lpfnHook
;
3695 if (ofn
->lpTemplateName
)
3696 ofn16
->lpTemplateName
= SEGPTR_GET(SEGPTR_STRDUP(ofn
->lpTemplateName
));
3698 ret
= dofunction(SEGPTR_GET(ofn16
));
3700 ofn
->nFileOffset
= ofn16
->nFileOffset
;
3701 ofn
->nFileExtension
= ofn16
->nFileExtension
;
3702 if (ofn16
->lpstrFilter
)
3703 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFilter
));
3704 if (ofn16
->lpTemplateName
)
3705 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpTemplateName
));
3706 if (ofn16
->lpstrDefExt
)
3707 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrDefExt
));
3708 if (ofn16
->lpstrTitle
)
3709 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrTitle
));
3710 if (ofn16
->lpstrInitialDir
)
3711 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrInitialDir
));
3712 if (ofn16
->lpstrCustomFilter
)
3713 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrCustomFilter
));
3715 if (ofn16
->lpstrFile
)
3717 strcpy(ofn
->lpstrFile
,PTR_SEG_TO_LIN(ofn16
->lpstrFile
));
3718 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFile
));
3721 if (ofn16
->lpstrFileTitle
)
3723 strcpy(ofn
->lpstrFileTitle
,PTR_SEG_TO_LIN(ofn16
->lpstrFileTitle
));
3724 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFileTitle
));
3730 static BOOL32
Commdlg_GetFileName32W( BOOL16 (CALLBACK
*dofunction
)(SEGPTR x
),
3731 LPOPENFILENAME32W ofn
)
3734 LPOPENFILENAME16 ofn16
= SEGPTR_ALLOC(sizeof(OPENFILENAME16
));
3736 memset(ofn16
,'\0',sizeof(*ofn16
));
3737 ofn16
->lStructSize
= sizeof(*ofn16
);
3738 ofn16
->hwndOwner
= ofn
->hwndOwner
;
3739 /* FIXME: OPENFILENAME16 got only 16 bit for HINSTANCE... */
3740 ofn16
->hInstance
= 0;
3741 if (ofn
->lpstrFilter
) {
3746 /* filter is a list... title\0ext\0......\0\0 */
3747 s
= (LPWSTR
)ofn
->lpstrFilter
;
3749 s
= s
+lstrlen32W(s
)+1;
3751 n
= s
- ofn
->lpstrFilter
; /* already divides by 2. ptr magic */
3752 x
= y
= (LPSTR
)SEGPTR_ALLOC(n
);
3753 s
= (LPWSTR
)ofn
->lpstrFilter
;
3760 ofn16
->lpstrFilter
= SEGPTR_GET(y
);
3762 if (ofn
->lpstrCustomFilter
) {
3767 /* filter is a list... title\0ext\0......\0\0 */
3768 s
= (LPWSTR
)ofn
->lpstrCustomFilter
;
3770 s
= s
+lstrlen32W(s
)+1;
3772 n
= s
- ofn
->lpstrCustomFilter
;
3773 x
= y
= (LPSTR
)SEGPTR_ALLOC(n
);
3774 s
= (LPWSTR
)ofn
->lpstrCustomFilter
;
3781 ofn16
->lpstrCustomFilter
= SEGPTR_GET(y
);
3783 ofn16
->nMaxCustFilter
= ofn
->nMaxCustFilter
;
3784 ofn16
->nFilterIndex
= ofn
->nFilterIndex
;
3786 ofn16
->lpstrFile
= SEGPTR_GET(SEGPTR_ALLOC(ofn
->nMaxFile
));
3787 ofn16
->nMaxFile
= ofn
->nMaxFile
;
3788 ofn16
->nMaxFileTitle
= ofn
->nMaxFileTitle
;
3789 if (ofn
->nMaxFileTitle
)
3790 ofn16
->lpstrFileTitle
= SEGPTR_GET(SEGPTR_ALLOC(ofn
->nMaxFileTitle
));
3791 if (ofn
->lpstrInitialDir
)
3792 ofn16
->lpstrInitialDir
= SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn
->lpstrInitialDir
));
3793 if (ofn
->lpstrTitle
)
3794 ofn16
->lpstrTitle
= SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn
->lpstrTitle
));
3795 ofn16
->Flags
= ofn
->Flags
|OFN_WINE32
|OFN_UNICODE
;
3796 ofn16
->nFileOffset
= ofn
->nFileOffset
;
3797 ofn16
->nFileExtension
= ofn
->nFileExtension
;
3798 if (ofn
->lpstrDefExt
)
3799 ofn16
->lpstrDefExt
= SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn
->lpstrDefExt
));
3800 ofn16
->lCustData
= ofn
->lCustData
;
3801 ofn16
->lpfnHook
= (WNDPROC16
)ofn
->lpfnHook
;
3802 if (ofn
->lpTemplateName
)
3803 ofn16
->lpTemplateName
= SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn
->lpTemplateName
));
3804 ret
= dofunction(SEGPTR_GET(ofn16
));
3806 ofn
->nFileOffset
= ofn16
->nFileOffset
;
3807 ofn
->nFileExtension
= ofn16
->nFileExtension
;
3808 if (ofn16
->lpstrFilter
)
3809 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFilter
));
3810 if (ofn16
->lpTemplateName
)
3811 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpTemplateName
));
3812 if (ofn16
->lpstrDefExt
)
3813 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrDefExt
));
3814 if (ofn16
->lpstrTitle
)
3815 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrTitle
));
3816 if (ofn16
->lpstrInitialDir
)
3817 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrInitialDir
));
3818 if (ofn16
->lpstrCustomFilter
)
3819 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrCustomFilter
));
3821 if (ofn16
->lpstrFile
) {
3822 lstrcpyAtoW(ofn
->lpstrFile
,PTR_SEG_TO_LIN(ofn16
->lpstrFile
));
3823 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFile
));
3826 if (ofn16
->lpstrFileTitle
) {
3827 lstrcpyAtoW(ofn
->lpstrFileTitle
,PTR_SEG_TO_LIN(ofn16
->lpstrFileTitle
));
3828 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFileTitle
));
3834 /***********************************************************************
3835 * GetOpenFileName32A (COMDLG32.10)
3837 BOOL32 WINAPI
GetOpenFileName32A( LPOPENFILENAME32A ofn
)
3839 BOOL16 (CALLBACK
* dofunction
)(SEGPTR ofn16
) = GetOpenFileName16
;
3840 return Commdlg_GetFileName32A(dofunction
,ofn
);
3843 /***********************************************************************
3844 * GetOpenFileName32W (COMDLG32.11)
3846 BOOL32 WINAPI
GetOpenFileName32W( LPOPENFILENAME32W ofn
)
3848 BOOL16 (CALLBACK
* dofunction
)(SEGPTR ofn16
) = GetOpenFileName16
;
3849 return Commdlg_GetFileName32W(dofunction
,ofn
);
3852 /***********************************************************************
3853 * GetSaveFileName32A (COMDLG32.12)
3855 BOOL32 WINAPI
GetSaveFileName32A( LPOPENFILENAME32A ofn
)
3857 BOOL16 (CALLBACK
* dofunction
)(SEGPTR ofn16
) = GetSaveFileName16
;
3858 return Commdlg_GetFileName32A(dofunction
,ofn
);
3861 /***********************************************************************
3862 * GetSaveFileName32W (COMDLG32.13)
3864 BOOL32 WINAPI
GetSaveFileName32W( LPOPENFILENAME32W ofn
)
3866 BOOL16 (CALLBACK
* dofunction
)(SEGPTR ofn16
) = GetSaveFileName16
;
3867 return Commdlg_GetFileName32W(dofunction
,ofn
);
3870 /***********************************************************************
3871 * ChooseColorA (COMDLG32.1)
3873 BOOL32 WINAPI
ChooseColor32A(LPCHOOSECOLOR32A lpChCol
)
3878 COLORREF
* ccref
=SEGPTR_ALLOC(64);
3879 LPCHOOSECOLOR16 lpcc16
=SEGPTR_ALLOC(sizeof(CHOOSECOLOR16
));
3881 memset(lpcc16
,'\0',sizeof(*lpcc16
));
3882 lpcc16
->lStructSize
=sizeof(*lpcc16
);
3883 lpcc16
->hwndOwner
=lpChCol
->hwndOwner
;
3884 lpcc16
->hInstance
=0; /* FIXME:MODULE_HANDLEtoHMODULE16(lpChCol->hInstance)*/
3885 lpcc16
->rgbResult
=lpChCol
->rgbResult
;
3886 memcpy(ccref
,lpChCol
->lpCustColors
,64);
3887 lpcc16
->lpCustColors
=(COLORREF
*)SEGPTR_GET(ccref
);
3888 lpcc16
->Flags
=lpChCol
->Flags
;
3889 lpcc16
->lCustData
=lpChCol
->lCustData
;
3890 lpcc16
->lpfnHook
=(WNDPROC16
)lpChCol
->lpfnHook
;
3891 if (lpChCol
->lpTemplateName
)
3892 str
= SEGPTR_STRDUP(lpChCol
->lpTemplateName
);
3893 lpcc16
->lpTemplateName
=SEGPTR_GET(str
);
3895 ret
= ChooseColor16(lpcc16
);
3898 memcpy(lpChCol
->lpCustColors
,ccref
,64);
3900 SEGPTR_FREE(lpcc16
);
3904 /***********************************************************************
3905 * ChooseColorW (COMDLG32.2)
3907 BOOL32 WINAPI
ChooseColor32W(LPCHOOSECOLOR32W lpChCol
)
3912 COLORREF
* ccref
=SEGPTR_ALLOC(64);
3913 LPCHOOSECOLOR16 lpcc16
=SEGPTR_ALLOC(sizeof(CHOOSECOLOR16
));
3915 memset(lpcc16
,'\0',sizeof(*lpcc16
));
3916 lpcc16
->lStructSize
=sizeof(*lpcc16
);
3917 lpcc16
->hwndOwner
=lpChCol
->hwndOwner
;
3918 lpcc16
->hInstance
=0; /*FIXME:MODULE_HANDLEtoHMODULE16(lpChCol->hInstance)*/
3919 lpcc16
->rgbResult
=lpChCol
->rgbResult
;
3920 memcpy(ccref
,lpChCol
->lpCustColors
,64);
3921 lpcc16
->lpCustColors
=(COLORREF
*)SEGPTR_GET(ccref
);
3922 lpcc16
->Flags
=lpChCol
->Flags
;
3923 lpcc16
->lCustData
=lpChCol
->lCustData
;
3924 lpcc16
->lpfnHook
=(WNDPROC16
)lpChCol
->lpfnHook
;
3925 if (lpChCol
->lpTemplateName
)
3926 str
= SEGPTR_STRDUP_WtoA(lpChCol
->lpTemplateName
);
3927 lpcc16
->lpTemplateName
=SEGPTR_GET(str
);
3929 ret
= ChooseColor16(lpcc16
);
3932 memcpy(lpChCol
->lpCustColors
,ccref
,64);
3934 SEGPTR_FREE(lpcc16
);
3938 /***********************************************************************
3939 * PageSetupDlgA (COMDLG32.15)
3941 BOOL32 WINAPI
PageSetupDlg32A(LPPAGESETUPDLG32A setupdlg
) {
3942 FIXME(commdlg
,"(%p), stub!\n",setupdlg
);