2 * COMMDLG - Print Dialog
4 * Copyright 1994 Martin Ayotte
5 * Copyright 1996 Albrecht Kleine
6 * Copyright 1999 Klaas van Gend
7 * Copyright 2000 Huw D M Davies
9 * This library is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public
11 * License as published by the Free Software Foundation; either
12 * version 2.1 of the License, or (at your option) any later version.
14 * This library is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with this library; if not, write to the Free Software
21 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
33 #include "wine/wingdi16.h"
35 #include "wine/winuser16.h"
38 #include "wine/debug.h"
43 WINE_DEFAULT_DEBUG_CHANNEL(commdlg
);
45 static void global_handle_to_16( HGLOBAL16
*h16
, HGLOBAL handle
)
51 size
= GlobalSize( handle
);
52 if (*h16
) ret
= GlobalReAlloc16( *h16
, size
, GMEM_MOVEABLE
);
53 else ret
= GlobalAlloc16( GMEM_MOVEABLE
, size
);
56 void *src
= GlobalLock( handle
);
57 void *dst
= GlobalLock16( ret
);
58 memcpy( dst
, src
, size
);
59 GlobalUnlock( handle
);
60 GlobalUnlock16( ret
);
65 static HGLOBAL
global_handle_from_16( HGLOBAL16 handle
)
70 if (!handle
) return 0;
71 size
= GlobalSize16( handle
);
72 if ((ret
= GlobalAlloc( GMEM_MOVEABLE
, size
)))
74 void *src
= GlobalLock16( handle
);
75 void *dst
= GlobalLock( ret
);
76 memcpy( dst
, src
, size
);
77 GlobalUnlock16( handle
);
83 /**********************************************************************
88 /***********************************************************************
89 * PrintDlg (COMMDLG.20)
91 * Displays the PRINT dialog box, which enables the user to specify
92 * specific properties of the print job.
95 * nonzero if the user pressed the OK button
96 * zero if the user cancelled the window or an error occurred
99 * * calls up to the 32-bit versions of the Dialogs, which look different
100 * * Customizing is *not* implemented.
103 BOOL16 WINAPI
PrintDlg16( LPPRINTDLG16 lppd
)
108 if (!lppd
) return PrintDlgA(NULL
); /* generate failure with CDERR_INITIALIZATION */
110 pd32
.lStructSize
= sizeof(pd32
);
111 pd32
.Flags
= lppd
->Flags
& ~(PD_ENABLEPRINTTEMPLATE
| PD_ENABLEPRINTTEMPLATEHANDLE
|
112 PD_ENABLESETUPTEMPLATE
| PD_ENABLESETUPTEMPLATEHANDLE
|
113 PD_ENABLEPRINTHOOK
| PD_ENABLESETUPHOOK
);
114 pd32
.hwndOwner
= HWND_32(lppd
->hwndOwner
);
115 pd32
.hDevMode
= global_handle_from_16( lppd
->hDevMode
);
116 pd32
.hDevNames
= global_handle_from_16( lppd
->hDevNames
);
117 pd32
.nFromPage
= lppd
->nFromPage
;
118 pd32
.nToPage
= lppd
->nToPage
;
119 pd32
.nMinPage
= lppd
->nMinPage
;
120 pd32
.nMaxPage
= lppd
->nMaxPage
;
121 pd32
.nCopies
= lppd
->nCopies
;
123 if (lppd
->Flags
& (PD_ENABLEPRINTTEMPLATE
| PD_ENABLEPRINTTEMPLATEHANDLE
|
124 PD_ENABLESETUPTEMPLATE
| PD_ENABLESETUPTEMPLATEHANDLE
))
125 FIXME( "custom templates no longer supported, using default\n" );
126 if (lppd
->Flags
& PD_ENABLEPRINTHOOK
)
127 FIXME( "custom print hook %p no longer supported\n", lppd
->lpfnPrintHook
);
128 if (lppd
->Flags
& PD_ENABLESETUPHOOK
)
129 FIXME( "custom setup hook %p no longer supported\n", lppd
->lpfnSetupHook
);
131 /* Generate failure with CDERR_STRUCTSIZE, when needed */
132 if (lppd
->lStructSize
!= sizeof(PRINTDLG16
)) pd32
.lStructSize
--;
134 if ((ret
= PrintDlgA( &pd32
)))
136 lppd
->hDC
= HDC_16( pd32
.hDC
);
137 global_handle_to_16( &lppd
->hDevNames
, pd32
.hDevNames
);
138 global_handle_to_16( &lppd
->hDevMode
, pd32
.hDevMode
);
140 lppd
->nFromPage
= pd32
.nFromPage
;
141 lppd
->nToPage
= pd32
.nToPage
;
142 lppd
->nMinPage
= pd32
.nMinPage
;
143 lppd
->nMaxPage
= pd32
.nMaxPage
;
144 lppd
->nCopies
= pd32
.nCopies
;
146 GlobalFree( pd32
.hDevNames
);
147 GlobalFree( pd32
.hDevMode
);
151 /***********************************************************************
152 * PrintDlgProc (COMMDLG.21)
154 BOOL16 CALLBACK
PrintDlgProc16(HWND16 hDlg16
, UINT16 uMsg
, WPARAM16 wParam
, LPARAM lParam
)
156 FIXME( "%04x %04x %04x %08lx: stub\n", hDlg16
, uMsg
, wParam
, lParam
);
160 /***********************************************************************
161 * PrintSetupDlgProc (COMMDLG.22)
163 BOOL16 CALLBACK
PrintSetupDlgProc16(HWND16 hWnd16
, UINT16 wMsg
, WPARAM16 wParam
,
166 HWND hWnd
= HWND_32(hWnd16
);
170 TRACE("WM_INITDIALOG lParam=%08lX\n", lParam
);
171 ShowWindow(hWnd
, SW_SHOWNORMAL
);
176 EndDialog(hWnd
, TRUE
);
179 EndDialog(hWnd
, FALSE
);