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;
32 /***********************************************************************
33 * FileDlg_Init [internal]
35 static BOOL32
FileDlg_Init()
37 static BOOL32 initialized
= 0;
40 if (!hFolder
) hFolder
= LoadBitmap16(0, MAKEINTRESOURCE(OBM_FOLDER
));
41 if (!hFolder2
) hFolder2
= LoadBitmap16(0, MAKEINTRESOURCE(OBM_FOLDER2
));
42 if (!hFloppy
) hFloppy
= LoadBitmap16(0, MAKEINTRESOURCE(OBM_FLOPPY
));
43 if (!hHDisk
) hHDisk
= LoadBitmap16(0, MAKEINTRESOURCE(OBM_HDISK
));
44 if (!hCDRom
) hCDRom
= LoadBitmap16(0, MAKEINTRESOURCE(OBM_CDROM
));
45 if (hFolder
== 0 || hFolder2
== 0 || hFloppy
== 0 ||
46 hHDisk
== 0 || hCDRom
== 0)
48 fprintf(stderr
, "FileDlg_Init // Error loading bitmaps !");
56 /***********************************************************************
57 * GetOpenFileName (COMMDLG.1)
59 BOOL16 WINAPI
GetOpenFileName16( SEGPTR ofn
)
62 HANDLE32 hDlgTmpl
= 0, hResInfo
;
63 BOOL32 bRet
= FALSE
, win32Format
= FALSE
;
65 LPOPENFILENAME16 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(ofn
);
68 if (!lpofn
|| !FileDlg_Init()) return FALSE
;
70 if (lpofn
->Flags
& OFN_WINE32
) {
71 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
)
73 if (!(template = LockResource32( lpofn
->hInstance
)))
75 CommDlgLastError
= CDERR_LOADRESFAILURE
;
79 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
81 if (!(hResInfo
= FindResource32A(lpofn
->hInstance
,
82 PTR_SEG_TO_LIN(lpofn
->lpTemplateName
), (LPSTR
)RT_DIALOG
)))
84 CommDlgLastError
= CDERR_FINDRESFAILURE
;
87 if (!(hDlgTmpl
= LoadResource32( lpofn
->hInstance
, hResInfo
)) ||
88 !(template = LockResource32( hDlgTmpl
)))
90 CommDlgLastError
= CDERR_LOADRESFAILURE
;
94 template = SYSRES_GetResPtr( SYSRES_DIALOG_OPEN_FILE
);
98 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
)
100 if (!(template = LockResource16( lpofn
->hInstance
)))
102 CommDlgLastError
= CDERR_LOADRESFAILURE
;
106 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
108 if (!(hResInfo
= FindResource16(lpofn
->hInstance
,
109 lpofn
->lpTemplateName
, RT_DIALOG
)))
111 CommDlgLastError
= CDERR_FINDRESFAILURE
;
114 if (!(hDlgTmpl
= LoadResource16( lpofn
->hInstance
, hResInfo
)) ||
115 !(template = LockResource16( hDlgTmpl
)))
117 CommDlgLastError
= CDERR_LOADRESFAILURE
;
121 template = SYSRES_GetResPtr( SYSRES_DIALOG_OPEN_FILE
);
126 hInst
= WIN_GetWindowInstance( lpofn
->hwndOwner
);
127 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, win32Format
,
129 (DLGPROC16
)MODULE_GetWndProcEntry16("FileOpenDlgProc"),
131 if (hwndDialog
) bRet
= DIALOG_DoDialogBox( hwndDialog
, lpofn
->hwndOwner
);
134 if (lpofn
->Flags
& OFN_WINE32
)
135 FreeResource32( hDlgTmpl
);
137 FreeResource16( hDlgTmpl
);
140 dprintf_commdlg(stddeb
,"GetOpenFileName // return lpstrFile='%s' !\n",
141 (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFile
));
146 /***********************************************************************
147 * GetSaveFileName (COMMDLG.2)
149 BOOL16 WINAPI
GetSaveFileName16( SEGPTR ofn
)
152 HANDLE32 hDlgTmpl
= 0;
153 BOOL32 bRet
= FALSE
, win32Format
= FALSE
;
154 LPOPENFILENAME16 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(ofn
);
158 if (!lpofn
|| !FileDlg_Init()) return FALSE
;
160 if (lpofn
->Flags
& OFN_WINE32
) {
161 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
)
163 if (!(template = LockResource32( lpofn
->hInstance
)))
165 CommDlgLastError
= CDERR_LOADRESFAILURE
;
169 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
172 if (!(hResInfo
= FindResource32A(lpofn
->hInstance
,
173 PTR_SEG_TO_LIN(lpofn
->lpTemplateName
), (LPSTR
)RT_DIALOG
)))
175 CommDlgLastError
= CDERR_FINDRESFAILURE
;
178 if (!(hDlgTmpl
= LoadResource32(lpofn
->hInstance
,hResInfo
)) ||
179 !(template = LockResource32(hDlgTmpl
)))
181 CommDlgLastError
= CDERR_LOADRESFAILURE
;
186 template = SYSRES_GetResPtr( SYSRES_DIALOG_SAVE_FILE
);
190 if (lpofn
->Flags
& OFN_ENABLETEMPLATEHANDLE
)
192 if (!(template = LockResource16( lpofn
->hInstance
)))
194 CommDlgLastError
= CDERR_LOADRESFAILURE
;
198 else if (lpofn
->Flags
& OFN_ENABLETEMPLATE
)
201 if (!(hResInfo
= FindResource16(lpofn
->hInstance
,
202 lpofn
->lpTemplateName
, RT_DIALOG
)))
204 CommDlgLastError
= CDERR_FINDRESFAILURE
;
207 if (!(hDlgTmpl
= LoadResource16( lpofn
->hInstance
, hResInfo
)) ||
208 !(template = LockResource16( hDlgTmpl
)))
210 CommDlgLastError
= CDERR_LOADRESFAILURE
;
214 template = SYSRES_GetResPtr( SYSRES_DIALOG_SAVE_FILE
);
219 hInst
= WIN_GetWindowInstance( lpofn
->hwndOwner
);
221 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, win32Format
,
223 (DLGPROC16
)MODULE_GetWndProcEntry16("FileSaveDlgProc"),
225 if (hwndDialog
) bRet
= DIALOG_DoDialogBox( hwndDialog
, lpofn
->hwndOwner
);
228 if (lpofn
->Flags
& OFN_WINE32
)
229 FreeResource32( hDlgTmpl
);
231 FreeResource16( hDlgTmpl
);
234 dprintf_commdlg(stddeb
, "GetSaveFileName // return lpstrFile='%s' !\n",
235 (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFile
));
239 /***********************************************************************
240 * FILEDLG_StripEditControl [internal]
241 * Strip pathnames off the contents of the edit control.
243 static void FILEDLG_StripEditControl(HWND16 hwnd
)
247 GetDlgItemText32A( hwnd
, edt1
, temp
, sizeof(temp
) );
248 cp
= strrchr(temp
, '\\');
252 cp
= strrchr(temp
, ':');
256 /* FIXME: shouldn't we do something with the result here? ;-) */
259 /***********************************************************************
260 * FILEDLG_ScanDir [internal]
262 static BOOL32
FILEDLG_ScanDir(HWND16 hWnd
, LPSTR newPath
)
267 lstrcpyn32A( str
, newPath
, 512 );
269 GetDlgItemText32A( hWnd
, edt1
, str
+ len
, sizeof(str
) - len
);
270 if (!DlgDirList32A( hWnd
, str
, lst1
, 0, 0x0000 )) return FALSE
;
271 strcpy( str
, "*.*" );
272 return DlgDirList32A( hWnd
, str
, lst2
, stc1
, 0x8010 );
275 /***********************************************************************
276 * FILEDLG_GetFileType [internal]
279 static LPSTR
FILEDLG_GetFileType(LPSTR cfptr
, LPSTR fptr
, WORD index
)
284 for ( ;(n
= strlen(cfptr
)) != 0; i
++)
289 cfptr
+= strlen(cfptr
) + 1;
292 for ( ;(n
= strlen(fptr
)) != 0; i
++)
297 fptr
+= strlen(fptr
) + 1;
299 return "*.*"; /* FIXME */
302 /***********************************************************************
303 * FILEDLG_WMDrawItem [internal]
305 static LONG
FILEDLG_WMDrawItem(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
,int savedlg
)
307 LPDRAWITEMSTRUCT16 lpdis
= (LPDRAWITEMSTRUCT16
)PTR_SEG_TO_LIN(lParam
);
310 HBITMAP16 hBitmap
, hPrevBitmap
;
314 if (lpdis
->CtlType
== ODT_LISTBOX
&& lpdis
->CtlID
== lst1
)
316 if (!(str
= SEGPTR_ALLOC(512))) return FALSE
;
317 hBrush
= SelectObject32(lpdis
->hDC
, GetStockObject32(LTGRAY_BRUSH
));
318 SelectObject32(lpdis
->hDC
, hBrush
);
319 FillRect16(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
320 SendMessage16(lpdis
->hwndItem
, LB_GETTEXT16
, lpdis
->itemID
,
321 (LPARAM
)SEGPTR_GET(str
));
323 if (savedlg
) /* use _gray_ text in FileSaveDlg */
324 if (!lpdis
->itemState
)
325 SetTextColor32(lpdis
->hDC
,GetSysColor32(COLOR_GRAYTEXT
) );
327 SetTextColor32(lpdis
->hDC
,GetSysColor32(COLOR_WINDOWTEXT
) );
328 /* inversion of gray would be bad readable */
330 TextOut16(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
332 if (lpdis
->itemState
!= 0) {
333 InvertRect16(lpdis
->hDC
, &lpdis
->rcItem
);
339 if (lpdis
->CtlType
== ODT_LISTBOX
&& lpdis
->CtlID
== lst2
)
341 if (!(str
= SEGPTR_ALLOC(512))) return FALSE
;
342 hBrush
= SelectObject32(lpdis
->hDC
, GetStockObject32(LTGRAY_BRUSH
));
343 SelectObject32(lpdis
->hDC
, hBrush
);
344 FillRect16(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
345 SendMessage16(lpdis
->hwndItem
, LB_GETTEXT16
, lpdis
->itemID
,
346 (LPARAM
)SEGPTR_GET(str
));
349 GetObject16( hBitmap
, sizeof(bm
), &bm
);
350 TextOut16(lpdis
->hDC
, lpdis
->rcItem
.left
+ bm
.bmWidth
,
351 lpdis
->rcItem
.top
, str
, strlen(str
));
352 hMemDC
= CreateCompatibleDC32(lpdis
->hDC
);
353 hPrevBitmap
= SelectObject32(hMemDC
, hBitmap
);
354 BitBlt32(lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
355 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
356 SelectObject32(hMemDC
, hPrevBitmap
);
358 if (lpdis
->itemState
!= 0) InvertRect16(lpdis
->hDC
, &lpdis
->rcItem
);
362 if (lpdis
->CtlType
== ODT_COMBOBOX
&& lpdis
->CtlID
== cmb2
)
364 if (!(str
= SEGPTR_ALLOC(512))) return FALSE
;
365 hBrush
= SelectObject32(lpdis
->hDC
, GetStockObject32(LTGRAY_BRUSH
));
366 SelectObject32(lpdis
->hDC
, hBrush
);
367 FillRect16(lpdis
->hDC
, &lpdis
->rcItem
, hBrush
);
368 SendMessage16(lpdis
->hwndItem
, CB_GETLBTEXT16
, lpdis
->itemID
,
369 (LPARAM
)SEGPTR_GET(str
));
370 switch(DRIVE_GetType( str
[2] - 'a' ))
372 case TYPE_FLOPPY
: hBitmap
= hFloppy
; break;
373 case TYPE_CDROM
: hBitmap
= hCDRom
; break;
376 default: hBitmap
= hHDisk
; break;
378 GetObject16( hBitmap
, sizeof(bm
), &bm
);
379 TextOut16(lpdis
->hDC
, lpdis
->rcItem
.left
+ bm
.bmWidth
,
380 lpdis
->rcItem
.top
, str
, strlen(str
));
381 hMemDC
= CreateCompatibleDC32(lpdis
->hDC
);
382 hPrevBitmap
= SelectObject32(hMemDC
, hBitmap
);
383 BitBlt32( lpdis
->hDC
, lpdis
->rcItem
.left
, lpdis
->rcItem
.top
,
384 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
385 SelectObject32(hMemDC
, hPrevBitmap
);
387 if (lpdis
->itemState
!= 0) InvertRect16(lpdis
->hDC
, &lpdis
->rcItem
);
394 /***********************************************************************
395 * FILEDLG_WMMeasureItem [internal]
397 static LONG
FILEDLG_WMMeasureItem(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
)
400 LPMEASUREITEMSTRUCT16 lpmeasure
;
402 GetObject16( hFolder2
, sizeof(bm
), &bm
);
403 lpmeasure
= (LPMEASUREITEMSTRUCT16
)PTR_SEG_TO_LIN(lParam
);
404 lpmeasure
->itemHeight
= bm
.bmHeight
;
408 /***********************************************************************
409 * FILEDLG_HookCallChk [internal]
411 static int FILEDLG_HookCallChk(LPOPENFILENAME16 lpofn
)
414 if (lpofn
->Flags
& OFN_ENABLEHOOK
)
420 /***********************************************************************
421 * FILEDLG_CallWindowProc [internal]
423 * Adapt the structures back for win32 calls so the callee can read lpCustData
425 static BOOL32
FILEDLG_CallWindowProc(LPOPENFILENAME16 lpofn
,HWND32 hwnd
,
426 UINT32 wMsg
,WPARAM32 wParam
,LPARAM lParam
431 needstruct
= (PTR_SEG_TO_LIN(lParam
) == lpofn
);
433 if (!(lpofn
->Flags
& OFN_WINE32
))
434 return (BOOL32
)CallWindowProc16(
435 lpofn
->lpfnHook
,hwnd
,(UINT16
)wMsg
,(WPARAM16
)wParam
,lParam
438 if (lpofn
->Flags
& OFN_UNICODE
) {
440 OPENFILENAME32W ofnw
;
442 /* FIXME: probably needs more converted */
443 ofnw
.lCustData
= lpofn
->lCustData
;
444 return (BOOL32
)CallWindowProc32W(
445 (WNDPROC32
)lpofn
->lpfnHook
,hwnd
,wMsg
,wParam
,(LPARAM
)&ofnw
448 return (BOOL32
)CallWindowProc32W(
449 (WNDPROC32
)lpofn
->lpfnHook
,hwnd
,wMsg
,wParam
,lParam
454 OPENFILENAME32A ofna
;
456 /* FIXME: probably needs more converted */
457 ofna
.lCustData
= lpofn
->lCustData
;
458 return (BOOL32
)CallWindowProc32A(
459 (WNDPROC32
)lpofn
->lpfnHook
,hwnd
,wMsg
,wParam
,(LPARAM
)&ofna
462 return (BOOL32
)CallWindowProc32A(
463 (WNDPROC32
)lpofn
->lpfnHook
,hwnd
,wMsg
,wParam
,lParam
468 /***********************************************************************
469 * FILEDLG_WMInitDialog [internal]
472 static LONG
FILEDLG_WMInitDialog(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
)
475 LPOPENFILENAME16 lpofn
;
478 SetWindowLong32A(hWnd
, DWL_USER
, lParam
);
479 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(lParam
);
480 if (lpofn
->lpstrTitle
) SetWindowText16( hWnd
, lpofn
->lpstrTitle
);
481 /* read custom filter information */
482 if (lpofn
->lpstrCustomFilter
)
484 pstr
= (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
);
486 dprintf_commdlg(stddeb
,"lpstrCustomFilter = %p\n", pstr
);
489 dprintf_commdlg(stddeb
,"lpstrCustomFilter // add str='%s' ",pstr
);
490 i
= SendDlgItemMessage16(hWnd
, cmb1
, CB_ADDSTRING16
, 0,
491 (LPARAM
)lpofn
->lpstrCustomFilter
+ n
);
492 n
+= strlen(pstr
) + 1;
493 pstr
+= strlen(pstr
) + 1;
494 dprintf_commdlg(stddeb
,"associated to '%s'\n", pstr
);
495 SendDlgItemMessage16(hWnd
, cmb1
, CB_SETITEMDATA16
, i
, (LPARAM
)pstr
);
496 n
+= strlen(pstr
) + 1;
497 pstr
+= strlen(pstr
) + 1;
500 /* read filter information */
501 if (lpofn
->lpstrFilter
) {
502 pstr
= (LPSTR
)PTR_SEG_TO_LIN(lpofn
->lpstrFilter
);
505 dprintf_commdlg(stddeb
,"lpstrFilter // add str='%s' ", pstr
);
506 i
= SendDlgItemMessage16(hWnd
, cmb1
, CB_ADDSTRING16
, 0,
507 (LPARAM
)lpofn
->lpstrFilter
+ n
);
508 n
+= strlen(pstr
) + 1;
509 pstr
+= strlen(pstr
) + 1;
510 dprintf_commdlg(stddeb
,"associated to '%s'\n", pstr
);
511 SendDlgItemMessage16(hWnd
, cmb1
, CB_SETITEMDATA16
, i
, (LPARAM
)pstr
);
512 n
+= strlen(pstr
) + 1;
513 pstr
+= strlen(pstr
) + 1;
516 /* set default filter */
517 if (lpofn
->nFilterIndex
== 0 && lpofn
->lpstrCustomFilter
== (SEGPTR
)NULL
)
518 lpofn
->nFilterIndex
= 1;
519 SendDlgItemMessage16(hWnd
, cmb1
, CB_SETCURSEL16
, lpofn
->nFilterIndex
- 1, 0);
520 strncpy(tmpstr
, FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
521 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
), lpofn
->nFilterIndex
- 1),511);
523 dprintf_commdlg(stddeb
,"nFilterIndex = %ld // SetText of edt1 to '%s'\n",
524 lpofn
->nFilterIndex
, tmpstr
);
525 SetDlgItemText32A( hWnd
, edt1
, tmpstr
);
528 DlgDirListComboBox32A(hWnd
, tmpstr
, cmb2
, 0, 0xC000);
529 /* read initial directory */
530 if (PTR_SEG_TO_LIN(lpofn
->lpstrInitialDir
) != NULL
)
532 strncpy(tmpstr
, PTR_SEG_TO_LIN(lpofn
->lpstrInitialDir
), 510);
534 if (strlen(tmpstr
) > 0 && tmpstr
[strlen(tmpstr
)-1] != '\\'
535 && tmpstr
[strlen(tmpstr
)-1] != ':')
540 if (!FILEDLG_ScanDir(hWnd
, tmpstr
))
541 fprintf(stderr
, "FileDlg: couldn't read initial directory %s!\n", tmpstr
);
542 /* select current drive in combo 2 */
543 n
= DRIVE_GetCurrentDrive();
544 SendDlgItemMessage16(hWnd
, cmb2
, CB_SETCURSEL16
, n
, 0);
545 if (!(lpofn
->Flags
& OFN_SHOWHELP
))
546 ShowWindow32(GetDlgItem32(hWnd
, pshHelp
), SW_HIDE
);
547 if (lpofn
->Flags
& OFN_HIDEREADONLY
)
548 ShowWindow32(GetDlgItem32(hWnd
, chx1
), SW_HIDE
);
549 if (FILEDLG_HookCallChk(lpofn
))
550 return (BOOL16
)FILEDLG_CallWindowProc(lpofn
,hWnd
,WM_INITDIALOG
,wParam
,lParam
);
555 /***********************************************************************
556 * FILEDLG_WMCommand [internal]
558 static LRESULT
FILEDLG_WMCommand(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
)
561 LPOPENFILENAME16 lpofn
;
563 char tmpstr
[512], tmpstr2
[512];
565 UINT16 control
,notification
;
567 /* Notifications are packaged differently in Win32 */
569 notification
= HIWORD(lParam
);
571 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
574 case lst1
: /* file list */
575 FILEDLG_StripEditControl(hWnd
);
576 if (notification
== LBN_DBLCLK
)
578 lRet
= SendDlgItemMessage16(hWnd
, lst1
, LB_GETCURSEL16
, 0, 0);
579 if (lRet
== LB_ERR
) return TRUE
;
580 if ((pstr
= SEGPTR_ALLOC(512)))
582 SendDlgItemMessage16(hWnd
, lst1
, LB_GETTEXT16
, lRet
,
583 (LPARAM
)SEGPTR_GET(pstr
));
584 SetDlgItemText32A( hWnd
, edt1
, pstr
);
587 if (FILEDLG_HookCallChk(lpofn
))
588 FILEDLG_CallWindowProc(lpofn
,hWnd
,
589 RegisterWindowMessage32A( LBSELCHSTRING
),
590 control
, MAKELONG(lRet
,CD_LBSELCHANGE
));
591 /* FIXME: for OFN_ALLOWMULTISELECT we need CD_LBSELSUB, CD_SELADD, CD_LBSELNOITEMS */
593 case lst2
: /* directory list */
594 FILEDLG_StripEditControl(hWnd
);
595 if (notification
== LBN_DBLCLK
)
597 lRet
= SendDlgItemMessage16(hWnd
, lst2
, LB_GETCURSEL16
, 0, 0);
598 if (lRet
== LB_ERR
) return TRUE
;
599 pstr
= SEGPTR_ALLOC(512);
600 SendDlgItemMessage16(hWnd
, lst2
, LB_GETTEXT16
, lRet
,
601 (LPARAM
)SEGPTR_GET(pstr
));
602 strcpy( tmpstr
, pstr
);
604 if (tmpstr
[0] == '[')
606 tmpstr
[strlen(tmpstr
) - 1] = 0;
607 strcpy(tmpstr
,tmpstr
+1);
609 strcat(tmpstr
, "\\");
613 case cmb1
: /* file type drop list */
614 if (notification
== CBN_SELCHANGE
)
620 case cmb2
: /* disk drop list */
621 FILEDLG_StripEditControl(hWnd
);
622 lRet
= SendDlgItemMessage16(hWnd
, cmb2
, CB_GETCURSEL16
, 0, 0L);
623 if (lRet
== LB_ERR
) return 0;
624 pstr
= SEGPTR_ALLOC(512);
625 SendDlgItemMessage16(hWnd
, cmb2
, CB_GETLBTEXT16
, lRet
,
626 (LPARAM
)SEGPTR_GET(pstr
));
627 sprintf(tmpstr
, "%c:", pstr
[2]);
630 lRet
= SendDlgItemMessage16(hWnd
, cmb1
, CB_GETCURSEL16
, 0, 0);
633 pstr
= (LPSTR
)SendDlgItemMessage16(hWnd
, cmb1
, CB_GETITEMDATA16
, lRet
, 0);
634 dprintf_commdlg(stddeb
,"Selected filter : %s\n", pstr
);
635 SetDlgItemText32A( hWnd
, edt1
, pstr
);
636 FILEDLG_ScanDir(hWnd
, tmpstr
);
644 ofn2
=*lpofn
; /* for later restoring */
645 GetDlgItemText32A( hWnd
, edt1
, tmpstr
, sizeof(tmpstr
) );
646 pstr
= strrchr(tmpstr
, '\\');
648 pstr
= strrchr(tmpstr
, ':');
649 if (strchr(tmpstr
,'*') != NULL
|| strchr(tmpstr
,'?') != NULL
)
651 /* edit control contains wildcards */
654 strncpy(tmpstr2
, pstr
+1, 511); tmpstr2
[511]=0;
659 strcpy(tmpstr2
, tmpstr
);
662 dprintf_commdlg(stddeb
,"commdlg: %s, %s\n", tmpstr
, tmpstr2
);
663 SetDlgItemText32A( hWnd
, edt1
, tmpstr2
);
664 FILEDLG_ScanDir(hWnd
, tmpstr
);
667 /* no wildcards, we might have a directory or a filename */
668 /* try appending a wildcard and reading the directory */
669 pstr2
= tmpstr
+ strlen(tmpstr
);
670 if (pstr
== NULL
|| *(pstr
+1) != 0)
671 strcat(tmpstr
, "\\");
672 lRet
= SendDlgItemMessage16(hWnd
, cmb1
, CB_GETCURSEL16
, 0, 0);
673 if (lRet
== LB_ERR
) return TRUE
;
674 lpofn
->nFilterIndex
= lRet
+ 1;
675 dprintf_commdlg(stddeb
,"commdlg: lpofn->nFilterIndex=%ld\n", lpofn
->nFilterIndex
);
677 FILEDLG_GetFileType(PTR_SEG_TO_LIN(lpofn
->lpstrCustomFilter
),
678 PTR_SEG_TO_LIN(lpofn
->lpstrFilter
),
679 lRet
), sizeof(tmpstr2
));
680 SetDlgItemText32A( hWnd
, edt1
, tmpstr2
);
681 /* if ScanDir succeeds, we have changed the directory */
682 if (FILEDLG_ScanDir(hWnd
, tmpstr
)) return TRUE
;
683 /* if not, this must be a filename */
687 /* strip off the pathname */
689 SetDlgItemText32A( hWnd
, edt1
, pstr
+ 1 );
690 lstrcpyn32A(tmpstr2
, pstr
+1, sizeof(tmpstr2
) );
691 /* Should we MessageBox() if this fails? */
692 if (!FILEDLG_ScanDir(hWnd
, tmpstr
)) return TRUE
;
693 strcpy(tmpstr
, tmpstr2
);
695 else SetDlgItemText32A( hWnd
, edt1
, tmpstr
);
697 ShowWindow16(hWnd
, SW_HIDE
); /* this should not be necessary ?! (%%%) */
700 int drive
= DRIVE_GetCurrentDrive();
701 tmpstr2
[0] = 'A'+ drive
;
704 strncpy(tmpstr2
+ 3, DRIVE_GetDosCwd(drive
), 507); tmpstr2
[510]=0;
705 if (strlen(tmpstr2
) > 3)
706 strcat(tmpstr2
, "\\");
707 strncat(tmpstr2
, tmpstr
, 511-strlen(tmpstr2
)); tmpstr2
[511]=0;
708 strcpy(PTR_SEG_TO_LIN(lpofn
->lpstrFile
), tmpstr2
);
710 lpofn
->nFileOffset
= 0;
711 lpofn
->nFileExtension
= 0;
712 while(tmpstr2
[lpofn
->nFileExtension
] != '.' && tmpstr2
[lpofn
->nFileExtension
] != '\0')
713 lpofn
->nFileExtension
++;
714 if (lpofn
->nFileExtension
== '\0')
715 lpofn
->nFileExtension
= 0;
717 lpofn
->nFileExtension
++;
718 if (PTR_SEG_TO_LIN(lpofn
->lpstrFileTitle
) != NULL
)
720 lRet
= SendDlgItemMessage16(hWnd
, lst1
, LB_GETCURSEL16
, 0, 0);
721 SendDlgItemMessage16(hWnd
, lst1
, LB_GETTEXT16
, lRet
,
722 lpofn
->lpstrFileTitle
);
724 if (FILEDLG_HookCallChk(lpofn
))
726 lRet
= (BOOL16
)FILEDLG_CallWindowProc(lpofn
,
727 hWnd
, RegisterWindowMessage32A( FILEOKSTRING
), 0, lParam
);
730 *lpofn
=ofn2
; /* restore old state */
732 ShowWindow16(hWnd
, SW_SHOW
); /* only if above (%%%) SW_HIDE used */
737 EndDialog32(hWnd
, TRUE
);
740 EndDialog32(hWnd
, FALSE
);
747 /***********************************************************************
748 * FileOpenDlgProc (COMMDLG.6)
750 LRESULT WINAPI
FileOpenDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
753 LPOPENFILENAME16 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
755 if (wMsg
!=WM_INITDIALOG
)
756 if (FILEDLG_HookCallChk(lpofn
))
758 LRESULT lRet
=(BOOL16
)FILEDLG_CallWindowProc(lpofn
,hWnd
,wMsg
,wParam
,lParam
);
760 return lRet
; /* else continue message processing */
765 return FILEDLG_WMInitDialog(hWnd
, wParam
, lParam
);
767 return FILEDLG_WMMeasureItem(hWnd
, wParam
, lParam
);
769 return FILEDLG_WMDrawItem(hWnd
, wParam
, lParam
, FALSE
);
771 return FILEDLG_WMCommand(hWnd
, wParam
, lParam
);
774 SetBkColor((HDC16
)wParam
, 0x00C0C0C0);
775 switch (HIWORD(lParam
))
778 SetTextColor((HDC16
)wParam
, 0x00000000);
780 case CTLCOLOR_STATIC
:
781 SetTextColor((HDC16
)wParam
, 0x00000000);
791 /***********************************************************************
792 * FileSaveDlgProc (COMMDLG.7)
794 LRESULT WINAPI
FileSaveDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
797 LPOPENFILENAME16 lpofn
= (LPOPENFILENAME16
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
799 if (wMsg
!=WM_INITDIALOG
)
800 if (FILEDLG_HookCallChk(lpofn
))
802 LRESULT lRet
=(BOOL16
)FILEDLG_CallWindowProc(lpofn
,hWnd
,wMsg
,wParam
,lParam
);
804 return lRet
; /* else continue message processing */
808 return FILEDLG_WMInitDialog(hWnd
, wParam
, lParam
);
811 return FILEDLG_WMMeasureItem(hWnd
, wParam
, lParam
);
814 return FILEDLG_WMDrawItem(hWnd
, wParam
, lParam
, TRUE
);
817 return FILEDLG_WMCommand(hWnd
, wParam
, lParam
);
822 SetBkColor((HDC16)wParam, 0x00C0C0C0);
823 switch (HIWORD(lParam))
826 SetTextColor((HDC16)wParam, 0x00000000);
828 case CTLCOLOR_STATIC:
829 SetTextColor((HDC16)wParam, 0x00000000);
839 /***********************************************************************
840 * FindTextDlg (COMMDLG.11)
842 HWND16 WINAPI
FindText( SEGPTR find
)
846 LPFINDREPLACE lpFind
= (LPFINDREPLACE
)PTR_SEG_TO_LIN(find
);
849 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
850 * For now, only the standard dialog works.
853 * FIXME : We should do error checking on the lpFind structure here
854 * and make CommDlgExtendedError() return the error condition.
856 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_FIND_TEXT
);
857 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
858 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
859 (DLGPROC16
)MODULE_GetWndProcEntry16("FindTextDlgProc"),
864 /***********************************************************************
865 * ReplaceText (COMMDLG.12)
867 HWND16 WINAPI
ReplaceText( SEGPTR find
)
871 LPFINDREPLACE lpFind
= (LPFINDREPLACE
)PTR_SEG_TO_LIN(find
);
874 * FIXME : Should respond to FR_ENABLETEMPLATE and FR_ENABLEHOOK here
875 * For now, only the standard dialog works.
878 * FIXME : We should do error checking on the lpFind structure here
879 * and make CommDlgExtendedError() return the error condition.
881 ptr
= SYSRES_GetResPtr( SYSRES_DIALOG_REPLACE_TEXT
);
882 hInst
= WIN_GetWindowInstance( lpFind
->hwndOwner
);
883 return DIALOG_CreateIndirect( hInst
, ptr
, TRUE
, lpFind
->hwndOwner
,
884 (DLGPROC16
)MODULE_GetWndProcEntry16("ReplaceTextDlgProc"),
889 /***********************************************************************
890 * FINDDLG_WMInitDialog [internal]
892 static LRESULT
FINDDLG_WMInitDialog(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
)
896 SetWindowLong32A(hWnd
, DWL_USER
, lParam
);
897 lpfr
= (LPFINDREPLACE
)PTR_SEG_TO_LIN(lParam
);
898 lpfr
->Flags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_REPLACEALL
| FR_DIALOGTERM
);
900 * FIXME : If the initial FindWhat string is empty, we should disable the
901 * FindNext (IDOK) button. Only after typing some text, the button should be
904 SetDlgItemText16(hWnd
, edt1
, lpfr
->lpstrFindWhat
);
905 CheckRadioButton32(hWnd
, rad1
, rad2
, (lpfr
->Flags
& FR_DOWN
) ? rad2
: rad1
);
906 if (lpfr
->Flags
& (FR_HIDEUPDOWN
| FR_NOUPDOWN
)) {
907 EnableWindow32(GetDlgItem32(hWnd
, rad1
), FALSE
);
908 EnableWindow32(GetDlgItem32(hWnd
, rad2
), FALSE
);
910 if (lpfr
->Flags
& FR_HIDEUPDOWN
) {
911 ShowWindow32(GetDlgItem32(hWnd
, rad1
), SW_HIDE
);
912 ShowWindow32(GetDlgItem32(hWnd
, rad2
), SW_HIDE
);
913 ShowWindow32(GetDlgItem32(hWnd
, grp1
), SW_HIDE
);
915 CheckDlgButton32(hWnd
, chx1
, (lpfr
->Flags
& FR_WHOLEWORD
) ? 1 : 0);
916 if (lpfr
->Flags
& (FR_HIDEWHOLEWORD
| FR_NOWHOLEWORD
))
917 EnableWindow32(GetDlgItem32(hWnd
, chx1
), FALSE
);
918 if (lpfr
->Flags
& FR_HIDEWHOLEWORD
)
919 ShowWindow32(GetDlgItem32(hWnd
, chx1
), SW_HIDE
);
920 CheckDlgButton32(hWnd
, chx2
, (lpfr
->Flags
& FR_MATCHCASE
) ? 1 : 0);
921 if (lpfr
->Flags
& (FR_HIDEMATCHCASE
| FR_NOMATCHCASE
))
922 EnableWindow32(GetDlgItem32(hWnd
, chx2
), FALSE
);
923 if (lpfr
->Flags
& FR_HIDEMATCHCASE
)
924 ShowWindow32(GetDlgItem32(hWnd
, chx2
), SW_HIDE
);
925 if (!(lpfr
->Flags
& FR_SHOWHELP
)) {
926 EnableWindow32(GetDlgItem32(hWnd
, pshHelp
), FALSE
);
927 ShowWindow32(GetDlgItem32(hWnd
, pshHelp
), SW_HIDE
);
929 ShowWindow32(hWnd
, SW_SHOWNORMAL
);
934 /***********************************************************************
935 * FINDDLG_WMCommand [internal]
937 static LRESULT
FINDDLG_WMCommand(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
)
940 int uFindReplaceMessage
= RegisterWindowMessage32A( FINDMSGSTRING
);
941 int uHelpMessage
= RegisterWindowMessage32A( HELPMSGSTRING
);
943 lpfr
= (LPFINDREPLACE
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
946 GetDlgItemText16(hWnd
, edt1
, lpfr
->lpstrFindWhat
, lpfr
->wFindWhatLen
);
947 if (IsDlgButtonChecked32(hWnd
, rad2
))
948 lpfr
->Flags
|= FR_DOWN
;
949 else lpfr
->Flags
&= ~FR_DOWN
;
950 if (IsDlgButtonChecked32(hWnd
, chx1
))
951 lpfr
->Flags
|= FR_WHOLEWORD
;
952 else lpfr
->Flags
&= ~FR_WHOLEWORD
;
953 if (IsDlgButtonChecked32(hWnd
, chx2
))
954 lpfr
->Flags
|= FR_MATCHCASE
;
955 else lpfr
->Flags
&= ~FR_MATCHCASE
;
956 lpfr
->Flags
&= ~(FR_REPLACE
| FR_REPLACEALL
| FR_DIALOGTERM
);
957 lpfr
->Flags
|= FR_FINDNEXT
;
958 SendMessage16(lpfr
->hwndOwner
, uFindReplaceMessage
, 0,
959 GetWindowLong32A(hWnd
, DWL_USER
) );
962 lpfr
->Flags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_REPLACEALL
);
963 lpfr
->Flags
|= FR_DIALOGTERM
;
964 SendMessage16(lpfr
->hwndOwner
, uFindReplaceMessage
, 0,
965 GetWindowLong32A(hWnd
, DWL_USER
) );
966 DestroyWindow16(hWnd
);
969 /* FIXME : should lpfr structure be passed as an argument ??? */
970 SendMessage16(lpfr
->hwndOwner
, uHelpMessage
, 0, 0);
977 /***********************************************************************
978 * FindTextDlgProc (COMMDLG.13)
980 LRESULT WINAPI
FindTextDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
985 return FINDDLG_WMInitDialog(hWnd
, wParam
, lParam
);
987 return FINDDLG_WMCommand(hWnd
, wParam
, lParam
);
993 /***********************************************************************
994 * REPLACEDLG_WMInitDialog [internal]
996 static LRESULT
REPLACEDLG_WMInitDialog(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
)
1000 SetWindowLong32A(hWnd
, DWL_USER
, lParam
);
1001 lpfr
= (LPFINDREPLACE
)PTR_SEG_TO_LIN(lParam
);
1002 lpfr
->Flags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_REPLACEALL
| FR_DIALOGTERM
);
1004 * FIXME : If the initial FindWhat string is empty, we should disable the FinNext /
1005 * Replace / ReplaceAll buttons. Only after typing some text, the buttons should be
1008 SetDlgItemText16(hWnd
, edt1
, lpfr
->lpstrFindWhat
);
1009 SetDlgItemText16(hWnd
, edt2
, lpfr
->lpstrReplaceWith
);
1010 CheckDlgButton32(hWnd
, chx1
, (lpfr
->Flags
& FR_WHOLEWORD
) ? 1 : 0);
1011 if (lpfr
->Flags
& (FR_HIDEWHOLEWORD
| FR_NOWHOLEWORD
))
1012 EnableWindow32(GetDlgItem32(hWnd
, chx1
), FALSE
);
1013 if (lpfr
->Flags
& FR_HIDEWHOLEWORD
)
1014 ShowWindow32(GetDlgItem32(hWnd
, chx1
), SW_HIDE
);
1015 CheckDlgButton32(hWnd
, chx2
, (lpfr
->Flags
& FR_MATCHCASE
) ? 1 : 0);
1016 if (lpfr
->Flags
& (FR_HIDEMATCHCASE
| FR_NOMATCHCASE
))
1017 EnableWindow32(GetDlgItem32(hWnd
, chx2
), FALSE
);
1018 if (lpfr
->Flags
& FR_HIDEMATCHCASE
)
1019 ShowWindow32(GetDlgItem32(hWnd
, chx2
), SW_HIDE
);
1020 if (!(lpfr
->Flags
& FR_SHOWHELP
)) {
1021 EnableWindow32(GetDlgItem32(hWnd
, pshHelp
), FALSE
);
1022 ShowWindow32(GetDlgItem32(hWnd
, pshHelp
), SW_HIDE
);
1024 ShowWindow32(hWnd
, SW_SHOWNORMAL
);
1029 /***********************************************************************
1030 * REPLACEDLG_WMCommand [internal]
1032 static LRESULT
REPLACEDLG_WMCommand(HWND16 hWnd
, WPARAM16 wParam
, LPARAM lParam
)
1035 int uFindReplaceMessage
= RegisterWindowMessage32A( FINDMSGSTRING
);
1036 int uHelpMessage
= RegisterWindowMessage32A( HELPMSGSTRING
);
1038 lpfr
= (LPFINDREPLACE
)PTR_SEG_TO_LIN(GetWindowLong32A(hWnd
, DWL_USER
));
1041 GetDlgItemText16(hWnd
, edt1
, lpfr
->lpstrFindWhat
, lpfr
->wFindWhatLen
);
1042 GetDlgItemText16(hWnd
, edt2
, lpfr
->lpstrReplaceWith
, lpfr
->wReplaceWithLen
);
1043 if (IsDlgButtonChecked32(hWnd
, chx1
))
1044 lpfr
->Flags
|= FR_WHOLEWORD
;
1045 else lpfr
->Flags
&= ~FR_WHOLEWORD
;
1046 if (IsDlgButtonChecked32(hWnd
, chx2
))
1047 lpfr
->Flags
|= FR_MATCHCASE
;
1048 else lpfr
->Flags
&= ~FR_MATCHCASE
;
1049 lpfr
->Flags
&= ~(FR_REPLACE
| FR_REPLACEALL
| FR_DIALOGTERM
);
1050 lpfr
->Flags
|= FR_FINDNEXT
;
1051 SendMessage16(lpfr
->hwndOwner
, uFindReplaceMessage
, 0,
1052 GetWindowLong32A(hWnd
, DWL_USER
) );
1055 lpfr
->Flags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_REPLACEALL
);
1056 lpfr
->Flags
|= FR_DIALOGTERM
;
1057 SendMessage16(lpfr
->hwndOwner
, uFindReplaceMessage
, 0,
1058 GetWindowLong32A(hWnd
, DWL_USER
) );
1059 DestroyWindow16(hWnd
);
1062 GetDlgItemText16(hWnd
, edt1
, lpfr
->lpstrFindWhat
, lpfr
->wFindWhatLen
);
1063 GetDlgItemText16(hWnd
, edt2
, lpfr
->lpstrReplaceWith
, lpfr
->wReplaceWithLen
);
1064 if (IsDlgButtonChecked32(hWnd
, chx1
))
1065 lpfr
->Flags
|= FR_WHOLEWORD
;
1066 else lpfr
->Flags
&= ~FR_WHOLEWORD
;
1067 if (IsDlgButtonChecked32(hWnd
, chx2
))
1068 lpfr
->Flags
|= FR_MATCHCASE
;
1069 else lpfr
->Flags
&= ~FR_MATCHCASE
;
1070 lpfr
->Flags
&= ~(FR_FINDNEXT
| FR_REPLACEALL
| FR_DIALOGTERM
);
1071 lpfr
->Flags
|= FR_REPLACE
;
1072 SendMessage16(lpfr
->hwndOwner
, uFindReplaceMessage
, 0,
1073 GetWindowLong32A(hWnd
, DWL_USER
) );
1076 GetDlgItemText16(hWnd
, edt1
, lpfr
->lpstrFindWhat
, lpfr
->wFindWhatLen
);
1077 GetDlgItemText16(hWnd
, edt2
, lpfr
->lpstrReplaceWith
, lpfr
->wReplaceWithLen
);
1078 if (IsDlgButtonChecked32(hWnd
, chx1
))
1079 lpfr
->Flags
|= FR_WHOLEWORD
;
1080 else lpfr
->Flags
&= ~FR_WHOLEWORD
;
1081 if (IsDlgButtonChecked32(hWnd
, chx2
))
1082 lpfr
->Flags
|= FR_MATCHCASE
;
1083 else lpfr
->Flags
&= ~FR_MATCHCASE
;
1084 lpfr
->Flags
&= ~(FR_FINDNEXT
| FR_REPLACE
| FR_DIALOGTERM
);
1085 lpfr
->Flags
|= FR_REPLACEALL
;
1086 SendMessage16(lpfr
->hwndOwner
, uFindReplaceMessage
, 0,
1087 GetWindowLong32A(hWnd
, DWL_USER
) );
1090 /* FIXME : should lpfr structure be passed as an argument ??? */
1091 SendMessage16(lpfr
->hwndOwner
, uHelpMessage
, 0, 0);
1098 /***********************************************************************
1099 * ReplaceTextDlgProc (COMMDLG.14)
1101 LRESULT WINAPI
ReplaceTextDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
1106 return REPLACEDLG_WMInitDialog(hWnd
, wParam
, lParam
);
1108 return REPLACEDLG_WMCommand(hWnd
, wParam
, lParam
);
1114 /***********************************************************************
1115 * PrintDlg16 (COMMDLG.20)
1117 BOOL16 WINAPI
PrintDlg16( SEGPTR printdlg
)
1120 BOOL16 bRet
= FALSE
;
1123 LPPRINTDLG16 lpPrint
= (LPPRINTDLG16
)PTR_SEG_TO_LIN(printdlg
);
1125 dprintf_commdlg(stddeb
,"PrintDlg(%p) // Flags=%08lX\n", lpPrint
, lpPrint
->Flags
);
1127 if (lpPrint
->Flags
& PD_RETURNDEFAULT
)
1128 /* FIXME: should fill lpPrint->hDevMode and lpPrint->hDevNames here */
1131 if (lpPrint
->Flags
& PD_PRINTSETUP
)
1132 template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT_SETUP
);
1134 template = SYSRES_GetResPtr( SYSRES_DIALOG_PRINT
);
1136 hInst
= WIN_GetWindowInstance( lpPrint
->hwndOwner
);
1137 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, TRUE
,
1139 (DLGPROC16
)((lpPrint
->Flags
& PD_PRINTSETUP
) ?
1140 MODULE_GetWndProcEntry16("PrintSetupDlgProc") :
1141 MODULE_GetWndProcEntry16("PrintDlgProc")),
1142 printdlg
, WIN_PROC_16
);
1143 if (hwndDialog
) bRet
= DIALOG_DoDialogBox( hwndDialog
, lpPrint
->hwndOwner
);
1148 /***********************************************************************
1149 * PrintDlg32A (COMDLG32.17)
1151 BOOL32 WINAPI
PrintDlg32A( LPPRINTDLG32A printdlg
)
1153 fprintf( stdnimp
, "PrintDlg32A: empty stub\n" );
1158 /***********************************************************************
1159 * PrintDlg32W (COMDLG32.18)
1161 BOOL32 WINAPI
PrintDlg32W( LPPRINTDLG32W printdlg
)
1163 fprintf( stdnimp
, "PrintDlg32A: empty stub\n" );
1168 /***********************************************************************
1169 * PrintDlgProc (COMMDLG.21)
1171 LRESULT WINAPI
PrintDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
1177 dprintf_commdlg(stddeb
,"PrintDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
1178 ShowWindow16(hWnd
, SW_SHOWNORMAL
);
1184 EndDialog32(hWnd
, TRUE
);
1187 EndDialog32(hWnd
, FALSE
);
1196 /***********************************************************************
1197 * PrintSetupDlgProc (COMMDLG.22)
1199 LRESULT WINAPI
PrintSetupDlgProc(HWND16 hWnd
, UINT16 wMsg
, WPARAM16 wParam
,
1205 dprintf_commdlg(stddeb
,"PrintSetupDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
1206 ShowWindow16(hWnd
, SW_SHOWNORMAL
);
1211 EndDialog32(hWnd
, TRUE
);
1214 EndDialog32(hWnd
, FALSE
);
1223 /***********************************************************************
1224 * CommDlgExtendedError (COMMDLG.26)
1226 DWORD WINAPI
CommDlgExtendedError(void)
1228 return CommDlgLastError
;
1231 /***********************************************************************
1232 * GetFileTitleA (COMDLG32.8)
1234 short WINAPI
GetFileTitle32A(LPCSTR lpFile
, LPSTR lpTitle
, UINT32 cbBuf
)
1237 dprintf_commdlg(stddeb
,"GetFileTitle(%p %p %d); \n", lpFile
, lpTitle
, cbBuf
);
1238 if (lpFile
== NULL
|| lpTitle
== NULL
)
1240 len
= strlen(lpFile
);
1243 if (strpbrk(lpFile
, "*[]"))
1246 if (lpFile
[len
] == '/' || lpFile
[len
] == '\\' || lpFile
[len
] == ':')
1248 for (i
= len
; i
>= 0; i
--)
1249 if (lpFile
[i
] == '/' || lpFile
[i
] == '\\' || lpFile
[i
] == ':')
1254 dprintf_commdlg(stddeb
,"\n---> '%s' ", &lpFile
[i
]);
1256 len
= strlen(lpFile
+i
)+1;
1260 strncpy(lpTitle
, &lpFile
[i
], len
);
1265 /***********************************************************************
1266 * GetFileTitleA (COMDLG32.8)
1268 short WINAPI
GetFileTitle32W(LPCWSTR lpFile
, LPWSTR lpTitle
, UINT32 cbBuf
)
1270 LPSTR file
= HEAP_strdupWtoA(GetProcessHeap(),0,lpFile
);
1271 LPSTR title
= HeapAlloc(GetProcessHeap(),0,cbBuf
);
1274 ret
= GetFileTitle32A(file
,title
,cbBuf
);
1276 lstrcpynAtoW(lpTitle
,title
,cbBuf
);
1277 HeapFree(GetProcessHeap(),0,file
);
1278 HeapFree(GetProcessHeap(),0,title
);
1281 /***********************************************************************
1282 * GetFileTitle (COMMDLG.27)
1284 short WINAPI
GetFileTitle16(LPCSTR lpFile
, LPSTR lpTitle
, UINT16 cbBuf
)
1286 return GetFileTitle32A(lpFile
,lpTitle
,cbBuf
);
1290 /* ------------------------ Choose Color Dialog --------------------------- */
1292 /***********************************************************************
1293 * ChooseColor (COMMDLG.5)
1295 BOOL16 WINAPI
ChooseColor(LPCHOOSECOLOR lpChCol
)
1298 HANDLE16 hDlgTmpl
= 0;
1299 BOOL16 bRet
= FALSE
, win32Format
= FALSE
;
1303 dprintf_commdlg(stddeb
,"ChooseColor\n");
1304 if (!lpChCol
) return FALSE
;
1306 if (lpChCol
->Flags
& CC_ENABLETEMPLATEHANDLE
)
1308 if (!(template = LockResource16( lpChCol
->hInstance
)))
1310 CommDlgLastError
= CDERR_LOADRESFAILURE
;
1314 else if (lpChCol
->Flags
& CC_ENABLETEMPLATE
)
1317 if (!(hResInfo
= FindResource16(lpChCol
->hInstance
,
1318 lpChCol
->lpTemplateName
, RT_DIALOG
)))
1320 CommDlgLastError
= CDERR_FINDRESFAILURE
;
1323 if (!(hDlgTmpl
= LoadResource16( lpChCol
->hInstance
, hResInfo
)) ||
1324 !(template = LockResource16( hDlgTmpl
)))
1326 CommDlgLastError
= CDERR_LOADRESFAILURE
;
1332 template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_COLOR
);
1336 hInst
= WIN_GetWindowInstance( lpChCol
->hwndOwner
);
1337 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, win32Format
,
1339 (DLGPROC16
)MODULE_GetWndProcEntry16("ColorDlgProc"),
1340 (DWORD
)lpChCol
, WIN_PROC_16
);
1341 if (hwndDialog
) bRet
= DIALOG_DoDialogBox( hwndDialog
, lpChCol
->hwndOwner
);
1342 if (hDlgTmpl
) FreeResource16( hDlgTmpl
);
1347 static const COLORREF predefcolors
[6][8]=
1349 { 0x008080FFL
, 0x0080FFFFL
, 0x0080FF80L
, 0x0080FF00L
,
1350 0x00FFFF80L
, 0x00FF8000L
, 0x00C080FFL
, 0x00FF80FFL
},
1351 { 0x000000FFL
, 0x0000FFFFL
, 0x0000FF80L
, 0x0040FF00L
,
1352 0x00FFFF00L
, 0x00C08000L
, 0x00C08080L
, 0x00FF00FFL
},
1354 { 0x00404080L
, 0x004080FFL
, 0x0000FF00L
, 0x00808000L
,
1355 0x00804000L
, 0x00FF8080L
, 0x00400080L
, 0x008000FFL
},
1356 { 0x00000080L
, 0x000080FFL
, 0x00008000L
, 0x00408000L
,
1357 0x00FF0000L
, 0x00A00000L
, 0x00800080L
, 0x00FF0080L
},
1359 { 0x00000040L
, 0x00004080L
, 0x00004000L
, 0x00404000L
,
1360 0x00800000L
, 0x00400000L
, 0x00400040L
, 0x00800040L
},
1361 { 0x00000000L
, 0x00008080L
, 0x00408080L
, 0x00808080L
,
1362 0x00808040L
, 0x00C0C0C0L
, 0x00400040L
, 0x00FFFFFFL
},
1367 LPCHOOSECOLOR lpcc
; /* points to public known data structure */
1368 int nextuserdef
; /* next free place in user defined color array */
1369 HDC16 hdcMem
; /* color graph used for BitBlt() */
1370 HBITMAP16 hbmMem
; /* color graph bitmap */
1371 RECT16 fullsize
; /* original dialog window size */
1372 UINT16 msetrgb
; /* # of SETRGBSTRING message (today not used) */
1373 RECT16 old3angle
; /* last position of l-marker */
1374 RECT16 oldcross
; /* last position of color/satuation marker */
1375 BOOL32 updating
; /* to prevent recursive WM_COMMAND/EN_UPDATE procesing */
1378 int l
; /* for temporary storing of hue,sat,lum */
1381 /***********************************************************************
1382 * CC_HSLtoRGB [internal]
1384 static int CC_HSLtoRGB(char c
,int hue
,int sat
,int lum
)
1391 case 'R':if (hue
>80) hue
-=80; else hue
+=160; break;
1392 case 'G':if (hue
>160) hue
-=160; else hue
+=80; break;
1397 maxrgb
=(256*MIN(120,lum
))/120; /* 0 .. 256 */
1403 res
=(hue
-80)* maxrgb
; /* 0...10240 */
1404 res
/=40; /* 0...256 */
1411 res
=(240-hue
)* maxrgb
;
1414 res
=res
-maxrgb
/2; /* -128...128 */
1417 res
=maxrgb
/2 + (sat
*res
) /240; /* 0..256 */
1420 if (lum
>120 && res
<256)
1421 res
+=((lum
-120) * (256-res
))/120;
1423 return MIN(res
,255);
1426 /***********************************************************************
1427 * CC_RGBtoHSL [internal]
1429 static int CC_RGBtoHSL(char c
,int r
,int g
,int b
)
1431 WORD maxi
,mini
,mmsum
,mmdif
,result
=0;
1445 case 'L':mmsum
*=120; /* 0...61200=(255+255)*120 */
1446 result
=mmsum
/255; /* 0...240 */
1449 case 'S':if (!mmsum
)
1452 if (!mini
|| maxi
==255)
1456 result
=mmdif
*240; /* 0...61200=255*240 */
1457 result
/= (mmsum
>255 ? mmsum
=510-mmsum
: mmsum
); /* 0..255 */
1461 case 'H':if (!mmdif
)
1467 iresult
=40*(g
-b
); /* -10200 ... 10200 */
1468 iresult
/=(int)mmdif
; /* -40 .. 40 */
1470 iresult
+=240; /* 0..40 and 200..240 */
1476 iresult
/=(int)mmdif
;
1477 iresult
+=80; /* 40 .. 120 */
1483 iresult
/=(int)mmdif
;
1484 iresult
+=160; /* 120 .. 200 */
1490 return result
; /* is this integer arithmetic precise enough ? */
1495 /***********************************************************************
1496 * CC_MouseCheckPredefColorArray [internal]
1498 static int CC_MouseCheckPredefColorArray(HWND16 hDlg
,int dlgitem
,int rows
,int cols
,
1499 LPARAM lParam
,COLORREF
*cr
)
1502 POINT16 point
= MAKEPOINT16(lParam
);
1506 ClientToScreen16(hDlg
,&point
);
1507 hwnd
=GetDlgItem32(hDlg
,dlgitem
);
1508 GetWindowRect16(hwnd
,&rect
);
1509 if (PtInRect16(&rect
,point
))
1511 dx
=(rect
.right
-rect
.left
)/cols
;
1512 dy
=(rect
.bottom
-rect
.top
)/rows
;
1513 ScreenToClient16(hwnd
,&point
);
1515 if (point
.x
% dx
< (dx
-DISTANCE
) && point
.y
% dy
< (dy
-DISTANCE
))
1519 *cr
=predefcolors
[y
][x
];
1520 /* FIXME: Draw_a_Focus_Rect() */
1527 /***********************************************************************
1528 * CC_MouseCheckUserColorArray [internal]
1530 static int CC_MouseCheckUserColorArray(HWND16 hDlg
,int dlgitem
,int rows
,int cols
,
1531 LPARAM lParam
,COLORREF
*cr
,COLORREF
*crarr
)
1534 POINT16 point
= MAKEPOINT16(lParam
);
1538 ClientToScreen16(hDlg
,&point
);
1539 hwnd
=GetDlgItem32(hDlg
,dlgitem
);
1540 GetWindowRect16(hwnd
,&rect
);
1541 if (PtInRect16(&rect
,point
))
1543 dx
=(rect
.right
-rect
.left
)/cols
;
1544 dy
=(rect
.bottom
-rect
.top
)/rows
;
1545 ScreenToClient16(hwnd
,&point
);
1547 if (point
.x
% dx
< (dx
-DISTANCE
) && point
.y
% dy
< (dy
-DISTANCE
))
1551 *cr
=crarr
[x
+cols
*y
];
1552 /* FIXME: Draw_a_Focus_Rect() */
1562 /* 240 ^...... ^^ 240
1569 /***********************************************************************
1570 * CC_MouseCheckColorGraph [internal]
1572 static int CC_MouseCheckColorGraph(HWND16 hDlg
,int dlgitem
,int *hori
,int *vert
,LPARAM lParam
)
1575 POINT16 point
= MAKEPOINT16(lParam
);
1579 ClientToScreen16(hDlg
,&point
);
1580 hwnd
=GetDlgItem32(hDlg
,dlgitem
);
1581 GetWindowRect16(hwnd
,&rect
);
1582 if (PtInRect16(&rect
,point
))
1584 GetClientRect16(hwnd
,&rect
);
1585 ScreenToClient16(hwnd
,&point
);
1587 x
=(long)point
.x
*MAXHORI
;
1589 y
=(long)(rect
.bottom
-point
.y
)*MAXVERT
;
1601 /***********************************************************************
1602 * CC_MouseCheckResultWindow [internal]
1604 static int CC_MouseCheckResultWindow(HWND16 hDlg
,LPARAM lParam
)
1607 POINT16 point
= MAKEPOINT16(lParam
);
1610 ClientToScreen16(hDlg
,&point
);
1611 hwnd
=GetDlgItem32(hDlg
,0x2c5);
1612 GetWindowRect16(hwnd
,&rect
);
1613 if (PtInRect16(&rect
,point
))
1615 PostMessage16(hDlg
,WM_COMMAND
,0x2c9,0);
1621 /***********************************************************************
1622 * CC_CheckDigitsInEdit [internal]
1624 static int CC_CheckDigitsInEdit(HWND16 hwnd
,int maxval
)
1626 int i
,k
,m
,result
,value
;
1629 GetWindowText32A(hwnd
,buffer
,sizeof(buffer
));
1634 if (buffer
[i
]<'0' || buffer
[i
]>'9')
1636 for (k
=i
+1;k
<=m
;k
++) /* delete bad character */
1638 buffer
[i
]=buffer
[k
];
1646 if (value
>maxval
) /* build a new string */
1648 sprintf(buffer
,"%d",maxval
);
1653 editpos
=SendMessage16(hwnd
,EM_GETSEL16
,0,0);
1654 SetWindowText32A(hwnd
,buffer
);
1655 SendMessage16(hwnd
,EM_SETSEL16
,0,editpos
);
1662 /***********************************************************************
1663 * CC_PaintSelectedColor [internal]
1665 static void CC_PaintSelectedColor(HWND16 hDlg
,COLORREF cr
)
1670 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2c5);
1671 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
1674 GetClientRect16 (hwnd
, &rect
) ;
1675 hBrush
= CreateSolidBrush32(cr
);
1678 hBrush
= SelectObject32 (hdc
, hBrush
) ;
1679 Rectangle32(hdc
, rect
.left
,rect
.top
,rect
.right
/2,rect
.bottom
);
1680 DeleteObject32 (SelectObject32 (hdc
,hBrush
)) ;
1681 hBrush
=CreateSolidBrush32(GetNearestColor32(hdc
,cr
));
1684 hBrush
= SelectObject32 (hdc
, hBrush
) ;
1685 Rectangle32( hdc
, rect
.right
/2-1,rect
.top
,rect
.right
,rect
.bottom
);
1686 DeleteObject32( SelectObject32 (hdc
, hBrush
)) ;
1689 ReleaseDC32(hwnd
,hdc
);
1693 /***********************************************************************
1694 * CC_PaintTriangle [internal]
1696 static void CC_PaintTriangle(HWND16 hDlg
,int y
)
1700 int w
=GetDialogBaseUnits();
1705 HWND16 hwnd
=GetDlgItem32(hDlg
,0x2be);
1706 struct CCPRIVATE
*lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
1708 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
1710 GetClientRect16(hwnd
,&rect
);
1714 points
[0].y
=rect
.top
;
1715 points
[0].x
=rect
.right
; /* | /| */
1716 ClientToScreen16(hwnd
,points
); /* | / | */
1717 ScreenToClient16(hDlg
,points
); /* |< | */
1718 oben
=points
[0].y
; /* | \ | */
1720 temp
=(long)height
*(long)y
;
1721 points
[0].y
=oben
+height
-temp
/(long)MAXVERT
;
1722 points
[1].y
=points
[0].y
+w
;
1723 points
[2].y
=points
[0].y
-w
;
1724 points
[2].x
=points
[1].x
=points
[0].x
+ w
;
1726 if (lpp
->old3angle
.left
)
1727 FillRect16(hDC
,&lpp
->old3angle
,GetStockObject32(WHITE_BRUSH
));
1728 lpp
->old3angle
.left
=points
[0].x
;
1729 lpp
->old3angle
.right
=points
[1].x
+1;
1730 lpp
->old3angle
.top
=points
[2].y
-1;
1731 lpp
->old3angle
.bottom
=points
[1].y
+1;
1732 Polygon16(hDC
,points
,3);
1733 ReleaseDC32(hDlg
,hDC
);
1738 /***********************************************************************
1739 * CC_PaintCross [internal]
1741 static void CC_PaintCross(HWND16 hDlg
,int x
,int y
)
1744 int w
=GetDialogBaseUnits();
1745 HWND16 hwnd
=GetDlgItem32(hDlg
,0x2c6);
1746 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
1751 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
1753 GetClientRect16(hwnd
,&rect
);
1755 SelectClipRgn32(hDC
,CreateRectRgnIndirect16(&rect
));
1756 hPen
=CreatePen32(PS_SOLID
,2,0);
1757 hPen
=SelectObject32(hDC
,hPen
);
1758 point
.x
=((long)rect
.right
*(long)x
)/(long)MAXHORI
;
1759 point
.y
=rect
.bottom
-((long)rect
.bottom
*(long)y
)/(long)MAXVERT
;
1760 if (lpp
->oldcross
.left
!=lpp
->oldcross
.right
)
1761 BitBlt32(hDC
,lpp
->oldcross
.left
,lpp
->oldcross
.top
,
1762 lpp
->oldcross
.right
-lpp
->oldcross
.left
,
1763 lpp
->oldcross
.bottom
-lpp
->oldcross
.top
,
1764 lpp
->hdcMem
,lpp
->oldcross
.left
,lpp
->oldcross
.top
,SRCCOPY
);
1765 lpp
->oldcross
.left
=point
.x
-w
-1;
1766 lpp
->oldcross
.right
=point
.x
+w
+1;
1767 lpp
->oldcross
.top
=point
.y
-w
-1;
1768 lpp
->oldcross
.bottom
=point
.y
+w
+1;
1770 MoveTo(hDC
,point
.x
-w
,point
.y
);
1771 LineTo32(hDC
,point
.x
+w
,point
.y
);
1772 MoveTo(hDC
,point
.x
,point
.y
-w
);
1773 LineTo32(hDC
,point
.x
,point
.y
+w
);
1774 DeleteObject32(SelectObject32(hDC
,hPen
));
1775 ReleaseDC32(hwnd
,hDC
);
1784 /***********************************************************************
1785 * CC_PrepareColorGraph [internal]
1787 static void CC_PrepareColorGraph(HWND16 hDlg
)
1789 int sdif
,hdif
,xdif
,ydif
,r
,g
,b
,hue
,sat
;
1790 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2c6);
1791 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
1795 HCURSOR16 hcursor
=SetCursor16(LoadCursor16(0,IDC_WAIT
));
1797 GetClientRect16(hwnd
,&client
);
1799 lpp
->hdcMem
= CreateCompatibleDC32(hdc
);
1800 lpp
->hbmMem
= CreateCompatibleBitmap32(hdc
,client
.right
,client
.bottom
);
1801 SelectObject32(lpp
->hdcMem
,lpp
->hbmMem
);
1803 xdif
=client
.right
/XSTEPS
;
1804 ydif
=client
.bottom
/YSTEPS
+1;
1807 for(rect
.left
=hue
=0;hue
<239+hdif
;hue
+=hdif
)
1809 rect
.right
=rect
.left
+xdif
;
1810 rect
.bottom
=client
.bottom
;
1811 for(sat
=0;sat
<240+sdif
;sat
+=sdif
)
1813 rect
.top
=rect
.bottom
-ydif
;
1814 r
=CC_HSLtoRGB('R',hue
,sat
,120);
1815 g
=CC_HSLtoRGB('G',hue
,sat
,120);
1816 b
=CC_HSLtoRGB('B',hue
,sat
,120);
1817 hbrush
=CreateSolidBrush32(RGB(r
,g
,b
));
1818 FillRect16(lpp
->hdcMem
,&rect
,hbrush
);
1819 DeleteObject32(hbrush
);
1820 rect
.bottom
=rect
.top
;
1822 rect
.left
=rect
.right
;
1824 ReleaseDC32(hwnd
,hdc
);
1825 SetCursor16(hcursor
);
1828 /***********************************************************************
1829 * CC_PaintColorGraph [internal]
1831 static void CC_PaintColorGraph(HWND16 hDlg
)
1833 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2c6);
1834 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
1837 if (IsWindowVisible32(hwnd
)) /* if full size */
1840 CC_PrepareColorGraph(hDlg
); /* should not be necessary */
1843 GetClientRect16(hwnd
,&rect
);
1845 BitBlt32(hDC
,0,0,rect
.right
,rect
.bottom
,lpp
->hdcMem
,0,0,SRCCOPY
);
1847 fprintf(stderr
,"choose color: hdcMem is not defined\n");
1848 ReleaseDC32(hwnd
,hDC
);
1851 /***********************************************************************
1852 * CC_PaintLumBar [internal]
1854 static void CC_PaintLumBar(HWND16 hDlg
,int hue
,int sat
)
1856 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2be);
1858 int lum
,ldif
,ydif
,r
,g
,b
;
1862 if (IsWindowVisible32(hwnd
))
1865 GetClientRect16(hwnd
,&client
);
1869 ydif
=client
.bottom
/YSTEPS
+1;
1870 for(lum
=0;lum
<240+ldif
;lum
+=ldif
)
1872 rect
.top
=MAX(0,rect
.bottom
-ydif
);
1873 r
=CC_HSLtoRGB('R',hue
,sat
,lum
);
1874 g
=CC_HSLtoRGB('G',hue
,sat
,lum
);
1875 b
=CC_HSLtoRGB('B',hue
,sat
,lum
);
1876 hbrush
=CreateSolidBrush32(RGB(r
,g
,b
));
1877 FillRect16(hDC
,&rect
,hbrush
);
1878 DeleteObject32(hbrush
);
1879 rect
.bottom
=rect
.top
;
1881 GetClientRect16(hwnd
,&rect
);
1882 FrameRect16(hDC
,&rect
,GetStockObject32(BLACK_BRUSH
));
1883 ReleaseDC32(hwnd
,hDC
);
1887 /***********************************************************************
1888 * CC_EditSetRGB [internal]
1890 static void CC_EditSetRGB(HWND16 hDlg
,COLORREF cr
)
1893 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
1894 int r
=GetRValue(cr
);
1895 int g
=GetGValue(cr
);
1896 int b
=GetBValue(cr
);
1897 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
1900 sprintf(buffer
,"%d",r
);
1901 SetWindowText32A(GetDlgItem32(hDlg
,0x2c2),buffer
);
1902 sprintf(buffer
,"%d",g
);
1903 SetWindowText32A(GetDlgItem32(hDlg
,0x2c3),buffer
);
1904 sprintf(buffer
,"%d",b
);
1905 SetWindowText32A(GetDlgItem32(hDlg
,0x2c4),buffer
);
1906 lpp
->updating
=FALSE
;
1910 /***********************************************************************
1911 * CC_EditSetHSL [internal]
1913 static void CC_EditSetHSL(HWND16 hDlg
,int h
,int s
,int l
)
1916 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
1918 if (IsWindowVisible32(GetDlgItem32(hDlg
,0x2c6))) /* if full size */
1921 sprintf(buffer
,"%d",h
);
1922 SetWindowText32A(GetDlgItem32(hDlg
,0x2bf),buffer
);
1923 sprintf(buffer
,"%d",s
);
1924 SetWindowText32A(GetDlgItem32(hDlg
,0x2c0),buffer
);
1925 sprintf(buffer
,"%d",l
);
1926 SetWindowText32A(GetDlgItem32(hDlg
,0x2c1),buffer
);
1927 lpp
->updating
=FALSE
;
1929 CC_PaintLumBar(hDlg
,h
,s
);
1932 /***********************************************************************
1933 * CC_SwitchToFullSize [internal]
1935 static void CC_SwitchToFullSize(HWND16 hDlg
,COLORREF result
,LPRECT16 lprect
)
1938 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
1940 EnableWindow32(GetDlgItem32(hDlg
,0x2cf),FALSE
);
1941 CC_PrepareColorGraph(hDlg
);
1942 for (i
=0x2bf;i
<0x2c5;i
++)
1943 EnableWindow32(GetDlgItem32(hDlg
,i
),TRUE
);
1944 for (i
=0x2d3;i
<0x2d9;i
++)
1945 EnableWindow32(GetDlgItem32(hDlg
,i
),TRUE
);
1946 EnableWindow32(GetDlgItem32(hDlg
,0x2c9),TRUE
);
1947 EnableWindow32(GetDlgItem32(hDlg
,0x2c8),TRUE
);
1950 SetWindowPos32(hDlg
,NULL
,0,0,lprect
->right
-lprect
->left
,
1951 lprect
->bottom
-lprect
->top
, SWP_NOMOVE
|SWP_NOZORDER
);
1953 ShowWindow32(GetDlgItem32(hDlg
,0x2c6),SW_SHOW
);
1954 ShowWindow32(GetDlgItem32(hDlg
,0x2be),SW_SHOW
);
1955 ShowWindow32(GetDlgItem32(hDlg
,0x2c5),SW_SHOW
);
1957 CC_EditSetRGB(hDlg
,result
);
1958 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
1961 /***********************************************************************
1962 * CC_PaintPredefColorArray [internal]
1964 static void CC_PaintPredefColorArray(HWND16 hDlg
,int rows
,int cols
)
1966 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2d0);
1972 GetClientRect16(hwnd
,&rect
);
1974 dy
=rect
.bottom
/rows
;
1978 GetClientRect16 (hwnd
, &rect
) ;
1980 for (j
=0;j
<rows
;j
++)
1982 for (i
=0;i
<cols
;i
++)
1984 hBrush
= CreateSolidBrush32(predefcolors
[j
][i
]);
1987 hBrush
= SelectObject32 (hdc
, hBrush
) ;
1988 Rectangle32(hdc
, rect
.left
, rect
.top
,
1989 rect
.left
+dx
-DISTANCE
, rect
.top
+dy
-DISTANCE
);
1990 rect
.left
=rect
.left
+dx
;
1991 DeleteObject32( SelectObject32 (hdc
, hBrush
)) ;
1994 rect
.top
=rect
.top
+dy
;
1997 ReleaseDC32(hwnd
,hdc
);
1998 /* FIXME: draw_a_focus_rect */
2000 /***********************************************************************
2001 * CC_PaintUserColorArray [internal]
2003 static void CC_PaintUserColorArray(HWND16 hDlg
,int rows
,int cols
,COLORREF
* lpcr
)
2005 HWND32 hwnd
=GetDlgItem32(hDlg
,0x2d1);
2011 GetClientRect16(hwnd
,&rect
);
2014 dy
=rect
.bottom
/rows
;
2020 for (j
=0;j
<rows
;j
++)
2022 for (i
=0;i
<cols
;i
++)
2024 hBrush
= CreateSolidBrush32(lpcr
[i
+j
*cols
]);
2027 hBrush
= SelectObject32 (hdc
, hBrush
) ;
2028 Rectangle32( hdc
, rect
.left
, rect
.top
,
2029 rect
.left
+dx
-DISTANCE
, rect
.top
+dy
-DISTANCE
);
2030 rect
.left
=rect
.left
+dx
;
2031 DeleteObject32( SelectObject32 (hdc
, hBrush
)) ;
2034 rect
.top
=rect
.top
+dy
;
2037 ReleaseDC32(hwnd
,hdc
);
2039 /* FIXME: draw_a_focus_rect */
2044 /***********************************************************************
2045 * CC_HookCallChk [internal]
2047 static BOOL32
CC_HookCallChk(LPCHOOSECOLOR lpcc
)
2050 if(lpcc
->Flags
& CC_ENABLEHOOK
)
2056 /***********************************************************************
2057 * CC_WMInitDialog [internal]
2059 static LONG
CC_WMInitDialog(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2065 struct CCPRIVATE
* lpp
;
2067 dprintf_commdlg(stddeb
,"ColorDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
2068 lpp
=calloc(1,sizeof(struct CCPRIVATE
));
2069 lpp
->lpcc
=(LPCHOOSECOLOR
)lParam
;
2070 if (lpp
->lpcc
->lStructSize
!= sizeof(CHOOSECOLOR
))
2072 EndDialog32 (hDlg
, 0) ;
2075 SetWindowLong32A(hDlg
, DWL_USER
, (LONG
)lpp
);
2077 if (!(lpp
->lpcc
->Flags
& CC_SHOWHELP
))
2078 ShowWindow32(GetDlgItem32(hDlg
,0x40e),SW_HIDE
);
2079 lpp
->msetrgb
=RegisterWindowMessage32A( SETRGBSTRING
);
2081 cpos
=MAKELONG(5,7); /* init */
2082 if (lpp
->lpcc
->Flags
& CC_RGBINIT
)
2086 if (predefcolors
[i
][j
]==lpp
->lpcc
->rgbResult
)
2093 /* FIXME: Draw_a_focus_rect & set_init_values */
2095 GetWindowRect16(hDlg
,&lpp
->fullsize
);
2096 if (lpp
->lpcc
->Flags
& CC_FULLOPEN
|| lpp
->lpcc
->Flags
& CC_PREVENTFULLOPEN
)
2098 hwnd
=GetDlgItem32(hDlg
,0x2cf);
2099 EnableWindow32(hwnd
,FALSE
);
2101 if (!(lpp
->lpcc
->Flags
& CC_FULLOPEN
) || lpp
->lpcc
->Flags
& CC_PREVENTFULLOPEN
)
2104 res
=rect
.bottom
-rect
.top
;
2105 hwnd
=GetDlgItem32(hDlg
,0x2c6); /* cut at left border */
2107 ClientToScreen16(hwnd
,&point
);
2108 ScreenToClient16(hDlg
,&point
);
2109 GetClientRect16(hDlg
,&rect
);
2110 point
.x
+=GetSystemMetrics32(SM_CXDLGFRAME
);
2111 SetWindowPos32(hDlg
,NULL
,0,0,point
.x
,res
,SWP_NOMOVE
|SWP_NOZORDER
);
2113 ShowWindow32(GetDlgItem32(hDlg
,0x2c6),SW_HIDE
);
2114 ShowWindow32(GetDlgItem32(hDlg
,0x2c5),SW_HIDE
);
2117 CC_SwitchToFullSize(hDlg
,lpp
->lpcc
->rgbResult
,NULL
);
2119 for (i
=0x2bf;i
<0x2c5;i
++)
2120 SendMessage16(GetDlgItem32(hDlg
,i
),EM_LIMITTEXT16
,3,0); /* max 3 digits: xyz */
2121 if (CC_HookCallChk(lpp
->lpcc
))
2122 res
=CallWindowProc16(lpp
->lpcc
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
2126 /***********************************************************************
2127 * CC_WMCommand [internal]
2129 static LRESULT
CC_WMCommand(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2135 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2136 dprintf_commdlg(stddeb
,"CC_WMCommand wParam=%x lParam=%lx\n",wParam
,lParam
);
2139 case 0x2c2: /* edit notify RGB */
2142 if (HIWORD(lParam
)==EN_UPDATE
&& !lpp
->updating
)
2144 i
=CC_CheckDigitsInEdit(LOWORD(lParam
),255);
2145 r
=GetRValue(lpp
->lpcc
->rgbResult
);
2146 g
=GetGValue(lpp
->lpcc
->rgbResult
);
2147 b
=GetBValue(lpp
->lpcc
->rgbResult
);
2151 case 0x2c2:if ((xx
=(i
!=r
))) r
=i
;break;
2152 case 0x2c3:if ((xx
=(i
!=g
))) g
=i
;break;
2153 case 0x2c4:if ((xx
=(i
!=b
))) b
=i
;break;
2155 if (xx
) /* something has changed */
2157 lpp
->lpcc
->rgbResult
=RGB(r
,g
,b
);
2158 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2159 lpp
->h
=CC_RGBtoHSL('H',r
,g
,b
);
2160 lpp
->s
=CC_RGBtoHSL('S',r
,g
,b
);
2161 lpp
->l
=CC_RGBtoHSL('L',r
,g
,b
);
2162 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
2163 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2164 CC_PaintTriangle(hDlg
,lpp
->l
);
2169 case 0x2bf: /* edit notify HSL */
2172 if (HIWORD(lParam
)==EN_UPDATE
&& !lpp
->updating
)
2174 i
=CC_CheckDigitsInEdit(LOWORD(lParam
),wParam
==0x2bf?239:240);
2178 case 0x2bf:if ((xx
=(i
!=lpp
->h
))) lpp
->h
=i
;break;
2179 case 0x2c0:if ((xx
=(i
!=lpp
->s
))) lpp
->s
=i
;break;
2180 case 0x2c1:if ((xx
=(i
!=lpp
->l
))) lpp
->l
=i
;break;
2182 if (xx
) /* something has changed */
2184 r
=CC_HSLtoRGB('R',lpp
->h
,lpp
->s
,lpp
->l
);
2185 g
=CC_HSLtoRGB('G',lpp
->h
,lpp
->s
,lpp
->l
);
2186 b
=CC_HSLtoRGB('B',lpp
->h
,lpp
->s
,lpp
->l
);
2187 lpp
->lpcc
->rgbResult
=RGB(r
,g
,b
);
2188 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2189 CC_EditSetRGB(hDlg
,lpp
->lpcc
->rgbResult
);
2190 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2191 CC_PaintTriangle(hDlg
,lpp
->l
);
2197 CC_SwitchToFullSize(hDlg
,lpp
->lpcc
->rgbResult
,&lpp
->fullsize
);
2198 InvalidateRect32( hDlg
, NULL
, TRUE
);
2199 SetFocus32(GetDlgItem32(hDlg
,0x2bf));
2202 case 0x2c8: /* add colors ... column by column */
2203 cr
=PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
);
2204 cr
[(lpp
->nextuserdef
%2)*8 + lpp
->nextuserdef
/2]=lpp
->lpcc
->rgbResult
;
2205 if (++lpp
->nextuserdef
==16)
2207 CC_PaintUserColorArray(hDlg
,2,8,PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
));
2210 case 0x2c9: /* resulting color */
2212 lpp
->lpcc
->rgbResult
=GetNearestColor32(hdc
,lpp
->lpcc
->rgbResult
);
2213 ReleaseDC32(hDlg
,hdc
);
2214 CC_EditSetRGB(hDlg
,lpp
->lpcc
->rgbResult
);
2215 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2216 r
=GetRValue(lpp
->lpcc
->rgbResult
);
2217 g
=GetGValue(lpp
->lpcc
->rgbResult
);
2218 b
=GetBValue(lpp
->lpcc
->rgbResult
);
2219 lpp
->h
=CC_RGBtoHSL('H',r
,g
,b
);
2220 lpp
->s
=CC_RGBtoHSL('S',r
,g
,b
);
2221 lpp
->l
=CC_RGBtoHSL('L',r
,g
,b
);
2222 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
2223 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2224 CC_PaintTriangle(hDlg
,lpp
->l
);
2227 case 0x40e: /* Help! */ /* The Beatles, 1965 ;-) */
2228 i
=RegisterWindowMessage32A( HELPMSGSTRING
);
2229 if (lpp
->lpcc
->hwndOwner
)
2230 SendMessage16(lpp
->lpcc
->hwndOwner
,i
,0,(LPARAM
)lpp
->lpcc
);
2231 if (CC_HookCallChk(lpp
->lpcc
))
2232 CallWindowProc16(lpp
->lpcc
->lpfnHook
,hDlg
,
2233 WM_COMMAND
,psh15
,(LPARAM
)lpp
->lpcc
);
2237 cokmsg
=RegisterWindowMessage32A( COLOROKSTRING
);
2238 if (lpp
->lpcc
->hwndOwner
)
2239 if (SendMessage16(lpp
->lpcc
->hwndOwner
,cokmsg
,0,(LPARAM
)lpp
->lpcc
))
2240 break; /* do NOT close */
2242 EndDialog32 (hDlg
, 1) ;
2246 EndDialog32 (hDlg
, 0) ;
2253 /***********************************************************************
2254 * CC_WMPaint [internal]
2256 static LRESULT
CC_WMPaint(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2258 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2259 /* we have to paint dialog children except text and buttons */
2261 CC_PaintPredefColorArray(hDlg
,6,8);
2262 CC_PaintUserColorArray(hDlg
,2,8,PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
));
2263 CC_PaintColorGraph(hDlg
);
2264 CC_PaintLumBar(hDlg
,lpp
->h
,lpp
->s
);
2265 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2266 CC_PaintTriangle(hDlg
,lpp
->l
);
2267 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2269 /* special necessary for Wine */
2270 ValidateRect32(GetDlgItem32(hDlg
,0x2d0),NULL
);
2271 ValidateRect32(GetDlgItem32(hDlg
,0x2d1),NULL
);
2272 ValidateRect32(GetDlgItem32(hDlg
,0x2c6),NULL
);
2273 ValidateRect32(GetDlgItem32(hDlg
,0x2be),NULL
);
2274 ValidateRect32(GetDlgItem32(hDlg
,0x2c5),NULL
);
2275 /* hope we can remove it later -->FIXME */
2280 /***********************************************************************
2281 * CC_WMLButtonDown [internal]
2283 static LRESULT
CC_WMLButtonDown(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2285 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2288 if (CC_MouseCheckPredefColorArray(hDlg
,0x2d0,6,8,lParam
,&lpp
->lpcc
->rgbResult
))
2291 if (CC_MouseCheckUserColorArray(hDlg
,0x2d1,2,8,lParam
,&lpp
->lpcc
->rgbResult
,
2292 PTR_SEG_TO_LIN(lpp
->lpcc
->lpCustColors
)))
2295 if (CC_MouseCheckColorGraph(hDlg
,0x2c6,&lpp
->h
,&lpp
->s
,lParam
))
2298 if (CC_MouseCheckColorGraph(hDlg
,0x2be,NULL
,&lpp
->l
,lParam
))
2302 r
=CC_HSLtoRGB('R',lpp
->h
,lpp
->s
,lpp
->l
);
2303 g
=CC_HSLtoRGB('G',lpp
->h
,lpp
->s
,lpp
->l
);
2304 b
=CC_HSLtoRGB('B',lpp
->h
,lpp
->s
,lpp
->l
);
2305 lpp
->lpcc
->rgbResult
=RGB(r
,g
,b
);
2309 r
=GetRValue(lpp
->lpcc
->rgbResult
);
2310 g
=GetGValue(lpp
->lpcc
->rgbResult
);
2311 b
=GetBValue(lpp
->lpcc
->rgbResult
);
2312 lpp
->h
=CC_RGBtoHSL('H',r
,g
,b
);
2313 lpp
->s
=CC_RGBtoHSL('S',r
,g
,b
);
2314 lpp
->l
=CC_RGBtoHSL('L',r
,g
,b
);
2318 CC_EditSetRGB(hDlg
,lpp
->lpcc
->rgbResult
);
2319 CC_EditSetHSL(hDlg
,lpp
->h
,lpp
->s
,lpp
->l
);
2320 CC_PaintCross(hDlg
,lpp
->h
,lpp
->s
);
2321 CC_PaintTriangle(hDlg
,lpp
->l
);
2322 CC_PaintSelectedColor(hDlg
,lpp
->lpcc
->rgbResult
);
2328 /***********************************************************************
2329 * ColorDlgProc (COMMDLG.8)
2331 LRESULT WINAPI
ColorDlgProc(HWND16 hDlg
, UINT16 message
,
2332 WPARAM16 wParam
, LONG lParam
)
2335 struct CCPRIVATE
* lpp
=(struct CCPRIVATE
*)GetWindowLong32A(hDlg
, DWL_USER
);
2336 if (message
!=WM_INITDIALOG
)
2341 if (CC_HookCallChk(lpp
->lpcc
))
2342 res
=CallWindowProc16(lpp
->lpcc
->lpfnHook
,hDlg
,message
,wParam
,lParam
);
2347 /* FIXME: SetRGB message
2348 if (message && message==msetrgb)
2349 return HandleSetRGB(hDlg,lParam);
2355 return CC_WMInitDialog(hDlg
,wParam
,lParam
);
2357 DeleteDC32(lpp
->hdcMem
);
2358 DeleteObject32(lpp
->hbmMem
);
2360 SetWindowLong32A(hDlg
, DWL_USER
, 0L); /* we don't need it anymore */
2363 if (CC_WMCommand(hDlg
, wParam
, lParam
))
2367 CC_WMPaint(hDlg
, wParam
, lParam
);
2369 case WM_LBUTTONDBLCLK
:
2370 if (CC_MouseCheckResultWindow(hDlg
,lParam
))
2373 case WM_MOUSEMOVE
: /* FIXME: calculate new hue,sat,lum (if in color graph) */
2375 case WM_LBUTTONUP
: /* FIXME: ClipCursor off (if in color graph)*/
2377 case WM_LBUTTONDOWN
:/* FIXME: ClipCursor on (if in color graph)*/
2378 if (CC_WMLButtonDown(hDlg
, wParam
, lParam
))
2387 /***********************************************************************
2388 * ChooseFont (COMMDLG.15)
2390 BOOL16 WINAPI
ChooseFont(LPCHOOSEFONT lpChFont
)
2393 HANDLE16 hDlgTmpl
= 0;
2394 BOOL16 bRet
= FALSE
, win32Format
= FALSE
;
2398 dprintf_commdlg(stddeb
,"ChooseFont\n");
2399 if (!lpChFont
) return FALSE
;
2401 if (lpChFont
->Flags
& CF_ENABLETEMPLATEHANDLE
)
2403 if (!(template = LockResource16( lpChFont
->hInstance
)))
2405 CommDlgLastError
= CDERR_LOADRESFAILURE
;
2409 else if (lpChFont
->Flags
& CF_ENABLETEMPLATE
)
2412 if (!(hResInfo
= FindResource16( lpChFont
->hInstance
,
2413 lpChFont
->lpTemplateName
, RT_DIALOG
)))
2415 CommDlgLastError
= CDERR_FINDRESFAILURE
;
2418 if (!(hDlgTmpl
= LoadResource16( lpChFont
->hInstance
, hResInfo
)) ||
2419 !(template = LockResource16( hDlgTmpl
)))
2421 CommDlgLastError
= CDERR_LOADRESFAILURE
;
2427 template = SYSRES_GetResPtr( SYSRES_DIALOG_CHOOSE_FONT
);
2431 hInst
= WIN_GetWindowInstance( lpChFont
->hwndOwner
);
2433 hwndDialog
= DIALOG_CreateIndirect( hInst
, template, win32Format
,
2434 lpChFont
->hwndOwner
,
2435 (DLGPROC16
)MODULE_GetWndProcEntry16("FormatCharDlgProc"),
2436 (DWORD
)lpChFont
, WIN_PROC_16
);
2437 if (hwndDialog
) bRet
= DIALOG_DoDialogBox(hwndDialog
, lpChFont
->hwndOwner
);
2438 if (hDlgTmpl
) FreeResource16( hDlgTmpl
);
2443 #define TEXT_EXTRAS 4
2444 #define TEXT_COLORS 16
2446 static const COLORREF textcolors
[TEXT_COLORS
]=
2448 0x00000000L
,0x00000080L
,0x00008000L
,0x00008080L
,
2449 0x00800000L
,0x00800080L
,0x00808000L
,0x00808080L
,
2450 0x00c0c0c0L
,0x000000ffL
,0x0000ff00L
,0x0000ffffL
,
2451 0x00ff0000L
,0x00ff00ffL
,0x00ffff00L
,0x00FFFFFFL
2454 /***********************************************************************
2455 * CFn_HookCallChk [internal]
2457 static BOOL32
CFn_HookCallChk(LPCHOOSEFONT lpcf
)
2460 if(lpcf
->Flags
& CF_ENABLEHOOK
)
2467 /***********************************************************************
2468 * FontFamilyEnumProc (COMMDLG.19)
2470 INT16 WINAPI
FontFamilyEnumProc( SEGPTR logfont
, SEGPTR metrics
,
2471 UINT16 nFontType
, LPARAM lParam
)
2475 HWND16 hwnd
=LOWORD(lParam
);
2476 HWND16 hDlg
=GetParent16(hwnd
);
2477 LPCHOOSEFONT lpcf
=(LPCHOOSEFONT
)GetWindowLong32A(hDlg
, DWL_USER
);
2478 LOGFONT16
*lplf
= (LOGFONT16
*)PTR_SEG_TO_LIN( logfont
);
2480 dprintf_commdlg(stddeb
,"FontFamilyEnumProc: font=%s (nFontType=%d)\n",
2481 lplf
->lfFaceName
,nFontType
);
2483 if (lpcf
->Flags
& CF_FIXEDPITCHONLY
)
2484 if (!(lplf
->lfPitchAndFamily
& FIXED_PITCH
))
2486 if (lpcf
->Flags
& CF_ANSIONLY
)
2487 if (lplf
->lfCharSet
!= ANSI_CHARSET
)
2489 if (lpcf
->Flags
& CF_TTONLY
)
2490 if (!(nFontType
& 0x0004)) /* this means 'TRUETYPE_FONTTYPE' */
2493 i
=SendMessage16(hwnd
,CB_ADDSTRING16
,0,
2494 (LPARAM
)logfont
+ ((char *)lplf
->lfFaceName
- (char *)lplf
));
2497 w
=(lplf
->lfCharSet
<< 8) | lplf
->lfPitchAndFamily
;
2498 SendMessage16(hwnd
, CB_SETITEMDATA16
,i
,MAKELONG(nFontType
,w
));
2499 return 1 ; /* store some important font information */
2505 /*************************************************************************
2506 * SetFontStylesToCombo2 [internal]
2508 * Fill font style information into combobox (without using font.c directly)
2510 static int SetFontStylesToCombo2(HWND16 hwnd
, HDC16 hdc
, LPLOGFONT16 lplf
,
2511 LPTEXTMETRIC16 lptm
)
2518 static struct FONTSTYLE fontstyles
[FSTYLES
]={
2519 { 0,FW_NORMAL
,"Regular"},{0,FW_BOLD
,"Bold"},
2520 { 1,FW_NORMAL
,"Italic"}, {1,FW_BOLD
,"Bold Italic"}};
2524 for (i
=0;i
<FSTYLES
;i
++)
2526 lplf
->lfItalic
=fontstyles
[i
].italic
;
2527 lplf
->lfWeight
=fontstyles
[i
].weight
;
2528 hf
=CreateFontIndirect16(lplf
);
2529 hf
=SelectObject32(hdc
,hf
);
2530 GetTextMetrics16(hdc
,lptm
);
2531 hf
=SelectObject32(hdc
,hf
);
2534 if (lptm
->tmWeight
==fontstyles
[i
].weight
&&
2535 lptm
->tmItalic
==fontstyles
[i
].italic
) /* font successful created ? */
2537 char *str
= SEGPTR_STRDUP(fontstyles
[i
].stname
);
2538 j
=SendMessage16(hwnd
,CB_ADDSTRING16
,0,(LPARAM
)SEGPTR_GET(str
) );
2540 if (j
==CB_ERR
) return 1;
2541 j
=SendMessage16(hwnd
, CB_SETITEMDATA16
, j
,
2542 MAKELONG(fontstyles
[i
].weight
,fontstyles
[i
].italic
));
2543 if (j
==CB_ERR
) return 1;
2549 /*************************************************************************
2550 * SetFontSizesToCombo3 [internal]
2552 static int SetFontSizesToCombo3(HWND16 hwnd
, LPLOGFONT16 lplf
, LPCHOOSEFONT lpcf
)
2554 static const int sizes
[]={8,9,10,11,12,14,16,18,20,22,24,26,28,36,48,72,0};
2558 if (!(buffer
= SEGPTR_ALLOC(20))) return 1;
2559 for (i
=0;sizes
[i
] && !lplf
->lfHeight
;i
++)
2561 h
=lplf
->lfHeight
? lplf
->lfHeight
: sizes
[i
];
2563 if ( (!(lpcf
->Flags
& CF_LIMITSIZE
)) ||
2564 ((lpcf
->Flags
& CF_LIMITSIZE
) && (h
>= lpcf
->nSizeMin
) && (h
<= lpcf
->nSizeMax
)))
2566 sprintf(buffer
,"%2d",h
);
2567 j
=SendMessage16(hwnd
,CB_FINDSTRING16
,-1,(LPARAM
)SEGPTR_GET(buffer
));
2570 j
=SendMessage16(hwnd
,CB_ADDSTRING16
,0,(LPARAM
)SEGPTR_GET(buffer
));
2571 if (j
!=CB_ERR
) j
= SendMessage16(hwnd
, CB_SETITEMDATA16
, j
, h
);
2574 SEGPTR_FREE(buffer
);
2580 SEGPTR_FREE(buffer
);
2585 /***********************************************************************
2586 * FontStyleEnumProc (COMMDLG.18)
2588 INT16 WINAPI
FontStyleEnumProc( SEGPTR logfont
, SEGPTR metrics
,
2589 UINT16 nFontType
, LPARAM lParam
)
2591 HWND16 hcmb2
=LOWORD(lParam
);
2592 HWND16 hcmb3
=HIWORD(lParam
);
2593 HWND16 hDlg
=GetParent16(hcmb3
);
2594 LPCHOOSEFONT lpcf
=(LPCHOOSEFONT
)GetWindowLong32A(hDlg
, DWL_USER
);
2595 LOGFONT16
*lplf
= (LOGFONT16
*)PTR_SEG_TO_LIN(logfont
);
2596 TEXTMETRIC16
*lptm
= (TEXTMETRIC16
*)PTR_SEG_TO_LIN(metrics
);
2599 dprintf_commdlg(stddeb
,"FontStyleEnumProc: (nFontType=%d)\n",nFontType
);
2600 dprintf_commdlg(stddeb
," %s h=%d w=%d e=%d o=%d wg=%d i=%d u=%d s=%d ch=%d op=%d cp=%d q=%d pf=%xh\n",
2601 lplf
->lfFaceName
,lplf
->lfHeight
,lplf
->lfWidth
,lplf
->lfEscapement
,lplf
->lfOrientation
,
2602 lplf
->lfWeight
,lplf
->lfItalic
,lplf
->lfUnderline
,lplf
->lfStrikeOut
,lplf
->lfCharSet
,
2603 lplf
->lfOutPrecision
,lplf
->lfClipPrecision
,lplf
->lfQuality
,lplf
->lfPitchAndFamily
);
2605 if (SetFontSizesToCombo3(hcmb3
, lplf
,lpcf
))
2608 if (!SendMessage16(hcmb2
,CB_GETCOUNT16
,0,0))
2610 HDC32 hdc
= (lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
) ? lpcf
->hDC
: GetDC32(hDlg
);
2611 i
=SetFontStylesToCombo2(hcmb2
,hdc
,lplf
,lptm
);
2612 if (!(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
))
2613 ReleaseDC32(hDlg
,hdc
);
2621 /***********************************************************************
2622 * CFn_WMInitDialog [internal]
2624 LRESULT
CFn_WMInitDialog(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2630 HCURSOR16 hcursor
=SetCursor16(LoadCursor16(0,IDC_WAIT
));
2633 SetWindowLong32A(hDlg
, DWL_USER
, lParam
);
2634 lpcf
=(LPCHOOSEFONT
)lParam
;
2635 lpxx
=PTR_SEG_TO_LIN(lpcf
->lpLogFont
);
2636 dprintf_commdlg(stddeb
,"FormatCharDlgProc // WM_INITDIALOG lParam=%08lX\n", lParam
);
2638 if (lpcf
->lStructSize
!= sizeof(CHOOSEFONT
))
2640 dprintf_commdlg(stddeb
,"WM_INITDIALOG: structure size failure !!!\n");
2641 EndDialog32 (hDlg
, 0);
2645 hBitmapTT
= LoadBitmap16(0, MAKEINTRESOURCE(OBM_TRTYPE
));
2647 if (!(lpcf
->Flags
& CF_SHOWHELP
) || !IsWindow32(lpcf
->hwndOwner
))
2648 ShowWindow32(GetDlgItem32(hDlg
,pshHelp
),SW_HIDE
);
2649 if (!(lpcf
->Flags
& CF_APPLY
))
2650 ShowWindow32(GetDlgItem32(hDlg
,psh3
),SW_HIDE
);
2651 if (lpcf
->Flags
& CF_EFFECTS
)
2653 for (res
=1,i
=0;res
&& i
<TEXT_COLORS
;i
++)
2655 /* FIXME: load color name from resource: res=LoadString(...,i+....,buffer,.....); */
2656 char *name
= SEGPTR_ALLOC(20);
2657 strcpy( name
, "[color name]" );
2658 j
=SendDlgItemMessage16(hDlg
,cmb4
,CB_ADDSTRING16
,0,(LPARAM
)SEGPTR_GET(name
));
2660 SendDlgItemMessage16(hDlg
,cmb4
, CB_SETITEMDATA16
,j
,textcolors
[j
]);
2661 /* look for a fitting value in color combobox */
2662 if (textcolors
[j
]==lpcf
->rgbColors
)
2663 SendDlgItemMessage16(hDlg
,cmb4
, CB_SETCURSEL16
,j
,0);
2668 ShowWindow32(GetDlgItem32(hDlg
,cmb4
),SW_HIDE
);
2669 ShowWindow32(GetDlgItem32(hDlg
,chx1
),SW_HIDE
);
2670 ShowWindow32(GetDlgItem32(hDlg
,chx2
),SW_HIDE
);
2671 ShowWindow32(GetDlgItem32(hDlg
,grp1
),SW_HIDE
);
2672 ShowWindow32(GetDlgItem32(hDlg
,stc4
),SW_HIDE
);
2674 hdc
= (lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
) ? lpcf
->hDC
: GetDC32(hDlg
);
2677 if (!EnumFontFamilies16(hdc
, NULL
,FontFamilyEnumProc
,
2678 (LPARAM
)GetDlgItem32(hDlg
,cmb1
)))
2679 dprintf_commdlg(stddeb
,"WM_INITDIALOG: EnumFontFamilies returns 0\n");
2680 if (lpcf
->Flags
& CF_INITTOLOGFONTSTRUCT
)
2682 /* look for fitting font name in combobox1 */
2683 j
=SendDlgItemMessage16(hDlg
,cmb1
,CB_FINDSTRING16
,-1,(LONG
)lpxx
->lfFaceName
);
2686 SendDlgItemMessage16(hDlg
,cmb1
,CB_SETCURSEL16
,j
,0);
2687 SendMessage16(hDlg
,WM_COMMAND
,cmb1
,
2688 MAKELONG(GetDlgItem32(hDlg
,cmb1
),CBN_SELCHANGE
));
2690 /* look for fitting font style in combobox2 */
2691 l
=MAKELONG(lpxx
->lfWeight
> FW_MEDIUM
? FW_BOLD
:FW_NORMAL
,lpxx
->lfItalic
!=0);
2692 for (i
=0;i
<TEXT_EXTRAS
;i
++)
2694 if (l
==SendDlgItemMessage16(hDlg
,cmb2
, CB_GETITEMDATA16
,i
,0))
2695 SendDlgItemMessage16(hDlg
,cmb2
,CB_SETCURSEL16
,i
,0);
2698 /* look for fitting font size in combobox3 */
2699 j
=SendDlgItemMessage16(hDlg
,cmb3
,CB_GETCOUNT16
,0,0);
2702 if (lpxx
->lfHeight
==(int)SendDlgItemMessage16(hDlg
,cmb3
, CB_GETITEMDATA16
,i
,0))
2703 SendDlgItemMessage16(hDlg
,cmb3
,CB_SETCURSEL16
,i
,0);
2708 SendDlgItemMessage16(hDlg
,cmb1
,CB_SETCURSEL16
,0,0);
2709 SendMessage16(hDlg
,WM_COMMAND
,cmb1
,
2710 MAKELONG(GetDlgItem32(hDlg
,cmb1
),CBN_SELCHANGE
));
2713 if (lpcf
->Flags
& CF_USESTYLE
&& lpcf
->lpszStyle
)
2715 j
=SendDlgItemMessage16(hDlg
,cmb2
,CB_FINDSTRING16
,-1,(LONG
)lpcf
->lpszStyle
);
2718 j
=SendDlgItemMessage16(hDlg
,cmb2
,CB_SETCURSEL16
,j
,0);
2719 SendMessage16(hDlg
,WM_COMMAND
,cmb2
,
2720 MAKELONG(GetDlgItem32(hDlg
,cmb2
),CBN_SELCHANGE
));
2726 dprintf_commdlg(stddeb
,"WM_INITDIALOG: HDC failure !!!\n");
2727 EndDialog32 (hDlg
, 0);
2731 if (!(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
))
2732 ReleaseDC32(hDlg
,hdc
);
2734 if (CFn_HookCallChk(lpcf
))
2735 res
=CallWindowProc16(lpcf
->lpfnHook
,hDlg
,WM_INITDIALOG
,wParam
,lParam
);
2736 SetCursor16(hcursor
);
2741 /***********************************************************************
2742 * CFn_WMMeasureItem [internal]
2744 LRESULT
CFn_WMMeasureItem(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2747 LPMEASUREITEMSTRUCT16 lpmi
=PTR_SEG_TO_LIN((LPMEASUREITEMSTRUCT16
)lParam
);
2749 hBitmapTT
= LoadBitmap16(0, MAKEINTRESOURCE(OBM_TRTYPE
));
2750 GetObject16( hBitmapTT
, sizeof(bm
), &bm
);
2751 lpmi
->itemHeight
=bm
.bmHeight
;
2752 /* FIXME: use MAX of bm.bmHeight and tm.tmHeight .*/
2757 /***********************************************************************
2758 * CFn_WMDrawItem [internal]
2760 LRESULT
CFn_WMDrawItem(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2770 HBITMAP16 hBitmap
; /* for later TT usage */
2772 LPDRAWITEMSTRUCT16 lpdi
= (LPDRAWITEMSTRUCT16
)PTR_SEG_TO_LIN(lParam
);
2774 if (lpdi
->itemID
== 0xFFFF) /* got no items */
2775 DrawFocusRect16(lpdi
->hDC
, &lpdi
->rcItem
);
2778 if (lpdi
->CtlType
== ODT_COMBOBOX
)
2780 hBrush
= SelectObject32(lpdi
->hDC
, GetStockObject32(LTGRAY_BRUSH
));
2781 SelectObject32(lpdi
->hDC
, hBrush
);
2782 FillRect16(lpdi
->hDC
, &lpdi
->rcItem
, hBrush
);
2785 return TRUE
; /* this should never happen */
2788 buffer
= SEGPTR_ALLOC(40);
2789 switch (lpdi
->CtlID
)
2791 case cmb1
: /* dprintf_commdlg(stddeb,"WM_Drawitem cmb1\n"); */
2792 SendMessage16(lpdi
->hwndItem
, CB_GETLBTEXT16
, lpdi
->itemID
,
2793 (LPARAM
)SEGPTR_GET(buffer
));
2794 GetObject16( hBitmapTT
, sizeof(bm
), &bm
);
2795 TextOut16(lpdi
->hDC
, lpdi
->rcItem
.left
+ bm
.bmWidth
+ 10,
2796 lpdi
->rcItem
.top
, buffer
, lstrlen16(buffer
));
2798 nFontType
= SendMessage16(lpdi
->hwndItem
, CB_GETITEMDATA16
, lpdi
->itemID
,0L);
2799 /* FIXME: draw bitmap if truetype usage */
2800 if (nFontType
&TRUETYPE_FONTTYPE
)
2802 hMemDC
= CreateCompatibleDC32(lpdi
->hDC
);
2803 hBitmap
= SelectObject32(hMemDC
, hBitmapTT
);
2804 BitBlt32(lpdi
->hDC
, lpdi
->rcItem
.left
, lpdi
->rcItem
.top
,
2805 bm
.bmWidth
, bm
.bmHeight
, hMemDC
, 0, 0, SRCCOPY
);
2806 SelectObject32(hMemDC
, hBitmap
);
2812 case cmb3
: /* dprintf_commdlg(stddeb,"WM_DRAWITEN cmb2,cmb3\n"); */
2813 SendMessage16(lpdi
->hwndItem
, CB_GETLBTEXT16
, lpdi
->itemID
,
2814 (LPARAM
)SEGPTR_GET(buffer
));
2815 TextOut16(lpdi
->hDC
, lpdi
->rcItem
.left
,
2816 lpdi
->rcItem
.top
, buffer
, lstrlen16(buffer
));
2819 case cmb4
: /* dprintf_commdlg(stddeb,"WM_DRAWITEM cmb4 (=COLOR)\n"); */
2820 SendMessage16(lpdi
->hwndItem
, CB_GETLBTEXT16
, lpdi
->itemID
,
2821 (LPARAM
)SEGPTR_GET(buffer
));
2822 TextOut16(lpdi
->hDC
, lpdi
->rcItem
.left
+ 25+5,
2823 lpdi
->rcItem
.top
, buffer
, lstrlen16(buffer
));
2824 cr
= SendMessage16(lpdi
->hwndItem
, CB_GETITEMDATA16
, lpdi
->itemID
,0L);
2825 hBrush
= CreateSolidBrush32(cr
);
2828 hBrush
= SelectObject32 (lpdi
->hDC
, hBrush
) ;
2829 rect
.right
=rect
.left
+25;
2833 Rectangle32( lpdi
->hDC
, rect
.left
, rect
.top
,
2834 rect
.right
, rect
.bottom
);
2835 DeleteObject32( SelectObject32 (lpdi
->hDC
, hBrush
)) ;
2841 default: return TRUE
; /* this should never happen */
2843 SEGPTR_FREE(buffer
);
2844 if (lpdi
->itemState
==ODS_SELECTED
)
2845 InvertRect16(lpdi
->hDC
, &rect
);
2850 /***********************************************************************
2851 * CFn_WMCtlColor [internal]
2853 LRESULT
CFn_WMCtlColor(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2855 LPCHOOSEFONT lpcf
=(LPCHOOSEFONT
)GetWindowLong32A(hDlg
, DWL_USER
);
2857 if (lpcf
->Flags
& CF_EFFECTS
)
2858 if (HIWORD(lParam
)==CTLCOLOR_STATIC
&& GetDlgCtrlID32(LOWORD(lParam
))==stc6
)
2860 SetTextColor32(wParam
,lpcf
->rgbColors
);
2861 return GetStockObject32(WHITE_BRUSH
);
2866 /***********************************************************************
2867 * CFn_WMCommand [internal]
2869 LRESULT
CFn_WMCommand(HWND16 hDlg
, WPARAM16 wParam
, LPARAM lParam
)
2875 LPCHOOSEFONT lpcf
=(LPCHOOSEFONT
)GetWindowLong32A(hDlg
, DWL_USER
);
2876 LPLOGFONT16 lpxx
=PTR_SEG_TO_LIN(lpcf
->lpLogFont
);
2878 dprintf_commdlg(stddeb
,"FormatCharDlgProc // WM_COMMAND lParam=%08lX\n", lParam
);
2881 case cmb1
:if (HIWORD(lParam
)==CBN_SELCHANGE
)
2883 hdc
=(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
) ? lpcf
->hDC
: GetDC32(hDlg
);
2886 SendDlgItemMessage16(hDlg
,cmb2
,CB_RESETCONTENT16
,0,0);
2887 SendDlgItemMessage16(hDlg
,cmb3
,CB_RESETCONTENT16
,0,0);
2888 i
=SendDlgItemMessage16(hDlg
,cmb1
,CB_GETCURSEL16
,0,0);
2891 HCURSOR16 hcursor
=SetCursor16(LoadCursor16(0,IDC_WAIT
));
2892 char *str
= SEGPTR_ALLOC(256);
2893 SendDlgItemMessage16(hDlg
,cmb1
,CB_GETLBTEXT16
,i
,
2894 (LPARAM
)SEGPTR_GET(str
));
2895 dprintf_commdlg(stddeb
,"WM_COMMAND/cmb1 =>%s\n",str
);
2896 EnumFontFamilies16(hdc
,str
,FontStyleEnumProc
,
2897 MAKELONG(GetDlgItem32(hDlg
,cmb2
),GetDlgItem32(hDlg
,cmb3
)));
2898 SetCursor16(hcursor
);
2901 if (!(lpcf
->Flags
& CF_PRINTERFONTS
&& lpcf
->hDC
))
2902 ReleaseDC32(hDlg
,hdc
);
2906 dprintf_commdlg(stddeb
,"WM_COMMAND: HDC failure !!!\n");
2907 EndDialog32 (hDlg
, 0);
2914 case cmb3
:if (HIWORD(lParam
)==CBN_SELCHANGE
|| HIWORD(lParam
)== BN_CLICKED
)
2916 char *str
= SEGPTR_ALLOC(256);
2917 dprintf_commdlg(stddeb
,"WM_COMMAND/cmb2,3 =%08lX\n", lParam
);
2918 i
=SendDlgItemMessage16(hDlg
,cmb1
,CB_GETCURSEL16
,0,0);
2920 i
=GetDlgItemText32A( hDlg
, cmb1
, str
, 256 );
2923 SendDlgItemMessage16(hDlg
,cmb1
,CB_GETLBTEXT16
,i
,
2924 (LPARAM
)SEGPTR_GET(str
));
2925 l
=SendDlgItemMessage16(hDlg
,cmb1
,CB_GETITEMDATA16
,i
,0);
2927 lpcf
->nFontType
= LOWORD(l
);
2928 /* FIXME: lpcf->nFontType |= .... SIMULATED_FONTTYPE and so */
2929 /* same value reported to the EnumFonts
2930 call back with the extra FONTTYPE_... bits added */
2931 lpxx
->lfPitchAndFamily
=j
&0xff;
2932 lpxx
->lfCharSet
=j
>>8;
2934 strcpy(lpxx
->lfFaceName
,str
);
2936 i
=SendDlgItemMessage16(hDlg
,cmb2
,CB_GETCURSEL16
,0,0);
2939 l
=SendDlgItemMessage16(hDlg
,cmb2
,CB_GETITEMDATA16
,i
,0);
2940 if (0!=(lpxx
->lfItalic
=HIWORD(l
)))
2941 lpcf
->nFontType
|= ITALIC_FONTTYPE
;
2942 if ((lpxx
->lfWeight
=LOWORD(l
)) > FW_MEDIUM
)
2943 lpcf
->nFontType
|= BOLD_FONTTYPE
;
2945 i
=SendDlgItemMessage16(hDlg
,cmb3
,CB_GETCURSEL16
,0,0);
2947 lpxx
->lfHeight
=-LOWORD(SendDlgItemMessage16(hDlg
,cmb3
,CB_GETITEMDATA16
,i
,0));
2950 lpxx
->lfStrikeOut
=IsDlgButtonChecked32(hDlg
,chx1
);
2951 lpxx
->lfUnderline
=IsDlgButtonChecked32(hDlg
,chx2
);
2952 lpxx
->lfWidth
=lpxx
->lfOrientation
=lpxx
->lfEscapement
=0;
2953 lpxx
->lfOutPrecision
=OUT_DEFAULT_PRECIS
;
2954 lpxx
->lfClipPrecision
=CLIP_DEFAULT_PRECIS
;
2955 lpxx
->lfQuality
=DEFAULT_QUALITY
;
2956 lpcf
->iPointSize
= -10*lpxx
->lfHeight
;
2958 hFont
=CreateFontIndirect16(lpxx
);
2960 SendDlgItemMessage16(hDlg
,stc6
,WM_SETFONT
,hFont
,TRUE
);
2961 /* FIXME: Delete old font ...? */
2965 case cmb4
:i
=SendDlgItemMessage16(hDlg
,cmb4
,CB_GETCURSEL16
,0,0);
2968 lpcf
->rgbColors
=textcolors
[i
];
2969 InvalidateRect32( GetDlgItem32(hDlg
,stc6
), NULL
, 0 );
2973 case psh15
:i
=RegisterWindowMessage32A( HELPMSGSTRING
);
2974 if (lpcf
->hwndOwner
)
2975 SendMessage16(lpcf
->hwndOwner
,i
,0,(LPARAM
)lpcf
);
2976 if (CFn_HookCallChk(lpcf
))
2977 CallWindowProc16(lpcf
->lpfnHook
,hDlg
,WM_COMMAND
,psh15
,(LPARAM
)lpcf
);
2980 case IDOK
:if ( (!(lpcf
->Flags
& CF_LIMITSIZE
)) ||
2981 ( (lpcf
->Flags
& CF_LIMITSIZE
) &&
2982 (-lpxx
->lfHeight
>= lpcf
->nSizeMin
) &&
2983 (-lpxx
->lfHeight
<= lpcf
->nSizeMax
)))
2984 EndDialog32(hDlg
, TRUE
);
2988 sprintf(buffer
,"Select a font size between %d and %d points.",
2989 lpcf
->nSizeMin
,lpcf
->nSizeMax
);
2990 MessageBox16(hDlg
,buffer
,NULL
,MB_OK
);
2993 case IDCANCEL
:EndDialog32(hDlg
, FALSE
);
3000 /***********************************************************************
3001 * FormatCharDlgProc (COMMDLG.16)
3002 FIXME: 1. some strings are "hardcoded", but it's better load from sysres
3003 2. some CF_.. flags are not supported
3004 3. some TType extensions
3006 LRESULT WINAPI
FormatCharDlgProc(HWND16 hDlg
, UINT16 message
, WPARAM16 wParam
,
3009 LPCHOOSEFONT lpcf
=(LPCHOOSEFONT
)GetWindowLong32A(hDlg
, DWL_USER
);
3010 if (message
!=WM_INITDIALOG
)
3015 if (CFn_HookCallChk(lpcf
))
3016 res
=CallWindowProc16(lpcf
->lpfnHook
,hDlg
,message
,wParam
,lParam
);
3021 return CFn_WMInitDialog(hDlg
,wParam
,lParam
);
3024 case WM_MEASUREITEM
:
3025 return CFn_WMMeasureItem(hDlg
,wParam
,lParam
);
3027 return CFn_WMDrawItem(hDlg
,wParam
,lParam
);
3029 return CFn_WMCtlColor(hDlg
,wParam
,lParam
);
3031 return CFn_WMCommand(hDlg
,wParam
,lParam
);
3032 case WM_CHOOSEFONT_GETLOGFONT
:
3033 dprintf_commdlg(stddeb
,
3034 "FormatCharDlgProc // WM_CHOOSEFONT_GETLOGFONT lParam=%08lX\n", lParam
);
3035 /* FIXME: current logfont back to caller */
3042 #define GET_XXX_FILENAME(xxx) \
3043 BOOL32 WINAPI xxx##32A( LPOPENFILENAME32A ofn ) \
3046 LPOPENFILENAME16 ofn16 = SEGPTR_ALLOC(sizeof(OPENFILENAME16)); \
3048 memset(ofn16,'\0',sizeof(*ofn16)); \
3049 ofn16->lStructSize = sizeof(*ofn16); \
3050 ofn16->hwndOwner = ofn->hwndOwner; \
3051 /* FIXME: OPENFILENAME16 got only 16 bit for HINSTANCE... */ \
3052 ofn16->hInstance = MODULE_HANDLEtoHMODULE16(ofn->hInstance); \
3053 if (ofn->lpstrFilter) { \
3056 /* filter is a list... title\0ext\0......\0\0 */ \
3057 s = (LPSTR)ofn->lpstrFilter; \
3059 s = s+strlen(s)+1; \
3061 x = (LPSTR)SEGPTR_ALLOC(s-ofn->lpstrFilter); \
3062 memcpy(x,ofn->lpstrFilter,s-ofn->lpstrFilter); \
3063 ofn16->lpstrFilter = SEGPTR_GET(x); \
3065 if (ofn->lpstrCustomFilter) { \
3068 /* filter is a list... title\0ext\0......\0\0 */ \
3069 s = (LPSTR)ofn->lpstrCustomFilter; \
3071 s = s+strlen(s)+1; \
3072 x = SEGPTR_ALLOC(s-ofn->lpstrCustomFilter); \
3074 memcpy(x,ofn->lpstrCustomFilter,s-ofn->lpstrCustomFilter);\
3075 ofn16->lpstrCustomFilter = SEGPTR_GET(x); \
3077 ofn16->nMaxCustFilter = ofn->nMaxCustFilter; \
3078 ofn16->nFilterIndex = ofn->nFilterIndex; \
3079 ofn16->lpstrFile = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFile)); \
3080 ofn16->nMaxFile = ofn->nMaxFile; \
3081 if (ofn->lpstrFileTitle) \
3082 ofn16->lpstrFileTitle= SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrFileTitle));\
3083 ofn16->nMaxFileTitle = ofn->nMaxFileTitle; \
3084 if (ofn->lpstrInitialDir) \
3085 ofn16->lpstrInitialDir = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrInitialDir));\
3086 if (ofn->lpstrTitle) \
3087 ofn16->lpstrTitle = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrTitle));\
3088 ofn16->Flags = ofn->Flags|OFN_WINE32; \
3089 ofn16->nFileOffset = ofn->nFileOffset; \
3090 ofn16->nFileExtension = ofn->nFileExtension; \
3091 if (ofn->lpstrDefExt) \
3092 ofn16->lpstrDefExt = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpstrDefExt));\
3093 ofn16->lCustData = ofn->lCustData; \
3094 ofn16->lpfnHook = (WNDPROC16)ofn->lpfnHook; \
3096 if (ofn->lpTemplateName) \
3097 ofn16->lpTemplateName = SEGPTR_GET(SEGPTR_STRDUP(ofn->lpTemplateName));\
3099 ret = xxx##16(SEGPTR_GET(ofn16)); \
3101 if (ofn16->lpstrFilter) \
3102 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFilter)); \
3103 if (ofn16->lpTemplateName) \
3104 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpTemplateName)); \
3105 if (ofn16->lpstrDefExt) \
3106 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrDefExt)); \
3107 if (ofn16->lpstrTitle) \
3108 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrTitle)); \
3109 if (ofn16->lpstrInitialDir) \
3110 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrInitialDir)); \
3111 if (ofn16->lpstrCustomFilter) \
3112 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrCustomFilter)); \
3114 strcpy(ofn->lpstrFile,PTR_SEG_TO_LIN(ofn16->lpstrFile)); \
3115 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFile)); \
3117 if (ofn16->lpstrFileTitle) \
3118 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFileTitle)); \
3119 SEGPTR_FREE(ofn16); \
3123 BOOL32 WINAPI xxx##32W( LPOPENFILENAME32W ofn ) \
3126 LPOPENFILENAME16 ofn16 = SEGPTR_ALLOC(sizeof(OPENFILENAME16)); \
3128 memset(ofn16,'\0',sizeof(*ofn16)); \
3129 ofn16->lStructSize = sizeof(*ofn16); \
3130 ofn16->hwndOwner = ofn->hwndOwner; \
3131 /* FIXME: OPENFILENAME16 got only 16 bit for HINSTANCE... */ \
3132 ofn16->hInstance = MODULE_HANDLEtoHMODULE16(ofn->hInstance); \
3133 if (ofn->lpstrFilter) { \
3138 /* filter is a list... title\0ext\0......\0\0 */ \
3139 s = (LPWSTR)ofn->lpstrFilter; \
3141 s = s+lstrlen32W(s)+1; \
3143 n = s - ofn->lpstrFilter; /* already divides by 2. ptr magic */\
3144 x = y = (LPSTR)SEGPTR_ALLOC(n); \
3145 s = (LPWSTR)ofn->lpstrFilter; \
3148 x+=lstrlen32A(x)+1; \
3149 s+=lstrlen32W(s)+1; \
3152 ofn16->lpstrFilter = SEGPTR_GET(y); \
3154 if (ofn->lpstrCustomFilter) { \
3159 /* filter is a list... title\0ext\0......\0\0 */ \
3160 s = (LPWSTR)ofn->lpstrCustomFilter; \
3162 s = s+lstrlen32W(s)+1; \
3164 n = s - ofn->lpstrCustomFilter; \
3165 x = y = (LPSTR)SEGPTR_ALLOC(n); \
3166 s = (LPWSTR)ofn->lpstrCustomFilter; \
3169 x+=lstrlen32A(x)+1; \
3170 s+=lstrlen32W(s)+1; \
3173 ofn16->lpstrCustomFilter = SEGPTR_GET(y); \
3175 ofn16->nMaxCustFilter = ofn->nMaxCustFilter; \
3176 ofn16->nFilterIndex = ofn->nFilterIndex; \
3177 ofn16->lpstrFile = SEGPTR_GET(SEGPTR_ALLOC(ofn->nMaxFile)); \
3178 ofn16->nMaxFile = ofn->nMaxFile; \
3179 if (ofn->lpstrFileTitle) \
3180 ofn16->lpstrFileTitle= SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrFileTitle));\
3181 ofn16->nMaxFileTitle = ofn->nMaxFileTitle; \
3182 if (ofn->lpstrInitialDir) \
3183 ofn16->lpstrInitialDir = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrInitialDir));\
3184 if (ofn->lpstrTitle) \
3185 ofn16->lpstrTitle = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrTitle));\
3186 ofn16->Flags = ofn->Flags|OFN_WINE32|OFN_UNICODE; \
3187 ofn16->nFileOffset = ofn->nFileOffset; \
3188 ofn16->nFileExtension = ofn->nFileExtension; \
3189 if (ofn->lpstrDefExt) \
3190 ofn16->lpstrDefExt = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpstrDefExt));\
3191 ofn16->lCustData = ofn->lCustData; \
3192 ofn16->lpfnHook = (WNDPROC16)ofn->lpfnHook; \
3193 if (ofn->lpTemplateName) { \
3194 ofn16->lpTemplateName = SEGPTR_GET(SEGPTR_STRDUP_WtoA(ofn->lpTemplateName));\
3196 ret = xxx##16(SEGPTR_GET(ofn16)); \
3198 if (ofn16->lpstrFilter) \
3199 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFilter)); \
3200 if (ofn16->lpTemplateName) \
3201 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpTemplateName)); \
3202 if (ofn16->lpstrDefExt) \
3203 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrDefExt)); \
3204 if (ofn16->lpstrTitle) \
3205 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrTitle)); \
3206 if (ofn16->lpstrInitialDir) \
3207 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrInitialDir)); \
3208 if (ofn16->lpstrCustomFilter) \
3209 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrCustomFilter)); \
3211 lstrcpyAtoW(ofn->lpstrFile,PTR_SEG_TO_LIN(ofn16->lpstrFile)); \
3212 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFile)); \
3214 if (ofn16->lpstrFileTitle) \
3215 SEGPTR_FREE(PTR_SEG_TO_LIN(ofn16->lpstrFileTitle)); \
3216 SEGPTR_FREE(ofn16); \
3220 GET_XXX_FILENAME(GetOpenFileName
)
3221 GET_XXX_FILENAME(GetSaveFileName
)