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" );
1454 /***********************************************************************
1455 * PrintDlg32W (COMDLG32.18)
1457 BOOL32 WINAPI
PrintDlg32W( LPPRINTDLG32W printdlg
)
1459 FIXME(commdlg
, "empty stub\n" );
1464 /***********************************************************************
1465 * PrintDlgProc (COMMDLG.21)
1467 LRESULT WINAPI
PrintDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
1473 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
1474 ShowWindow16(hWnd
, SW_SHOWNORMAL
);
1480 EndDialog32(hWnd
, TRUE
);
1483 EndDialog32(hWnd
, FALSE
);
1492 /***********************************************************************
1493 * PrintSetupDlgProc (COMMDLG.22)
1495 LRESULT WINAPI
PrintSetupDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
1501 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
1502 ShowWindow16(hWnd
, SW_SHOWNORMAL
);
1507 EndDialog32(hWnd
, TRUE
);
1510 EndDialog32(hWnd
, FALSE
);
1519 /***********************************************************************
1520 * CommDlgExtendedError (COMMDLG.26)
1522 DWORD WINAPI
CommDlgExtendedError(void)
1524 return CommDlgLastError
;
1527 /***********************************************************************
1528 * GetFileTitleA (COMDLG32.8)
1530 short WINAPI
GetFileTitle32A(LPCSTR lpFile
, LPSTR lpTitle
, UINT32 cbBuf
)
1533 TRACE(commdlg
,"(%p %p %d); \n", lpFile
, lpTitle
, cbBuf
);
1534 if (lpFile
== NULL
|| lpTitle
== NULL
)
1536 len
= strlen(lpFile
);
1539 if (strpbrk(lpFile
, "*[]"))
1542 if (lpFile
[len
] == '/' || lpFile
[len
] == '\\' || lpFile
[len
] == ':')
1544 for (i
= len
; i
>= 0; i
--)
1545 if (lpFile
[i
] == '/' || lpFile
[i
] == '\\' || lpFile
[i
] == ':')
1550 TRACE(commdlg
,"---> '%s' \n", &lpFile
[i
]);
1552 len
= strlen(lpFile
+i
)+1;
1556 strncpy(lpTitle
, &lpFile
[i
], len
);
1561 /***********************************************************************
1562 * GetFileTitleA (COMDLG32.8)
1564 short WINAPI
GetFileTitle32W(LPCWSTR lpFile
, LPWSTR lpTitle
, UINT32 cbBuf
)
1566 LPSTR file
= HEAP_strdupWtoA(GetProcessHeap(),0,lpFile
);
1567 LPSTR title
= HeapAlloc(GetProcessHeap(),0,cbBuf
);
1570 ret
= GetFileTitle32A(file
,title
,cbBuf
);
1572 lstrcpynAtoW(lpTitle
,title
,cbBuf
);
1573 HeapFree(GetProcessHeap(),0,file
);
1574 HeapFree(GetProcessHeap(),0,title
);
1577 /***********************************************************************
1578 * GetFileTitle (COMMDLG.27)
1580 short WINAPI
GetFileTitle16(LPCSTR lpFile
, LPSTR lpTitle
, UINT16 cbBuf
)
1582 return GetFileTitle32A(lpFile
,lpTitle
,cbBuf
);
1586 /* ------------------------ Choose Color Dialog --------------------------- */
1588 /***********************************************************************
1589 * ChooseColor (COMMDLG.5)
1591 BOOL16 WINAPI
ChooseColor16(LPCHOOSECOLOR16 lpChCol
)
1594 HANDLE16 hDlgTmpl
= 0;
1595 BOOL16 bRet
= FALSE
, win32Format
= FALSE
;
1599 TRACE(commdlg
,"ChooseColor\n");
1600 if (!lpChCol
) return FALSE
;
1602 if (lpChCol
->Flags
& CC_ENABLETEMPLATEHANDLE
)
1604 if (!(template = LockResource16( lpChCol
->hInstance
)))
1606 CommDlgLastError
= CDERR_LOADRESFAILURE
;
1610 else if (lpChCol
->Flags
& CC_ENABLETEMPLATE
)
1613 if (!(hResInfo
= FindResource16(lpChCol
->hInstance
,
1614 lpChCol
->lpTemplateName
,
1617 CommDlgLastError
= CDERR_FINDRESFAILURE
;
1620 if (!(hDlgTmpl
= LoadResource16( lpChCol
->hInstance
, hResInfo
)) ||
1621 !(template = LockResource16( hDlgTmpl
)))
1623 CommDlgLastError
= CDERR_LOADRESFAILURE
;
1629 template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_COLOR
);
1633 hInst
= WIN_GetWindowInstance( lpChCol
->hwndOwner
);
1634 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, win32Format
,
1636 (DLGPROC16
)MODULE_GetWndProcEntry16("ColorDlgProc"),
1637 (DWORD
)lpChCol
, WIN_PROC_16
);
1638 if (hwndDialog
) bRet
= DIALOG_DoDialogBox( hwndDialog
, lpChCol
->hwndOwner
);
1639 if (hDlgTmpl
) FreeResource16( hDlgTmpl
);
1644 static const COLORREF predefcolors
[6][8]=
1646 { 0x008080FFL
, 0x0080FFFFL
, 0x0080FF80L
, 0x0080FF00L
,
1647 0x00FFFF80L
, 0x00FF8000L
, 0x00C080FFL
, 0x00FF80FFL
},
1648 { 0x000000FFL
, 0x0000FFFFL
, 0x0000FF80L
, 0x0040FF00L
,
1649 0x00FFFF00L
, 0x00C08000L
, 0x00C08080L
, 0x00FF00FFL
},
1651 { 0x00404080L
, 0x004080FFL
, 0x0000FF00L
, 0x00808000L
,
1652 0x00804000L
, 0x00FF8080L
, 0x00400080L
, 0x008000FFL
},
1653 { 0x00000080L
, 0x000080FFL
, 0x00008000L
, 0x00408000L
,
1654 0x00FF0000L
, 0x00A00000L
, 0x00800080L
, 0x00FF0080L
},
1656 { 0x00000040L
, 0x00004080L
, 0x00004000L
, 0x00404000L
,
1657 0x00800000L
, 0x00400000L
, 0x00400040L
, 0x00800040L
},
1658 { 0x00000000L
, 0x00008080L
, 0x00408080L
, 0x00808080L
,
1659 0x00808040L
, 0x00C0C0C0L
, 0x00400040L
, 0x00FFFFFFL
},
1664 LPCHOOSECOLOR16 lpcc
; /* points to public known data structure */
1665 int nextuserdef
; /* next free place in user defined color array */
1666 HDC16 hdcMem
; /* color graph used for BitBlt() */
1667 HBITMAP16 hbmMem
; /* color graph bitmap */
1668 RECT16 fullsize
; /* original dialog window size */
1669 UINT16 msetrgb
; /* # of SETRGBSTRING message (today not used) */
1670 RECT16 old3angle
; /* last position of l-marker */
1671 RECT16 oldcross
; /* last position of color/satuation marker */
1672 BOOL32 updating
; /* to prevent recursive WM_COMMAND/EN_UPDATE procesing */
1675 int l
; /* for temporary storing of hue,sat,lum */
1678 /***********************************************************************
1679 * CC_HSLtoRGB [internal]
1681 static int CC_HSLtoRGB(char c
,int hue
,int sat
,int lum
)
1688 case 'R':if (hue
>80) hue
-=80; else hue
+=160; break;
1689 case 'G':if (hue
>160) hue
-=160; else hue
+=80; break;
1694 maxrgb
=(256*MIN(120,lum
))/120; /* 0 .. 256 */
1700 res
=(hue
-80)* maxrgb
; /* 0...10240 */
1701 res
/=40; /* 0...256 */
1708 res
=(240-hue
)* maxrgb
;
1711 res
=res
-maxrgb
/2; /* -128...128 */
1714 res
=maxrgb
/2 + (sat
*res
) /240; /* 0..256 */
1717 if (lum
>120 && res
<256)
1718 res
+=((lum
-120) * (256-res
))/120;
1720 return MIN(res
,255);
1723 /***********************************************************************
1724 * CC_RGBtoHSL [internal]
1726 static int CC_RGBtoHSL(char c
,int r
,int g
,int b
)
1728 WORD maxi
,mini
,mmsum
,mmdif
,result
=0;
1742 case 'L':mmsum
*=120; /* 0...61200=(255+255)*120 */
1743 result
=mmsum
/255; /* 0...240 */
1746 case 'S':if (!mmsum
)
1749 if (!mini
|| maxi
==255)
1753 result
=mmdif
*240; /* 0...61200=255*240 */
1754 result
/= (mmsum
>255 ? mmsum
=510-mmsum
: mmsum
); /* 0..255 */
1758 case 'H':if (!mmdif
)
1764 iresult
=40*(g
-b
); /* -10200 ... 10200 */
1765 iresult
/=(int)mmdif
; /* -40 .. 40 */
1767 iresult
+=240; /* 0..40 and 200..240 */
1773 iresult
/=(int)mmdif
;
1774 iresult
+=80; /* 40 .. 120 */
1780 iresult
/=(int)mmdif
;
1781 iresult
+=160; /* 120 .. 200 */
1787 return result
; /* is this integer arithmetic precise enough ? */
1792 /***********************************************************************
1793 * CC_MouseCheckPredefColorArray [internal]
1795 static int CC_MouseCheckPredefColorArray(HWND16 hDlg
,int dlgitem
,int rows
,int cols
,
1796 LPARAM lParam
,COLORREF
*cr
)
1799 POINT16 point
= MAKEPOINT16(lParam
);
1803 ClientToScreen16(hDlg
,&point
);
1804 hwnd
=GetDlgItem32(hDlg
,dlgitem
);
1805 GetWindowRect16(hwnd
,&rect
);
1806 if (PtInRect16(&rect
,point
))
1808 dx
=(rect
.right
-rect
.left
)/cols
;
1809 dy
=(rect
.bottom
-rect
.top
)/rows
;
1810 ScreenToClient16(hwnd
,&point
);
1812 if (point
.x
% dx
< (dx
-DISTANCE
) && point
.y
% dy
< (dy
-DISTANCE
))
1816 *cr
=predefcolors
[y
][x
];
1817 /* FIXME: Draw_a_Focus_Rect() */
1824 /***********************************************************************
1825 * CC_MouseCheckUserColorArray [internal]
1827 static int CC_MouseCheckUserColorArray(HWND16 hDlg
,int dlgitem
,int rows
,int cols
,
1828 LPARAM lParam
,COLORREF
*cr
,COLORREF
*crarr
)
1831 POINT16 point
= MAKEPOINT16(lParam
);
1835 ClientToScreen16(hDlg
,&point
);
1836 hwnd
=GetDlgItem32(hDlg
,dlgitem
);
1837 GetWindowRect16(hwnd
,&rect
);
1838 if (PtInRect16(&rect
,point
))
1840 dx
=(rect
.right
-rect
.left
)/cols
;
1841 dy
=(rect
.bottom
-rect
.top
)/rows
;
1842 ScreenToClient16(hwnd
,&point
);
1844 if (point
.x
% dx
< (dx
-DISTANCE
) && point
.y
% dy
< (dy
-DISTANCE
))
1848 *cr
=crarr
[x
+cols
*y
];
1849 /* FIXME: Draw_a_Focus_Rect() */
1859 /* 240 ^...... ^^ 240
1866 /***********************************************************************
1867 * CC_MouseCheckColorGraph [internal]
1869 static int CC_MouseCheckColorGraph(HWND16 hDlg
,int dlgitem
,int *hori
,int *vert
,LPARAM lParam
)
1872 POINT16 point
= MAKEPOINT16(lParam
);
1876 ClientToScreen16(hDlg
,&point
);
1877 hwnd
=GetDlgItem32(hDlg
,dlgitem
);
1878 GetWindowRect16(hwnd
,&rect
);
1879 if (PtInRect16(&rect
,point
))
1881 GetClientRect16(hwnd
,&rect
);
1882 ScreenToClient16(hwnd
,&point
);
1884 x
=(long)point
.x
*MAXHORI
;
1886 y
=(long)(rect
.bottom
-point
.y
)*MAXVERT
;
1898 /***********************************************************************
1899 * CC_MouseCheckResultWindow [internal]
1901 static int CC_MouseCheckResultWindow(HWND16 hDlg
,LPARAM lParam
)
1904 POINT16 point
= MAKEPOINT16(lParam
);
1907 ClientToScreen16(hDlg
,&point
);
1908 hwnd
=GetDlgItem32(hDlg
,0x2c5);
1909 GetWindowRect16(hwnd
,&rect
);
1910 if (PtInRect16(&rect
,point
))
1912 PostMessage16(hDlg
,WM_COMMAND
,0x2c9,0);
1918 /***********************************************************************
1919 * CC_CheckDigitsInEdit [internal]
1921 static int CC_CheckDigitsInEdit(HWND16 hwnd
,int maxval
)
1923 int i
,k
,m
,result
,value
;
1926 GetWindowText32A(hwnd
,buffer
,sizeof(buffer
));
1931 if (buffer
[i
]<'0' || buffer
[i
]>'9')
1933 for (k
=i
+1;k
<=m
;k
++) /* delete bad character */
1935 buffer
[i
]=buffer
[k
];
1943 if (value
>maxval
) /* build a new string */
1945 sprintf(buffer
,"%d",maxval
);
1950 editpos
=SendMessage16(hwnd
,EM_GETSEL16
,0,0);
1951 SetWindowText32A(hwnd
,buffer
);
1952 SendMessage16(hwnd
,EM_SETSEL16
,0,editpos
);
1959 /***********************************************************************
1960 * CC_PaintSelectedColor [internal]
1962 static void CC_PaintSelectedColor(HWND16 hDlg
,COLORREF cr
)
1967 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2c5);
1968 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
1971 GetClientRect16 (hwnd
, &rect
) ;
1972 hBrush
= CreateSolidBrush32(cr
);
1975 hBrush
= SelectObject32 (hdc
, hBrush
) ;
1976 Rectangle32(hdc
, rect
.left
,rect
.top
,rect
.right
/2,rect
.bottom
);
1977 DeleteObject32 (SelectObject32 (hdc
,hBrush
)) ;
1978 hBrush
=CreateSolidBrush32(GetNearestColor32(hdc
,cr
));
1981 hBrush
= SelectObject32 (hdc
, hBrush
) ;
1982 Rectangle32( hdc
, rect
.right
/2-1,rect
.top
,rect
.right
,rect
.bottom
);
1983 DeleteObject32( SelectObject32 (hdc
, hBrush
)) ;
1986 ReleaseDC32(hwnd
,hdc
);
1990 /***********************************************************************
1991 * CC_PaintTriangle [internal]
1993 static void CC_PaintTriangle(HWND16 hDlg
,int y
)
1997 int w
=GetDialogBaseUnits();
2002 HWND16 hwnd
=GetDlgItem32(hDlg
,0x2be);
2003 struct CCPRIVATE
*lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2005 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
2007 GetClientRect16(hwnd
,&rect
);
2011 points
[0].y
=rect
.top
;
2012 points
[0].x
=rect
.right
; /* | /| */
2013 ClientToScreen16(hwnd
,points
); /* | / | */
2014 ScreenToClient16(hDlg
,points
); /* |< | */
2015 oben
=points
[0].y
; /* | \ | */
2017 temp
=(long)height
*(long)y
;
2018 points
[0].y
=oben
+height
-temp
/(long)MAXVERT
;
2019 points
[1].y
=points
[0].y
+w
;
2020 points
[2].y
=points
[0].y
-w
;
2021 points
[2].x
=points
[1].x
=points
[0].x
+ w
;
2023 if (lpp
->old3angle
.left
)
2024 FillRect16(hDC
,&lpp
->old3angle
,GetStockObject32(WHITE_BRUSH
));
2025 lpp
->old3angle
.left
=points
[0].x
;
2026 lpp
->old3angle
.right
=points
[1].x
+1;
2027 lpp
->old3angle
.top
=points
[2].y
-1;
2028 lpp
->old3angle
.bottom
=points
[1].y
+1;
2029 Polygon16(hDC
,points
,3);
2030 ReleaseDC32(hDlg
,hDC
);
2035 /***********************************************************************
2036 * CC_PaintCross [internal]
2038 static void CC_PaintCross(HWND16 hDlg
,int x
,int y
)
2041 int w
=GetDialogBaseUnits();
2042 HWND16 hwnd
=GetDlgItem32(hDlg
,0x2c6);
2043 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2048 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
2050 GetClientRect16(hwnd
,&rect
);
2052 SelectClipRgn32(hDC
,CreateRectRgnIndirect16(&rect
));
2053 hPen
=CreatePen32(PS_SOLID
,2,0);
2054 hPen
=SelectObject32(hDC
,hPen
);
2055 point
.x
=((long)rect
.right
*(long)x
)/(long)MAXHORI
;
2056 point
.y
=rect
.bottom
-((long)rect
.bottom
*(long)y
)/(long)MAXVERT
;
2057 if (lpp
->oldcross
.left
!=lpp
->oldcross
.right
)
2058 BitBlt32(hDC
,lpp
->oldcross
.left
,lpp
->oldcross
.top
,
2059 lpp
->oldcross
.right
-lpp
->oldcross
.left
,
2060 lpp
->oldcross
.bottom
-lpp
->oldcross
.top
,
2061 lpp
->hdcMem
,lpp
->oldcross
.left
,lpp
->oldcross
.top
,SRCCOPY
);
2062 lpp
->oldcross
.left
=point
.x
-w
-1;
2063 lpp
->oldcross
.right
=point
.x
+w
+1;
2064 lpp
->oldcross
.top
=point
.y
-w
-1;
2065 lpp
->oldcross
.bottom
=point
.y
+w
+1;
2067 MoveTo(hDC
,point
.x
-w
,point
.y
);
2068 LineTo32(hDC
,point
.x
+w
,point
.y
);
2069 MoveTo(hDC
,point
.x
,point
.y
-w
);
2070 LineTo32(hDC
,point
.x
,point
.y
+w
);
2071 DeleteObject32(SelectObject32(hDC
,hPen
));
2072 ReleaseDC32(hwnd
,hDC
);
2081 /***********************************************************************
2082 * CC_PrepareColorGraph [internal]
2084 static void CC_PrepareColorGraph(HWND16 hDlg
)
2086 int sdif
,hdif
,xdif
,ydif
,r
,g
,b
,hue
,sat
;
2087 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2c6);
2088 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2092 HCURSOR16 hcursor
=SetCursor16(LoadCursor16(0,IDC_WAIT16
));
2094 GetClientRect16(hwnd
,&client
);
2096 lpp
->hdcMem
= CreateCompatibleDC32(hdc
);
2097 lpp
->hbmMem
= CreateCompatibleBitmap32(hdc
,client
.right
,client
.bottom
);
2098 SelectObject32(lpp
->hdcMem
,lpp
->hbmMem
);
2100 xdif
=client
.right
/XSTEPS
;
2101 ydif
=client
.bottom
/YSTEPS
+1;
2104 for(rect
.left
=hue
=0;hue
<239+hdif
;hue
+=hdif
)
2106 rect
.right
=rect
.left
+xdif
;
2107 rect
.bottom
=client
.bottom
;
2108 for(sat
=0;sat
<240+sdif
;sat
+=sdif
)
2110 rect
.top
=rect
.bottom
-ydif
;
2111 r
=CC_HSLtoRGB('R',hue
,sat
,120);
2112 g
=CC_HSLtoRGB('G',hue
,sat
,120);
2113 b
=CC_HSLtoRGB('B',hue
,sat
,120);
2114 hbrush
=CreateSolidBrush32(RGB(r
,g
,b
));
2115 FillRect16(lpp
->hdcMem
,&rect
,hbrush
);
2116 DeleteObject32(hbrush
);
2117 rect
.bottom
=rect
.top
;
2119 rect
.left
=rect
.right
;
2121 ReleaseDC32(hwnd
,hdc
);
2122 SetCursor16(hcursor
);
2125 /***********************************************************************
2126 * CC_PaintColorGraph [internal]
2128 static void CC_PaintColorGraph(HWND16 hDlg
)
2130 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2c6);
2131 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2134 if (IsWindowVisible32(hwnd
)) /* if full size */
2137 CC_PrepareColorGraph(hDlg
); /* should not be necessary */
2140 GetClientRect16(hwnd
,&rect
);
2142 BitBlt32(hDC
,0,0,rect
.right
,rect
.bottom
,lpp
->hdcMem
,0,0,SRCCOPY
);
2144 WARN(commdlg
,"choose color: hdcMem is not defined\n");
2145 ReleaseDC32(hwnd
,hDC
);
2148 /***********************************************************************
2149 * CC_PaintLumBar [internal]
2151 static void CC_PaintLumBar(HWND16 hDlg
,int hue
,int sat
)
2153 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2be);
2155 int lum
,ldif
,ydif
,r
,g
,b
;
2159 if (IsWindowVisible32(hwnd
))
2162 GetClientRect16(hwnd
,&client
);
2166 ydif
=client
.bottom
/YSTEPS
+1;
2167 for(lum
=0;lum
<240+ldif
;lum
+=ldif
)
2169 rect
.top
=MAX(0,rect
.bottom
-ydif
);
2170 r
=CC_HSLtoRGB('R',hue
,sat
,lum
);
2171 g
=CC_HSLtoRGB('G',hue
,sat
,lum
);
2172 b
=CC_HSLtoRGB('B',hue
,sat
,lum
);
2173 hbrush
=CreateSolidBrush32(RGB(r
,g
,b
));
2174 FillRect16(hDC
,&rect
,hbrush
);
2175 DeleteObject32(hbrush
);
2176 rect
.bottom
=rect
.top
;
2178 GetClientRect16(hwnd
,&rect
);
2179 FrameRect16(hDC
,&rect
,GetStockObject32(BLACK_BRUSH
));
2180 ReleaseDC32(hwnd
,hDC
);
2184 /***********************************************************************
2185 * CC_EditSetRGB [internal]
2187 static void CC_EditSetRGB(HWND16 hDlg
,COLORREF cr
)
2190 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2191 int r
=GetRValue(cr
);
2192 int g
=GetGValue(cr
);
2193 int b
=GetBValue(cr
);
2194 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
2197 sprintf(buffer
,"%d",r
);
2198 SetWindowText32A(GetDlgItem32(hDlg
,0x2c2),buffer
);
2199 sprintf(buffer
,"%d",g
);
2200 SetWindowText32A(GetDlgItem32(hDlg
,0x2c3),buffer
);
2201 sprintf(buffer
,"%d",b
);
2202 SetWindowText32A(GetDlgItem32(hDlg
,0x2c4),buffer
);
2203 lpp
->updating
=FALSE
;
2207 /***********************************************************************
2208 * CC_EditSetHSL [internal]
2210 static void CC_EditSetHSL(HWND16 hDlg
,int h
,int s
,int l
)
2213 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2215 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
2218 sprintf(buffer
,"%d",h
);
2219 SetWindowText32A(GetDlgItem32(hDlg
,0x2bf),buffer
);
2220 sprintf(buffer
,"%d",s
);
2221 SetWindowText32A(GetDlgItem32(hDlg
,0x2c0),buffer
);
2222 sprintf(buffer
,"%d",l
);
2223 SetWindowText32A(GetDlgItem32(hDlg
,0x2c1),buffer
);
2224 lpp
->updating
=FALSE
;
2226 CC_PaintLumBar(hDlg
,h
,s
);
2229 /***********************************************************************
2230 * CC_SwitchToFullSize [internal]
2232 static void CC_SwitchToFullSize(HWND16 hDlg
,COLORREF result
,LPRECT16 lprect
)
2235 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2237 EnableWindow32(GetDlgItem32(hDlg
,0x2cf),FALSE
);
2238 CC_PrepareColorGraph(hDlg
);
2239 for (i
=0x2bf;i
<0x2c5;i
++)
2240 EnableWindow32(GetDlgItem32(hDlg
,i
),TRUE
);
2241 for (i
=0x2d3;i
<0x2d9;i
++)
2242 EnableWindow32(GetDlgItem32(hDlg
,i
),TRUE
);
2243 EnableWindow32(GetDlgItem32(hDlg
,0x2c9),TRUE
);
2244 EnableWindow32(GetDlgItem32(hDlg
,0x2c8),TRUE
);
2247 SetWindowPos32(hDlg
,NULL
,0,0,lprect
->right
-lprect
->left
,
2248 lprect
->bottom
-lprect
->top
, SWP_NOMOVE
|SWP_NOZORDER
);
2250 ShowWindow32(GetDlgItem32(hDlg
,0x2c6),SW_SHOW
);
2251 ShowWindow32(GetDlgItem32(hDlg
,0x2be),SW_SHOW
);
2252 ShowWindow32(GetDlgItem32(hDlg
,0x2c5),SW_SHOW
);
2254 CC_EditSetRGB(hDlg
,result
);
2255 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
2258 /***********************************************************************
2259 * CC_PaintPredefColorArray [internal]
2261 static void CC_PaintPredefColorArray(HWND16 hDlg
,int rows
,int cols
)
2263 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2d0);
2269 GetClientRect16(hwnd
,&rect
);
2271 dy
=rect
.bottom
/rows
;
2275 GetClientRect16 (hwnd
, &rect
) ;
2277 for (j
=0;j
<rows
;j
++)
2279 for (i
=0;i
<cols
;i
++)
2281 hBrush
= CreateSolidBrush32(predefcolors
[j
][i
]);
2284 hBrush
= SelectObject32 (hdc
, hBrush
) ;
2285 Rectangle32(hdc
, rect
.left
, rect
.top
,
2286 rect
.left
+dx
-DISTANCE
, rect
.top
+dy
-DISTANCE
);
2287 rect
.left
=rect
.left
+dx
;
2288 DeleteObject32( SelectObject32 (hdc
, hBrush
)) ;
2291 rect
.top
=rect
.top
+dy
;
2294 ReleaseDC32(hwnd
,hdc
);
2295 /* FIXME: draw_a_focus_rect */
2297 /***********************************************************************
2298 * CC_PaintUserColorArray [internal]
2300 static void CC_PaintUserColorArray(HWND16 hDlg
,int rows
,int cols
,COLORREF
* lpcr
)
2302 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2d1);
2308 GetClientRect16(hwnd
,&rect
);
2311 dy
=rect
.bottom
/rows
;
2317 for (j
=0;j
<rows
;j
++)
2319 for (i
=0;i
<cols
;i
++)
2321 hBrush
= CreateSolidBrush32(lpcr
[i
+j
*cols
]);
2324 hBrush
= SelectObject32 (hdc
, hBrush
) ;
2325 Rectangle32( hdc
, rect
.left
, rect
.top
,
2326 rect
.left
+dx
-DISTANCE
, rect
.top
+dy
-DISTANCE
);
2327 rect
.left
=rect
.left
+dx
;
2328 DeleteObject32( SelectObject32 (hdc
, hBrush
)) ;
2331 rect
.top
=rect
.top
+dy
;
2334 ReleaseDC32(hwnd
,hdc
);
2336 /* FIXME: draw_a_focus_rect */
2341 /***********************************************************************
2342 * CC_HookCallChk [internal]
2344 static BOOL32
CC_HookCallChk(LPCHOOSECOLOR16 lpcc
)
2347 if(lpcc
->Flags
& CC_ENABLEHOOK
)
2353 /***********************************************************************
2354 * CC_WMInitDialog [internal]
2356 static LONG
CC_WMInitDialog(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2362 struct CCPRIVATE
* lpp
;
2364 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
2365 lpp
=calloc(1,sizeof(struct CCPRIVATE
));
2366 lpp
->lpcc
=(LPCHOOSECOLOR16
)lParam
;
2367 if (lpp
->lpcc
->lStructSize
!= sizeof(CHOOSECOLOR16
))
2369 EndDialog32 (hDlg
, 0) ;
2372 SetWindowLong32A(hDlg
, DWL_USER
, (LONG
)lpp
);
2374 if (!(lpp
->lpcc
->Flags
& CC_SHOWHELP
))
2375 ShowWindow32(GetDlgItem32(hDlg
,0x40e),SW_HIDE
);
2376 lpp
->msetrgb
=RegisterWindowMessage32A( SETRGBSTRING
);
2378 cpos
=MAKELONG(5,7); /* init */
2379 if (lpp
->lpcc
->Flags
& CC_RGBINIT
)
2383 if (predefcolors
[i
][j
]==lpp
->lpcc
->rgbResult
)
2390 /* FIXME: Draw_a_focus_rect & set_init_values */
2392 GetWindowRect16(hDlg
,&lpp
->fullsize
);
2393 if (lpp
->lpcc
->Flags
& CC_FULLOPEN
|| lpp
->lpcc
->Flags
& CC_PREVENTFULLOPEN
)
2395 hwnd
=GetDlgItem32(hDlg
,0x2cf);
2396 EnableWindow32(hwnd
,FALSE
);
2398 if (!(lpp
->lpcc
->Flags
& CC_FULLOPEN
) || lpp
->lpcc
->Flags
& CC_PREVENTFULLOPEN
)
2401 res
=rect
.bottom
-rect
.top
;
2402 hwnd
=GetDlgItem32(hDlg
,0x2c6); /* cut at left border */
2404 ClientToScreen16(hwnd
,&point
);
2405 ScreenToClient16(hDlg
,&point
);
2406 GetClientRect16(hDlg
,&rect
);
2407 point
.x
+=GetSystemMetrics32(SM_CXDLGFRAME
);
2408 SetWindowPos32(hDlg
,NULL
,0,0,point
.x
,res
,SWP_NOMOVE
|SWP_NOZORDER
);
2410 ShowWindow32(GetDlgItem32(hDlg
,0x2c6),SW_HIDE
);
2411 ShowWindow32(GetDlgItem32(hDlg
,0x2c5),SW_HIDE
);
2414 CC_SwitchToFullSize(hDlg
,lpp
->lpcc
->rgbResult
,NULL
);
2416 for (i
=0x2bf;i
<0x2c5;i
++)
2417 SendMessage16(GetDlgItem32(hDlg
,i
),EM_LIMITTEXT16
,3,0); /* max 3 digits: xyz */
2418 if (CC_HookCallChk(lpp
->lpcc
))
2419 res
=CallWindowProc16(lpp
->lpcc
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
2423 /***********************************************************************
2424 * CC_WMCommand [internal]
2426 static LRESULT
CC_WMCommand(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2432 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2433 TRACE(commdlg
,"CC_WMCommand wParam=%x lParam=%lx\n",wParam
,lParam
);
2436 case 0x2c2: /* edit notify RGB */
2439 if (HIWORD(lParam
)==EN_UPDATE
&& !lpp
->updating
)
2441 i
=CC_CheckDigitsInEdit(LOWORD(lParam
),255);
2442 r
=GetRValue(lpp
->lpcc
->rgbResult
);
2443 g
=GetGValue(lpp
->lpcc
->rgbResult
);
2444 b
=GetBValue(lpp
->lpcc
->rgbResult
);
2448 case 0x2c2:if ((xx
=(i
!=r
))) r
=i
;break;
2449 case 0x2c3:if ((xx
=(i
!=g
))) g
=i
;break;
2450 case 0x2c4:if ((xx
=(i
!=b
))) b
=i
;break;
2452 if (xx
) /* something has changed */
2454 lpp
->lpcc
->rgbResult
=RGB(r
,g
,b
);
2455 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2456 lpp
->h
=CC_RGBtoHSL('H',r
,g
,b
);
2457 lpp
->s
=CC_RGBtoHSL('S',r
,g
,b
);
2458 lpp
->l
=CC_RGBtoHSL('L',r
,g
,b
);
2459 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
2460 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2461 CC_PaintTriangle(hDlg
,lpp
->l
);
2466 case 0x2bf: /* edit notify HSL */
2469 if (HIWORD(lParam
)==EN_UPDATE
&& !lpp
->updating
)
2471 i
=CC_CheckDigitsInEdit(LOWORD(lParam
),wParam
==0x2bf?239:240);
2475 case 0x2bf:if ((xx
=(i
!=lpp
->h
))) lpp
->h
=i
;break;
2476 case 0x2c0:if ((xx
=(i
!=lpp
->s
))) lpp
->s
=i
;break;
2477 case 0x2c1:if ((xx
=(i
!=lpp
->l
))) lpp
->l
=i
;break;
2479 if (xx
) /* something has changed */
2481 r
=CC_HSLtoRGB('R',lpp
->h
,lpp
->s
,lpp
->l
);
2482 g
=CC_HSLtoRGB('G',lpp
->h
,lpp
->s
,lpp
->l
);
2483 b
=CC_HSLtoRGB('B',lpp
->h
,lpp
->s
,lpp
->l
);
2484 lpp
->lpcc
->rgbResult
=RGB(r
,g
,b
);
2485 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2486 CC_EditSetRGB(hDlg
,lpp
->lpcc
->rgbResult
);
2487 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2488 CC_PaintTriangle(hDlg
,lpp
->l
);
2494 CC_SwitchToFullSize(hDlg
,lpp
->lpcc
->rgbResult
,&lpp
->fullsize
);
2495 InvalidateRect32( hDlg
, NULL
, TRUE
);
2496 SetFocus32(GetDlgItem32(hDlg
,0x2bf));
2499 case 0x2c8: /* add colors ... column by column */
2500 cr
=PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
);
2501 cr
[(lpp
->nextuserdef
%2)*8 + lpp
->nextuserdef
/2]=lpp
->lpcc
->rgbResult
;
2502 if (++lpp
->nextuserdef
==16)
2504 CC_PaintUserColorArray(hDlg
,2,8,PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
));
2507 case 0x2c9: /* resulting color */
2509 lpp
->lpcc
->rgbResult
=GetNearestColor32(hdc
,lpp
->lpcc
->rgbResult
);
2510 ReleaseDC32(hDlg
,hdc
);
2511 CC_EditSetRGB(hDlg
,lpp
->lpcc
->rgbResult
);
2512 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2513 r
=GetRValue(lpp
->lpcc
->rgbResult
);
2514 g
=GetGValue(lpp
->lpcc
->rgbResult
);
2515 b
=GetBValue(lpp
->lpcc
->rgbResult
);
2516 lpp
->h
=CC_RGBtoHSL('H',r
,g
,b
);
2517 lpp
->s
=CC_RGBtoHSL('S',r
,g
,b
);
2518 lpp
->l
=CC_RGBtoHSL('L',r
,g
,b
);
2519 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
2520 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2521 CC_PaintTriangle(hDlg
,lpp
->l
);
2524 case 0x40e: /* Help! */ /* The Beatles, 1965 ;-) */
2525 i
=RegisterWindowMessage32A( HELPMSGSTRING
);
2526 if (lpp
->lpcc
->hwndOwner
)
2527 SendMessage16(lpp
->lpcc
->hwndOwner
,i
,0,(LPARAM
)lpp
->lpcc
);
2528 if (CC_HookCallChk(lpp
->lpcc
))
2529 CallWindowProc16(lpp
->lpcc
->lpfnHook
,hDlg
,
2530 WM_COMMAND
,psh15
,(LPARAM
)lpp
->lpcc
);
2534 cokmsg
=RegisterWindowMessage32A( COLOROKSTRING
);
2535 if (lpp
->lpcc
->hwndOwner
)
2536 if (SendMessage16(lpp
->lpcc
->hwndOwner
,cokmsg
,0,(LPARAM
)lpp
->lpcc
))
2537 break; /* do NOT close */
2539 EndDialog32 (hDlg
, 1) ;
2543 EndDialog32 (hDlg
, 0) ;
2550 /***********************************************************************
2551 * CC_WMPaint [internal]
2553 static LRESULT
CC_WMPaint(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2555 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2556 /* we have to paint dialog children except text and buttons */
2558 CC_PaintPredefColorArray(hDlg
,6,8);
2559 CC_PaintUserColorArray(hDlg
,2,8,PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
));
2560 CC_PaintColorGraph(hDlg
);
2561 CC_PaintLumBar(hDlg
,lpp
->h
,lpp
->s
);
2562 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2563 CC_PaintTriangle(hDlg
,lpp
->l
);
2564 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2566 /* special necessary for Wine */
2567 ValidateRect32(GetDlgItem32(hDlg
,0x2d0),NULL
);
2568 ValidateRect32(GetDlgItem32(hDlg
,0x2d1),NULL
);
2569 ValidateRect32(GetDlgItem32(hDlg
,0x2c6),NULL
);
2570 ValidateRect32(GetDlgItem32(hDlg
,0x2be),NULL
);
2571 ValidateRect32(GetDlgItem32(hDlg
,0x2c5),NULL
);
2572 /* hope we can remove it later -->FIXME */
2577 /***********************************************************************
2578 * CC_WMLButtonDown [internal]
2580 static LRESULT
CC_WMLButtonDown(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2582 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2585 if (CC_MouseCheckPredefColorArray(hDlg
,0x2d0,6,8,lParam
,&lpp
->lpcc
->rgbResult
))
2588 if (CC_MouseCheckUserColorArray(hDlg
,0x2d1,2,8,lParam
,&lpp
->lpcc
->rgbResult
,
2589 PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
)))
2592 if (CC_MouseCheckColorGraph(hDlg
,0x2c6,&lpp
->h
,&lpp
->s
,lParam
))
2595 if (CC_MouseCheckColorGraph(hDlg
,0x2be,NULL
,&lpp
->l
,lParam
))
2599 r
=CC_HSLtoRGB('R',lpp
->h
,lpp
->s
,lpp
->l
);
2600 g
=CC_HSLtoRGB('G',lpp
->h
,lpp
->s
,lpp
->l
);
2601 b
=CC_HSLtoRGB('B',lpp
->h
,lpp
->s
,lpp
->l
);
2602 lpp
->lpcc
->rgbResult
=RGB(r
,g
,b
);
2606 r
=GetRValue(lpp
->lpcc
->rgbResult
);
2607 g
=GetGValue(lpp
->lpcc
->rgbResult
);
2608 b
=GetBValue(lpp
->lpcc
->rgbResult
);
2609 lpp
->h
=CC_RGBtoHSL('H',r
,g
,b
);
2610 lpp
->s
=CC_RGBtoHSL('S',r
,g
,b
);
2611 lpp
->l
=CC_RGBtoHSL('L',r
,g
,b
);
2615 CC_EditSetRGB(hDlg
,lpp
->lpcc
->rgbResult
);
2616 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
2617 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2618 CC_PaintTriangle(hDlg
,lpp
->l
);
2619 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2625 /***********************************************************************
2626 * ColorDlgProc (COMMDLG.8)
2628 LRESULT WINAPI
ColorDlgProc(HWND16 hDlg
, UINT16 message
,
2629 WPARAM16 wParam
, LONG lParam
)
2632 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2633 if (message
!=WM_INITDIALOG
)
2638 if (CC_HookCallChk(lpp
->lpcc
))
2639 res
=CallWindowProc16(lpp
->lpcc
->lpfnHook
,hDlg
,message
,wParam
,lParam
);
2644 /* FIXME: SetRGB message
2645 if (message && message==msetrgb)
2646 return HandleSetRGB(hDlg,lParam);
2652 return CC_WMInitDialog(hDlg
,wParam
,lParam
);
2654 DeleteDC32(lpp
->hdcMem
);
2655 DeleteObject32(lpp
->hbmMem
);
2657 SetWindowLong32A(hDlg
, DWL_USER
, 0L); /* we don't need it anymore */
2660 if (CC_WMCommand(hDlg
, wParam
, lParam
))
2664 CC_WMPaint(hDlg
, wParam
, lParam
);
2666 case WM_LBUTTONDBLCLK
:
2667 if (CC_MouseCheckResultWindow(hDlg
,lParam
))
2670 case WM_MOUSEMOVE
: /* FIXME: calculate new hue,sat,lum (if in color graph) */
2672 case WM_LBUTTONUP
: /* FIXME: ClipCursor off (if in color graph)*/
2674 case WM_LBUTTONDOWN
:/* FIXME: ClipCursor on (if in color graph)*/
2675 if (CC_WMLButtonDown(hDlg
, wParam
, lParam
))
2682 static void CFn_CHOOSEFONT16to32A(LPCHOOSEFONT16 chf16
, LPCHOOSEFONT32A chf32a
)
2684 chf32a
->lStructSize
=sizeof(CHOOSEFONT32A
);
2685 chf32a
->hwndOwner
=chf16
->hwndOwner
;
2686 chf32a
->hDC
=chf16
->hDC
;
2687 chf32a
->iPointSize
=chf16
->iPointSize
;
2688 chf32a
->Flags
=chf16
->Flags
;
2689 chf32a
->rgbColors
=chf16
->rgbColors
;
2690 chf32a
->lCustData
=chf16
->lCustData
;
2691 chf32a
->lpfnHook
=NULL
;
2692 chf32a
->lpTemplateName
=PTR_SEG_TO_LIN(chf16
->lpTemplateName
);
2693 chf32a
->hInstance
=chf16
->hInstance
;
2694 chf32a
->lpszStyle
=PTR_SEG_TO_LIN(chf16
->lpszStyle
);
2695 chf32a
->nFontType
=chf16
->nFontType
;
2696 chf32a
->nSizeMax
=chf16
->nSizeMax
;
2697 chf32a
->nSizeMin
=chf16
->nSizeMin
;
2698 FONT_LogFont16To32A(PTR_SEG_TO_LIN(chf16
->lpLogFont
), chf32a
->lpLogFont
);
2702 /***********************************************************************
2703 * ChooseFont16 (COMMDLG.15)
2705 BOOL16 WINAPI
ChooseFont16(LPCHOOSEFONT16 lpChFont
)
2708 HANDLE16 hDlgTmpl
= 0;
2709 BOOL16 bRet
= FALSE
, win32Format
= FALSE
;
2712 CHOOSEFONT32A cf32a
;
2714 SEGPTR lpTemplateName
;
2716 cf32a
.lpLogFont
=&lf32a
;
2717 CFn_CHOOSEFONT16to32A(lpChFont
, &cf32a
);
2719 TRACE(commdlg
,"ChooseFont\n");
2720 if (!lpChFont
) return FALSE
;
2722 if (lpChFont
->Flags
& CF_ENABLETEMPLATEHANDLE
)
2724 if (!(template = LockResource16( lpChFont
->hInstance
)))
2726 CommDlgLastError
= CDERR_LOADRESFAILURE
;
2730 else if (lpChFont
->Flags
& CF_ENABLETEMPLATE
)
2733 if (!(hResInfo
= FindResource16( lpChFont
->hInstance
,
2734 lpChFont
->lpTemplateName
,
2737 CommDlgLastError
= CDERR_FINDRESFAILURE
;
2740 if (!(hDlgTmpl
= LoadResource16( lpChFont
->hInstance
, hResInfo
)) ||
2741 !(template = LockResource16( hDlgTmpl
)))
2743 CommDlgLastError
= CDERR_LOADRESFAILURE
;
2749 template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT
);
2753 hInst
= WIN_GetWindowInstance( lpChFont
->hwndOwner
);
2755 /* lpTemplateName is not used in the dialog */
2756 lpTemplateName
=lpChFont
->lpTemplateName
;
2757 lpChFont
->lpTemplateName
=(SEGPTR
)&cf32a
;
2759 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, win32Format
,
2760 lpChFont
->hwndOwner
,
2761 (DLGPROC16
)MODULE_GetWndProcEntry16("FormatCharDlgProc"),
2762 (DWORD
)lpChFont
, WIN_PROC_16
);
2763 if (hwndDialog
) bRet
= DIALOG_DoDialogBox(hwndDialog
, lpChFont
->hwndOwner
);
2764 if (hDlgTmpl
) FreeResource16( hDlgTmpl
);
2765 lpChFont
->lpTemplateName
=lpTemplateName
;
2766 FONT_LogFont32ATo16(cf32a
.lpLogFont
,
2767 (LPLOGFONT16
)(PTR_SEG_TO_LIN(lpChFont
->lpLogFont
)));
2772 /***********************************************************************
2773 * ChooseFont32A (COMDLG32.3)
2775 BOOL32 WINAPI
ChooseFont32A(LPCHOOSEFONT32A lpChFont
)
2779 HINSTANCE32 hInst
=WIN_GetWindowInstance( lpChFont
->hwndOwner
);
2780 LPCVOID
template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT
);
2781 if (lpChFont
->Flags
& (CF_SELECTSCRIPT
| CF_NOVERTFONTS
| CF_ENABLETEMPLATE
|
2782 CF_ENABLETEMPLATEHANDLE
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
2783 hwndDialog
= DIALOG_CreateIndirect(hInst
, template, TRUE
, lpChFont
->hwndOwner
,
2784 (DLGPROC16
)FormatCharDlgProc32A
, (LPARAM
)lpChFont
, WIN_PROC_32A
);
2785 if (hwndDialog
) bRet
= DIALOG_DoDialogBox(hwndDialog
, lpChFont
->hwndOwner
);
2789 /***********************************************************************
2790 * ChooseFont32W (COMDLG32.4)
2792 BOOL32 WINAPI
ChooseFont32W(LPCHOOSEFONT32W lpChFont
)
2796 HINSTANCE32 hInst
=WIN_GetWindowInstance( lpChFont
->hwndOwner
);
2797 CHOOSEFONT32A cf32a
;
2799 LPCVOID
template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT
);
2800 if (lpChFont
->Flags
& (CF_SELECTSCRIPT
| CF_NOVERTFONTS
| CF_ENABLETEMPLATE
|
2801 CF_ENABLETEMPLATEHANDLE
)) FIXME(commdlg
, ": unimplemented flag (ignored)\n");
2802 memcpy(&cf32a
, lpChFont
, sizeof(cf32a
));
2803 memcpy(&lf32a
, lpChFont
->lpLogFont
, sizeof(LOGFONT32A
));
2804 lstrcpynWtoA(lf32a
.lfFaceName
, lpChFont
->lpLogFont
->lfFaceName
, LF_FACESIZE
);
2805 cf32a
.lpLogFont
=&lf32a
;
2806 cf32a
.lpszStyle
=HEAP_strdupWtoA(GetProcessHeap(), 0, lpChFont
->lpszStyle
);
2807 lpChFont
->lpTemplateName
=(LPWSTR
)&cf32a
;
2808 hwndDialog
=DIALOG_CreateIndirect(hInst
, template, TRUE
, lpChFont
->hwndOwner
,
2809 (DLGPROC16
)FormatCharDlgProc32W
, (LPARAM
)lpChFont
, WIN_PROC_32W
);
2810 if (hwndDialog
)bRet
=DIALOG_DoDialogBox(hwndDialog
, lpChFont
->hwndOwner
);
2811 HeapFree(GetProcessHeap(), 0, cf32a
.lpszStyle
);
2812 lpChFont
->lpTemplateName
=(LPWSTR
)cf32a
.lpTemplateName
;
2813 memcpy(lpChFont
->lpLogFont
, &lf32a
, sizeof(CHOOSEFONT32A
));
2814 lstrcpynAtoW(lpChFont
->lpLogFont
->lfFaceName
, lf32a
.lfFaceName
, LF_FACESIZE
);
2819 #define TEXT_EXTRAS 4
2820 #define TEXT_COLORS 16
2822 static const COLORREF textcolors
[TEXT_COLORS
]=
2824 0x00000000L
,0x00000080L
,0x00008000L
,0x00008080L
,
2825 0x00800000L
,0x00800080L
,0x00808000L
,0x00808080L
,
2826 0x00c0c0c0L
,0x000000ffL
,0x0000ff00L
,0x0000ffffL
,
2827 0x00ff0000L
,0x00ff00ffL
,0x00ffff00L
,0x00FFFFFFL
2830 /***********************************************************************
2831 * CFn_HookCallChk [internal]
2833 static BOOL32
CFn_HookCallChk(LPCHOOSEFONT16 lpcf
)
2836 if(lpcf
->Flags
& CF_ENABLEHOOK
)
2842 /***********************************************************************
2843 * CFn_HookCallChk32 [internal]
2845 static BOOL32
CFn_HookCallChk32(LPCHOOSEFONT32A lpcf
)
2848 if(lpcf
->Flags
& CF_ENABLEHOOK
)
2855 /*************************************************************************
2856 * AddFontFamily [internal]
2858 static INT32
AddFontFamily(LPLOGFONT32A lplf
, UINT32 nFontType
,
2859 LPCHOOSEFONT32A lpcf
, HWND32 hwnd
)
2864 TRACE(commdlg
,"font=%s (nFontType=%d)\n", lplf
->lfFaceName
,nFontType
);
2866 if (lpcf
->Flags
& CF_FIXEDPITCHONLY
)
2867 if (!(lplf
->lfPitchAndFamily
& FIXED_PITCH
))
2869 if (lpcf
->Flags
& CF_ANSIONLY
)
2870 if (lplf
->lfCharSet
!= ANSI_CHARSET
)
2872 if (lpcf
->Flags
& CF_TTONLY
)
2873 if (!(nFontType
& TRUETYPE_FONTTYPE
))
2876 i
=SendMessage32A(hwnd
, CB_ADDSTRING32
, 0, (LPARAM
)lplf
->lfFaceName
);
2879 w
=(lplf
->lfCharSet
<< 8) | lplf
->lfPitchAndFamily
;
2880 SendMessage32A(hwnd
, CB_SETITEMDATA32
, i
, MAKELONG(nFontType
,w
));
2881 return 1 ; /* store some important font information */
2891 LPCHOOSEFONT32A lpcf32a
;
2892 } CFn_ENUMSTRUCT
, *LPCFn_ENUMSTRUCT
;
2894 /*************************************************************************
2895 * FontFamilyEnumProc32 [internal]
2897 INT32 WINAPI
FontFamilyEnumProc32(LPENUMLOGFONT32A lpEnumLogFont
,
2898 LPNEWTEXTMETRIC32A metrics
, UINT32 nFontType
, LPARAM lParam
)
2901 e
=(LPCFn_ENUMSTRUCT
)lParam
;
2902 return AddFontFamily(&lpEnumLogFont
->elfLogFont
, nFontType
, e
->lpcf32a
, e
->hWnd1
);
2905 /***********************************************************************
2906 * FontFamilyEnumProc16 (COMMDLG.19)
2908 INT16 WINAPI
FontFamilyEnumProc16( SEGPTR logfont
, SEGPTR metrics
,
2909 UINT16 nFontType
, LPARAM lParam
)
2911 HWND16 hwnd
=LOWORD(lParam
);
2912 HWND16 hDlg
=GetParent16(hwnd
);
2913 LPCHOOSEFONT16 lpcf
=(LPCHOOSEFONT16
)GetWindowLong32A(hDlg
, DWL_USER
);
2914 LOGFONT16
*lplf
= (LOGFONT16
*)PTR_SEG_TO_LIN( logfont
);
2916 FONT_LogFont16To32A(lplf
, &lf32a
);
2917 return AddFontFamily(&lf32a
, nFontType
, (LPCHOOSEFONT32A
)lpcf
->lpTemplateName
,
2921 /*************************************************************************
2922 * SetFontStylesToCombo2 [internal]
2924 * Fill font style information into combobox (without using font.c directly)
2926 static int SetFontStylesToCombo2(HWND32 hwnd
, HDC32 hdc
, LPLOGFONT32A lplf
)
2933 static struct FONTSTYLE fontstyles
[FSTYLES
]={
2934 { 0,FW_NORMAL
,"Regular"},{0,FW_BOLD
,"Bold"},
2935 { 1,FW_NORMAL
,"Italic"}, {1,FW_BOLD
,"Bold Italic"}};
2940 for (i
=0;i
<FSTYLES
;i
++)
2942 lplf
->lfItalic
=fontstyles
[i
].italic
;
2943 lplf
->lfWeight
=fontstyles
[i
].weight
;
2944 hf
=CreateFontIndirect32A(lplf
);
2945 hf
=SelectObject32(hdc
,hf
);
2946 GetTextMetrics16(hdc
,&tm
);
2947 hf
=SelectObject32(hdc
,hf
);
2950 if (tm
.tmWeight
==fontstyles
[i
].weight
&&
2951 tm
.tmItalic
==fontstyles
[i
].italic
) /* font successful created ? */
2953 char *str
= SEGPTR_STRDUP(fontstyles
[i
].stname
);
2954 j
=SendMessage16(hwnd
,CB_ADDSTRING16
,0,(LPARAM
)SEGPTR_GET(str
) );
2956 if (j
==CB_ERR
) return 1;
2957 j
=SendMessage16(hwnd
, CB_SETITEMDATA16
, j
,
2958 MAKELONG(fontstyles
[i
].weight
,fontstyles
[i
].italic
));
2959 if (j
==CB_ERR
) return 1;
2965 /*************************************************************************
2966 * AddFontSizeToCombo3 [internal]
2968 static int AddFontSizeToCombo3(HWND32 hwnd
, UINT32 h
, LPCHOOSEFONT32A lpcf
)
2973 if ( (!(lpcf
->Flags
& CF_LIMITSIZE
)) ||
2974 ((lpcf
->Flags
& CF_LIMITSIZE
) && (h
>= lpcf
->nSizeMin
) && (h
<= lpcf
->nSizeMax
)))
2976 sprintf(buffer
, "%2d", h
);
2977 j
=SendMessage32A(hwnd
, CB_FINDSTRINGEXACT32
, -1, (LPARAM
)buffer
);
2980 j
=SendMessage32A(hwnd
, CB_ADDSTRING32
, 0, (LPARAM
)buffer
);
2981 if (j
!=CB_ERR
) j
= SendMessage32A(hwnd
, CB_SETITEMDATA32
, j
, h
);
2982 if (j
==CB_ERR
) return 1;
2988 /*************************************************************************
2989 * SetFontSizesToCombo3 [internal]
2991 static int SetFontSizesToCombo3(HWND32 hwnd
, LPCHOOSEFONT32A lpcf
)
2993 static const int sizes
[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72,0};
2996 for (i
=0; sizes
[i
]; i
++)
2997 if (AddFontSizeToCombo3(hwnd
, sizes
[i
], lpcf
)) return 1;
3001 /***********************************************************************
3002 * AddFontStyle [internal]
3004 INT32
AddFontStyle(LPLOGFONT32A lplf
, UINT32 nFontType
,
3005 LPCHOOSEFONT32A lpcf
, HWND32 hcmb2
, HWND32 hcmb3
, HWND32 hDlg
)
3009 TRACE(commdlg
,"(nFontType=%d)\n",nFontType
);
3010 TRACE(commdlg
," %s h=%d w=%d e=%d o=%d wg=%d i=%d u=%d s=%d"
3011 " ch=%d op=%d cp=%d q=%d pf=%xh\n",
3012 lplf
->lfFaceName
,lplf
->lfHeight
,lplf
->lfWidth
,
3013 lplf
->lfEscapement
,lplf
->lfOrientation
,
3014 lplf
->lfWeight
,lplf
->lfItalic
,lplf
->lfUnderline
,
3015 lplf
->lfStrikeOut
,lplf
->lfCharSet
, lplf
->lfOutPrecision
,
3016 lplf
->lfClipPrecision
,lplf
->lfQuality
, lplf
->lfPitchAndFamily
);
3017 if (nFontType
& RASTER_FONTTYPE
)
3019 if (AddFontSizeToCombo3(hcmb3
, lplf
->lfHeight
, lpcf
)) return 0;
3020 } else if (SetFontSizesToCombo3(hcmb3
, lpcf
)) return 0;
3022 if (!SendMessage32A(hcmb2
, CB_GETCOUNT32
, 0, 0))
3024 HDC32 hdc
= (lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
) ? lpcf
->hDC
: GetDC32(hDlg
);
3025 i
=SetFontStylesToCombo2(hcmb2
,hdc
,lplf
);
3026 if (!(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
))
3027 ReleaseDC32(hDlg
,hdc
);
3035 /***********************************************************************
3036 * FontStyleEnumProc16 (COMMDLG.18)
3038 INT16 WINAPI
FontStyleEnumProc16( SEGPTR logfont
, SEGPTR metrics
,
3039 UINT16 nFontType
, LPARAM lParam
)
3041 HWND16 hcmb2
=LOWORD(lParam
);
3042 HWND16 hcmb3
=HIWORD(lParam
);
3043 HWND16 hDlg
=GetParent16(hcmb3
);
3044 LPCHOOSEFONT16 lpcf
=(LPCHOOSEFONT16
)GetWindowLong32A(hDlg
, DWL_USER
);
3045 LOGFONT16
*lplf
= (LOGFONT16
*)PTR_SEG_TO_LIN(logfont
);
3047 FONT_LogFont16To32A(lplf
, &lf32a
);
3048 return AddFontStyle(&lf32a
, nFontType
, (LPCHOOSEFONT32A
)lpcf
->lpTemplateName
,
3049 hcmb2
, hcmb3
, hDlg
);
3052 /***********************************************************************
3053 * FontStyleEnumProc32 [internal]
3055 INT32 WINAPI
FontStyleEnumProc32( LPENUMLOGFONT32A lpFont
,
3056 LPNEWTEXTMETRIC32A metrics
, UINT32 nFontType
, LPARAM lParam
)
3058 LPCFn_ENUMSTRUCT s
=(LPCFn_ENUMSTRUCT
)lParam
;
3059 HWND32 hcmb2
=s
->hWnd1
;
3060 HWND32 hcmb3
=s
->hWnd2
;
3061 HWND32 hDlg
=GetParent32(hcmb3
);
3062 return AddFontStyle(&lpFont
->elfLogFont
, nFontType
, s
->lpcf32a
, hcmb2
,
3066 /***********************************************************************
3067 * CFn_WMInitDialog [internal]
3069 LRESULT
CFn_WMInitDialog(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
,
3070 LPCHOOSEFONT32A lpcf
)
3076 HCURSOR32 hcursor
=SetCursor32(LoadCursor32A(0,IDC_WAIT32A
));
3078 SetWindowLong32A(hDlg
, DWL_USER
, lParam
);
3079 lpxx
=lpcf
->lpLogFont
;
3080 TRACE(commdlg
,"WM_INITDIALOG lParam=%08lX\n", lParam
);
3082 if (lpcf
->lStructSize
!= sizeof(CHOOSEFONT32A
))
3084 ERR(commdlg
,"structure size failure !!!\n");
3085 EndDialog32 (hDlg
, 0);
3089 hBitmapTT
= LoadBitmap32A(0, MAKEINTRESOURCE32A(OBM_TRTYPE
));
3091 /* This font will be deleted by WM_COMMAND */
3092 SendDlgItemMessage32A(hDlg
,stc6
,WM_SETFONT
,
3093 CreateFont32A(0, 0, 1, 1, 400, 0, 0, 0, 0, 0, 0, 0, 0, NULL
),FALSE
);
3095 if (!(lpcf
->Flags
& CF_SHOWHELP
) || !IsWindow32(lpcf
->hwndOwner
))
3096 ShowWindow32(GetDlgItem32(hDlg
,pshHelp
),SW_HIDE
);
3097 if (!(lpcf
->Flags
& CF_APPLY
))
3098 ShowWindow32(GetDlgItem32(hDlg
,psh3
),SW_HIDE
);
3099 if (lpcf
->Flags
& CF_EFFECTS
)
3101 for (res
=1,i
=0;res
&& i
<TEXT_COLORS
;i
++)
3103 /* FIXME: load color name from resource: res=LoadString(...,i+....,buffer,.....); */
3105 strcpy( name
, "[color name]" );
3106 j
=SendDlgItemMessage32A(hDlg
, cmb4
, CB_ADDSTRING32
, 0, (LPARAM
)name
);
3107 SendDlgItemMessage32A(hDlg
, cmb4
, CB_SETITEMDATA16
, j
, textcolors
[j
]);
3108 /* look for a fitting value in color combobox */
3109 if (textcolors
[j
]==lpcf
->rgbColors
)
3110 SendDlgItemMessage32A(hDlg
,cmb4
, CB_SETCURSEL32
,j
,0);
3115 ShowWindow32(GetDlgItem32(hDlg
,cmb4
),SW_HIDE
);
3116 ShowWindow32(GetDlgItem32(hDlg
,chx1
),SW_HIDE
);
3117 ShowWindow32(GetDlgItem32(hDlg
,chx2
),SW_HIDE
);
3118 ShowWindow32(GetDlgItem32(hDlg
,grp1
),SW_HIDE
);
3119 ShowWindow32(GetDlgItem32(hDlg
,stc4
),SW_HIDE
);
3121 hdc
= (lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
) ? lpcf
->hDC
: GetDC32(hDlg
);
3125 s
.hWnd1
=GetDlgItem32(hDlg
,cmb1
);
3127 if (!EnumFontFamilies32A(hdc
, NULL
, FontFamilyEnumProc32
, (LPARAM
)&s
))
3128 TRACE(commdlg
,"EnumFontFamilies returns 0\n");
3129 if (lpcf
->Flags
& CF_INITTOLOGFONTSTRUCT
)
3131 /* look for fitting font name in combobox1 */
3132 j
=SendDlgItemMessage32A(hDlg
,cmb1
,CB_FINDSTRING32
,-1,(LONG
)lpxx
->lfFaceName
);
3135 SendDlgItemMessage32A(hDlg
, cmb1
, CB_SETCURSEL32
, j
, 0);
3136 SendMessage32A(hDlg
, WM_COMMAND
, MAKEWPARAM(cmb1
, CBN_SELCHANGE
),
3137 GetDlgItem32(hDlg
,cmb1
));
3139 /* look for fitting font style in combobox2 */
3140 l
=MAKELONG(lpxx
->lfWeight
> FW_MEDIUM
? FW_BOLD
:FW_NORMAL
,lpxx
->lfItalic
!=0);
3141 for (i
=0;i
<TEXT_EXTRAS
;i
++)
3143 if (l
==SendDlgItemMessage32A(hDlg
, cmb2
, CB_GETITEMDATA32
, i
, 0))
3144 SendDlgItemMessage32A(hDlg
, cmb2
, CB_SETCURSEL32
, i
, 0);
3147 /* look for fitting font size in combobox3 */
3148 j
=SendDlgItemMessage32A(hDlg
, cmb3
, CB_GETCOUNT32
, 0, 0);
3151 if (lpxx
->lfHeight
==(int)SendDlgItemMessage32A(hDlg
,cmb3
, CB_GETITEMDATA32
,i
,0))
3152 SendDlgItemMessage32A(hDlg
,cmb3
,CB_SETCURSEL32
,i
,0);
3158 SendDlgItemMessage32A(hDlg
,cmb1
,CB_SETCURSEL32
,0,0);
3159 SendMessage32A(hDlg
, WM_COMMAND
, MAKEWPARAM(cmb1
, CBN_SELCHANGE
),
3160 GetDlgItem32(hDlg
,cmb1
));
3162 if (lpcf
->Flags
& CF_USESTYLE
&& lpcf
->lpszStyle
)
3164 j
=SendDlgItemMessage32A(hDlg
,cmb2
,CB_FINDSTRING32
,-1,(LONG
)lpcf
->lpszStyle
);
3167 j
=SendDlgItemMessage32A(hDlg
,cmb2
,CB_SETCURSEL32
,j
,0);
3168 SendMessage32A(hDlg
,WM_COMMAND
,cmb2
,
3169 MAKELONG(GetDlgItem32(hDlg
,cmb2
),CBN_SELCHANGE
));
3175 WARN(commdlg
,"HDC failure !!!\n");
3176 EndDialog32 (hDlg
, 0);
3180 if (!(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
))
3181 ReleaseDC32(hDlg
,hdc
);
3182 SetCursor32(hcursor
);
3187 /***********************************************************************
3188 * CFn_WMMeasureItem [internal]
3190 LRESULT
CFn_WMMeasureItem(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
)
3193 LPMEASUREITEMSTRUCT32 lpmi
=(LPMEASUREITEMSTRUCT32
)lParam
;
3195 hBitmapTT
= LoadBitmap32A(0, MAKEINTRESOURCE32A(OBM_TRTYPE
));
3196 GetObject32A( hBitmapTT
, sizeof(bm
), &bm
);
3197 lpmi
->itemHeight
=bm
.bmHeight
;
3198 /* FIXME: use MAX of bm.bmHeight and tm.tmHeight .*/
3203 /***********************************************************************
3204 * CFn_WMDrawItem [internal]
3206 LRESULT
CFn_WMDrawItem(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
)
3211 COLORREF cr
, oldText
=0, oldBk
=0;
3216 HBITMAP32 hBitmap
; /* for later TT usage */
3218 LPDRAWITEMSTRUCT32 lpdi
= (LPDRAWITEMSTRUCT32
)lParam
;
3220 if (lpdi
->itemID
== 0xFFFF) /* got no items */
3221 DrawFocusRect32(lpdi
->hDC
, &lpdi
->rcItem
);
3224 if (lpdi
->CtlType
== ODT_COMBOBOX
)
3226 if (lpdi
->itemState
==ODS_SELECTED
)
3228 hBrush
=GetSysColorBrush32(COLOR_HIGHLIGHT
);
3229 oldText
=SetTextColor32(lpdi
->hDC
, GetSysColor32(COLOR_HIGHLIGHTTEXT
));
3230 oldBk
=SetBkColor32(lpdi
->hDC
, GetSysColor32(COLOR_HIGHLIGHT
));
3233 hBrush
= SelectObject32(lpdi
->hDC
, GetStockObject32(LTGRAY_BRUSH
));
3234 SelectObject32(lpdi
->hDC
, hBrush
);
3236 FillRect32(lpdi
->hDC
, &lpdi
->rcItem
, hBrush
);
3239 return TRUE
; /* this should never happen */
3242 switch (lpdi
->CtlID
)
3244 case cmb1
: /* TRACE(commdlg,"WM_Drawitem cmb1\n"); */
3245 SendMessage32A(lpdi
->hwndItem
, CB_GETLBTEXT32
, lpdi
->itemID
,
3247 GetObject32A( hBitmapTT
, sizeof(bm
), &bm
);
3248 TextOut32A(lpdi
->hDC
, lpdi
->rcItem
.left
+ bm
.bmWidth
+ 10,
3249 lpdi
->rcItem
.top
, buffer
, lstrlen32A(buffer
));
3251 nFontType
= SendMessage32A(lpdi
->hwndItem
, CB_GETITEMDATA32
, lpdi
->itemID
,0L);
3252 /* FIXME: draw bitmap if truetype usage */
3253 if (nFontType
&TRUETYPE_FONTTYPE
)
3255 hMemDC
= CreateCompatibleDC32(lpdi
->hDC
);
3256 hBitmap
= SelectObject32(hMemDC
, hBitmapTT
);
3257 BitBlt32(lpdi
->hDC
, lpdi
->rcItem
.left
, lpdi
->rcItem
.top
,
3258 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
3259 SelectObject32(hMemDC
, hBitmap
);
3265 case cmb3
: /* TRACE(commdlg,"WM_DRAWITEN cmb2,cmb3\n"); */
3266 SendMessage32A(lpdi
->hwndItem
, CB_GETLBTEXT32
, lpdi
->itemID
,
3268 TextOut32A(lpdi
->hDC
, lpdi
->rcItem
.left
,
3269 lpdi
->rcItem
.top
, buffer
, lstrlen32A(buffer
));
3272 case cmb4
: /* TRACE(commdlg,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
3273 SendMessage32A(lpdi
->hwndItem
, CB_GETLBTEXT32
, lpdi
->itemID
,
3275 TextOut32A(lpdi
->hDC
, lpdi
->rcItem
.left
+ 25+5,
3276 lpdi
->rcItem
.top
, buffer
, lstrlen32A(buffer
));
3277 cr
= SendMessage32A(lpdi
->hwndItem
, CB_GETITEMDATA32
, lpdi
->itemID
,0L);
3278 hBrush
= CreateSolidBrush32(cr
);
3281 hBrush
= SelectObject32 (lpdi
->hDC
, hBrush
) ;
3282 rect
.right
=rect
.left
+25;
3286 Rectangle32( lpdi
->hDC
, rect
.left
, rect
.top
,
3287 rect
.right
, rect
.bottom
);
3288 DeleteObject32( SelectObject32 (lpdi
->hDC
, hBrush
)) ;
3294 default: return TRUE
; /* this should never happen */
3296 if (lpdi
->itemState
== ODS_SELECTED
)
3298 SetTextColor32(lpdi
->hDC
, oldText
);
3299 SetBkColor32(lpdi
->hDC
, oldBk
);
3305 /***********************************************************************
3306 * CFn_WMCtlColor [internal]
3308 LRESULT
CFn_WMCtlColorStatic(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
,
3309 LPCHOOSEFONT32A lpcf
)
3311 if (lpcf
->Flags
& CF_EFFECTS
)
3312 if (GetDlgCtrlID32(lParam
)==stc6
)
3314 SetTextColor32((HDC32
)wParam
, lpcf
->rgbColors
);
3315 return GetStockObject32(WHITE_BRUSH
);
3320 /***********************************************************************
3321 * CFn_WMCommand [internal]
3323 LRESULT
CFn_WMCommand(HWND32 hDlg
, WPARAM32 wParam
, LPARAM lParam
,
3324 LPCHOOSEFONT32A lpcf
)
3330 LPLOGFONT32A lpxx
=lpcf
->lpLogFont
;
3332 TRACE(commdlg
,"WM_COMMAND wParam=%08lX lParam=%08lX\n", (LONG
)wParam
, lParam
);
3333 switch (LOWORD(wParam
))
3335 case cmb1
:if (HIWORD(wParam
)==CBN_SELCHANGE
)
3337 hdc
=(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
) ? lpcf
->hDC
: GetDC32(hDlg
);
3340 SendDlgItemMessage32A(hDlg
, cmb2
, CB_RESETCONTENT16
, 0, 0);
3341 SendDlgItemMessage32A(hDlg
, cmb3
, CB_RESETCONTENT16
, 0, 0);
3342 i
=SendDlgItemMessage32A(hDlg
, cmb1
, CB_GETCURSEL16
, 0, 0);
3345 HCURSOR32 hcursor
=SetCursor32(LoadCursor32A(0,IDC_WAIT32A
));
3348 SendDlgItemMessage32A(hDlg
, cmb1
, CB_GETLBTEXT32
, i
,
3350 TRACE(commdlg
,"WM_COMMAND/cmb1 =>%s\n",str
);
3351 s
.hWnd1
=GetDlgItem32(hDlg
, cmb2
);
3352 s
.hWnd2
=GetDlgItem32(hDlg
, cmb3
);
3354 EnumFontFamilies32A(hdc
, str
, FontStyleEnumProc32
, (LPARAM
)&s
);
3355 SetCursor32(hcursor
);
3357 if (!(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
))
3358 ReleaseDC32(hDlg
,hdc
);
3362 WARN(commdlg
,"HDC failure !!!\n");
3363 EndDialog32 (hDlg
, 0);
3370 case cmb3
:if (HIWORD(wParam
)==CBN_SELCHANGE
|| HIWORD(wParam
)== BN_CLICKED
)
3373 TRACE(commdlg
,"WM_COMMAND/cmb2,3 =%08lX\n", lParam
);
3374 i
=SendDlgItemMessage32A(hDlg
,cmb1
,CB_GETCURSEL32
,0,0);
3376 i
=GetDlgItemText32A( hDlg
, cmb1
, str
, 256 );
3379 SendDlgItemMessage32A(hDlg
,cmb1
,CB_GETLBTEXT32
,i
,
3381 l
=SendDlgItemMessage32A(hDlg
,cmb1
,CB_GETITEMDATA32
,i
,0);
3383 lpcf
->nFontType
= LOWORD(l
);
3384 /* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */
3385 /* same value reported to the EnumFonts
3386 call back with the extra FONTTYPE_... bits added */
3387 lpxx
->lfPitchAndFamily
=j
&0xff;
3388 lpxx
->lfCharSet
=j
>>8;
3390 strcpy(lpxx
->lfFaceName
,str
);
3391 i
=SendDlgItemMessage32A(hDlg
, cmb2
, CB_GETCURSEL32
, 0, 0);
3394 l
=SendDlgItemMessage32A(hDlg
, cmb2
, CB_GETITEMDATA32
, i
, 0);
3395 if (0!=(lpxx
->lfItalic
=HIWORD(l
)))
3396 lpcf
->nFontType
|= ITALIC_FONTTYPE
;
3397 if ((lpxx
->lfWeight
=LOWORD(l
)) > FW_MEDIUM
)
3398 lpcf
->nFontType
|= BOLD_FONTTYPE
;
3400 i
=SendDlgItemMessage32A(hDlg
, cmb3
, CB_GETCURSEL32
, 0, 0);
3402 lpxx
->lfHeight
=-LOWORD(SendDlgItemMessage32A(hDlg
, cmb3
, CB_GETITEMDATA32
, i
, 0));
3405 lpxx
->lfStrikeOut
=IsDlgButtonChecked32(hDlg
,chx1
);
3406 lpxx
->lfUnderline
=IsDlgButtonChecked32(hDlg
,chx2
);
3407 lpxx
->lfWidth
=lpxx
->lfOrientation
=lpxx
->lfEscapement
=0;
3408 lpxx
->lfOutPrecision
=OUT_DEFAULT_PRECIS
;
3409 lpxx
->lfClipPrecision
=CLIP_DEFAULT_PRECIS
;
3410 lpxx
->lfQuality
=DEFAULT_QUALITY
;
3411 lpcf
->iPointSize
= -10*lpxx
->lfHeight
;
3413 hFont
=CreateFontIndirect32A(lpxx
);
3416 HFONT32 oldFont
=SendDlgItemMessage32A(hDlg
, stc6
,
3418 SendDlgItemMessage32A(hDlg
,stc6
,WM_SETFONT
,hFont
,TRUE
);
3419 DeleteObject32(oldFont
);
3424 case cmb4
:i
=SendDlgItemMessage32A(hDlg
, cmb4
, CB_GETCURSEL32
, 0, 0);
3427 lpcf
->rgbColors
=textcolors
[i
];
3428 InvalidateRect32( GetDlgItem32(hDlg
,stc6
), NULL
, 0 );
3432 case psh15
:i
=RegisterWindowMessage32A( HELPMSGSTRING
);
3433 if (lpcf
->hwndOwner
)
3434 SendMessage32A(lpcf
->hwndOwner
, i
, 0, (LPARAM
)GetWindowLong32A(hDlg
, DWL_USER
));
3435 /* if (CFn_HookCallChk(lpcf))
3436 CallWindowProc16(lpcf->lpfnHook,hDlg,WM_COMMAND,psh15,(LPARAM)lpcf);*/
3439 case IDOK
:if ( (!(lpcf
->Flags
& CF_LIMITSIZE
)) ||
3440 ( (lpcf
->Flags
& CF_LIMITSIZE
) &&
3441 (-lpxx
->lfHeight
>= lpcf
->nSizeMin
) &&
3442 (-lpxx
->lfHeight
<= lpcf
->nSizeMax
)))
3443 EndDialog32(hDlg
, TRUE
);
3447 sprintf(buffer
,"Select a font size between %d and %d points.",
3448 lpcf
->nSizeMin
,lpcf
->nSizeMax
);
3449 MessageBox32A(hDlg
, buffer
, NULL
, MB_OK
);
3452 case IDCANCEL
:EndDialog32(hDlg
, FALSE
);
3458 static LRESULT
CFn_WMDestroy(HWND32 hwnd
, WPARAM32 wParam
, LPARAM lParam
)
3460 DeleteObject32(SendDlgItemMessage32A(hwnd
, stc6
, WM_GETFONT
, 0, 0));
3465 /***********************************************************************
3466 * FormatCharDlgProc16 (COMMDLG.16)
3467 FIXME: 1. some strings are "hardcoded", but it's better load from sysres
3468 2. some CF_.. flags are not supported
3469 3. some TType extensions
3471 LRESULT WINAPI
FormatCharDlgProc16(HWND16 hDlg
, UINT16 message
, WPARAM16 wParam
,
3474 LPCHOOSEFONT16 lpcf
;
3475 LPCHOOSEFONT32A lpcf32a
;
3479 if (message
!=WM_INITDIALOG
)
3481 lpcf
=(LPCHOOSEFONT16
)GetWindowLong32A(hDlg
, DWL_USER
);
3484 if (CFn_HookCallChk(lpcf
))
3485 res
=CallWindowProc16(lpcf
->lpfnHook
,hDlg
,message
,wParam
,lParam
);
3491 lpcf
=(LPCHOOSEFONT16
)lParam
;
3492 lpcf32a
=(LPCHOOSEFONT32A
)lpcf
->lpTemplateName
;
3493 if (!CFn_WMInitDialog(hDlg
, wParam
, lParam
, lpcf32a
))
3495 TRACE(commdlg
, "CFn_WMInitDialog returned FALSE\n");
3498 if (CFn_HookCallChk(lpcf
))
3499 return CallWindowProc16(lpcf
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
3501 WINPROC_MapMsg16To32A(message
, wParam
, &uMsg32
, &wParam32
, &lParam
);
3502 lpcf32a
=(LPCHOOSEFONT32A
)lpcf
->lpTemplateName
;
3505 case WM_MEASUREITEM
:
3506 res
=CFn_WMMeasureItem(hDlg
, wParam32
, lParam
);
3509 res
=CFn_WMDrawItem(hDlg
, wParam32
, lParam
);
3511 case WM_CTLCOLORSTATIC
:
3512 res
=CFn_WMCtlColorStatic(hDlg
, wParam32
, lParam
, lpcf32a
);
3515 res
=CFn_WMCommand(hDlg
, wParam32
, lParam
, lpcf32a
);
3518 res
=CFn_WMDestroy(hDlg
, wParam32
, lParam
);
3520 case WM_CHOOSEFONT_GETLOGFONT
:
3521 TRACE(commdlg
,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3523 FIXME(commdlg
, "current logfont back to caller\n");
3526 WINPROC_UnmapMsg16To32A(uMsg32
, wParam32
, lParam
, res
);
3530 /***********************************************************************
3531 * FormatCharDlgProc32A [internal]
3533 LRESULT WINAPI
FormatCharDlgProc32A(HWND32 hDlg
, UINT32 uMsg
, WPARAM32 wParam
,
3536 LPCHOOSEFONT32A lpcf
;
3538 if (uMsg
!=WM_INITDIALOG
)
3540 lpcf
=(LPCHOOSEFONT32A
)GetWindowLong32A(hDlg
, DWL_USER
);
3543 if (CFn_HookCallChk32(lpcf
))
3544 res
=CallWindowProc32A(lpcf
->lpfnHook
, hDlg
, uMsg
, wParam
, lParam
);
3550 lpcf
=(LPCHOOSEFONT32A
)lParam
;
3551 if (!CFn_WMInitDialog(hDlg
, wParam
, lParam
, lpcf
))
3553 TRACE(commdlg
, "CFn_WMInitDialog returned FALSE\n");
3556 if (CFn_HookCallChk32(lpcf
))
3557 return CallWindowProc32A(lpcf
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
3561 case WM_MEASUREITEM
:
3562 return CFn_WMMeasureItem(hDlg
, wParam
, lParam
);
3564 return CFn_WMDrawItem(hDlg
, wParam
, lParam
);
3565 case WM_CTLCOLORSTATIC
:
3566 return CFn_WMCtlColorStatic(hDlg
, wParam
, lParam
, lpcf
);
3568 return CFn_WMCommand(hDlg
, wParam
, lParam
, lpcf
);
3570 return CFn_WMDestroy(hDlg
, wParam
, lParam
);
3571 case WM_CHOOSEFONT_GETLOGFONT
:
3572 TRACE(commdlg
,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3574 FIXME(commdlg
, "current logfont back to caller\n");
3580 /***********************************************************************
3581 * FormatCharDlgProc32W [internal]
3583 LRESULT WINAPI
FormatCharDlgProc32W(HWND32 hDlg
, UINT32 uMsg
, WPARAM32 wParam
,
3586 LPCHOOSEFONT32W lpcf32w
;
3587 LPCHOOSEFONT32A lpcf32a
;
3589 if (uMsg
!=WM_INITDIALOG
)
3591 lpcf32w
=(LPCHOOSEFONT32W
)GetWindowLong32A(hDlg
, DWL_USER
);
3594 if (CFn_HookCallChk32((LPCHOOSEFONT32A
)lpcf32w
))
3595 res
=CallWindowProc32W(lpcf32w
->lpfnHook
, hDlg
, uMsg
, wParam
, lParam
);
3601 lpcf32w
=(LPCHOOSEFONT32W
)lParam
;
3602 lpcf32a
=(LPCHOOSEFONT32A
)lpcf32w
->lpTemplateName
;
3603 if (!CFn_WMInitDialog(hDlg
, wParam
, lParam
, lpcf32a
))
3605 TRACE(commdlg
, "CFn_WMInitDialog returned FALSE\n");
3608 if (CFn_HookCallChk32((LPCHOOSEFONT32A
)lpcf32w
))
3609 return CallWindowProc32W(lpcf32w
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
3611 lpcf32a
=(LPCHOOSEFONT32A
)lpcf32w
->lpTemplateName
;
3614 case WM_MEASUREITEM
:
3615 return CFn_WMMeasureItem(hDlg
, wParam
, lParam
);
3617 return CFn_WMDrawItem(hDlg
, wParam
, lParam
);
3618 case WM_CTLCOLORSTATIC
:
3619 return CFn_WMCtlColorStatic(hDlg
, wParam
, lParam
, lpcf32a
);
3621 return CFn_WMCommand(hDlg
, wParam
, lParam
, lpcf32a
);
3623 return CFn_WMDestroy(hDlg
, wParam
, lParam
);
3624 case WM_CHOOSEFONT_GETLOGFONT
:
3625 TRACE(commdlg
,"WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n",
3627 FIXME(commdlg
, "current logfont back to caller\n");
3634 static BOOL32
Commdlg_GetFileName32A( BOOL16 (*dofunction
)(),
3635 LPOPENFILENAME32A ofn
)
3638 LPOPENFILENAME16 ofn16
= SEGPTR_ALLOC(sizeof(OPENFILENAME16
));
3640 memset(ofn16
,'\0',sizeof(*ofn16
));
3641 ofn16
->lStructSize
= sizeof(*ofn16
);
3642 ofn16
->hwndOwner
= ofn
->hwndOwner
;
3643 /* FIXME: OPENFILENAME16 got only 16 bit for HINSTANCE... */
3644 ofn16
->hInstance
= 0;
3645 if (ofn
->lpstrFilter
) {
3648 /* filter is a list... title\0ext\0......\0\0 */
3649 s
= (LPSTR
)ofn
->lpstrFilter
;
3653 x
= (LPSTR
)SEGPTR_ALLOC(s
-ofn
->lpstrFilter
);
3654 memcpy(x
,ofn
->lpstrFilter
,s
-ofn
->lpstrFilter
);
3655 ofn16
->lpstrFilter
= SEGPTR_GET(x
);
3657 if (ofn
->lpstrCustomFilter
) {
3660 /* filter is a list... title\0ext\0......\0\0 */
3661 s
= (LPSTR
)ofn
->lpstrCustomFilter
;
3664 x
= SEGPTR_ALLOC(s
-ofn
->lpstrCustomFilter
);
3666 memcpy(x
,ofn
->lpstrCustomFilter
,s
-ofn
->lpstrCustomFilter
);
3667 ofn16
->lpstrCustomFilter
= SEGPTR_GET(x
);
3669 ofn16
->nMaxCustFilter
= ofn
->nMaxCustFilter
;
3670 ofn16
->nFilterIndex
= ofn
->nFilterIndex
;
3672 ofn16
->lpstrFile
= SEGPTR_GET(SEGPTR_ALLOC(ofn
->nMaxFile
));
3673 ofn16
->nMaxFile
= ofn
->nMaxFile
;
3674 ofn16
->nMaxFileTitle
= ofn
->nMaxFileTitle
;
3675 if (ofn16
->nMaxFileTitle
)
3676 ofn16
->lpstrFileTitle
= SEGPTR_GET(SEGPTR_ALLOC(ofn
->nMaxFileTitle
));
3677 if (ofn
->lpstrInitialDir
)
3678 ofn16
->lpstrInitialDir
= SEGPTR_GET(SEGPTR_STRDUP(ofn
->lpstrInitialDir
));
3679 if (ofn
->lpstrTitle
)
3680 ofn16
->lpstrTitle
= SEGPTR_GET(SEGPTR_STRDUP(ofn
->lpstrTitle
));
3681 ofn16
->Flags
= ofn
->Flags
|OFN_WINE32
;
3682 ofn16
->nFileOffset
= ofn
->nFileOffset
;
3683 ofn16
->nFileExtension
= ofn
->nFileExtension
;
3684 if (ofn
->lpstrDefExt
)
3685 ofn16
->lpstrDefExt
= SEGPTR_GET(SEGPTR_STRDUP(ofn
->lpstrDefExt
));
3686 ofn16
->lCustData
= ofn
->lCustData
;
3687 ofn16
->lpfnHook
= (WNDPROC16
)ofn
->lpfnHook
;
3689 if (ofn
->lpTemplateName
)
3690 ofn16
->lpTemplateName
= SEGPTR_GET(SEGPTR_STRDUP(ofn
->lpTemplateName
));
3692 ret
= dofunction(SEGPTR_GET(ofn16
));
3694 ofn
->nFileOffset
= ofn16
->nFileOffset
;
3695 ofn
->nFileExtension
= ofn16
->nFileExtension
;
3696 if (ofn16
->lpstrFilter
)
3697 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFilter
));
3698 if (ofn16
->lpTemplateName
)
3699 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpTemplateName
));
3700 if (ofn16
->lpstrDefExt
)
3701 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrDefExt
));
3702 if (ofn16
->lpstrTitle
)
3703 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrTitle
));
3704 if (ofn16
->lpstrInitialDir
)
3705 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrInitialDir
));
3706 if (ofn16
->lpstrCustomFilter
)
3707 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrCustomFilter
));
3709 if (ofn16
->lpstrFile
)
3711 strcpy(ofn
->lpstrFile
,PTR_SEG_TO_LIN(ofn16
->lpstrFile
));
3712 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFile
));
3715 if (ofn16
->lpstrFileTitle
)
3717 strcpy(ofn
->lpstrFileTitle
,PTR_SEG_TO_LIN(ofn16
->lpstrFileTitle
));
3718 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFileTitle
));
3724 static BOOL32
Commdlg_GetFileName32W( BOOL16 (*dofunction
)(),
3725 LPOPENFILENAME32W ofn
)
3728 LPOPENFILENAME16 ofn16
= SEGPTR_ALLOC(sizeof(OPENFILENAME16
));
3730 memset(ofn16
,'\0',sizeof(*ofn16
));
3731 ofn16
->lStructSize
= sizeof(*ofn16
);
3732 ofn16
->hwndOwner
= ofn
->hwndOwner
;
3733 /* FIXME: OPENFILENAME16 got only 16 bit for HINSTANCE... */
3734 ofn16
->hInstance
= 0;
3735 if (ofn
->lpstrFilter
) {
3740 /* filter is a list... title\0ext\0......\0\0 */
3741 s
= (LPWSTR
)ofn
->lpstrFilter
;
3743 s
= s
+lstrlen32W(s
)+1;
3745 n
= s
- ofn
->lpstrFilter
; /* already divides by 2. ptr magic */
3746 x
= y
= (LPSTR
)SEGPTR_ALLOC(n
);
3747 s
= (LPWSTR
)ofn
->lpstrFilter
;
3754 ofn16
->lpstrFilter
= SEGPTR_GET(y
);
3756 if (ofn
->lpstrCustomFilter
) {
3761 /* filter is a list... title\0ext\0......\0\0 */
3762 s
= (LPWSTR
)ofn
->lpstrCustomFilter
;
3764 s
= s
+lstrlen32W(s
)+1;
3766 n
= s
- ofn
->lpstrCustomFilter
;
3767 x
= y
= (LPSTR
)SEGPTR_ALLOC(n
);
3768 s
= (LPWSTR
)ofn
->lpstrCustomFilter
;
3775 ofn16
->lpstrCustomFilter
= SEGPTR_GET(y
);
3777 ofn16
->nMaxCustFilter
= ofn
->nMaxCustFilter
;
3778 ofn16
->nFilterIndex
= ofn
->nFilterIndex
;
3780 ofn16
->lpstrFile
= SEGPTR_GET(SEGPTR_ALLOC(ofn
->nMaxFile
));
3781 ofn16
->nMaxFile
= ofn
->nMaxFile
;
3782 ofn16
->nMaxFileTitle
= ofn
->nMaxFileTitle
;
3783 if (ofn
->nMaxFileTitle
)
3784 ofn16
->lpstrFileTitle
= SEGPTR_GET(SEGPTR_ALLOC(ofn
->nMaxFileTitle
));
3785 if (ofn
->lpstrInitialDir
)
3786 ofn16
->lpstrInitialDir
= SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn
->lpstrInitialDir
));
3787 if (ofn
->lpstrTitle
)
3788 ofn16
->lpstrTitle
= SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn
->lpstrTitle
));
3789 ofn16
->Flags
= ofn
->Flags
|OFN_WINE32
|OFN_UNICODE
;
3790 ofn16
->nFileOffset
= ofn
->nFileOffset
;
3791 ofn16
->nFileExtension
= ofn
->nFileExtension
;
3792 if (ofn
->lpstrDefExt
)
3793 ofn16
->lpstrDefExt
= SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn
->lpstrDefExt
));
3794 ofn16
->lCustData
= ofn
->lCustData
;
3795 ofn16
->lpfnHook
= (WNDPROC16
)ofn
->lpfnHook
;
3796 if (ofn
->lpTemplateName
)
3797 ofn16
->lpTemplateName
= SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn
->lpTemplateName
));
3798 ret
= dofunction(SEGPTR_GET(ofn16
));
3800 ofn
->nFileOffset
= ofn16
->nFileOffset
;
3801 ofn
->nFileExtension
= ofn16
->nFileExtension
;
3802 if (ofn16
->lpstrFilter
)
3803 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFilter
));
3804 if (ofn16
->lpTemplateName
)
3805 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpTemplateName
));
3806 if (ofn16
->lpstrDefExt
)
3807 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrDefExt
));
3808 if (ofn16
->lpstrTitle
)
3809 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrTitle
));
3810 if (ofn16
->lpstrInitialDir
)
3811 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrInitialDir
));
3812 if (ofn16
->lpstrCustomFilter
)
3813 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrCustomFilter
));
3815 if (ofn16
->lpstrFile
) {
3816 lstrcpyAtoW(ofn
->lpstrFile
,PTR_SEG_TO_LIN(ofn16
->lpstrFile
));
3817 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFile
));
3820 if (ofn16
->lpstrFileTitle
) {
3821 lstrcpyAtoW(ofn
->lpstrFileTitle
,PTR_SEG_TO_LIN(ofn16
->lpstrFileTitle
));
3822 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16
->lpstrFileTitle
));
3828 /***********************************************************************
3829 * GetOpenFileName32A (COMDLG32.10)
3831 BOOL32 WINAPI
GetOpenFileName32A( LPOPENFILENAME32A ofn
)
3833 BOOL16 (WINAPI
* dofunction
)(SEGPTR ofn16
) = GetOpenFileName16
;
3834 return Commdlg_GetFileName32A(dofunction
,ofn
);
3837 /***********************************************************************
3838 * GetOpenFileName32W (COMDLG32.11)
3840 BOOL32 WINAPI
GetOpenFileName32W( LPOPENFILENAME32W ofn
)
3842 BOOL16 (WINAPI
* dofunction
)(SEGPTR ofn16
) = GetOpenFileName16
;
3843 return Commdlg_GetFileName32W(dofunction
,ofn
);
3846 /***********************************************************************
3847 * GetSaveFileName32A (COMDLG32.12)
3849 BOOL32 WINAPI
GetSaveFileName32A( LPOPENFILENAME32A ofn
)
3851 BOOL16 (WINAPI
* dofunction
)(SEGPTR ofn16
) = GetSaveFileName16
;
3852 return Commdlg_GetFileName32A(dofunction
,ofn
);
3855 /***********************************************************************
3856 * GetSaveFileName32W (COMDLG32.13)
3858 BOOL32 WINAPI
GetSaveFileName32W( LPOPENFILENAME32W ofn
)
3860 BOOL16 (WINAPI
* dofunction
)(SEGPTR ofn16
) = GetSaveFileName16
;
3861 return Commdlg_GetFileName32W(dofunction
,ofn
);
3864 /***********************************************************************
3865 * ChooseColorA (COMDLG32.1)
3867 BOOL32 WINAPI
ChooseColor32A(LPCHOOSECOLOR32A lpChCol
)
3872 COLORREF
* ccref
=SEGPTR_ALLOC(64);
3873 LPCHOOSECOLOR16 lpcc16
=SEGPTR_ALLOC(sizeof(CHOOSECOLOR16
));
3875 memset(lpcc16
,'\0',sizeof(*lpcc16
));
3876 lpcc16
->lStructSize
=sizeof(*lpcc16
);
3877 lpcc16
->hwndOwner
=lpChCol
->hwndOwner
;
3878 lpcc16
->hInstance
=0; /* FIXME:MODULE_HANDLEtoHMODULE16(lpChCol->hInstance)*/
3879 lpcc16
->rgbResult
=lpChCol
->rgbResult
;
3880 memcpy(ccref
,lpChCol
->lpCustColors
,64);
3881 lpcc16
->lpCustColors
=(COLORREF
*)SEGPTR_GET(ccref
);
3882 lpcc16
->Flags
=lpChCol
->Flags
;
3883 lpcc16
->lCustData
=lpChCol
->lCustData
;
3884 lpcc16
->lpfnHook
=(WNDPROC16
)lpChCol
->lpfnHook
;
3885 if (lpChCol
->lpTemplateName
)
3886 str
= SEGPTR_STRDUP(lpChCol
->lpTemplateName
);
3887 lpcc16
->lpTemplateName
=SEGPTR_GET(str
);
3889 ret
= ChooseColor16(lpcc16
);
3892 memcpy(lpChCol
->lpCustColors
,ccref
,64);
3894 SEGPTR_FREE(lpcc16
);
3898 /***********************************************************************
3899 * ChooseColorW (COMDLG32.2)
3901 BOOL32 WINAPI
ChooseColor32W(LPCHOOSECOLOR32W lpChCol
)
3906 COLORREF
* ccref
=SEGPTR_ALLOC(64);
3907 LPCHOOSECOLOR16 lpcc16
=SEGPTR_ALLOC(sizeof(CHOOSECOLOR16
));
3909 memset(lpcc16
,'\0',sizeof(*lpcc16
));
3910 lpcc16
->lStructSize
=sizeof(*lpcc16
);
3911 lpcc16
->hwndOwner
=lpChCol
->hwndOwner
;
3912 lpcc16
->hInstance
=0; /*FIXME:MODULE_HANDLEtoHMODULE16(lpChCol->hInstance)*/
3913 lpcc16
->rgbResult
=lpChCol
->rgbResult
;
3914 memcpy(ccref
,lpChCol
->lpCustColors
,64);
3915 lpcc16
->lpCustColors
=(COLORREF
*)SEGPTR_GET(ccref
);
3916 lpcc16
->Flags
=lpChCol
->Flags
;
3917 lpcc16
->lCustData
=lpChCol
->lCustData
;
3918 lpcc16
->lpfnHook
=(WNDPROC16
)lpChCol
->lpfnHook
;
3919 if (lpChCol
->lpTemplateName
)
3920 str
= SEGPTR_STRDUP_WtoA(lpChCol
->lpTemplateName
);
3921 lpcc16
->lpTemplateName
=SEGPTR_GET(str
);
3923 ret
= ChooseColor16(lpcc16
);
3926 memcpy(lpChCol
->lpCustColors
,ccref
,64);
3928 SEGPTR_FREE(lpcc16
);