ReactOS  0.4.11-dev-195-gef016bf
printdlg.c File Reference
#include <ctype.h>
#include <stdlib.h>
#include <stdarg.h>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include "windef.h"
#include "winbase.h"
#include "wingdi.h"
#include "winuser.h"
#include "winspool.h"
#include "winerror.h"
#include "objbase.h"
#include "commdlg.h"
#include "wine/unicode.h"
#include "wine/debug.h"
#include "dlgs.h"
#include "cderr.h"
#include "cdlg.h"
Include dependency graph for printdlg.c:

Go to the source code of this file.

Classes

struct  PRINT_PTRA
 
struct  PRINT_PTRW
 
struct  pd_flags
 
struct  pagesetup_data
 
struct  callback_data
 

Macros

#define COBJMACROS
 
#define NONAMELESSUNION
 
#define NONAMELESSSTRUCT
 
#define UPDOWN_ID   0x270f
 
#define MAX_COPIES   9999
 

Enumerations

enum  devnames_name { devnames_driver_name, devnames_device_name, devnames_output_name }
 
enum  hook_type { page_setup_hook, page_paint_hook }
 

Functions

 WINE_DEFAULT_DEBUG_CHANNEL (commdlg)
 
static LPWSTR strdupW (LPCWSTR p)
 
static DRIVER_INFO_3Wget_driver_infoW (HANDLE hprn)
 
static DRIVER_INFO_3Aget_driver_infoA (HANDLE hprn)
 
static PRINTER_INFO_2Wget_printer_infoW (HANDLE hprn)
 
static PRINTER_INFO_2Aget_printer_infoA (HANDLE hprn)
 
static HGLOBAL update_devmode_handleW (HGLOBAL hdm, DEVMODEW *dm)
 
static HGLOBAL update_devmode_handleA (HGLOBAL hdm, DEVMODEA *dm)
 
static DEVMODEAconvert_to_devmodeA (const DEVMODEW *dmW)
 
static BOOL PRINTDLG_OpenDefaultPrinter (HANDLE *hprn)
 
static INT PRINTDLG_SetUpPrinterListComboA (HWND hDlg, UINT id, LPCSTR name)
 
static INT PRINTDLG_SetUpPrinterListComboW (HWND hDlg, UINT id, LPCWSTR name)
 
static BOOL PRINTDLG_CreateDevNames (HGLOBAL *hmem, const char *DeviceDriverName, const char *DeviceName, const char *OutputPort)
 
static BOOL PRINTDLG_CreateDevNamesW (HGLOBAL *hmem, LPCWSTR DeviceDriverName, LPCWSTR DeviceName, LPCWSTR OutputPort)
 
static BOOL PRINTDLG_UpdatePrintDlgA (HWND hDlg, PRINT_PTRA *PrintStructures)
 
static BOOL PRINTDLG_UpdatePrintDlgW (HWND hDlg, PRINT_PTRW *PrintStructures)
 
static BOOL PRINTDLG_SetUpPaperComboBoxA (HWND hDlg, int nIDComboBox, char *PrinterName, char *PortName, LPDEVMODEA dm)
 
static BOOL PRINTDLG_SetUpPaperComboBoxW (HWND hDlg, int nIDComboBox, const WCHAR *PrinterName, const WCHAR *PortName, LPDEVMODEW dm)
 
static void PRINTDLG_UpdatePrinterInfoTextsA (HWND hDlg, const PRINTER_INFO_2A *pi)
 
static void PRINTDLG_UpdatePrinterInfoTextsW (HWND hDlg, const PRINTER_INFO_2W *pi)
 
static BOOL PRINTDLG_ChangePrinterA (HWND hDlg, char *name, PRINT_PTRA *PrintStructures)
 
static BOOL PRINTDLG_ChangePrinterW (HWND hDlg, WCHAR *name, PRINT_PTRW *PrintStructures)
 
static LRESULT check_printer_setup (HWND hDlg)
 
static LRESULT PRINTDLG_WMInitDialog (HWND hDlg, PRINT_PTRA *PrintStructures)
 
static LRESULT PRINTDLG_WMInitDialogW (HWND hDlg, PRINT_PTRW *PrintStructures)
 
static LRESULT PRINTDLG_WMCommandA (HWND hDlg, WPARAM wParam, PRINT_PTRA *PrintStructures)
 
static LRESULT PRINTDLG_WMCommandW (HWND hDlg, WPARAM wParam, PRINT_PTRW *PrintStructures)
 
static INT_PTR CALLBACK PrintDlgProcA (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static INT_PTR CALLBACK PrintDlgProcW (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static HGLOBAL PRINTDLG_GetDlgTemplateA (const PRINTDLGA *lppd)
 
static HGLOBAL PRINTDLG_GetDlgTemplateW (const PRINTDLGW *lppd)
 
static BOOL PRINTDLG_CreateDCA (LPPRINTDLGA lppd)
 
static BOOL PRINTDLG_CreateDCW (LPPRINTDLGW lppd)
 
BOOL WINAPI PrintDlgA (LPPRINTDLGA lppd)
 
BOOL WINAPI PrintDlgW (LPPRINTDLGW lppd)
 
static DWORD pagesetup_get_flags (const pagesetup_data *data)
 
static BOOL is_metric (const pagesetup_data *data)
 
static LONG tenths_mm_to_size (const pagesetup_data *data, LONG size)
 
static LONG thousandths_inch_to_size (const pagesetup_data *data, LONG size)
 
static WCHAR get_decimal_sep (void)
 
static void size2str (const pagesetup_data *data, DWORD size, LPWSTR strout)
 
static BOOL is_default_metric (void)
 
static void rotate_rect (RECT *rc, BOOL sense)
 
static void pagesetup_set_orientation (pagesetup_data *data, WORD orient)
 
static WORD pagesetup_get_orientation (const pagesetup_data *data)
 
static void pagesetup_set_papersize (pagesetup_data *data, WORD paper)
 
static WORD pagesetup_get_papersize (const pagesetup_data *data)
 
static void pagesetup_set_defaultsource (pagesetup_data *data, WORD source)
 
static WORD get_devname_offset (const DEVNAMES *dn, devnames_name which)
 
static WCHARpagesetup_get_a_devname (const pagesetup_data *data, devnames_name which)
 
static WCHARpagesetup_get_drvname (const pagesetup_data *data)
 
static WCHARpagesetup_get_devname (const pagesetup_data *data)
 
static WCHARpagesetup_get_portname (const pagesetup_data *data)
 
static void pagesetup_release_a_devname (const pagesetup_data *data, WCHAR *name)
 
static void pagesetup_set_devnames (pagesetup_data *data, LPCWSTR drv, LPCWSTR devname, LPCWSTR port)
 
static DEVMODEWpagesetup_get_devmode (const pagesetup_data *data)
 
static void pagesetup_release_devmode (const pagesetup_data *data, DEVMODEW *dm)
 
static void pagesetup_set_devmode (pagesetup_data *data, DEVMODEW *dm)
 
static POINTpagesetup_get_papersize_pt (const pagesetup_data *data)
 
static RECTpagesetup_get_margin_rect (const pagesetup_data *data)
 
static LPPAGESETUPHOOK pagesetup_get_hook (const pagesetup_data *data, hook_type which)
 
static LPARAM pagesetup_get_dlg_struct (const pagesetup_data *data)
 
static void swap_point (POINT *pt)
 
static BOOL pagesetup_update_papersize (pagesetup_data *data)
 
static BOOL pagesetup_change_printer (LPWSTR name, pagesetup_data *data)
 
static void pagesetup_init_combos (HWND hDlg, pagesetup_data *data)
 
static void pagesetup_change_printer_dialog (HWND hDlg, pagesetup_data *data)
 
static void pagesetup_change_preview (const pagesetup_data *data)
 
static LONGelement_from_margin_id (RECT *rc, WORD id)
 
static void update_margin_edits (HWND hDlg, const pagesetup_data *data, WORD id)
 
static void margin_edit_notification (HWND hDlg, const pagesetup_data *data, WORD msg, WORD id)
 
static void set_margin_groupbox_title (HWND hDlg, const pagesetup_data *data)
 
static void pagesetup_update_orientation_buttons (HWND hDlg, const pagesetup_data *data)
 
static void pagesetup_printer_properties (HWND hDlg, pagesetup_data *data)
 
static BOOL pagesetup_wm_command (HWND hDlg, WPARAM wParam, LPARAM lParam, pagesetup_data *data)
 
static UINT_PTR default_page_paint_hook (HWND hwndDlg, UINT uMsg, WPARAM wParam, LPARAM lParam, const pagesetup_data *data)
 
static LRESULT CALLBACK PRINTDLG_PagePaintProc (HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static LRESULT CALLBACK pagesetup_margin_editproc (HWND hwnd, UINT msg, WPARAM wparam, LPARAM lparam)
 
static void subclass_margin_edits (HWND hDlg)
 
static INT_PTR CALLBACK pagesetup_dlg_proc (HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
 
static WCHARget_default_printer (void)
 
static void pagesetup_dump_dlg_struct (const pagesetup_data *data)
 
static voidpagesetup_get_template (pagesetup_data *data)
 
static BOOL pagesetup_common (pagesetup_data *data)
 
BOOL WINAPI PageSetupDlgA (LPPAGESETUPDLGA setupdlg)
 
BOOL WINAPI PageSetupDlgW (LPPAGESETUPDLGW setupdlg)
 
static void pdlgex_to_pdlg (const PRINTDLGEXW *pdlgex, PRINTDLGW *pdlg)
 
static void pdlg_to_pdlgex (const PRINTDLGW *pdlg, PRINTDLGEXW *pdlgex)
 
static UINT_PTR CALLBACK pdlgex_hook_proc (HWND hwnd, UINT msg, WPARAM wp, LPARAM lp)
 
HRESULT WINAPI PrintDlgExA (LPPRINTDLGEXA lppd)
 
HRESULT WINAPI PrintDlgExW (LPPRINTDLGEXW lppd)
 

Variables

static const struct pd_flags psd_flags []
 
static const struct pd_flags pd_flags []
 
static WNDPROC lpfnStaticWndProc
 
static WNDPROC edit_wndproc
 
static WCHAR wszFakeDocumentText [1024]
 
static const WCHAR pd32_collateW [] = { 'P', 'D', '3', '2', '_', 'C', 'O', 'L', 'L', 'A', 'T', 'E', 0 }
 
static const WCHAR pd32_nocollateW [] = { 'P', 'D', '3', '2', '_', 'N', 'O', 'C', 'O', 'L', 'L', 'A', 'T', 'E', 0 }
 
static const WCHAR pd32_portraitW [] = { 'P', 'D', '3', '2', '_', 'P', 'O', 'R', 'T', 'R', 'A', 'I', 'T', 0 }
 
static const WCHAR pd32_landscapeW [] = { 'P', 'D', '3', '2', '_', 'L', 'A', 'N', 'D', 'S', 'C', 'A', 'P', 'E', 0 }
 
static const WCHAR printdlg_prop [] = {'_','_','W','I','N','E','_','P','R','I','N','T','D','L','G','D','A','T','A',0}
 
static const WCHAR pagesetupdlg_prop []
 

Macro Definition Documentation

#define COBJMACROS

Definition at line 31 of file printdlg.c.

#define MAX_COPIES   9999
#define NONAMELESSSTRUCT

Definition at line 33 of file printdlg.c.

#define NONAMELESSUNION

Definition at line 32 of file printdlg.c.

#define UPDOWN_ID   0x270f

Definition at line 53 of file printdlg.c.

Referenced by PRINTDLG_WMInitDialog(), and PRINTDLG_WMInitDialogW().

Enumeration Type Documentation

Enumerator
devnames_driver_name 
devnames_device_name 
devnames_output_name 

Definition at line 2755 of file printdlg.c.

Enumerator
page_setup_hook 
page_paint_hook 

Definition at line 2944 of file printdlg.c.

2945 {
2948 } hook_type;
hook_type
Definition: printdlg.c:2944

Function Documentation

static LRESULT check_printer_setup ( HWND  hDlg)
static

Definition at line 1441 of file printdlg.c.

Referenced by PrintDlgProcA(), and PrintDlgProcW().

1442 {
1443  DWORD needed,num;
1444  WCHAR resourcestr[256],resultstr[256];
1445 
1446  EnumPrintersW(PRINTER_ENUM_LOCAL, NULL, 2, NULL, 0, &needed, &num);
1447  if(needed == 0)
1448  {
1449  EnumPrintersW(PRINTER_ENUM_CONNECTIONS, NULL, 2, NULL, 0, &needed, &num);
1450  }
1451  if(needed > 0)
1452  return TRUE;
1453  else
1454  {
1456  LoadStringW(COMDLG32_hInstance, PD32_PRINT_TITLE,resourcestr, 255);
1457  MessageBoxW(hDlg, resultstr, resourcestr,MB_OK | MB_ICONWARNING);
1458  return FALSE;
1459  }
1460 }
#define PD32_NO_DEVICES
Definition: cdlg.h:63
#define PRINTER_ENUM_CONNECTIONS
Definition: winspool.h:804
#define TRUE
Definition: types.h:120
DECLSPEC_HIDDEN HINSTANCE COMDLG32_hInstance
Definition: cdlg32.c:42
__wchar_t WCHAR
Definition: xmlstorage.h:180
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
DWORD DWORD
Definition: winlogon.h:84
#define MB_ICONWARNING
Definition: winuser.h:780
#define FALSE
Definition: types.h:117
smooth NULL
Definition: ftsmooth.c:416
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
#define PRINTER_ENUM_LOCAL
Definition: winspool.h:803
GLuint GLuint num
Definition: glext.h:9618
WINBOOL WINAPI EnumPrintersW(DWORD Flags, LPWSTR Name, DWORD Level, LPBYTE pPrinterEnum, DWORD cbBuf, LPDWORD pcbNeeded, LPDWORD pcReturned)
#define MB_OK
Definition: winuser.h:784
#define PD32_PRINT_TITLE
Definition: cdlg.h:49
static DEVMODEA* convert_to_devmodeA ( const DEVMODEW dmW)
static

Definition at line 326 of file printdlg.c.

Referenced by pagesetup_set_devmode().

327 {
328  DEVMODEA *dmA;
329  DWORD size;
330 
331  if (!dmW) return NULL;
332  size = dmW->dmSize - CCHDEVICENAME -
333  ((dmW->dmSize > FIELD_OFFSET(DEVMODEW, dmFormName)) ? CCHFORMNAME : 0);
334 
335  dmA = HeapAlloc(GetProcessHeap(), 0, size + dmW->dmDriverExtra);
336  if (!dmA) return NULL;
337 
340 
341  if (FIELD_OFFSET(DEVMODEW, dmFormName) >= dmW->dmSize)
342  {
343  memcpy(&dmA->dmSpecVersion, &dmW->dmSpecVersion,
344  dmW->dmSize - FIELD_OFFSET(DEVMODEW, dmSpecVersion));
345  }
346  else
347  {
348  memcpy(&dmA->dmSpecVersion, &dmW->dmSpecVersion,
349  FIELD_OFFSET(DEVMODEW, dmFormName) - FIELD_OFFSET(DEVMODEW, dmSpecVersion));
352 
353  memcpy(&dmA->dmLogPixels, &dmW->dmLogPixels, dmW->dmSize - FIELD_OFFSET(DEVMODEW, dmLogPixels));
354  }
355 
356  dmA->dmSize = size;
357  memcpy((char *)dmA + dmA->dmSize, (const char *)dmW + dmW->dmSize, dmW->dmDriverExtra);
358  return dmA;
359 }
#define WideCharToMultiByte
Definition: compat.h:101
WORD dmSize
Definition: wingdi.h:1545
#define CP_ACP
Definition: compat.h:99
WORD dmDriverExtra
Definition: wingdi.h:1598
WCHAR dmFormName[CCHFORMNAME]
Definition: wingdi.h:1622
char * LPSTR
Definition: xmlstorage.h:182
BYTE dmFormName[CCHFORMNAME]
Definition: wingdi.h:1570
DWORD DWORD
Definition: winlogon.h:84
WORD dmLogPixels
Definition: wingdi.h:1623
smooth NULL
Definition: ftsmooth.c:416
WORD dmSpecVersion
Definition: wingdi.h:1543
WORD dmSpecVersion
Definition: wingdi.h:1595
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
WORD dmSize
Definition: wingdi.h:1597
WCHAR dmDeviceName[CCHDEVICENAME]
Definition: wingdi.h:1594
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
#define CCHFORMNAME
Definition: wingdi.h:67
#define CCHDEVICENAME
Definition: ddrawi.h:63
#define FIELD_OFFSET(t, f)
Definition: typedefs.h:254
WORD dmLogPixels
Definition: wingdi.h:1571
BYTE dmDeviceName[CCHDEVICENAME]
Definition: wingdi.h:1542
static UINT_PTR default_page_paint_hook ( HWND  hwndDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam,
const pagesetup_data data 
)
static

Definition at line 3445 of file printdlg.c.

Referenced by PRINTDLG_PagePaintProc().

3447 {
3448  LPRECT lprc = (LPRECT) lParam;
3449  HDC hdc = (HDC) wParam;
3450  HPEN hpen, holdpen;
3451  LOGFONTW lf;
3452  HFONT hfont, holdfont;
3453  INT oldbkmode;
3454  TRACE("uMsg: WM_USER+%d\n",uMsg-WM_USER);
3455  /* Call user paint hook if enable */
3457  if (pagesetup_get_hook(data, page_paint_hook)(hwndDlg, uMsg, wParam, lParam))
3458  return TRUE;
3459 
3460  switch (uMsg) {
3461  /* LPPAGESETUPDLG in lParam */
3462  case WM_PSD_PAGESETUPDLG:
3463  /* Inform about the sample page rectangle */
3464  case WM_PSD_FULLPAGERECT:
3465  /* Inform about the margin rectangle */
3466  case WM_PSD_MINMARGINRECT:
3467  return FALSE;
3468 
3469  /* Draw dashed rectangle showing margins */
3470  case WM_PSD_MARGINRECT:
3472  holdpen = SelectObject(hdc, hpen);
3473  Rectangle(hdc, lprc->left, lprc->top, lprc->right, lprc->bottom);
3474  DeleteObject(SelectObject(hdc, holdpen));
3475  return TRUE;
3476  /* Draw the fake document */
3477  case WM_PSD_GREEKTEXTRECT:
3478  /* select a nice scalable font, because we want the text really small */
3479  SystemParametersInfoW(SPI_GETICONTITLELOGFONT, sizeof(lf), &lf, 0);
3480  lf.lfHeight = 6; /* value chosen based on visual effect */
3481  hfont = CreateFontIndirectW(&lf);
3482  holdfont = SelectObject(hdc, hfont);
3483 
3484  /* if text not loaded, then do so now */
3485  if (wszFakeDocumentText[0] == '\0')
3490 
3491  oldbkmode = SetBkMode(hdc, TRANSPARENT);
3493  SetBkMode(hdc, oldbkmode);
3494 
3495  DeleteObject(SelectObject(hdc, holdfont));
3496  return TRUE;
3497 
3498  /* Envelope stamp */
3499  case WM_PSD_ENVSTAMPRECT:
3500  /* Return address */
3501  case WM_PSD_YAFULLPAGERECT:
3502  FIXME("envelope/stamp is not implemented\n");
3503  return FALSE;
3504  default:
3505  FIXME("Unknown message %x\n",uMsg);
3506  return FALSE;
3507  }
3508  return TRUE;
3509 }
#define HDC
Definition: msvc.h:22
#define WM_PSD_FULLPAGERECT
Definition: commdlg.h:189
#define TRUE
Definition: types.h:120
HPEN WINAPI CreatePen(_In_ int, _In_ int, _In_ COLORREF)
DECLSPEC_HIDDEN HINSTANCE COMDLG32_hInstance
Definition: cdlg32.c:42
_In_ int _Inout_ LPRECT lprc
Definition: winuser.h:4334
BOOL WINAPI Rectangle(_In_ HDC, _In_ int, _In_ int, _In_ int, _In_ int)
#define IDS_FAKEDOCTEXT
Definition: cdlg.h:184
#define DT_WORDBREAK
Definition: winuser.h:544
LONG lfHeight
Definition: dimm.idl:59
UINT uMsg
Definition: precomp.h:45
LONG top
Definition: windef.h:297
HGDIOBJ WINAPI SelectObject(_In_ HDC, _In_ HGDIOBJ)
Definition: dc.c:1497
BOOL WINAPI DeleteObject(_In_ HGDIOBJ)
static HPEN hpen
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
#define WM_PSD_GREEKTEXTRECT
Definition: commdlg.h:192
#define DT_NOPREFIX
Definition: winuser.h:537
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
int32_t INT
Definition: typedefs.h:56
DWORD WINAPI GetSysColor(_In_ int)
#define COLOR_3DSHADOW
Definition: winuser.h:921
int WINAPI SetBkMode(_In_ HDC, _In_ int)
Definition: dc.c:1032
#define FALSE
Definition: types.h:117
#define DT_LEFT
Definition: winuser.h:534
#define FIXME(fmt,...)
Definition: debug.h:110
#define TRANSPARENT
Definition: wingdi.h:948
HDC hdc
Definition: msvc.h:53
HFONT WINAPI CreateFontIndirectW(_In_ const LOGFONTW *)
#define ARRAY_SIZE(A)
Definition: reg.h:24
static HFONT hfont
BOOL WINAPI SystemParametersInfoW(_In_ UINT, _In_ UINT, _Inout_opt_ PVOID, _In_ UINT)
#define LPRECT
Definition: msvc.h:30
#define TRACE(s)
Definition: solgame.cpp:4
static WCHAR wszFakeDocumentText[1024]
Definition: printdlg.c:144
UINT WPARAM wParam
Definition: precomp.h:45
static LPPAGESETUPHOOK pagesetup_get_hook(const pagesetup_data *data, hook_type which)
Definition: printdlg.c:2950
#define WM_PSD_MARGINRECT
Definition: commdlg.h:191
#define WM_PSD_PAGESETUPDLG
Definition: commdlg.h:188
#define WM_PSD_YAFULLPAGERECT
Definition: commdlg.h:194
#define PS_DASH
Definition: wingdi.h:585
#define WM_USER
Definition: winuser.h:1856
#define DT_TOP
Definition: winuser.h:542
UINT WPARAM LPARAM lParam
Definition: precomp.h:45
#define SPI_GETICONTITLELOGFONT
Definition: winuser.h:1362
#define WM_PSD_MINMARGINRECT
Definition: commdlg.h:190
static DWORD *static HFONT(WINAPI *pCreateFontIndirectExA)(const ENUMLOGFONTEXDVA *)
LONG bottom
Definition: windef.h:299
#define WM_PSD_ENVSTAMPRECT
Definition: commdlg.h:193
#define PSD_ENABLEPAGEPAINTHOOK
Definition: commdlg.h:186
INT WINAPI DrawTextW(HDC hdc, LPCWSTR str, INT count, LPRECT rect, UINT flags)
Definition: defwnd.c:17
static DWORD pagesetup_get_flags(const pagesetup_data *data)
Definition: printdlg.c:2580
static LONG* element_from_margin_id ( RECT rc,
WORD  id 
)
inlinestatic

Definition at line 3209 of file printdlg.c.

Referenced by margin_edit_notification(), and update_margin_edits().

3210 {
3211  switch(id)
3212  {
3213  case edt4: return &rc->left;
3214  case edt5: return &rc->top;
3215  case edt6: return &rc->right;
3216  case edt7: return &rc->bottom;
3217  }
3218  return NULL;
3219 }
#define edt5
Definition: dlgs.h:69
LONG top
Definition: windef.h:297
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
#define edt4
Definition: dlgs.h:68
smooth NULL
Definition: ftsmooth.c:416
#define edt7
Definition: dlgs.h:71
LONG bottom
Definition: windef.h:299
#define edt6
Definition: dlgs.h:70
static WCHAR get_decimal_sep ( void  )
static

Definition at line 2606 of file printdlg.c.

Referenced by margin_edit_notification(), pagesetup_margin_editproc(), and size2str().

2607 {
2608  static WCHAR sep;
2609 
2610  if(!sep)
2611  {
2612  WCHAR buf[] = {'.', 0};
2614  sep = buf[0];
2615  }
2616  return sep;
2617 }
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define LOCALE_USER_DEFAULT
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:807
#define LOCALE_SDECIMAL
Definition: winnls.h:42
#define ARRAY_SIZE(A)
Definition: reg.h:24
static WCHAR* get_default_printer ( void  )
static

Definition at line 3765 of file printdlg.c.

Referenced by pagesetup_common().

3766 {
3767  WCHAR *name = NULL;
3768  DWORD len = 0;
3769 
3770  GetDefaultPrinterW(NULL, &len);
3771  if(len)
3772  {
3773  name = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
3774  GetDefaultPrinterW(name, &len);
3775  }
3776  return name;
3777 }
WINBOOL WINAPI GetDefaultPrinterW(LPWSTR pszBuffer, LPDWORD pcchBuffer)
Definition: printers.c:409
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD DWORD
Definition: winlogon.h:84
GLuint const GLchar * name
Definition: glext.h:6031
smooth NULL
Definition: ftsmooth.c:416
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLenum GLsizei len
Definition: glext.h:6722
Definition: name.c:36
static WORD get_devname_offset ( const DEVNAMES dn,
devnames_name  which 
)
inlinestatic

Definition at line 2763 of file printdlg.c.

Referenced by pagesetup_get_a_devname().

2764 {
2765  switch(which)
2766  {
2767  case devnames_driver_name: return dn->wDriverOffset;
2768  case devnames_device_name: return dn->wDeviceOffset;
2769  case devnames_output_name: return dn->wOutputOffset;
2770  }
2771  ERR("Shouldn't be here\n");
2772  return 0;
2773 }
static GLenum which
Definition: wgl_font.c:159
WORD wDeviceOffset
Definition: commdlg.h:298
WORD wDriverOffset
Definition: commdlg.h:297
#define ERR(fmt,...)
Definition: debug.h:109
WORD wOutputOffset
Definition: commdlg.h:299
static DRIVER_INFO_3A* get_driver_infoA ( HANDLE  hprn)
static

Definition at line 192 of file printdlg.c.

Referenced by PrintDlgExA().

193 {
194  DRIVER_INFO_3A *di3 = NULL;
195  DWORD needed = 0;
196  BOOL res;
197 
198  res = GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
199  if (!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
200  di3 = HeapAlloc(GetProcessHeap(), 0, needed);
201  res = GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)di3, needed, &needed);
202  }
203 
204  if (res)
205  return di3;
206 
207  TRACE("GetPrinterDriverA failed with %u\n", GetLastError());
208  HeapFree(GetProcessHeap(), 0, di3);
209  return NULL;
210 }
WINBOOL WINAPI GetPrinterDriverA(HANDLE hPrinter, LPSTR pEnvironment, DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf, LPDWORD pcbNeeded)
Definition: printers.c:507
unsigned char * LPBYTE
Definition: typedefs.h:52
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD DWORD
Definition: winlogon.h:84
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLuint res
Definition: glext.h:9613
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
static DRIVER_INFO_3W* get_driver_infoW ( HANDLE  hprn)
static

Definition at line 172 of file printdlg.c.

Referenced by PrintDlgExW().

173 {
174  DRIVER_INFO_3W *di3 = NULL;
175  DWORD needed = 0;
176  BOOL res;
177 
178  res = GetPrinterDriverW(hprn, NULL, 3, NULL, 0, &needed);
179  if (!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
180  di3 = HeapAlloc(GetProcessHeap(), 0, needed);
181  res = GetPrinterDriverW(hprn, NULL, 3, (LPBYTE)di3, needed, &needed);
182  }
183 
184  if (res)
185  return di3;
186 
187  TRACE("GetPrinterDriverW failed with %u\n", GetLastError());
188  HeapFree(GetProcessHeap(), 0, di3);
189  return NULL;
190 }
unsigned char * LPBYTE
Definition: typedefs.h:52
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
WINBOOL WINAPI GetPrinterDriverW(HANDLE hPrinter, LPWSTR pEnvironment, DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf, LPDWORD pcbNeeded)
Definition: printers.c:514
DWORD DWORD
Definition: winlogon.h:84
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLuint res
Definition: glext.h:9613
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
static PRINTER_INFO_2A* get_printer_infoA ( HANDLE  hprn)
static

Definition at line 239 of file printdlg.c.

Referenced by PrintDlgExA().

240 {
241  PRINTER_INFO_2A *pi2 = NULL;
242  DWORD needed = 0;
243  BOOL res;
244 
245  res = GetPrinterA(hprn, 2, NULL, 0, &needed);
246  if (!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
247  pi2 = HeapAlloc(GetProcessHeap(), 0, needed);
248  res = GetPrinterA(hprn, 2, (LPBYTE)pi2, needed, &needed);
249  }
250 
251  if (res)
252  return pi2;
253 
254  TRACE("GetPrinterA failed with %u\n", GetLastError());
255  HeapFree(GetProcessHeap(), 0, pi2);
256  return NULL;
257 }
WINBOOL WINAPI GetPrinterA(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter, DWORD cbBuf, LPDWORD pcbNeeded)
Definition: printers.c:500
unsigned char * LPBYTE
Definition: typedefs.h:52
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD DWORD
Definition: winlogon.h:84
smooth NULL
Definition: ftsmooth.c:416
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLuint res
Definition: glext.h:9613
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
static PRINTER_INFO_2W* get_printer_infoW ( HANDLE  hprn)
static

Definition at line 219 of file printdlg.c.

Referenced by PrintDlgExW().

220 {
221  PRINTER_INFO_2W *pi2 = NULL;
222  DWORD needed = 0;
223  BOOL res;
224 
225  res = GetPrinterW(hprn, 2, NULL, 0, &needed);
226  if (!res && (GetLastError() == ERROR_INSUFFICIENT_BUFFER)) {
227  pi2 = HeapAlloc(GetProcessHeap(), 0, needed);
228  res = GetPrinterW(hprn, 2, (LPBYTE)pi2, needed, &needed);
229  }
230 
231  if (res)
232  return pi2;
233 
234  TRACE("GetPrinterW failed with %u\n", GetLastError());
235  HeapFree(GetProcessHeap(), 0, pi2);
236  return NULL;
237 }
unsigned char * LPBYTE
Definition: typedefs.h:52
DWORD WINAPI GetLastError(VOID)
Definition: except.c:1059
DWORD DWORD
Definition: winlogon.h:84
smooth NULL
Definition: ftsmooth.c:416
WINBOOL WINAPI GetPrinterW(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter, DWORD cbBuf, LPDWORD pcbNeeded)
Definition: printers.c:521
#define TRACE(s)
Definition: solgame.cpp:4
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
GLuint res
Definition: glext.h:9613
#define HeapFree(x, y, z)
Definition: compat.h:394
#define ERROR_INSUFFICIENT_BUFFER
Definition: dderror.h:10
static BOOL is_default_metric ( void  )
inlinestatic

Definition at line 2644 of file printdlg.c.

Referenced by pagesetup_common().

2645 {
2646  DWORD system;
2647  GetLocaleInfoW(LOCALE_USER_DEFAULT, LOCALE_IMEASURE | LOCALE_RETURN_NUMBER,
2648  (LPWSTR)&system, sizeof(system));
2649  return system == 0;
2650 }
#define LOCALE_USER_DEFAULT
#define LOCALE_IMEASURE
Definition: winnls.h:41
DWORD DWORD
Definition: winlogon.h:84
INT WINAPI GetLocaleInfoW(LCID lcid, LCTYPE lctype, LPWSTR buffer, INT len)
Definition: lang.c:807
int __cdecl system(_In_opt_z_ const char *_Command)
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static BOOL is_metric ( const pagesetup_data data)
inlinestatic

Definition at line 2585 of file printdlg.c.

Referenced by margin_edit_notification(), set_margin_groupbox_title(), size2str(), tenths_mm_to_size(), and thousandths_inch_to_size().

2586 {
2588 }
#define PSD_INHUNDREDTHSOFMILLIMETERS
Definition: commdlg.h:175
static DWORD pagesetup_get_flags(const pagesetup_data *data)
Definition: printdlg.c:2580
static void margin_edit_notification ( HWND  hDlg,
const pagesetup_data data,
WORD  msg,
WORD  id 
)
static

Definition at line 3236 of file printdlg.c.

Referenced by pagesetup_wm_command().

3237 {
3238  switch (msg)
3239  {
3240  case EN_CHANGE:
3241  {
3242  WCHAR buf[10];
3243  LONG val = 0;
3245 
3246  if (GetDlgItemTextW(hDlg, id, buf, ARRAY_SIZE(buf)) != 0)
3247  {
3248  WCHAR *end;
3249  WCHAR decimal = get_decimal_sep();
3250 
3251  val = strtolW(buf, &end, 10);
3252  if(end != buf || *end == decimal)
3253  {
3254  int mult = is_metric(data) ? 100 : 1000;
3255  val *= mult;
3256  if(*end == decimal)
3257  {
3258  while(mult > 1)
3259  {
3260  end++;
3261  mult /= 10;
3262  if(isdigitW(*end))
3263  val += (*end - '0') * mult;
3264  else
3265  break;
3266  }
3267  }
3268  }
3269  }
3270  *value = val;
3271  return;
3272  }
3273 
3274  case EN_KILLFOCUS:
3275  update_margin_edits(hDlg, data, id);
3276  return;
3277  }
3278 }
UINT WINAPI GetDlgItemTextW(HWND hDlg, int nIDDlgItem, LPWSTR lpString, int nMaxCount)
Definition: dialog.c:2195
Definition: get.c:139
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
__wchar_t WCHAR
Definition: xmlstorage.h:180
static void update_margin_edits(HWND hDlg, const pagesetup_data *data, WORD id)
Definition: printdlg.c:3221
#define strtolW(s, e, b)
Definition: unicode.h:33
GLuint GLuint end
Definition: gl.h:1545
static WCHAR get_decimal_sep(void)
Definition: printdlg.c:2606
#define EN_KILLFOCUS
Definition: winuser.h:1986
long LONG
Definition: pedump.c:60
#define ARRAY_SIZE(A)
Definition: reg.h:24
GLuint GLfloat * val
Definition: glext.h:7180
static BOOL is_metric(const pagesetup_data *data)
Definition: printdlg.c:2585
static LONG * element_from_margin_id(RECT *rc, WORD id)
Definition: printdlg.c:3209
WINE_UNICODE_INLINE int isdigitW(WCHAR wc)
Definition: unicode.h:170
UINT msg
Definition: msvc.h:92
static RECT * pagesetup_get_margin_rect(const pagesetup_data *data)
Definition: printdlg.c:2939
#define EN_CHANGE
Definition: winuser.h:1983
static void pagesetup_change_preview ( const pagesetup_data data)
static

Definition at line 3178 of file printdlg.c.

Referenced by pagesetup_dlg_proc(), pagesetup_printer_properties(), and pagesetup_wm_command().

3179 {
3180  LONG width, height, x, y;
3181  RECT tmp;
3182  const int shadow = 4;
3183 
3185  {
3186  width = data->rtDrawRect.right - data->rtDrawRect.left;
3187  height = pagesetup_get_papersize_pt(data)->y * width / pagesetup_get_papersize_pt(data)->x;
3188  }
3189  else
3190  {
3191  height = data->rtDrawRect.bottom - data->rtDrawRect.top;
3192  width = pagesetup_get_papersize_pt(data)->x * height / pagesetup_get_papersize_pt(data)->y;
3193  }
3194  x = (data->rtDrawRect.right + data->rtDrawRect.left - width) / 2;
3195  y = (data->rtDrawRect.bottom + data->rtDrawRect.top - height) / 2;
3196  TRACE("draw rect %s x=%d, y=%d, w=%d, h=%d\n",
3197  wine_dbgstr_rect(&data->rtDrawRect), x, y, width, height);
3198 
3199  MoveWindow(GetDlgItem(data->hDlg, rct2), x + width, y + shadow, shadow, height, FALSE);
3200  MoveWindow(GetDlgItem(data->hDlg, rct3), x + shadow, y + height, width, shadow, FALSE);
3201  MoveWindow(GetDlgItem(data->hDlg, rct1), x, y, width, height, FALSE);
3202 
3203  tmp = data->rtDrawRect;
3204  tmp.right += shadow;
3205  tmp.bottom += shadow;
3206  InvalidateRect(data->hDlg, &tmp, TRUE);
3207 }
#define TRUE
Definition: types.h:120
static POINT * pagesetup_get_papersize_pt(const pagesetup_data *data)
Definition: printdlg.c:2934
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
LONG top
Definition: windef.h:297
LONG left
Definition: windef.h:296
LONG right
Definition: windef.h:298
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
#define TRACE(s)
Definition: solgame.cpp:4
GLint GLint GLsizei width
Definition: gl.h:1546
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define DMORIENT_LANDSCAPE
Definition: wingdi.h:1092
const char * wine_dbgstr_rect(const RECT *rect)
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
BOOL WINAPI MoveWindow(_In_ HWND, _In_ int, _In_ int, _In_ int, _In_ int, _In_ BOOL)
static WORD pagesetup_get_orientation(const pagesetup_data *data)
Definition: printdlg.c:2695
GLint GLint GLsizei GLsizei height
Definition: gl.h:1546
#define rct3
Definition: dlgs.h:149
LONG bottom
Definition: windef.h:299
INT INT y
Definition: msvc.h:62
#define rct1
Definition: dlgs.h:147
#define rct2
Definition: dlgs.h:148
INT x
Definition: msvc.h:62
static BOOL pagesetup_change_printer ( LPWSTR  name,
pagesetup_data data 
)
static

Definition at line 3046 of file printdlg.c.

Referenced by pagesetup_common(), and pagesetup_wm_command().

3047 {
3048  HANDLE hprn;
3049  DWORD needed;
3050  PRINTER_INFO_2W *prn_info = NULL;
3051  DRIVER_INFO_3W *drv_info = NULL;
3052  DEVMODEW *dm = NULL;
3053  BOOL retval = FALSE;
3054 
3055  if(!OpenPrinterW(name, &hprn, NULL))
3056  {
3057  ERR("Can't open printer %s\n", debugstr_w(name));
3058  goto end;
3059  }
3060 
3061  GetPrinterW(hprn, 2, NULL, 0, &needed);
3062  prn_info = HeapAlloc(GetProcessHeap(), 0, needed);
3063  GetPrinterW(hprn, 2, (LPBYTE)prn_info, needed, &needed);
3064  GetPrinterDriverW(hprn, NULL, 3, NULL, 0, &needed);
3065  drv_info = HeapAlloc(GetProcessHeap(), 0, needed);
3066  if(!GetPrinterDriverW(hprn, NULL, 3, (LPBYTE)drv_info, needed, &needed))
3067  {
3068  ERR("GetPrinterDriverA failed for %s, fix your config!\n", debugstr_w(prn_info->pPrinterName));
3069  goto end;
3070  }
3071  ClosePrinter(hprn);
3072 
3073  needed = DocumentPropertiesW(0, 0, name, NULL, NULL, 0);
3074  if(needed == -1)
3075  {
3076  ERR("DocumentProperties fails on %s\n", debugstr_w(name));
3077  goto end;
3078  }
3079 
3080  dm = HeapAlloc(GetProcessHeap(), 0, needed);
3082 
3083  pagesetup_set_devmode(data, dm);
3084  pagesetup_set_devnames(data, drv_info->pDriverPath, prn_info->pPrinterName,
3085  prn_info->pPortName);
3086 
3087  retval = TRUE;
3088 end:
3089  HeapFree(GetProcessHeap(), 0, dm);
3090  HeapFree(GetProcessHeap(), 0, prn_info);
3091  HeapFree(GetProcessHeap(), 0, drv_info);
3092  return retval;
3093 }
#define TRUE
Definition: types.h:120
unsigned char * LPBYTE
Definition: typedefs.h:52
GLuint GLuint end
Definition: gl.h:1545
LONG WINAPI DocumentPropertiesW(HWND hWnd, HANDLE hPrinter, LPWSTR pDeviceName, PDEVMODEW pDevModeOutput, PDEVMODEW pDevModeInput, DWORD fMode)
Definition: printers.c:204
WINBOOL WINAPI GetPrinterDriverW(HANDLE hPrinter, LPWSTR pEnvironment, DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf, LPDWORD pcbNeeded)
Definition: printers.c:514
DWORD DWORD
Definition: winlogon.h:84
#define FALSE
Definition: types.h:117
#define DM_OUT_BUFFER
Definition: windef.h:349
#define debugstr_w
Definition: kernel32.h:32
WINBOOL WINAPI ClosePrinter(HANDLE hPrinter)
Definition: printers.c:12
smooth NULL
Definition: ftsmooth.c:416
static void pagesetup_set_devmode(pagesetup_data *data, DEVMODEW *dm)
Definition: printdlg.c:2904
WINBOOL WINAPI GetPrinterW(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter, DWORD cbBuf, LPDWORD pcbNeeded)
Definition: printers.c:521
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define ERR(fmt,...)
Definition: debug.h:109
WINBOOL WINAPI OpenPrinterW(LPWSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSW pDefault)
Definition: printers.c:635
DWORD *typedef HANDLE
Definition: winlogon.h:61
LPWSTR pPortName
Definition: winspool.h:65
Definition: name.c:36
LPWSTR pPrinterName
Definition: winspool.h:63
static void pagesetup_set_devnames(pagesetup_data *data, LPCWSTR drv, LPCWSTR devname, LPCWSTR port)
Definition: printdlg.c:2813
#define HeapFree(x, y, z)
Definition: compat.h:394
static void pagesetup_change_printer_dialog ( HWND  hDlg,
pagesetup_data data 
)
static

Definition at line 3127 of file printdlg.c.

Referenced by pagesetup_wm_command().

3128 {
3129  PRINTDLGW prnt;
3130  LPWSTR drvname, devname, portname;
3131  DEVMODEW *tmp_dm, *dm;
3132 
3133  memset(&prnt, 0, sizeof(prnt));
3134  prnt.lStructSize = sizeof(prnt);
3135  prnt.Flags = 0;
3136  prnt.hwndOwner = hDlg;
3137 
3138  drvname = pagesetup_get_drvname(data);
3139  devname = pagesetup_get_devname(data);
3140  portname = pagesetup_get_portname(data);
3141  prnt.hDevNames = 0;
3142  PRINTDLG_CreateDevNamesW(&prnt.hDevNames, drvname, devname, portname);
3143  pagesetup_release_a_devname(data, portname);
3144  pagesetup_release_a_devname(data, devname);
3145  pagesetup_release_a_devname(data, drvname);
3146 
3147  tmp_dm = pagesetup_get_devmode(data);
3148  prnt.hDevMode = GlobalAlloc(GMEM_MOVEABLE, tmp_dm->dmSize + tmp_dm->dmDriverExtra);
3149  dm = GlobalLock(prnt.hDevMode);
3150  memcpy(dm, tmp_dm, tmp_dm->dmSize + tmp_dm->dmDriverExtra);
3151  GlobalUnlock(prnt.hDevMode);
3152  pagesetup_release_devmode(data, tmp_dm);
3153 
3154  if (PrintDlgW(&prnt))
3155  {
3156  DEVMODEW *dm = GlobalLock(prnt.hDevMode);
3157  DEVNAMES *dn = GlobalLock(prnt.hDevNames);
3158 
3159  pagesetup_set_devnames(data, (WCHAR*)dn + dn->wDriverOffset,
3160  (WCHAR*)dn + dn->wDeviceOffset, (WCHAR *)dn + dn->wOutputOffset);
3161  pagesetup_set_devmode(data, dm);
3162  GlobalUnlock(prnt.hDevNames);
3163  GlobalUnlock(prnt.hDevMode);
3164  pagesetup_init_combos(hDlg, data);
3165  }
3166 
3167  GlobalFree(prnt.hDevMode);
3168  GlobalFree(prnt.hDevNames);
3169 
3170 }
static BOOL PRINTDLG_CreateDevNamesW(HGLOBAL *hmem, LPCWSTR DeviceDriverName, LPCWSTR DeviceName, LPCWSTR OutputPort)
Definition: printdlg.c:519
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
HWND hwndOwner
Definition: commdlg.h:487
__wchar_t WCHAR
Definition: xmlstorage.h:180
WORD dmDriverExtra
Definition: wingdi.h:1598
DWORD Flags
Definition: commdlg.h:491
HANDLE hDevNames
Definition: commdlg.h:489
static WCHAR * pagesetup_get_devname(const pagesetup_data *data)
Definition: printdlg.c:2798
WORD wDeviceOffset
Definition: commdlg.h:298
BOOL WINAPI PrintDlgW(LPPRINTDLGW lppd)
Definition: printdlg.c:2391
WORD wDriverOffset
Definition: commdlg.h:297
static void pagesetup_set_devmode(pagesetup_data *data, DEVMODEW *dm)
Definition: printdlg.c:2904
DWORD lStructSize
Definition: commdlg.h:486
static DEVMODEW * pagesetup_get_devmode(const pagesetup_data *data)
Definition: printdlg.c:2880
WORD dmSize
Definition: wingdi.h:1597
HGLOBAL NTAPI GlobalFree(HGLOBAL hMem)
Definition: heapmem.c:611
static void pagesetup_init_combos(HWND hDlg, pagesetup_data *data)
Definition: printdlg.c:3101
static void pagesetup_release_devmode(const pagesetup_data *data, DEVMODEW *dm)
Definition: printdlg.c:2899
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
static WCHAR * pagesetup_get_portname(const pagesetup_data *data)
Definition: printdlg.c:2803
HANDLE hDevMode
Definition: commdlg.h:488
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
static void pagesetup_set_devnames(pagesetup_data *data, LPCWSTR drv, LPCWSTR devname, LPCWSTR port)
Definition: printdlg.c:2813
WORD wOutputOffset
Definition: commdlg.h:299
static void pagesetup_release_a_devname(const pagesetup_data *data, WCHAR *name)
Definition: printdlg.c:2808
#define memset(x, y, z)
Definition: compat.h:39
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static WCHAR * pagesetup_get_drvname(const pagesetup_data *data)
Definition: printdlg.c:2793
#define GMEM_MOVEABLE
Definition: winbase.h:291
static BOOL pagesetup_common ( pagesetup_data data)
static

Definition at line 3830 of file printdlg.c.

Referenced by PageSetupDlgA(), and PageSetupDlgW().

3831 {
3832  BOOL ret;
3833  void *tmpl;
3834 
3835  if(!pagesetup_get_dlg_struct(data))
3836  {
3838  return FALSE;
3839  }
3840 
3842 
3843  if(data->u.dlgw->lStructSize != sizeof(PAGESETUPDLGW))
3844  {
3846  return FALSE;
3847  }
3848 
3851  {
3853  return FALSE;
3854  }
3855 
3857  data->u.dlgw->Flags |= is_default_metric() ?
3859 
3860  if (!data->u.dlgw->hDevMode || !data->u.dlgw->hDevNames)
3861  {
3862  WCHAR *def = get_default_printer();
3863  if(!def)
3864  {
3865  if (!(pagesetup_get_flags(data) & PSD_NOWARNING))
3866  {
3867  WCHAR errstr[256];
3869  MessageBoxW(data->u.dlgw->hwndOwner, errstr, 0, MB_OK | MB_ICONERROR);
3870  }
3872  return FALSE;
3873  }
3874  pagesetup_change_printer(def, data);
3875  HeapFree(GetProcessHeap(), 0, def);
3876  }
3877 
3879  {
3881  return TRUE;
3882  }
3883 
3884  tmpl = pagesetup_get_template(data);
3885 
3886  ret = DialogBoxIndirectParamW(data->u.dlgw->hInstance, tmpl,
3887  data->u.dlgw->hwndOwner,
3888  pagesetup_dlg_proc, (LPARAM)data) > 0;
3889  return ret;
3890 }
#define TRUE
Definition: types.h:120
DECLSPEC_HIDDEN HINSTANCE COMDLG32_hInstance
Definition: cdlg32.c:42
#define PSD_INHUNDREDTHSOFMILLIMETERS
Definition: commdlg.h:175
__wchar_t WCHAR
Definition: xmlstorage.h:180
int WINAPI LoadStringW(_In_opt_ HINSTANCE hInstance, _In_ UINT uID, _Out_writes_to_(cchBufferMax, return+1) LPWSTR lpBuffer, _In_ int cchBufferMax)
static WCHAR * get_default_printer(void)
Definition: printdlg.c:3765
HGLOBAL hDevNames
Definition: commdlg.h:452
#define PSD_NOWARNING
Definition: commdlg.h:178
LPPAGESETUPDLGW dlgw
Definition: printdlg.c:2574
#define CDERR_STRUCTSIZE
Definition: cderr.h:6
#define PDERR_NODEFAULTPRN
Definition: cderr.h:26
#define FALSE
Definition: types.h:117
LONG_PTR LPARAM
Definition: windef.h:208
static LPARAM pagesetup_get_dlg_struct(const pagesetup_data *data)
Definition: printdlg.c:2962
DWORD lStructSize
Definition: commdlg.h:449
smooth NULL
Definition: ftsmooth.c:416
HWND hwndOwner
Definition: commdlg.h:450
#define PD32_NO_DEFAULT_PRINTER
Definition: cdlg.h:58
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
int WINAPI MessageBoxW(_In_opt_ HWND, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_ UINT)
static BOOL is_default_metric(void)
Definition: printdlg.c:2644
#define CDERR_INITIALIZATION
Definition: cderr.h:7
static LPPAGESETUPHOOK pagesetup_get_hook(const pagesetup_data *data, hook_type which)
Definition: printdlg.c:2950
static void pagesetup_dump_dlg_struct(const pagesetup_data *data)
Definition: printdlg.c:3779
#define PSD_INTHOUSANDTHSOFINCHES
Definition: commdlg.h:174
static void * pagesetup_get_template(pagesetup_data *data)
Definition: printdlg.c:3802
static BOOL pagesetup_update_papersize(pagesetup_data *data)
Definition: printdlg.c:2974
#define CDERR_NOHOOK
Definition: cderr.h:16
int ret
HGLOBAL hDevMode
Definition: commdlg.h:451
#define MB_ICONERROR
Definition: winuser.h:781
void COMDLG32_SetCommDlgExtendedError(DWORD err) DECLSPEC_HIDDEN
Definition: cdlg32.c:119
DWORD Flags
Definition: commdlg.h:453
INT_PTR WINAPI DialogBoxIndirectParamW(_In_opt_ HINSTANCE, _In_ LPCDLGTEMPLATE, _In_opt_ HWND, _In_opt_ DLGPROC, _In_ LPARAM)
#define MB_OK
Definition: winuser.h:784
HINSTANCE hInstance
Definition: commdlg.h:457
#define PSD_RETURNDEFAULT
Definition: commdlg.h:181
static BOOL pagesetup_change_printer(LPWSTR name, pagesetup_data *data)
Definition: printdlg.c:3046
static INT_PTR CALLBACK pagesetup_dlg_proc(HWND hDlg, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: printdlg.c:3667
const char * errstr(int errcode)
#define HeapFree(x, y, z)
Definition: compat.h:394
#define PSD_ENABLEPAGEPAINTHOOK
Definition: commdlg.h:186
union pagesetup_data::@338 u
static DWORD pagesetup_get_flags(const pagesetup_data *data)
Definition: printdlg.c:2580
static INT_PTR CALLBACK pagesetup_dlg_proc ( HWND  hDlg,
UINT  uMsg,
WPARAM  wParam,
LPARAM  lParam 
)
static

Definition at line 3667 of file printdlg.c.

Referenced by pagesetup_common().

3668 {
3670  INT_PTR res = FALSE;
3671  HWND hDrawWnd;
3672 
3673  if (uMsg == WM_INITDIALOG) { /*Init dialog*/
3674  data = (pagesetup_data *)lParam;
3675  data->hDlg = hDlg;
3676 
3677  hDrawWnd = GetDlgItem(hDlg, rct1);
3678  TRACE("set property to %p\n", data);
3679  SetPropW(hDlg, pagesetupdlg_prop, data);
3680  SetPropW(hDrawWnd, pagesetupdlg_prop, data);
3681  GetWindowRect(hDrawWnd, &data->rtDrawRect); /* Calculating rect in client coordinates where paper draws */
3682  MapWindowPoints( 0, hDlg, (LPPOINT)&data->rtDrawRect, 2 );
3684  hDrawWnd,
3685  GWLP_WNDPROC,
3687 
3688  /* FIXME: Paint hook. Must it be at begin of initialization or at end? */
3689  res = TRUE;
3691  {
3692  if (!pagesetup_get_hook(data, page_setup_hook)(hDlg, uMsg, wParam,
3693  pagesetup_get_dlg_struct(data)))
3694  FIXME("Setup page hook failed?\n");
3695  }
3696 
3697  /* if printer button disabled */
3699  EnableWindow(GetDlgItem(hDlg, psh3), FALSE);
3700  /* if margin edit boxes disabled */
3702  {
3703  EnableWindow(GetDlgItem(hDlg, edt4), FALSE);
3704  EnableWindow(GetDlgItem(hDlg, edt5), FALSE);
3705  EnableWindow(GetDlgItem(hDlg, edt6), FALSE);
3706  EnableWindow(GetDlgItem(hDlg, edt7), FALSE);
3707  }
3708 
3709  /* Set orientation radiobuttons properly */
3711 
3712  /* if orientation disabled */
3714  {
3717  }
3718 
3719  /* We fill them out enabled or not */
3720  if (!(pagesetup_get_flags(data) & PSD_MARGINS))
3721  {
3722  /* default is 1 inch */
3723  LONG size = thousandths_inch_to_size(data, 1000);
3724  SetRect(pagesetup_get_margin_rect(data), size, size, size, size);
3725  }
3726  update_margin_edits(hDlg, data, 0);
3727  subclass_margin_edits(hDlg);
3728  set_margin_groupbox_title(hDlg, data);
3729 
3730  /* if paper disabled */
3732  {
3735  }
3736 
3737  /* filling combos: printer, paper, source. selecting current printer (from DEVMODEA) */
3738  pagesetup_init_combos(hDlg, data);
3740  pagesetup_set_defaultsource(data, DMBIN_FORMSOURCE); /* FIXME: This is the auto select bin. Is this correct? */
3741 
3742  /* Drawing paper prev */
3744  return TRUE;
3745  } else {
3746  data = GetPropW(hDlg, pagesetupdlg_prop);
3747  if (!data)
3748  {
3749  WARN("__WINE_PAGESETUPDLGDATA prop not set?\n");
3750  return FALSE;
3751  }
3753  {
3754  res = pagesetup_get_hook(data, page_setup_hook)(hDlg, uMsg, wParam, lParam);
3755  if (res) return res;
3756  }
3757  }
3758  switch (uMsg) {
3759  case WM_COMMAND:
3760  return pagesetup_wm_command(hDlg, wParam, lParam, data);
3761  }
3762  return FALSE;
3763 }
#define GWLP_WNDPROC
Definition: winuser.h:848
#define TRUE
Definition: types.h:120
int WINAPI MapWindowPoints(_In_opt_ HWND hWndFrom, _In_opt_ HWND hWndTo, _Inout_updates_(cPoints) LPPOINT lpPoints, _In_ UINT cPoints)
#define PSD_DISABLEPRINTER
Definition: commdlg.h:177
#define PSD_MARGINS
Definition: commdlg.h:173
static void update_margin_edits(HWND hDlg, const pagesetup_data *data, WORD id)
Definition: printdlg.c:3221
#define WARN(fmt,...)
Definition: debug.h:111
UINT uMsg
Definition: precomp.h:45
#define edt5
Definition: dlgs.h:69
HANDLE HWND
Definition: compat.h:13
static BOOL pagesetup_wm_command(HWND hDlg, WPARAM wParam, LPARAM lParam, pagesetup_data *data)
Definition: printdlg.c:3359
static void pagesetup_update_orientation_buttons(HWND hDlg, const pagesetup_data *data)
Definition: printdlg.c:3289
int32_t INT_PTR
Definition: typedefs.h:62
uint32_t ULONG_PTR
Definition: typedefs.h:63
#define rad2
Definition: dlgs.h:131
#define FALSE
Definition: types.h:117
long LONG
Definition: pedump.c:60
static LPARAM pagesetup_get_dlg_struct(const pagesetup_data *data)
Definition: printdlg.c:2962
#define psh3
Definition: dlgs.h:114
#define FIXME(fmt,...)
Definition: debug.h:110
static WNDPROC lpfnStaticWndProc
Definition: printdlg.c:141
#define edt4
Definition: dlgs.h:68
#define PSD_DISABLEORIENTATION
Definition: commdlg.h:179
LRESULT(CALLBACK * WNDPROC)(HWND, UINT, WPARAM, LPARAM)
Definition: winuser.h:2859
#define TRACE(s)
Definition: solgame.cpp:4
GLsizeiptr size
Definition: glext.h:5919
BOOL WINAPI SetPropW(_In_ HWND, _In_ LPCWSTR, _In_opt_ HANDLE)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
UINT WPARAM wParam
Definition: precomp.h:45
static void pagesetup_change_preview(const pagesetup_data *data)
Definition: printdlg.c:3178
static LPPAGESETUPHOOK pagesetup_get_hook(const pagesetup_data *data, hook_type which)
Definition: printdlg.c:2950
static void pagesetup_init_combos(HWND hDlg, pagesetup_data *data)
Definition: printdlg.c:3101
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
static BOOL pagesetup_update_papersize(pagesetup_data *data)
Definition: printdlg.c:2974
#define WM_COMMAND
Definition: winuser.h:1716
static void set_margin_groupbox_title(HWND hDlg, const pagesetup_data *data)
Definition: printdlg.c:3280
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define cmb2
Definition: dlgs.h:49
BOOL WINAPI SetRect(_Out_ LPRECT, _In_ int, _In_ int, _In_ int, _In_ int)
static void pagesetup_set_defaultsource(pagesetup_data *data, WORD source)
Definition: printdlg.c:2741
#define cmb3
Definition: dlgs.h:50
UINT WPARAM LPARAM lParam
Definition: precomp.h:45
HANDLE WINAPI GetPropW(_In_ HWND, _In_ LPCWSTR)
static void subclass_margin_edits(HWND hDlg)
Definition: printdlg.c:3648
#define edt7
Definition: dlgs.h:71
GLuint res
Definition: glext.h:9613
static LRESULT CALLBACK PRINTDLG_PagePaintProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
Definition: printdlg.c:3544
#define DMBIN_FORMSOURCE
Definition: wingdi.h:1178
static const WCHAR pagesetupdlg_prop[]
Definition: printdlg.c:150
BOOL WINAPI GetWindowRect(_In_ HWND, _Out_ LPRECT)
#define SetWindowLongPtrW
Definition: winuser.h:5215
static RECT * pagesetup_get_margin_rect(const pagesetup_data *data)
Definition: printdlg.c:2939
#define PSD_ENABLEPAGESETUPHOOK
Definition: commdlg.h:183
#define PSD_DISABLEMARGINS
Definition: commdlg.h:176
#define rct1
Definition: dlgs.h:147
#define WM_INITDIALOG
Definition: winuser.h:1715
#define PSD_DISABLEPAPER
Definition: commdlg.h:180
static LONG thousandths_inch_to_size(const pagesetup_data *data, LONG size)
Definition: printdlg.c:2598
#define rad1
Definition: dlgs.h:130
#define edt6
Definition: dlgs.h:70
static DWORD pagesetup_get_flags(const pagesetup_data *data)
Definition: printdlg.c:2580
static void pagesetup_dump_dlg_struct ( const pagesetup_data data)
static

Definition at line 3779 of file printdlg.c.

Referenced by pagesetup_common().

3780 {
3781  if(TRACE_ON(commdlg))
3782  {
3783  char flagstr[1000] = "";
3784  const struct pd_flags *pflag = psd_flags;
3785  for( ; pflag->name; pflag++)
3786  {
3787  if(pagesetup_get_flags(data) & pflag->flag)
3788  {
3789  strcat(flagstr, pflag->name);
3790  strcat(flagstr, "|");
3791  }
3792  }
3793  TRACE("%s: (%p): hwndOwner = %p, hDevMode = %p, hDevNames = %p\n"
3794  "hinst %p, flags %08x (%s)\n",
3795  data->unicode ? "unicode" : "ansi",
3796  data->u.dlgw, data->u.dlgw->hwndOwner, data->u.dlgw->hDevMode,
3797  data->u.dlgw->hDevNames, data->u.dlgw->hInstance,
3798  pagesetup_get_flags(data), flagstr);
3799  }
3800 }
char * strcat(char *DstString, const char *SrcString)
Definition: utclib.c:568
LPCSTR name
Definition: printdlg.c:92
HGLOBAL hDevNames
Definition: commdlg.h:452
LPPAGESETUPDLGW dlgw
Definition: printdlg.c:2574
static const struct pd_flags psd_flags[]
Definition: printdlg.c:95
HWND hwndOwner
Definition: commdlg.h:450
DWORD flag
Definition: printdlg.c:91
#define TRACE(s)
Definition: solgame.cpp:4
HGLOBAL hDevMode
Definition: commdlg.h:451
HINSTANCE hInstance
Definition: commdlg.h:457
#define TRACE_ON(x)
Definition: compat.h:65
union pagesetup_data::@338 u
static DWORD pagesetup_get_flags(const pagesetup_data *data)
Definition: printdlg.c:2580
static WCHAR* pagesetup_get_a_devname ( const pagesetup_data data,
devnames_name  which 
)
static

Definition at line 2775 of file printdlg.c.

Referenced by pagesetup_get_devname(), pagesetup_get_drvname(), and pagesetup_get_portname().

2776 {
2777  DEVNAMES *dn;
2778  WCHAR *name;
2779 
2780  dn = GlobalLock(data->u.dlgw->hDevNames);
2781  if(data->unicode)
2782  name = strdupW((WCHAR *)dn + get_devname_offset(dn, which));
2783  else
2784  {
2785  int len = MultiByteToWideChar(CP_ACP, 0, (char*)dn + get_devname_offset(dn, which), -1, NULL, 0);
2786  name = HeapAlloc(GetProcessHeap(), 0, len * sizeof(WCHAR));
2787  MultiByteToWideChar(CP_ACP, 0, (char*)dn + get_devname_offset(dn, which), -1, name, len);
2788  }
2789  GlobalUnlock(data->u.dlgw->hDevNames);
2790  return name;
2791 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CP_ACP
Definition: compat.h:99
static GLenum which
Definition: wgl_font.c:159
HGLOBAL hDevNames
Definition: commdlg.h:452
LPPAGESETUPDLGW dlgw
Definition: printdlg.c:2574
GLuint const GLchar * name
Definition: glext.h:6031
smooth NULL
Definition: ftsmooth.c:416
static WORD get_devname_offset(const DEVNAMES *dn, devnames_name which)
Definition: printdlg.c:2763
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
GLenum GLsizei len
Definition: glext.h:6722
static LPWSTR strdupW(LPCWSTR p)
Definition: printdlg.c:154
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define MultiByteToWideChar
Definition: compat.h:100
union pagesetup_data::@338 u
static DEVMODEW* pagesetup_get_devmode ( const pagesetup_data data)
static

Definition at line 2880 of file printdlg.c.

Referenced by pagesetup_change_printer_dialog(), pagesetup_init_combos(), pagesetup_printer_properties(), and pagesetup_update_papersize().

2881 {
2882  DEVMODEW *dm = GlobalLock(data->u.dlgw->hDevMode);
2883  DEVMODEW *ret;
2884 
2885  if(data->unicode)
2886  {
2887  /* We make a copy even in the unicode case because the ptr
2888  may get passed back to us in pagesetup_set_devmode. */
2889  ret = HeapAlloc(GetProcessHeap(), 0, dm->dmSize + dm->dmDriverExtra);
2890  memcpy(ret, dm, dm->dmSize + dm->dmDriverExtra);
2891  }
2892  else
2893  ret = GdiConvertToDevmodeW((DEVMODEA *)dm);
2894 
2895  GlobalUnlock(data->u.dlgw->hDevMode);
2896  return ret;
2897 }
WORD dmDriverExtra
Definition: wingdi.h:1598
DEVMODEW *WINAPI GdiConvertToDevmodeW(const DEVMODEA *)
Definition: misc.c:968
LPPAGESETUPDLGW dlgw
Definition: printdlg.c:2574
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
WORD dmSize
Definition: wingdi.h:1597
int ret
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
HGLOBAL hDevMode
Definition: commdlg.h:451
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
union pagesetup_data::@338 u
static WCHAR* pagesetup_get_devname ( const pagesetup_data data)
static

Definition at line 2798 of file printdlg.c.

Referenced by pagesetup_change_printer_dialog(), pagesetup_init_combos(), pagesetup_printer_properties(), and pagesetup_update_papersize().

2799 {
2801 }
static WCHAR * pagesetup_get_a_devname(const pagesetup_data *data, devnames_name which)
Definition: printdlg.c:2775
static LPARAM pagesetup_get_dlg_struct ( const pagesetup_data data)
inlinestatic

Definition at line 2962 of file printdlg.c.

Referenced by pagesetup_common(), pagesetup_dlg_proc(), and PRINTDLG_PagePaintProc().

2963 {
2964  return (LPARAM)data->u.dlgw;
2965 }
LPPAGESETUPDLGW dlgw
Definition: printdlg.c:2574
LONG_PTR LPARAM
Definition: windef.h:208
union pagesetup_data::@338 u
static WCHAR* pagesetup_get_drvname ( const pagesetup_data data)
static

Definition at line 2793 of file printdlg.c.

Referenced by pagesetup_change_printer_dialog().

2794 {
2796 }
static WCHAR * pagesetup_get_a_devname(const pagesetup_data *data, devnames_name which)
Definition: printdlg.c:2775
static DWORD pagesetup_get_flags ( const pagesetup_data data)
inlinestatic

Definition at line 2580 of file printdlg.c.

Referenced by default_page_paint_hook(), is_metric(), pagesetup_common(), pagesetup_dlg_proc(), pagesetup_dump_dlg_struct(), and pagesetup_get_template().

2581 {
2582  return data->u.dlgw->Flags;
2583 }
LPPAGESETUPDLGW dlgw
Definition: printdlg.c:2574
DWORD Flags
Definition: commdlg.h:453
union pagesetup_data::@338 u
static LPPAGESETUPHOOK pagesetup_get_hook ( const pagesetup_data data,
hook_type  which 
)
inlinestatic

Definition at line 2950 of file printdlg.c.

Referenced by default_page_paint_hook(), pagesetup_common(), and pagesetup_dlg_proc().

2951 {
2952  switch(which)
2953  {
2954  case page_setup_hook: return data->u.dlgw->lpfnPageSetupHook;
2955  case page_paint_hook: return data->u.dlgw->lpfnPagePaintHook;
2956  }
2957  return NULL;
2958 }
static GLenum which
Definition: wgl_font.c:159
LPPAGESETUPDLGW dlgw
Definition: printdlg.c:2574
smooth NULL
Definition: ftsmooth.c:416
LPPAGESETUPHOOK lpfnPageSetupHook
Definition: commdlg.h:459
LPPAGEPAINTHOOK lpfnPagePaintHook
Definition: commdlg.h:460
union pagesetup_data::@338 u
static RECT* pagesetup_get_margin_rect ( const pagesetup_data data)
inlinestatic

Definition at line 2939 of file printdlg.c.

Referenced by margin_edit_notification(), pagesetup_dlg_proc(), pagesetup_wm_command(), PRINTDLG_PagePaintProc(), and update_margin_edits().

2940 {
2941  return &data->u.dlgw->rtMargin;
2942 }
RECT rtMargin
Definition: commdlg.h:456
LPPAGESETUPDLGW dlgw
Definition: printdlg.c:2574
union pagesetup_data::@338 u
static WORD pagesetup_get_orientation ( const pagesetup_data data)
static

Definition at line 2695 of file printdlg.c.

Referenced by pagesetup_change_preview(), pagesetup_update_orientation_buttons(), pagesetup_update_papersize(), and pagesetup_wm_command().

2696 {
2697  DEVMODEW *dm = GlobalLock(data->u.dlgw->hDevMode);
2698  WORD orient;
2699 
2700  if(data->unicode)
2701  orient = dm->u1.s1.dmOrientation;
2702  else
2703  {
2704  DEVMODEA *dmA = (DEVMODEA *)dm;
2705  orient = dmA->u1.s1.dmOrientation;
2706  }
2707  GlobalUnlock(data->u.dlgw->hDevMode);
2708  return orient;
2709 }
unsigned short WORD
Definition: ntddk_ex.h:93
short dmOrientation
Definition: wingdi.h:1602
LPPAGESETUPDLGW dlgw
Definition: printdlg.c:2574
short dmOrientation
Definition: wingdi.h:1550
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
HGLOBAL hDevMode
Definition: commdlg.h:451
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
union pagesetup_data::@338 u
static WORD pagesetup_get_papersize ( const pagesetup_data data)
static

Definition at line 2725 of file printdlg.c.

Referenced by pagesetup_printer_properties(), and pagesetup_update_papersize().

2726 {
2727  DEVMODEW *dm = GlobalLock(data->u.dlgw->hDevMode);
2728  WORD paper;
2729 
2730  if(data->unicode)
2731  paper = dm->u1.s1.dmPaperSize;
2732  else
2733  {
2734  DEVMODEA *dmA = (DEVMODEA *)dm;
2735  paper = dmA->u1.s1.dmPaperSize;
2736  }
2737  GlobalUnlock(data->u.dlgw->hDevMode);
2738  return paper;
2739 }
unsigned short WORD
Definition: ntddk_ex.h:93
LPPAGESETUPDLGW dlgw
Definition: printdlg.c:2574
short dmPaperSize
Definition: wingdi.h:1603
short dmPaperSize
Definition: wingdi.h:1551
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
HGLOBAL hDevMode
Definition: commdlg.h:451
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
union pagesetup_data::@338 u
static POINT* pagesetup_get_papersize_pt ( const pagesetup_data data)
inlinestatic

Definition at line 2934 of file printdlg.c.

Referenced by pagesetup_change_preview(), pagesetup_update_papersize(), and PRINTDLG_PagePaintProc().

2935 {
2936  return &data->u.dlgw->ptPaperSize;
2937 }
LPPAGESETUPDLGW dlgw
Definition: printdlg.c:2574
POINT ptPaperSize
Definition: commdlg.h:454
union pagesetup_data::@338 u
static WCHAR* pagesetup_get_portname ( const pagesetup_data data)
static

Definition at line 2803 of file printdlg.c.

Referenced by pagesetup_change_printer_dialog(), pagesetup_init_combos(), and pagesetup_update_papersize().

2804 {
2806 }
static WCHAR * pagesetup_get_a_devname(const pagesetup_data *data, devnames_name which)
Definition: printdlg.c:2775
static void* pagesetup_get_template ( pagesetup_data data)
static

Definition at line 3802 of file printdlg.c.

Referenced by pagesetup_common().

3803 {
3804  HRSRC res;
3805  HGLOBAL tmpl_handle;
3806 
3808  {
3809  tmpl_handle = data->u.dlgw->hPageSetupTemplate;
3810  }
3812  {
3813  if(data->unicode)
3814  res = FindResourceW(data->u.dlgw->hInstance,
3816  else
3817  res = FindResourceA(data->u.dlga->hInstance,
3819  tmpl_handle = LoadResource(data->u.dlgw->hInstance, res);
3820  }
3821  else
3822  {
3823  res = FindResourceW(COMDLG32_hInstance, MAKEINTRESOURCEW(PAGESETUPDLGORD),
3824  (LPWSTR)RT_DIALOG);
3825  tmpl_handle = LoadResource(COMDLG32_hInstance, res);
3826  }
3827  return LockResource(tmpl_handle);
3828 }
LPCWSTR lpPageSetupTemplateName
Definition: commdlg.h:461
HANDLE HGLOBAL
Definition: windef.h:243
DECLSPEC_HIDDEN HINSTANCE COMDLG32_hInstance
Definition: cdlg32.c:42
#define PSD_ENABLEPAGESETUPTEMPLATE
Definition: commdlg.h:184
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
LPVOID WINAPI LockResource(HGLOBAL handle)
Definition: res.c:550
LPCSTR lpPageSetupTemplateName
Definition: commdlg.h:445
char * LPSTR
Definition: xmlstorage.h:182
HRSRC WINAPI FindResourceW(HINSTANCE hModule, LPCWSTR name, LPCWSTR type)
Definition: res.c:176
LPPAGESETUPDLGW dlgw
Definition: printdlg.c:2574
#define PSD_ENABLEPAGESETUPTEMPLATEHANDLE
Definition: commdlg.h:185
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
HGLOBAL hPageSetupTemplate
Definition: commdlg.h:462
#define RT_DIALOG
Definition: pedump.c:367
HINSTANCE hInstance
Definition: commdlg.h:441
HINSTANCE hInstance
Definition: commdlg.h:457
LPPAGESETUPDLGA dlga
Definition: printdlg.c:2573
GLuint res
Definition: glext.h:9613
#define MAKEINTRESOURCEW(i)
Definition: winuser.h:582
WCHAR * LPWSTR
Definition: xmlstorage.h:184
union pagesetup_data::@338 u
static DWORD pagesetup_get_flags(const pagesetup_data *data)
Definition: printdlg.c:2580
static void pagesetup_init_combos ( HWND  hDlg,
pagesetup_data data 
)
static

Definition at line 3101 of file printdlg.c.

Referenced by pagesetup_change_printer_dialog(), pagesetup_dlg_proc(), and pagesetup_wm_command().

3102 {
3103  DEVMODEW *dm;
3104  LPWSTR devname, portname;
3105 
3106  dm = pagesetup_get_devmode(data);
3107  devname = pagesetup_get_devname(data);
3108  portname = pagesetup_get_portname(data);
3109 
3110  PRINTDLG_SetUpPrinterListComboW(hDlg, cmb1, devname);
3111  PRINTDLG_SetUpPaperComboBoxW(hDlg, cmb2, devname, portname, dm);
3112  PRINTDLG_SetUpPaperComboBoxW(hDlg, cmb3, devname, portname, dm);
3113 
3114  pagesetup_release_a_devname(data, portname);
3115  pagesetup_release_a_devname(data, devname);
3116  pagesetup_release_devmode(data, dm);
3117 }
static WCHAR * pagesetup_get_devname(const pagesetup_data *data)
Definition: printdlg.c:2798
static DEVMODEW * pagesetup_get_devmode(const pagesetup_data *data)
Definition: printdlg.c:2880
static void pagesetup_release_devmode(const pagesetup_data *data, DEVMODEW *dm)
Definition: printdlg.c:2899
static WCHAR * pagesetup_get_portname(const pagesetup_data *data)
Definition: printdlg.c:2803
static INT PRINTDLG_SetUpPrinterListComboW(HWND hDlg, UINT id, LPCWSTR name)
Definition: printdlg.c:431
#define cmb2
Definition: dlgs.h:49
#define cmb3
Definition: dlgs.h:50
static BOOL PRINTDLG_SetUpPaperComboBoxW(HWND hDlg, int nIDComboBox, const WCHAR *PrinterName, const WCHAR *PortName, LPDEVMODEW dm)
Definition: printdlg.c:889
static void pagesetup_release_a_devname(const pagesetup_data *data, WCHAR *name)
Definition: printdlg.c:2808
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define cmb1
Definition: dlgs.h:48
static LRESULT CALLBACK pagesetup_margin_editproc ( HWND  hwnd,
UINT  msg,
WPARAM  wparam,
LPARAM  lparam 
)
static

Definition at line 3637 of file printdlg.c.

Referenced by subclass_margin_edits().

3638 {
3639  if (msg == WM_CHAR)
3640  {
3641  WCHAR decimal = get_decimal_sep();
3642  WCHAR wc = (WCHAR)wparam;
3643  if(!isdigitW(wc) && wc != decimal && wc != VK_BACK) return 0;
3644  }
3646 }
const DOCKBAR PVOID HWND HWND * hwnd
Definition: tooldock.h:22
#define WM_CHAR
Definition: winuser.h:1693
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define WCHAR
Definition: msvc.h:43
static WCHAR get_decimal_sep(void)
Definition: printdlg.c:2606
static WNDPROC edit_wndproc
Definition: printdlg.c:142
#define VK_BACK
Definition: winuser.h:2152
UINT WPARAM LPARAM lparam
Definition: msvc.h:92
WINE_UNICODE_INLINE int isdigitW(WCHAR wc)
Definition: unicode.h:170
LRESULT WINAPI CallWindowProcW(_In_ WNDPROC, _In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
UINT msg
Definition: msvc.h:92
UINT WPARAM wparam
Definition: msvc.h:92
static void pagesetup_printer_properties ( HWND  hDlg,
pagesetup_data data 
)
static

Definition at line 3302 of file printdlg.c.

Referenced by pagesetup_wm_command().

3303 {
3304  HANDLE hprn;
3305  LPWSTR devname;
3306  DEVMODEW *dm;
3307  LRESULT count;
3308  int i;
3309 
3310  devname = pagesetup_get_devname(data);
3311 
3312  if (!OpenPrinterW(devname, &hprn, NULL))
3313  {
3314  FIXME("Call to OpenPrinter did not succeed!\n");
3315  pagesetup_release_a_devname(data, devname);
3316  return;
3317  }
3318 
3319  dm = pagesetup_get_devmode(data);
3320  DocumentPropertiesW(hDlg, hprn, devname, dm, dm, DM_IN_BUFFER | DM_OUT_BUFFER | DM_IN_PROMPT);
3321  pagesetup_set_devmode(data, dm);
3322  pagesetup_release_devmode(data, dm);
3323  pagesetup_release_a_devname(data, devname);
3324  ClosePrinter(hprn);
3325 
3326  /* Changing paper */
3329 
3330  /* Changing paper preview */
3332 
3333  /* Selecting paper in combo */
3334  count = SendDlgItemMessageW(hDlg, cmb2, CB_GETCOUNT, 0, 0);
3335  if(count != CB_ERR)
3336  {
3337  WORD paperword = pagesetup_get_papersize(data);
3338  for(i = 0; i < count; i++)
3339  {
3340  if(SendDlgItemMessageW(hDlg, cmb2, CB_GETITEMDATA, i, 0) == paperword) {
3341  SendDlgItemMessageW(hDlg, cmb2, CB_SETCURSEL, i, 0);
3342  break;
3343  }
3344  }
3345  }
3346 }
static WORD pagesetup_get_papersize(const pagesetup_data *data)
Definition: printdlg.c:2725
unsigned short WORD
Definition: ntddk_ex.h:93
#define DM_IN_PROMPT
Definition: windef.h:348
#define CB_GETITEMDATA
Definition: winuser.h:1911
static void pagesetup_update_orientation_buttons(HWND hDlg, const pagesetup_data *data)
Definition: printdlg.c:3289
LONG WINAPI DocumentPropertiesW(HWND hWnd, HANDLE hPrinter, LPWSTR pDeviceName, PDEVMODEW pDevModeOutput, PDEVMODEW pDevModeInput, DWORD fMode)
Definition: printers.c:204
static WCHAR * pagesetup_get_devname(const pagesetup_data *data)
Definition: printdlg.c:2798
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define DM_OUT_BUFFER
Definition: windef.h:349
#define FIXME(fmt,...)
Definition: debug.h:110
WINBOOL WINAPI ClosePrinter(HANDLE hPrinter)
Definition: printers.c:12
smooth NULL
Definition: ftsmooth.c:416
static void pagesetup_set_devmode(pagesetup_data *data, DEVMODEW *dm)
Definition: printdlg.c:2904
#define CB_ERR
Definition: winuser.h:2389
static DEVMODEW * pagesetup_get_devmode(const pagesetup_data *data)
Definition: printdlg.c:2880
static void pagesetup_change_preview(const pagesetup_data *data)
Definition: printdlg.c:3178
GLuint GLuint GLsizei count
Definition: gl.h:1545
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static BOOL pagesetup_update_papersize(pagesetup_data *data)
Definition: printdlg.c:2974
static void pagesetup_release_devmode(const pagesetup_data *data, DEVMODEW *dm)
Definition: printdlg.c:2899
#define CB_SETCURSEL
Definition: winuser.h:1922
#define cmb2
Definition: dlgs.h:49
WINBOOL WINAPI OpenPrinterW(LPWSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSW pDefault)
Definition: printers.c:635
DWORD *typedef HANDLE
Definition: winlogon.h:61
#define DM_IN_BUFFER
Definition: windef.h:347
#define CB_GETCOUNT
Definition: winuser.h:1903
LONG_PTR LRESULT
Definition: windef.h:209
static void pagesetup_release_a_devname(const pagesetup_data *data, WCHAR *name)
Definition: printdlg.c:2808
WCHAR * LPWSTR
Definition: xmlstorage.h:184
static void pagesetup_release_a_devname ( const pagesetup_data data,
WCHAR name 
)
static

Definition at line 2808 of file printdlg.c.

Referenced by pagesetup_change_printer_dialog(), pagesetup_init_combos(), pagesetup_printer_properties(), and pagesetup_update_papersize().

2809 {
2810  HeapFree(GetProcessHeap(), 0, name);
2811 }
#define GetProcessHeap()
Definition: compat.h:395
Definition: name.c:36
#define HeapFree(x, y, z)
Definition: compat.h:394
static void pagesetup_release_devmode ( const pagesetup_data data,
DEVMODEW dm 
)
static

Definition at line 2899 of file printdlg.c.

Referenced by pagesetup_change_printer_dialog(), pagesetup_init_combos(), pagesetup_printer_properties(), and pagesetup_update_papersize().

2900 {
2901  HeapFree(GetProcessHeap(), 0, dm);
2902 }
#define GetProcessHeap()
Definition: compat.h:395
#define HeapFree(x, y, z)
Definition: compat.h:394
static void pagesetup_set_defaultsource ( pagesetup_data data,
WORD  source 
)
static

Definition at line 2741 of file printdlg.c.

Referenced by pagesetup_dlg_proc(), and pagesetup_wm_command().

2742 {
2743  DEVMODEW *dm = GlobalLock(data->u.dlgw->hDevMode);
2744 
2745  if(data->unicode)
2746  dm->u1.s1.dmDefaultSource = source;
2747  else
2748  {
2749  DEVMODEA *dmA = (DEVMODEA *)dm;
2750  dmA->u1.s1.dmDefaultSource = source;
2751  }
2752  GlobalUnlock(data->u.dlgw->hDevMode);
2753 }
LPPAGESETUPDLGW dlgw
Definition: printdlg.c:2574
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
HGLOBAL hDevMode
Definition: commdlg.h:451
short dmDefaultSource
Definition: wingdi.h:1608
GLsizei GLsizei GLchar * source
Definition: glext.h:6048
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
short dmDefaultSource
Definition: wingdi.h:1556
union pagesetup_data::@338 u
static void pagesetup_set_devmode ( pagesetup_data data,
DEVMODEW dm 
)
static

Definition at line 2904 of file printdlg.c.

Referenced by pagesetup_change_printer(), pagesetup_change_printer_dialog(), and pagesetup_printer_properties().

2905 {
2906  DEVMODEA *dmA = NULL;
2907  void *src, *dst;
2908  DWORD size;
2909 
2910  if(data->unicode)
2911  {
2912  size = dm->dmSize + dm->dmDriverExtra;
2913  src = dm;
2914  }
2915  else
2916  {
2917  dmA = convert_to_devmodeA(dm);
2918  size = dmA->dmSize + dmA->dmDriverExtra;
2919  src = dmA;
2920  }
2921 
2922  if(data->u.dlgw->hDevMode)
2923  data->u.dlgw->hDevMode = GlobalReAlloc(data->u.dlgw->hDevMode, size,
2924  GMEM_MOVEABLE);
2925  else
2926  data->u.dlgw->hDevMode = GlobalAlloc(GMEM_MOVEABLE, size);
2927 
2928  dst = GlobalLock(data->u.dlgw->hDevMode);
2929  memcpy(dst, src, size);
2930  GlobalUnlock(data->u.dlgw->hDevMode);
2931  HeapFree(GetProcessHeap(), 0, dmA);
2932 }
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
HGLOBAL NTAPI GlobalReAlloc(HGLOBAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:825
WORD dmSize
Definition: wingdi.h:1545
WORD dmDriverExtra
Definition: wingdi.h:1546
WORD dmDriverExtra
Definition: wingdi.h:1598
DWORD DWORD
Definition: winlogon.h:84
LPPAGESETUPDLGW dlgw
Definition: printdlg.c:2574
GLuint const GLubyte GLvoid * src
Definition: s_context.h:57
smooth NULL
Definition: ftsmooth.c:416
GLsizeiptr size
Definition: glext.h:5919
#define GetProcessHeap()
Definition: compat.h:395
WORD dmSize
Definition: wingdi.h:1597
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
HGLOBAL hDevMode
Definition: commdlg.h:451
#define memcpy(s1, s2, n)
Definition: mkisofs.h:878
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
GLuint const GLubyte GLvoid const GLvoid * dst
Definition: s_context.h:57
static DEVMODEA * convert_to_devmodeA(const DEVMODEW *dmW)
Definition: printdlg.c:326
#define HeapFree(x, y, z)
Definition: compat.h:394
#define GMEM_MOVEABLE
Definition: winbase.h:291
union pagesetup_data::@338 u
static void pagesetup_set_devnames ( pagesetup_data data,
LPCWSTR  drv,
LPCWSTR  devname,
LPCWSTR  port 
)
static

Definition at line 2813 of file printdlg.c.

Referenced by pagesetup_change_printer(), and pagesetup_change_printer_dialog().

2814 {
2815  DEVNAMES *dn;
2816  WCHAR def[256];
2817  DWORD len = sizeof(DEVNAMES), drv_len, dev_len, port_len;
2818 
2819  if(data->unicode)
2820  {
2821  drv_len = (strlenW(drv) + 1) * sizeof(WCHAR);
2822  dev_len = (strlenW(devname) + 1) * sizeof(WCHAR);
2823  port_len = (strlenW(port) + 1) * sizeof(WCHAR);
2824  }
2825  else
2826  {
2827  drv_len = WideCharToMultiByte(CP_ACP, 0, drv, -1, NULL, 0, NULL, NULL);
2828  dev_len = WideCharToMultiByte(CP_ACP, 0, devname, -1, NULL, 0, NULL, NULL);
2829  port_len = WideCharToMultiByte(CP_ACP, 0, port, -1, NULL, 0, NULL, NULL);
2830  }
2831  len += drv_len + dev_len + port_len;
2832 
2833  if(data->u.dlgw->hDevNames)
2834  data->u.dlgw->hDevNames = GlobalReAlloc(data->u.dlgw->hDevNames, len, GMEM_MOVEABLE);
2835  else
2836  data->u.dlgw->hDevNames = GlobalAlloc(GMEM_MOVEABLE, len);
2837 
2838  dn = GlobalLock(data->u.dlgw->hDevNames);
2839 
2840  if(data->unicode)
2841  {
2842  WCHAR *ptr = (WCHAR *)(dn + 1);
2843  len = sizeof(DEVNAMES) / sizeof(WCHAR);
2844  dn->wDriverOffset = len;
2845  strcpyW(ptr, drv);
2846  ptr += drv_len / sizeof(WCHAR);
2847  len += drv_len / sizeof(WCHAR);
2848  dn->wDeviceOffset = len;
2849  strcpyW(ptr, devname);
2850  ptr += dev_len / sizeof(WCHAR);
2851  len += dev_len / sizeof(WCHAR);
2852  dn->wOutputOffset = len;
2853  strcpyW(ptr, port);
2854  }
2855  else
2856  {
2857  char *ptr = (char *)(dn + 1);
2858  len = sizeof(DEVNAMES);
2859  dn->wDriverOffset = len;
2860  WideCharToMultiByte(CP_ACP, 0, drv, -1, ptr, drv_len, NULL, NULL);
2861  ptr += drv_len;
2862  len += drv_len;
2863  dn->wDeviceOffset = len;
2864  WideCharToMultiByte(CP_ACP, 0, devname, -1, ptr, dev_len, NULL, NULL);
2865  ptr += dev_len;
2866  len += dev_len;
2867  dn->wOutputOffset = len;
2868  WideCharToMultiByte(CP_ACP, 0, port, -1, ptr, port_len, NULL, NULL);
2869  }
2870 
2871  dn->wDefault = 0;
2872  len = ARRAY_SIZE(def);
2873  GetDefaultPrinterW(def, &len);
2874  if(!lstrcmpW(def, devname))
2875  dn->wDefault = 1;
2876 
2877  GlobalUnlock(data->u.dlgw->hDevNames);
2878 }
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
WINE_UNICODE_INLINE unsigned int strlenW(const WCHAR *str)
Definition: unicode.h:212
#define WideCharToMultiByte
Definition: compat.h:101
WINBOOL WINAPI GetDefaultPrinterW(LPWSTR pszBuffer, LPDWORD pcchBuffer)
Definition: printers.c:409
HGLOBAL NTAPI GlobalReAlloc(HGLOBAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:825
WORD wDefault
Definition: commdlg.h:300
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CP_ACP
Definition: compat.h:99
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
#define WCHAR
Definition: msvc.h:43
DWORD DWORD
Definition: winlogon.h:84
HGLOBAL hDevNames
Definition: commdlg.h:452
LPPAGESETUPDLGW dlgw
Definition: printdlg.c:2574
struct tagDEVNAMES DEVNAMES
static PVOID ptr
Definition: dispmode.c:27
WORD wDeviceOffset
Definition: commdlg.h:298
smooth NULL
Definition: ftsmooth.c:416
WORD wDriverOffset
Definition: commdlg.h:297
#define ARRAY_SIZE(A)
Definition: reg.h:24
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
GLenum GLsizei len
Definition: glext.h:6722
WINE_UNICODE_INLINE WCHAR * strcpyW(WCHAR *dst, const WCHAR *src)
Definition: unicode.h:219
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
WORD wOutputOffset
Definition: commdlg.h:299
USHORT port
Definition: uri.c:227
#define GMEM_MOVEABLE
Definition: winbase.h:291
union pagesetup_data::@338 u
static void pagesetup_set_orientation ( pagesetup_data data,
WORD  orient 
)
static

Definition at line 2679 of file printdlg.c.

Referenced by pagesetup_wm_command().

2680 {
2681  DEVMODEW *dm = GlobalLock(data->u.dlgw->hDevMode);
2682 
2683  assert(orient == DMORIENT_PORTRAIT || orient == DMORIENT_LANDSCAPE);
2684 
2685  if(data->unicode)
2686  dm->u1.s1.dmOrientation = orient;
2687  else
2688  {
2689  DEVMODEA *dmA = (DEVMODEA *)dm;
2690  dmA->u1.s1.dmOrientation = orient;
2691  }
2692  GlobalUnlock(data->u.dlgw->hDevMode);
2693 }
short dmOrientation
Definition: wingdi.h:1602
#define assert(x)
Definition: debug.h:53
LPPAGESETUPDLGW dlgw
Definition: printdlg.c:2574
short dmOrientation
Definition: wingdi.h:1550
#define DMORIENT_LANDSCAPE
Definition: wingdi.h:1092
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
HGLOBAL hDevMode
Definition: commdlg.h:451
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
#define DMORIENT_PORTRAIT
Definition: wingdi.h:1091
union pagesetup_data::@338 u
static void pagesetup_set_papersize ( pagesetup_data data,
WORD  paper 
)
static

Definition at line 2711 of file printdlg.c.

Referenced by pagesetup_wm_command().

2712 {
2713  DEVMODEW *dm = GlobalLock(data->u.dlgw->hDevMode);
2714 
2715  if(data->unicode)
2716  dm->u1.s1.dmPaperSize = paper;
2717  else
2718  {
2719  DEVMODEA *dmA = (DEVMODEA *)dm;
2720  dmA->u1.s1.dmPaperSize = paper;
2721  }
2722  GlobalUnlock(data->u.dlgw->hDevMode);
2723 }
LPPAGESETUPDLGW dlgw
Definition: printdlg.c:2574
short dmPaperSize
Definition: wingdi.h:1603
short dmPaperSize
Definition: wingdi.h:1551
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
HGLOBAL hDevMode
Definition: commdlg.h:451
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
union pagesetup_data::@338 u
static void pagesetup_update_orientation_buttons ( HWND  hDlg,
const pagesetup_data data 
)
static

Definition at line 3289 of file printdlg.c.

Referenced by pagesetup_dlg_proc(), and pagesetup_printer_properties().

3290 {
3292  CheckRadioButton(hDlg, rad1, rad2, rad2);
3293  else
3294  CheckRadioButton(hDlg, rad1, rad2, rad1);
3295 }
#define rad2
Definition: dlgs.h:131
#define DMORIENT_LANDSCAPE
Definition: wingdi.h:1092
static WORD pagesetup_get_orientation(const pagesetup_data *data)
Definition: printdlg.c:2695
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)
#define rad1
Definition: dlgs.h:130
static BOOL pagesetup_update_papersize ( pagesetup_data data)
static

Definition at line 2974 of file printdlg.c.

Referenced by pagesetup_common(), pagesetup_dlg_proc(), pagesetup_printer_properties(), and pagesetup_wm_command().

2975 {
2976  DEVMODEW *dm;
2977  LPWSTR devname, portname;
2978  int i, num;
2979  WORD *words = NULL, paperword;
2980  POINT *points = NULL;
2981  BOOL retval = FALSE;
2982 
2983  dm = pagesetup_get_devmode(data);
2984  devname = pagesetup_get_devname(data);
2985  portname = pagesetup_get_portname(data);
2986 
2987  num = DeviceCapabilitiesW(devname, portname, DC_PAPERS, NULL, dm);
2988  if (num <= 0)
2989  {
2990  FIXME("No papernames found for %s/%s\n", debugstr_w(devname), debugstr_w(portname));
2991  goto end;
2992  }
2993 
2994  words = HeapAlloc(GetProcessHeap(), 0, num * sizeof(WORD));
2995  points = HeapAlloc(GetProcessHeap(), 0, num * sizeof(POINT));
2996 
2997  if (num != DeviceCapabilitiesW(devname, portname, DC_PAPERS, (LPWSTR)words, dm))
2998  {
2999  FIXME("Number of returned words is not %d\n", num);
3000  goto end;
3001  }
3002 
3003  if (num != DeviceCapabilitiesW(devname, portname, DC_PAPERSIZE, (LPWSTR)points, dm))
3004  {
3005  FIXME("Number of returned sizes is not %d\n", num);
3006  goto end;
3007  }
3008 
3009  paperword = pagesetup_get_papersize(data);
3010 
3011  for (i = 0; i < num; i++)
3012  if (words[i] == paperword)
3013  break;
3014 
3015  if (i == num)
3016  {
3017  FIXME("Papersize %d not found in list?\n", paperword);
3018  goto end;
3019  }
3020 
3021  /* this is _10ths_ of a millimeter */
3022  pagesetup_get_papersize_pt(data)->x = tenths_mm_to_size(data, points[i].x);
3023  pagesetup_get_papersize_pt(data)->y = tenths_mm_to_size(data, points[i].y);
3024 
3027 
3028  retval = TRUE;
3029 
3030 end:
3031  HeapFree(GetProcessHeap(), 0, words);
3032  HeapFree(GetProcessHeap(), 0, points);
3033  pagesetup_release_a_devname(data, portname);
3034  pagesetup_release_a_devname(data, devname);
3035  pagesetup_release_devmode(data, dm);
3036 
3037  return retval;
3038 }
static WORD pagesetup_get_papersize(const pagesetup_data *data)
Definition: printdlg.c:2725
#define DC_PAPERS
Definition: windef.h:353
unsigned short WORD
Definition: ntddk_ex.h:93
#define TRUE
Definition: types.h:120
static POINT * pagesetup_get_papersize_pt(const pagesetup_data *data)
Definition: printdlg.c:2934
long y
Definition: polytest.cpp:48
long x
Definition: polytest.cpp:48
static LONG tenths_mm_to_size(const pagesetup_data *data, LONG size)
Definition: printdlg.c:2590
GLuint GLuint end
Definition: gl.h:1545
DWORD WINAPI DeviceCapabilitiesW(_In_ LPCWSTR pDevice, _In_opt_ LPCWSTR pPort, _In_ WORD fwCapability, _Out_writes_opt_(_Inexpressible_(1)) LPWSTR pOutput, _In_opt_ const DEVMODEW *pDevMode)
static WCHAR * pagesetup_get_devname(const pagesetup_data *data)
Definition: printdlg.c:2798
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define FALSE
Definition: types.h:117
#define debugstr_w
Definition: kernel32.h:32
#define FIXME(fmt,...)
Definition: debug.h:110
smooth NULL
Definition: ftsmooth.c:416
static DEVMODEW * pagesetup_get_devmode(const pagesetup_data *data)
Definition: printdlg.c:2880
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
#define DMORIENT_LANDSCAPE
Definition: wingdi.h:1092
GLuint GLuint num
Definition: glext.h:9618
GLsizei const GLfloat * points
Definition: glext.h:8112
static void pagesetup_release_devmode(const pagesetup_data *data, DEVMODEW *dm)
Definition: printdlg.c:2899
static void swap_point(POINT *pt)
Definition: printdlg.c:2967
static WCHAR * pagesetup_get_portname(const pagesetup_data *data)
Definition: printdlg.c:2803
static WORD pagesetup_get_orientation(const pagesetup_data *data)
Definition: printdlg.c:2695
#define DC_PAPERSIZE
Definition: windef.h:354
static void pagesetup_release_a_devname(const pagesetup_data *data, WCHAR *name)
Definition: printdlg.c:2808
INT INT y
Definition: msvc.h:62
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define HeapFree(x, y, z)
Definition: compat.h:394
INT x
Definition: msvc.h:62
static BOOL pagesetup_wm_command ( HWND  hDlg,
WPARAM  wParam,
LPARAM  lParam,
pagesetup_data data 
)
static

Definition at line 3359 of file printdlg.c.

Referenced by pagesetup_dlg_proc().

3360 {
3361  WORD msg = HIWORD(wParam);
3362  WORD id = LOWORD(wParam);
3363 
3364  TRACE("loword (lparam) %d, wparam 0x%lx, lparam %08lx\n",
3366  switch (id) {
3367  case IDOK:
3368  EndDialog(hDlg, TRUE);
3369  return TRUE ;
3370 
3371  case IDCANCEL:
3372  EndDialog(hDlg, FALSE);
3373  return FALSE ;
3374 
3375  case psh3: /* Printer... */
3376  pagesetup_change_printer_dialog(hDlg, data);
3377  return TRUE;
3378 
3379  case rad1: /* Portrait */
3380  case rad2: /* Landscape */
3381  if((id == rad1 && pagesetup_get_orientation(data) == DMORIENT_LANDSCAPE) ||
3382  (id == rad2 && pagesetup_get_orientation(data) == DMORIENT_PORTRAIT))
3383  {
3386  rotate_rect(pagesetup_get_margin_rect(data), (id == rad2));
3387  update_margin_edits(hDlg, data, 0);
3389  }
3390  break;
3391  case cmb1: /* Printer combo */
3392  if(msg == CBN_SELCHANGE)
3393  {
3394  WCHAR *name;
3395  INT index = SendDlgItemMessageW(hDlg, id, CB_GETCURSEL, 0, 0);
3396  INT length = SendDlgItemMessageW(hDlg, id, CB_GETLBTEXTLEN, index, 0);
3397  name = HeapAlloc(GetProcessHeap(),0,sizeof(WCHAR)*(length+1));
3398  SendDlgItemMessageW(hDlg, id, CB_GETLBTEXT, index, (LPARAM)name);
3399  pagesetup_change_printer(name, data);
3400  pagesetup_init_combos(hDlg, data);
3401  HeapFree(GetProcessHeap(),0,name);
3402  }
3403  break;
3404  case cmb2: /* Paper combo */
3405  if(msg == CBN_SELCHANGE)
3406  {
3407  DWORD paperword = SendDlgItemMessageW(hDlg, cmb2, CB_GETITEMDATA,
3408  SendDlgItemMessageW(hDlg, cmb2, CB_GETCURSEL, 0, 0), 0);
3409  if (paperword != CB_ERR)
3410  {
3411  pagesetup_set_papersize(data, paperword);
3414  } else
3415  FIXME("could not get dialog text for papersize cmbbox?\n");
3416  }
3417  break;
3418  case cmb3: /* Paper Source */
3419  if(msg == CBN_SELCHANGE)
3420  {
3422  SendDlgItemMessageW(hDlg, cmb3, CB_GETCURSEL, 0, 0), 0);
3423  pagesetup_set_defaultsource(data, source);
3424  }
3425  break;
3426  case psh2: /* Printer Properties button */
3427  pagesetup_printer_properties(hDlg, data);
3428  break;
3429  case edt4:
3430  case edt5:
3431  case edt6:
3432  case edt7:
3433  margin_edit_notification(hDlg, data, msg, id);
3434  break;
3435  }
3437  return FALSE;
3438 }
static void pagesetup_printer_properties(HWND hDlg, pagesetup_data *data)
Definition: printdlg.c:3302
#define CB_GETLBTEXTLEN
Definition: winuser.h:1914
unsigned short WORD
Definition: ntddk_ex.h:93
#define TRUE
Definition: types.h:120
#define IDOK
Definition: winuser.h:824
__wchar_t WCHAR
Definition: xmlstorage.h:180
#define CB_GETLBTEXT
Definition: winuser.h:1913
static void update_margin_edits(HWND hDlg, const pagesetup_data *data, WORD id)
Definition: printdlg.c:3221
#define CB_GETITEMDATA
Definition: winuser.h:1911
static void pagesetup_change_printer_dialog(HWND hDlg, pagesetup_data *data)
Definition: printdlg.c:3127
#define edt5
Definition: dlgs.h:69
static void pagesetup_set_orientation(pagesetup_data *data, WORD orient)
Definition: printdlg.c:2679
#define psh2
Definition: dlgs.h:113
int32_t INT
Definition: typedefs.h:56
#define CB_GETCURSEL
Definition: winuser.h:1904
BOOL WINAPI EndDialog(_In_ HWND, _In_ INT_PTR)
DWORD DWORD
Definition: winlogon.h:84
#define rad2
Definition: dlgs.h:131
GLuint const GLchar * name
Definition: glext.h:6031
#define FALSE
Definition: types.h:117
LONG_PTR LPARAM
Definition: windef.h:208
#define psh3
Definition: dlgs.h:114
#define FIXME(fmt,...)
Definition: debug.h:110
#define edt4
Definition: dlgs.h:68
smooth NULL
Definition: ftsmooth.c:416
GLuint index
Definition: glext.h:6031
#define CB_ERR
Definition: winuser.h:2389
static void rotate_rect(RECT *rc, BOOL sense)
Definition: printdlg.c:2658
#define TRACE(s)
Definition: solgame.cpp:4
#define GetProcessHeap()
Definition: compat.h:395
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define DMORIENT_LANDSCAPE
Definition: wingdi.h:1092
GLenum GLuint GLenum GLsizei length
Definition: glext.h:5579
UINT WPARAM wParam
Definition: precomp.h:45
static void pagesetup_change_preview(const pagesetup_data *data)
Definition: printdlg.c:3178
BOOL WINAPI InvalidateRect(_In_opt_ HWND, _In_opt_ LPCRECT, _In_ BOOL)
static void pagesetup_init_combos(HWND hDlg, pagesetup_data *data)
Definition: printdlg.c:3101
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
static BOOL pagesetup_update_papersize(pagesetup_data *data)
Definition: printdlg.c:2974
static void margin_edit_notification(HWND hDlg, const pagesetup_data *data, WORD msg, WORD id)
Definition: printdlg.c:3236
static WORD pagesetup_get_orientation(const pagesetup_data *data)
Definition: printdlg.c:2695
#define cmb2
Definition: dlgs.h:49
static void pagesetup_set_defaultsource(pagesetup_data *data, WORD source)
Definition: printdlg.c:2741
static void pagesetup_set_papersize(pagesetup_data *data, WORD paper)
Definition: printdlg.c:2711
#define cmb3
Definition: dlgs.h:50
UINT WPARAM LPARAM lParam
Definition: precomp.h:45
#define CBN_SELCHANGE
Definition: winuser.h:1940
#define edt7
Definition: dlgs.h:71
static BOOL pagesetup_change_printer(LPWSTR name, pagesetup_data *data)
Definition: printdlg.c:3046
#define DMORIENT_PORTRAIT
Definition: wingdi.h:1091
UINT msg
Definition: msvc.h:92
#define HIWORD(l)
Definition: typedefs.h:246
static RECT * pagesetup_get_margin_rect(const pagesetup_data *data)
Definition: printdlg.c:2939
#define IDCANCEL
Definition: winuser.h:825
#define cmb1
Definition: dlgs.h:48
#define rct1
Definition: dlgs.h:147
#define LOWORD(l)
Definition: pedump.c:82
#define rad1
Definition: dlgs.h:130
#define HeapFree(x, y, z)
Definition: compat.h:394
#define edt6
Definition: dlgs.h:70
BOOL WINAPI PageSetupDlgA ( LPPAGESETUPDLGA  setupdlg)

Definition at line 3911 of file printdlg.c.

Referenced by test_PageSetupDlgA().

3912 {
3914 
3915  data.unicode = FALSE;
3916  data.u.dlga = setupdlg;
3917 
3918  return pagesetup_common(&data);
3919 }
static BOOL pagesetup_common(pagesetup_data *data)
Definition: printdlg.c:3830
#define FALSE
Definition: types.h:117
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
LPPAGESETUPDLGA dlga
Definition: printdlg.c:2573
union pagesetup_data::@338 u
BOOL WINAPI PageSetupDlgW ( LPPAGESETUPDLGW  setupdlg)

Definition at line 3926 of file printdlg.c.

Referenced by dialog_printsetup(), and PageSetupDlgWrapW().

3927 {
3929 
3930  data.unicode = TRUE;
3931  data.u.dlgw = setupdlg;
3932 
3933  return pagesetup_common(&data);
3934 }
#define TRUE
Definition: types.h:120
static BOOL pagesetup_common(pagesetup_data *data)
Definition: printdlg.c:3830
LPPAGESETUPDLGW dlgw
Definition: printdlg.c:2574
GLint GLenum GLsizei GLsizei GLsizei GLint GLsizei const GLvoid * data
Definition: gl.h:1950
union pagesetup_data::@338 u
static void pdlg_to_pdlgex ( const PRINTDLGW pdlg,
PRINTDLGEXW *  pdlgex 
)
static

Definition at line 3968 of file printdlg.c.

Referenced by PrintDlgExA(), and PrintDlgExW().

3969 {
3970  pdlgex->hDevMode = pdlg->hDevMode;
3971  pdlgex->hDevNames = pdlg->hDevNames;
3972  pdlgex->hDC = pdlg->hDC;
3973  if (!(pdlgex->Flags & PD_NOPAGENUMS) && pdlgex->nPageRanges && pdlgex->lpPageRanges)
3974  {
3975  pdlgex->lpPageRanges[0].nFromPage = pdlg->nFromPage;
3976  pdlgex->lpPageRanges[0].nToPage = pdlg->nToPage;
3977  }
3978  pdlgex->nMinPage = pdlg->nMinPage;
3979  pdlgex->nMaxPage = pdlg->nMaxPage;
3980  pdlgex->nCopies = pdlg->nCopies;
3981 }
#define PD_NOPAGENUMS
Definition: commdlg.h:150
HANDLE hDevNames
Definition: commdlg.h:489
HDC hDC
Definition: commdlg.h:490
WORD nMinPage
Definition: commdlg.h:494
WORD nCopies
Definition: commdlg.h:496
WORD nToPage
Definition: commdlg.h:493
WORD nFromPage
Definition: commdlg.h:492
HANDLE hDevMode
Definition: commdlg.h:488
WORD nMaxPage
Definition: commdlg.h:495
static UINT_PTR CALLBACK pdlgex_hook_proc ( HWND  hwnd,
UINT  msg,
WPARAM  wp,
LPARAM  lp 
)
static

Definition at line 3989 of file printdlg.c.

Referenced by PrintDlgExA(), and PrintDlgExW().

3990 {
3991  if (msg == WM_INITDIALOG)
3992  {
3993  PRINTDLGW *pd = (PRINTDLGW *)lp;
3994  struct callback_data *cb = (struct callback_data *)pd->lCustData;
3995 
3996  if (cb->callback)
3997  {
3998  cb->callback->lpVtbl->SelectionChange(cb->callback);
3999  cb->callback->lpVtbl->InitDone(cb->callback);
4000  }
4001  }
4002  else
4003  {
4004 /* FIXME: store interface pointer somewhere in window properties and call it
4005  HRESULT hres;
4006  cb->callback->lpVtbl->HandleMessage(cb->callback, hwnd, msg, wp, lp, &hres);
4007 */
4008  }
4009 
4010  return 0;
4011 }
IPrintDialogCallback * callback
Definition: printdlg.c:3985
DWORD lCustData
Definition: commdlg.h:498
void UINT cb
Definition: fci.h:175
if(!(yy_init))
Definition: macro.lex.yy.c:717
UINT msg
Definition: msvc.h:92
#define WM_INITDIALOG
Definition: winuser.h:1715
static void pdlgex_to_pdlg ( const PRINTDLGEXW *  pdlgex,
PRINTDLGW pdlg 
)
static

Definition at line 3936 of file printdlg.c.

Referenced by PrintDlgExA(), and PrintDlgExW().

3937 {
3938  pdlg->lStructSize = sizeof(*pdlg);
3939  pdlg->hwndOwner = pdlgex->hwndOwner;
3940  pdlg->hDevMode = pdlgex->hDevMode;
3941  pdlg->hDevNames = pdlgex->hDevNames;
3942  pdlg->hDC = pdlgex->hDC;
3943  pdlg->Flags = pdlgex->Flags;
3944  if ((pdlgex->Flags & PD_NOPAGENUMS) || !pdlgex->nPageRanges || !pdlgex->lpPageRanges)
3945  {
3946  pdlg->nFromPage = 0;
3947  pdlg->nToPage = 65534;
3948  }
3949  else
3950  {
3951  pdlg->nFromPage = pdlgex->lpPageRanges[0].nFromPage;
3952  pdlg->nToPage = pdlgex->lpPageRanges[0].nToPage;
3953  }
3954  pdlg->nMinPage = pdlgex->nMinPage;
3955  pdlg->nMaxPage = pdlgex->nMaxPage;
3956  pdlg->nCopies = pdlgex->nCopies;
3957  pdlg->hInstance = pdlgex->hInstance;
3958  pdlg->lCustData = 0;
3959  pdlg->lpfnPrintHook = NULL;
3960  pdlg->lpfnSetupHook = NULL;
3961  pdlg->lpPrintTemplateName = pdlgex->lpPrintTemplateName;
3962  pdlg->lpSetupTemplateName = NULL;
3963  pdlg->hPrintTemplate = NULL;
3964  pdlg->hSetupTemplate = NULL;
3965 }
HWND hwndOwner
Definition: commdlg.h:487
DWORD Flags
Definition: commdlg.h:491
#define PD_NOPAGENUMS
Definition: commdlg.h:150
LPCWSTR lpSetupTemplateName
Definition: commdlg.h:502
HANDLE hDevNames
Definition: commdlg.h:489
DWORD lCustData
Definition: commdlg.h:498
HDC hDC
Definition: commdlg.h:490
WORD nMinPage
Definition: commdlg.h:494
WORD nCopies
Definition: commdlg.h:496
smooth NULL
Definition: ftsmooth.c:416
LPPRINTHOOKPROC lpfnPrintHook
Definition: commdlg.h:499
DWORD lStructSize
Definition: commdlg.h:486
LPCWSTR lpPrintTemplateName
Definition: commdlg.h:501
WORD nToPage
Definition: commdlg.h:493
LPSETUPHOOKPROC lpfnSetupHook
Definition: commdlg.h:500
HANDLE hSetupTemplate
Definition: commdlg.h:504
WORD nFromPage
Definition: commdlg.h:492
HANDLE hDevMode
Definition: commdlg.h:488
HINSTANCE hInstance
Definition: commdlg.h:497
WORD nMaxPage
Definition: commdlg.h:495
HANDLE hPrintTemplate
Definition: commdlg.h:503
static BOOL PRINTDLG_ChangePrinterA ( HWND  hDlg,
char name,
PRINT_PTRA PrintStructures 
)
static

Definition at line 1080 of file printdlg.c.

Referenced by PRINTDLG_WMCommandA(), and PRINTDLG_WMInitDialog().

1081 {
1082  LPPRINTDLGA lppd = PrintStructures->lpPrintDlg;
1083  LPDEVMODEA lpdm = NULL;
1084  LONG dmSize;
1085  DWORD needed;
1086  HANDLE hprn;
1087 
1088  HeapFree(GetProcessHeap(),0, PrintStructures->lpPrinterInfo);
1089  HeapFree(GetProcessHeap(),0, PrintStructures->lpDriverInfo);
1090  if(!OpenPrinterA(name, &hprn, NULL)) {
1091  ERR("Can't open printer %s\n", name);
1092  return FALSE;
1093  }
1094  GetPrinterA(hprn, 2, NULL, 0, &needed);
1095  PrintStructures->lpPrinterInfo = HeapAlloc(GetProcessHeap(),0,needed);
1096  GetPrinterA(hprn, 2, (LPBYTE)PrintStructures->lpPrinterInfo, needed,
1097  &needed);
1098  GetPrinterDriverA(hprn, NULL, 3, NULL, 0, &needed);
1099  PrintStructures->lpDriverInfo = HeapAlloc(GetProcessHeap(),0,needed);
1100  if (!GetPrinterDriverA(hprn, NULL, 3, (LPBYTE)PrintStructures->lpDriverInfo,
1101  needed, &needed)) {
1102  ERR("GetPrinterDriverA failed for %s, fix your config!\n",PrintStructures->lpPrinterInfo->pPrinterName);
1103  return FALSE;
1104  }
1105  ClosePrinter(hprn);
1106 
1107  PRINTDLG_UpdatePrinterInfoTextsA(hDlg, PrintStructures->lpPrinterInfo);
1108 
1109  HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
1110  PrintStructures->lpDevMode = NULL;
1111 
1112  dmSize = DocumentPropertiesA(0, 0, name, NULL, NULL, 0);
1113  if(dmSize == -1) {
1114  ERR("DocumentProperties fails on %s\n", debugstr_a(name));
1115  return FALSE;
1116  }
1117  PrintStructures->lpDevMode = HeapAlloc(GetProcessHeap(), 0, dmSize);
1118  dmSize = DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, NULL,
1119  DM_OUT_BUFFER);
1120  if(lppd->hDevMode && (lpdm = GlobalLock(lppd->hDevMode)) &&
1121  !lstrcmpA( (LPSTR) lpdm->dmDeviceName,
1122  (LPSTR) PrintStructures->lpDevMode->dmDeviceName)) {
1123  /* Supplied devicemode matches current printer so try to use it */
1124  DocumentPropertiesA(0, 0, name, PrintStructures->lpDevMode, lpdm,
1126  }
1127  if(lpdm)
1128  GlobalUnlock(lppd->hDevMode);
1129 
1130  lpdm = PrintStructures->lpDevMode; /* use this as a shortcut */
1131 
1132  if(!(lppd->Flags & PD_PRINTSETUP)) {
1133  /* Print range (All/Range/Selection) */
1134  if(lppd->nFromPage != 0xffff)
1135  SetDlgItemInt(hDlg, edt1, lppd->nFromPage, FALSE);
1136  if(lppd->nToPage != 0xffff)
1137  SetDlgItemInt(hDlg, edt2, lppd->nToPage, FALSE);
1138 
1139  CheckRadioButton(hDlg, rad1, rad3, rad1); /* default */
1140  if (lppd->Flags & PD_NOSELECTION)
1141  EnableWindow(GetDlgItem(hDlg, rad2), FALSE);
1142  else
1143  if (lppd->Flags & PD_SELECTION)
1144  CheckRadioButton(hDlg, rad1, rad3, rad2);
1145  if (lppd->Flags & PD_NOPAGENUMS) {
1146  EnableWindow(GetDlgItem(hDlg, rad3), FALSE);
1148  EnableWindow(GetDlgItem(hDlg, edt1), FALSE);
1150  EnableWindow(GetDlgItem(hDlg, edt2), FALSE);
1151  } else {
1152  if (lppd->Flags & PD_PAGENUMS)
1153  CheckRadioButton(hDlg, rad1, rad3, rad3);
1154  }
1155 
1156  /* Collate pages
1157  *
1158  * FIXME: The ico3 is not displayed for some reason. I don't know why.
1159  */
1160  if (lppd->Flags & PD_COLLATE) {
1162  (LPARAM)PrintStructures->hCollateIcon);
1163  CheckDlgButton(hDlg, chx2, 1);
1164  } else {
1166  (LPARAM)PrintStructures->hNoCollateIcon);
1167  CheckDlgButton(hDlg, chx2, 0);
1168  }
1169 
1170  if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
1171  /* if printer doesn't support it: no Collate */
1172  if (!(lpdm->dmFields & DM_COLLATE)) {
1173  EnableWindow(GetDlgItem(hDlg, chx2), FALSE);
1174  EnableWindow(GetDlgItem(hDlg, ico3), FALSE);
1175  }
1176  }
1177 
1178  /* nCopies */
1179  {
1180  INT copies;
1181  if (lppd->hDevMode == 0)
1182  copies = lppd->nCopies;
1183  else
1184  copies = lpdm->u1.s1.dmCopies;
1185  if(copies == 0) copies = 1;
1186  else if(copies < 0) copies = MAX_COPIES;
1187  SetDlgItemInt(hDlg, edt3, copies, FALSE);
1188  }
1189 
1190  if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
1191  /* if printer doesn't support it: no nCopies */
1192  if (!(lpdm->dmFields & DM_COPIES)) {
1193  EnableWindow(GetDlgItem(hDlg, edt3), FALSE);
1194  EnableWindow(GetDlgItem(hDlg, stc5), FALSE);
1195  }
1196  }
1197 
1198  /* print to file */
1199  CheckDlgButton(hDlg, chx1, (lppd->Flags & PD_PRINTTOFILE) ? 1 : 0);
1200  if (lppd->Flags & PD_DISABLEPRINTTOFILE)
1201  EnableWindow(GetDlgItem(hDlg, chx1), FALSE);
1202  if (lppd->Flags & PD_HIDEPRINTTOFILE)
1203  ShowWindow(GetDlgItem(hDlg, chx1), SW_HIDE);
1204 
1205  /* Fill print quality combo, PrintDlg16 */
1206  if(GetDlgItem(hDlg, cmb1))
1207  {
1208  DWORD numResolutions = DeviceCapabilitiesA(PrintStructures->lpPrinterInfo->pPrinterName,
1209  PrintStructures->lpPrinterInfo->pPortName,
1210  DC_ENUMRESOLUTIONS, NULL, lpdm);
1211 
1212  if(numResolutions != -1)
1213  {
1214  HWND hQuality = GetDlgItem(hDlg, cmb1);
1215  LONG* Resolutions;
1216  char buf[255];
1217  DWORD i;
1218  int dpiX, dpiY;
1219  HDC hPrinterDC = CreateDCA(PrintStructures->lpPrinterInfo->pDriverName,
1220  PrintStructures->lpPrinterInfo->pPrinterName,
1221  0, lpdm);
1222 
1223  Resolutions = HeapAlloc(GetProcessHeap(), 0, numResolutions*sizeof(LONG)*2);
1225  PrintStructures->lpPrinterInfo->pPortName,
1226  DC_ENUMRESOLUTIONS, (LPSTR)Resolutions, lpdm);
1227 
1228  dpiX = GetDeviceCaps(hPrinterDC, LOGPIXELSX);
1229  dpiY = GetDeviceCaps(hPrinterDC, LOGPIXELSY);
1230  DeleteDC(hPrinterDC);
1231 
1232  SendMessageA(hQuality, CB_RESETCONTENT, 0, 0);
1233  for(i = 0; i < (numResolutions * 2); i += 2)
1234  {
1235  BOOL IsDefault = FALSE;
1236  LRESULT Index;
1237 
1238  if(Resolutions[i] == Resolutions[i+1])
1239  {
1240  if(dpiX == Resolutions[i])
1241  IsDefault = TRUE;
1242  sprintf(buf, "%d dpi", Resolutions[i]);
1243  } else
1244  {
1245  if(dpiX == Resolutions[i] && dpiY == Resolutions[i+1])
1246  IsDefault = TRUE;
1247  sprintf(buf, "%d dpi x %d dpi", Resolutions[i], Resolutions[i+1]);
1248  }
1249 
1250  Index = SendMessageA(hQuality, CB_ADDSTRING, 0, (LPARAM)buf);
1251 
1252  if(IsDefault)
1253  SendMessageA(hQuality, CB_SETCURSEL, Index, 0);
1254 
1255  SendMessageA(hQuality, CB_SETITEMDATA, Index, MAKELONG(dpiX,dpiY));
1256  }
1257  HeapFree(GetProcessHeap(), 0, Resolutions);
1258  }
1259  }
1260  } else { /* PD_PRINTSETUP */
1261  BOOL bPortrait = (lpdm->u1.s1.dmOrientation == DMORIENT_PORTRAIT);
1262 
1264  PrintStructures->lpPrinterInfo->pPrinterName,
1265  PrintStructures->lpPrinterInfo->pPortName,
1266  lpdm);
1268  PrintStructures->lpPrinterInfo->pPrinterName,
1269  PrintStructures->lpPrinterInfo->pPortName,
1270  lpdm);
1271  CheckRadioButton(hDlg, rad1, rad2, bPortrait ? rad1: rad2);
1273  (LPARAM)(bPortrait ? PrintStructures->hPortraitIcon :
1274  PrintStructures->hLandscapeIcon));
1275 
1276  }
1277 
1278  /* help button */
1279  if ((lppd->Flags & PD_SHOWHELP)==0) {
1280  /* hide if PD_SHOWHELP not specified */
1282  }
1283  return TRUE;
1284 }
HICON hPortraitIcon
Definition: printdlg.c:69
WINBOOL WINAPI GetPrinterDriverA(HANDLE hPrinter, LPSTR pEnvironment, DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf, LPDWORD pcbNeeded)
Definition: printers.c:507
#define HDC
Definition: msvc.h:22
#define PD_HIDEPRINTTOFILE
Definition: commdlg.h:168
#define CB_SETITEMDATA
Definition: winuser.h:1927
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define LOGPIXELSX
Definition: wingdi.h:716
#define PD_NOSELECTION
Definition: commdlg.h:149
#define TRUE
Definition: types.h:120
#define IMAGE_ICON
Definition: winuser.h:212
HICON hNoCollateIcon
Definition: printdlg.c:68
HICON hCollateIcon
Definition: printdlg.c:67
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
#define SW_HIDE
Definition: winuser.h:762
LRESULT WINAPI SendMessageA(_In_ HWND, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
WINBOOL WINAPI GetPrinterA(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter, DWORD cbBuf, LPDWORD pcbNeeded)
Definition: printers.c:500
unsigned char * LPBYTE
Definition: typedefs.h:52
HANDLE HWND
Definition: compat.h:13
LPPRINTER_INFO_2A lpPrinterInfo
Definition: printdlg.c:64
int WINAPI lstrcmpA(LPCSTR lpString1, LPCSTR lpString2)
Definition: lstring.c:18
#define stc2
Definition: dlgs.h:161
WORD nCopies
Definition: commdlg.h:475
LPPRINTDLGA lpPrintDlg
Definition: printdlg.c:63
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
#define PD_NOPAGENUMS
Definition: commdlg.h:150
char * LPSTR
Definition: xmlstorage.h:182
#define DM_COLLATE
Definition: wingdi.h:1246
int32_t INT
Definition: typedefs.h:56
DWORD DWORD
Definition: winlogon.h:84
static void PRINTDLG_UpdatePrinterInfoTextsA(HWND hDlg, const PRINTER_INFO_2A *pi)
Definition: printdlg.c:1003
#define rad2
Definition: dlgs.h:131
static BOOL PRINTDLG_SetUpPaperComboBoxA(HWND hDlg, int nIDComboBox, char *PrinterName, char *PortName, LPDEVMODEA dm)
Definition: printdlg.c:780
#define ico1
Definition: dlgs.h:90
#define sprintf(buf, format,...)
Definition: sprintf.c:55
short dmCopies
Definition: wingdi.h:1555
LPDRIVER_INFO_3A lpDriverInfo
Definition: printdlg.c:65
GLenum GLclampf GLint i
Definition: glfuncs.h:14
#define PD_USEDEVMODECOPIESANDCOLLATE
Definition: commdlg.h:166
#define DC_ENUMRESOLUTIONS
Definition: windef.h:364
#define FALSE
Definition: types.h:117
#define chx1
Definition: dlgs.h:31
#define chx2
Definition: dlgs.h:32
long LONG
Definition: pedump.c:60
#define DM_OUT_BUFFER
Definition: windef.h:349
LONG_PTR LPARAM
Definition: windef.h:208
#define stc3
Definition: dlgs.h:162
short dmOrientation
Definition: wingdi.h:1550
WINBOOL WINAPI ClosePrinter(HANDLE hPrinter)
Definition: printers.c:12
#define PD_DISABLEPRINTTOFILE
Definition: commdlg.h:167
#define CB_ADDSTRING
Definition: winuser.h:1897
#define MAKELONG(a, b)
Definition: typedefs.h:248
WORD nFromPage
Definition: commdlg.h:471
smooth NULL
Definition: ftsmooth.c:416
LPSTR pDriverName
Definition: winspool.h:42
LONG WINAPI DocumentPropertiesA(HWND hWnd, HANDLE hPrinter, LPSTR pDeviceName, PDEVMODEA pDevModeOutput, PDEVMODEA pDevModeInput, DWORD fMode)
Definition: printers.c:196
#define PD_SELECTION
Definition: commdlg.h:147
HICON hLandscapeIcon
Definition: printdlg.c:70
WINBOOL WINAPI OpenPrinterA(LPSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSA pDefault)
Definition: printers.c:570
#define CB_RESETCONTENT
Definition: winuser.h:1920
LPSTR pPrinterName
Definition: winspool.h:39
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
#define PD_PRINTSETUP
Definition: commdlg.h:153
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
#define debugstr_a
Definition: kernel32.h:31
#define rad3
Definition: dlgs.h:132
static const UCHAR Index[8]
Definition: usbohci.c:18
DWORD WINAPI DeviceCapabilitiesA(_In_ LPCSTR pDevice, _In_opt_ LPCSTR pPort, _In_ WORD fwCapability, _Out_writes_opt_(_Inexpressible_(1)) LPSTR pOutput, _In_opt_ const DEVMODEA *pDevMode)
#define PD_SHOWHELP
Definition: commdlg.h:158
#define PD_PAGENUMS
Definition: commdlg.h:148
#define edt1
Definition: dlgs.h:65
DWORD dmFields
Definition: wingdi.h:1547
#define edt2
Definition: dlgs.h:66
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)
LPDEVMODEA lpDevMode
Definition: printdlg.c:62
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define PD_COLLATE
Definition: commdlg.h:151
int WINAPI GetDeviceCaps(_In_opt_ HDC, _In_ int)
LPSTR pPortName
Definition: winspool.h:41
#define CB_SETCURSEL
Definition: winuser.h:1922
#define PD_PRINTTOFILE
Definition: commdlg.h:152
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define ERR(fmt,...)
Definition: debug.h:109
#define cmb2
Definition: dlgs.h:49
DWORD *typedef HANDLE
Definition: winlogon.h:61
#define DM_IN_BUFFER
Definition: windef.h:347
BOOL WINAPI DeleteDC(_In_ HDC)
#define cmb3
Definition: dlgs.h:50
#define DM_COPIES
Definition: wingdi.h:1239
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
BYTE dmDeviceName[CCHDEVICENAME]
Definition: wingdi.h:1542
#define pshHelp
Definition: dlgs.h:127
#define STM_SETIMAGE
Definition: winuser.h:2054
WORD nToPage
Definition: commdlg.h:472
LRESULT WINAPI SendDlgItemMessageA(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
Definition: name.c:36
#define DMORIENT_PORTRAIT
Definition: wingdi.h:1091
#define edt3
Definition: dlgs.h:67
#define LOGPIXELSY
Definition: wingdi.h:717
DWORD Flags
Definition: commdlg.h:470
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)
LONG_PTR LRESULT
Definition: windef.h:209
HDC WINAPI CreateDCA(_In_opt_ LPCSTR pszDriver, _In_opt_ LPCSTR pszDevice, _In_opt_ LPCSTR pszOutput, _In_opt_ const DEVMODEA *pdmInit)
#define cmb1
Definition: dlgs.h:48
#define ico3
Definition: dlgs.h:92
HANDLE hDevMode
Definition: commdlg.h:467
#define rad1
Definition: dlgs.h:130
#define HeapFree(x, y, z)
Definition: compat.h:394
#define stc5
Definition: dlgs.h:164
#define MAX_COPIES
Definition: printdlg.c:54
static BOOL PRINTDLG_ChangePrinterW ( HWND  hDlg,
WCHAR name,
PRINT_PTRW PrintStructures 
)
static

Definition at line 1286 of file printdlg.c.

Referenced by PRINTDLG_WMCommandW(), and PRINTDLG_WMInitDialogW().

1288 {
1289  LPPRINTDLGW lppd = PrintStructures->lpPrintDlg;
1290  LPDEVMODEW lpdm = NULL;
1291  LONG dmSize;
1292  DWORD needed;
1293  HANDLE hprn;
1294 
1295  HeapFree(GetProcessHeap(),0, PrintStructures->lpPrinterInfo);
1296  HeapFree(GetProcessHeap(),0, PrintStructures->lpDriverInfo);
1297  if(!OpenPrinterW(name, &hprn, NULL)) {
1298  ERR("Can't open printer %s\n", debugstr_w(name));
1299  return FALSE;
1300  }
1301  GetPrinterW(hprn, 2, NULL, 0, &needed);
1302  PrintStructures->lpPrinterInfo = HeapAlloc(GetProcessHeap(),0,needed);
1303  GetPrinterW(hprn, 2, (LPBYTE)PrintStructures->lpPrinterInfo, needed,
1304  &needed);
1305  GetPrinterDriverW(hprn, NULL, 3, NULL, 0, &needed);
1306  PrintStructures->lpDriverInfo = HeapAlloc(GetProcessHeap(),0,needed);
1307  if (!GetPrinterDriverW(hprn, NULL, 3, (LPBYTE)PrintStructures->lpDriverInfo,
1308  needed, &needed)) {
1309  ERR("GetPrinterDriverA failed for %s, fix your config!\n",debugstr_w(PrintStructures->lpPrinterInfo->pPrinterName));
1310  return FALSE;
1311  }
1312  ClosePrinter(hprn);
1313 
1314  PRINTDLG_UpdatePrinterInfoTextsW(hDlg, PrintStructures->lpPrinterInfo);
1315 
1316  HeapFree(GetProcessHeap(), 0, PrintStructures->lpDevMode);
1317  PrintStructures->lpDevMode = NULL;
1318 
1319  dmSize = DocumentPropertiesW(0, 0, name, NULL, NULL, 0);
1320  if(dmSize == -1) {
1321  ERR("DocumentProperties fails on %s\n", debugstr_w(name));
1322  return FALSE;
1323  }
1324  PrintStructures->lpDevMode = HeapAlloc(GetProcessHeap(), 0, dmSize);
1325  dmSize = DocumentPropertiesW(0, 0, name, PrintStructures->lpDevMode, NULL,
1326  DM_OUT_BUFFER);
1327  if(lppd->hDevMode && (lpdm = GlobalLock(lppd->hDevMode)) &&
1328  !lstrcmpW(lpdm->dmDeviceName,
1329  PrintStructures->lpDevMode->dmDeviceName)) {
1330  /* Supplied devicemode matches current printer so try to use it */
1331  DocumentPropertiesW(0, 0, name, PrintStructures->lpDevMode, lpdm,
1333  }
1334  if(lpdm)
1335  GlobalUnlock(lppd->hDevMode);
1336 
1337  lpdm = PrintStructures->lpDevMode; /* use this as a shortcut */
1338 
1339  if(!(lppd->Flags & PD_PRINTSETUP)) {
1340  /* Print range (All/Range/Selection) */
1341  if(lppd->nFromPage != 0xffff)
1342  SetDlgItemInt(hDlg, edt1, lppd->nFromPage, FALSE);
1343  if(lppd->nToPage != 0xffff)
1344  SetDlgItemInt(hDlg, edt2, lppd->nToPage, FALSE);
1345 
1346  CheckRadioButton(hDlg, rad1, rad3, rad1); /* default */
1347  if (lppd->Flags & PD_NOSELECTION)
1348  EnableWindow(GetDlgItem(hDlg, rad2), FALSE);
1349  else
1350  if (lppd->Flags & PD_SELECTION)
1351  CheckRadioButton(hDlg, rad1, rad3, rad2);
1352  if (lppd->Flags & PD_NOPAGENUMS) {
1353  EnableWindow(GetDlgItem(hDlg, rad3), FALSE);
1355  EnableWindow(GetDlgItem(hDlg, edt1), FALSE);
1357  EnableWindow(GetDlgItem(hDlg, edt2), FALSE);
1358  } else {
1359  if (lppd->Flags & PD_PAGENUMS)
1360  CheckRadioButton(hDlg, rad1, rad3, rad3);
1361  }
1362 
1363  /* Collate pages
1364  *
1365  * FIXME: The ico3 is not displayed for some reason. I don't know why.
1366  */
1367  if (lppd->Flags & PD_COLLATE) {
1369  (LPARAM)PrintStructures->hCollateIcon);
1370  CheckDlgButton(hDlg, chx2, 1);
1371  } else {
1373  (LPARAM)PrintStructures->hNoCollateIcon);
1374  CheckDlgButton(hDlg, chx2, 0);
1375  }
1376 
1377  if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
1378  /* if printer doesn't support it: no Collate */
1379  if (!(lpdm->dmFields & DM_COLLATE)) {
1380  EnableWindow(GetDlgItem(hDlg, chx2), FALSE);
1381  EnableWindow(GetDlgItem(hDlg, ico3), FALSE);
1382  }
1383  }
1384 
1385  /* nCopies */
1386  {
1387  INT copies;
1388  if (lppd->hDevMode == 0)
1389  copies = lppd->nCopies;
1390  else
1391  copies = lpdm->u1.s1.dmCopies;
1392  if(copies == 0) copies = 1;
1393  else if(copies < 0) copies = MAX_COPIES;
1394  SetDlgItemInt(hDlg, edt3, copies, FALSE);
1395  }
1396 
1397  if (lppd->Flags & PD_USEDEVMODECOPIESANDCOLLATE) {
1398  /* if printer doesn't support it: no nCopies */
1399  if (!(lpdm->dmFields & DM_COPIES)) {
1400  EnableWindow(GetDlgItem(hDlg, edt3), FALSE);
1401  EnableWindow(GetDlgItem(hDlg, stc5), FALSE);
1402  }
1403  }
1404 
1405  /* print to file */
1406  CheckDlgButton(hDlg, chx1, (lppd->Flags & PD_PRINTTOFILE) ? 1 : 0);
1407  if (lppd->Flags & PD_DISABLEPRINTTOFILE)
1408  EnableWindow(GetDlgItem(hDlg, chx1), FALSE);
1409  if (lppd->Flags & PD_HIDEPRINTTOFILE)
1410  ShowWindow(GetDlgItem(hDlg, chx1), SW_HIDE);
1411 
1412  } else { /* PD_PRINTSETUP */
1413  BOOL bPortrait = (lpdm->u1.s1.dmOrientation == DMORIENT_PORTRAIT);
1414 
1416  PrintStructures->lpPrinterInfo->pPrinterName,
1417  PrintStructures->lpPrinterInfo->pPortName,
1418  lpdm);
1420  PrintStructures->lpPrinterInfo->pPrinterName,
1421  PrintStructures->lpPrinterInfo->pPortName,
1422  lpdm);
1423  CheckRadioButton(hDlg, rad1, rad2, bPortrait ? rad1: rad2);
1425  (LPARAM)(bPortrait ? PrintStructures->hPortraitIcon :
1426  PrintStructures->hLandscapeIcon));
1427 
1428  }
1429 
1430  /* help button */
1431  if ((lppd->Flags & PD_SHOWHELP)==0) {
1432  /* hide if PD_SHOWHELP not specified */
1434  }
1435  return TRUE;
1436 }
#define PD_HIDEPRINTTOFILE
Definition: commdlg.h:168
BOOL WINAPI CheckDlgButton(_In_ HWND, _In_ int, _In_ UINT)
#define PD_NOSELECTION
Definition: commdlg.h:149
#define TRUE
Definition: types.h:120
#define IMAGE_ICON
Definition: winuser.h:212
DWORD dmFields
Definition: wingdi.h:1599
#define SW_HIDE
Definition: winuser.h:762
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
unsigned char * LPBYTE
Definition: typedefs.h:52
short dmOrientation
Definition: wingdi.h:1602
#define stc2
Definition: dlgs.h:161
static void PRINTDLG_UpdatePrinterInfoTextsW(HWND hDlg, const PRINTER_INFO_2W *pi)
Definition: printdlg.c:1039
LONG WINAPI DocumentPropertiesW(HWND hWnd, HANDLE hPrinter, LPWSTR pDeviceName, PDEVMODEW pDevModeOutput, PDEVMODEW pDevModeInput, DWORD fMode)
Definition: printers.c:204
BOOL WINAPI ShowWindow(_In_ HWND, _In_ int)
DWORD Flags
Definition: commdlg.h:491
WINBOOL WINAPI GetPrinterDriverW(HANDLE hPrinter, LPWSTR pEnvironment, DWORD Level, LPBYTE pDriverInfo, DWORD cbBuf, LPDWORD pcbNeeded)
Definition: printers.c:514
#define PD_NOPAGENUMS
Definition: commdlg.h:150
#define DM_COLLATE
Definition: wingdi.h:1246
int32_t INT
Definition: typedefs.h:56
DWORD DWORD
Definition: winlogon.h:84
#define rad2
Definition: dlgs.h:131
#define ico1
Definition: dlgs.h:90
HICON hPortraitIcon
Definition: printdlg.c:83
LPDRIVER_INFO_3W lpDriverInfo
Definition: printdlg.c:79
#define PD_USEDEVMODECOPIESANDCOLLATE
Definition: commdlg.h:166
#define FALSE
Definition: types.h:117
#define chx1
Definition: dlgs.h:31
#define chx2
Definition: dlgs.h:32
long LONG
Definition: pedump.c:60
#define DM_OUT_BUFFER
Definition: windef.h:349
LONG_PTR LPARAM
Definition: windef.h:208
#define debugstr_w
Definition: kernel32.h:32
#define stc3
Definition: dlgs.h:162
HICON hCollateIcon
Definition: printdlg.c:81
WINBOOL WINAPI ClosePrinter(HANDLE hPrinter)
Definition: printers.c:12
#define PD_DISABLEPRINTTOFILE
Definition: commdlg.h:167
WORD nCopies
Definition: commdlg.h:496
smooth NULL
Definition: ftsmooth.c:416
#define PD_SELECTION
Definition: commdlg.h:147
WINBOOL WINAPI GetPrinterW(HANDLE hPrinter, DWORD Level, LPBYTE pPrinter, DWORD cbBuf, LPDWORD pcbNeeded)
Definition: printers.c:521
HICON hNoCollateIcon
Definition: printdlg.c:82
unsigned int BOOL
Definition: ntddk_ex.h:94
#define GetProcessHeap()
Definition: compat.h:395
#define PD_PRINTSETUP
Definition: commdlg.h:153
PVOID WINAPI HeapAlloc(HANDLE, DWORD, SIZE_T)
HWND WINAPI GetDlgItem(_In_opt_ HWND, _In_ int)
WORD nToPage
Definition: commdlg.h:493
LPPRINTDLGW lpPrintDlg
Definition: printdlg.c:77
#define rad3
Definition: dlgs.h:132
LPPRINTER_INFO_2W lpPrinterInfo
Definition: printdlg.c:78
LRESULT WINAPI SendDlgItemMessageW(_In_ HWND, _In_ int, _In_ UINT, _In_ WPARAM, _In_ LPARAM)
WCHAR dmDeviceName[CCHDEVICENAME]
Definition: wingdi.h:1594
#define PD_SHOWHELP
Definition: commdlg.h:158
#define PD_PAGENUMS
Definition: commdlg.h:148
#define edt1
Definition: dlgs.h:65
#define edt2
Definition: dlgs.h:66
BOOL WINAPI SetDlgItemInt(_In_ HWND, _In_ int, _In_ UINT, _In_ BOOL)
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
#define PD_COLLATE
Definition: commdlg.h:151
#define PD_PRINTTOFILE
Definition: commdlg.h:152
WORD nFromPage
Definition: commdlg.h:492
HANDLE hDevMode
Definition: commdlg.h:488
BOOL WINAPI EnableWindow(_In_ HWND, _In_ BOOL)
#define ERR(fmt,...)
Definition: debug.h:109
#define cmb2
Definition: dlgs.h:49
WINBOOL WINAPI OpenPrinterW(LPWSTR pPrinterName, LPHANDLE phPrinter, LPPRINTER_DEFAULTSW pDefault)
Definition: printers.c:635
DWORD *typedef HANDLE
Definition: winlogon.h:61
#define DM_IN_BUFFER
Definition: windef.h:347
#define cmb3
Definition: dlgs.h:50
#define DM_COPIES
Definition: wingdi.h:1239
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
LPDEVMODEW lpDevMode
Definition: printdlg.c:76
#define pshHelp
Definition: dlgs.h:127
HICON hLandscapeIcon
Definition: printdlg.c:84
#define STM_SETIMAGE
Definition: winuser.h:2054
LPWSTR pPortName
Definition: winspool.h:65
Definition: name.c:36
#define DMORIENT_PORTRAIT
Definition: wingdi.h:1091
LPWSTR pPrinterName
Definition: winspool.h:63
#define edt3
Definition: dlgs.h:67
short dmCopies
Definition: wingdi.h:1607
BOOL WINAPI CheckRadioButton(_In_ HWND, _In_ int, _In_ int, _In_ int)
static BOOL PRINTDLG_SetUpPaperComboBoxW(HWND hDlg, int nIDComboBox, const WCHAR *PrinterName, const WCHAR *PortName, LPDEVMODEW dm)
Definition: printdlg.c:889
#define ico3
Definition: dlgs.h:92
#define rad1
Definition: dlgs.h:130
#define HeapFree(x, y, z)
Definition: compat.h:394
#define stc5
Definition: dlgs.h:164
#define MAX_COPIES
Definition: printdlg.c:54
static BOOL PRINTDLG_CreateDCA ( LPPRINTDLGA  lppd)
static

Definition at line 2179 of file printdlg.c.

Referenced by PrintDlgA().

2180 {
2181  DEVNAMES *pdn = GlobalLock(lppd->hDevNames);
2182  DEVMODEA *pdm = GlobalLock(lppd->hDevMode);
2183 
2184  if(lppd->Flags & PD_RETURNDC) {
2185  lppd->hDC = CreateDCA((char*)pdn + pdn->wDriverOffset,
2186  (char*)pdn + pdn->wDeviceOffset,
2187  (char*)pdn + pdn->wOutputOffset,
2188  pdm );
2189  } else if(lppd->Flags & PD_RETURNIC) {
2190  lppd->hDC = CreateICA((char*)pdn + pdn->wDriverOffset,
2191  (char*)pdn + pdn->wDeviceOffset,
2192  (char*)pdn + pdn->wOutputOffset,
2193  pdm );
2194  }
2195  GlobalUnlock(lppd->hDevNames);
2196  GlobalUnlock(lppd->hDevMode);
2197  return lppd->hDC != NULL;
2198 }
HDC WINAPI CreateICA(_In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ LPCSTR, _In_opt_ const DEVMODEA *)
HANDLE hDevNames
Definition: commdlg.h:468
WORD wDeviceOffset
Definition: commdlg.h:298
#define PD_RETURNIC
Definition: commdlg.h:156
smooth NULL
Definition: ftsmooth.c:416
WORD wDriverOffset
Definition: commdlg.h:297
#define PD_RETURNDC
Definition: commdlg.h:155
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
DWORD Flags
Definition: commdlg.h:470
WORD wOutputOffset
Definition: commdlg.h:299
HDC WINAPI CreateDCA(_In_opt_ LPCSTR pszDriver, _In_opt_ LPCSTR pszDevice, _In_opt_ LPCSTR pszOutput, _In_opt_ const DEVMODEA *pdmInit)
HDC hDC
Definition: commdlg.h:469
HANDLE hDevMode
Definition: commdlg.h:467
static BOOL PRINTDLG_CreateDCW ( LPPRINTDLGW  lppd)
static

Definition at line 2200 of file printdlg.c.

Referenced by PrintDlgW().

2201 {
2202  DEVNAMES *pdn = GlobalLock(lppd->hDevNames);
2203  DEVMODEW *pdm = GlobalLock(lppd->hDevMode);
2204 
2205  if(lppd->Flags & PD_RETURNDC) {
2206  lppd->hDC = CreateDCW((WCHAR*)pdn + pdn->wDriverOffset,
2207  (WCHAR*)pdn + pdn->wDeviceOffset,
2208  (WCHAR*)pdn + pdn->wOutputOffset,
2209  pdm );
2210  } else if(lppd->Flags & PD_RETURNIC) {
2211  lppd->hDC = CreateICW((WCHAR*)pdn + pdn->wDriverOffset,
2212  (WCHAR*)pdn + pdn->wDeviceOffset,
2213  (WCHAR*)pdn + pdn->wOutputOffset,
2214  pdm );
2215  }
2216  GlobalUnlock(lppd->hDevNames);
2217  GlobalUnlock(lppd->hDevMode);
2218  return lppd->hDC != NULL;
2219 }
__wchar_t WCHAR
Definition: xmlstorage.h:180
DWORD Flags
Definition: commdlg.h:491
HANDLE hDevNames
Definition: commdlg.h:489
HDC hDC
Definition: commdlg.h:490
WORD wDeviceOffset
Definition: commdlg.h:298
#define PD_RETURNIC
Definition: commdlg.h:156
smooth NULL
Definition: ftsmooth.c:416
WORD wDriverOffset
Definition: commdlg.h:297
#define PD_RETURNDC
Definition: commdlg.h:155
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
HANDLE hDevMode
Definition: commdlg.h:488
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
HDC WINAPI CreateICW(_In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_opt_ LPCWSTR, _In_opt_ const DEVMODEW *)
HDC WINAPI CreateDCW(_In_opt_ LPCWSTR pszDriver, _In_opt_ LPCWSTR pszDevice, _In_opt_ LPCWSTR psz, _In_opt_ const DEVMODEW *pdmInit)
WORD wOutputOffset
Definition: commdlg.h:299
static BOOL PRINTDLG_CreateDevNames ( HGLOBAL hmem,
const char DeviceDriverName,
const char DeviceName,
const char OutputPort 
)
static

Definition at line 472 of file printdlg.c.

Referenced by PrintDlgA(), and PrintDlgExA().

474 {
475  long size;
476  char* pDevNamesSpace;
477  char* pTempPtr;
478  LPDEVNAMES lpDevNames;
479  char buf[260];
480  DWORD dwBufLen = ARRAY_SIZE(buf);
481  const char *p;
482 
483  p = strrchr( DeviceDriverName, '\\' );
484  if (p) DeviceDriverName = p + 1;
485 
486  size = strlen(DeviceDriverName) + 1
487  + strlen(DeviceName) + 1
488  + strlen(OutputPort) + 1
489  + sizeof(DEVNAMES);
490 
491  if(*hmem)
492  *hmem = GlobalReAlloc(*hmem, size, GMEM_MOVEABLE);
493  else
494  *hmem = GlobalAlloc(GMEM_MOVEABLE, size);
495  if (*hmem == 0)
496  return FALSE;
497 
498  pDevNamesSpace = GlobalLock(*hmem);
499  lpDevNames = (LPDEVNAMES) pDevNamesSpace;
500 
501  pTempPtr = pDevNamesSpace + sizeof(DEVNAMES);
502  strcpy(pTempPtr, DeviceDriverName);
503  lpDevNames->wDriverOffset = pTempPtr - pDevNamesSpace;
504 
505  pTempPtr += strlen(DeviceDriverName) + 1;
506  strcpy(pTempPtr, DeviceName);
507  lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace;
508 
509  pTempPtr += strlen(DeviceName) + 1;
510  strcpy(pTempPtr, OutputPort);
511  lpDevNames->wOutputOffset = pTempPtr - pDevNamesSpace;
512 
513  GetDefaultPrinterA(buf, &dwBufLen);
514  lpDevNames->wDefault = (strcmp(buf, DeviceName) == 0) ? 1 : 0;
515  GlobalUnlock(*hmem);
516  return TRUE;
517 }
struct tagDEVNAMES * LPDEVNAMES
#define TRUE
Definition: types.h:120
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
HGLOBAL NTAPI GlobalReAlloc(HGLOBAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:825
WORD wDefault
Definition: commdlg.h:300
ACPI_SIZE strlen(const char *String)
Definition: utclib.c:269
GLenum GLuint GLenum GLsizei const GLchar * buf
Definition: glext.h:7751
_Check_return_ _CRTIMP _CONST_RETURN char *__cdecl strrchr(_In_z_ const char *_Str, _In_ int _Ch)
WCHAR DeviceName[]
Definition: adapter.cpp:21
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_ DWORD _In_ DWORD dwBufLen
Definition: wincrypt.h:4243
DWORD DWORD
Definition: winlogon.h:84
#define FALSE
Definition: types.h:117
struct tagDEVNAMES DEVNAMES
WORD wDeviceOffset
Definition: commdlg.h:298
WORD wDriverOffset
Definition: commdlg.h:297
#define ARRAY_SIZE(A)
Definition: reg.h:24
GLsizeiptr size
Definition: glext.h:5919
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
WINBOOL WINAPI GetDefaultPrinterA(LPSTR pszBuffer, LPDWORD pcchBuffer)
Definition: printers.c:363
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
char * strcpy(char *DstString, const char *SrcString)
Definition: utclib.c:388
int strcmp(const char *String1, const char *String2)
Definition: utclib.c:469
WORD wOutputOffset
Definition: commdlg.h:299
GLfloat GLfloat p
Definition: glext.h:8902
#define GMEM_MOVEABLE
Definition: winbase.h:291
static BOOL PRINTDLG_CreateDevNamesW ( HGLOBAL hmem,
LPCWSTR  DeviceDriverName,
LPCWSTR  DeviceName,
LPCWSTR  OutputPort 
)
static

Definition at line 519 of file printdlg.c.

Referenced by pagesetup_change_printer_dialog(), PrintDlgExW(), and PrintDlgW().

521 {
522  long size;
523  LPWSTR pDevNamesSpace;
524  LPWSTR pTempPtr;
525  LPDEVNAMES lpDevNames;
526  WCHAR bufW[260];
527  DWORD dwBufLen = ARRAY_SIZE(bufW);
528  const WCHAR *p;
529 
530  p = strrchrW( DeviceDriverName, '\\' );
531  if (p) DeviceDriverName = p + 1;
532 
533  size = sizeof(WCHAR)*lstrlenW(DeviceDriverName) + 2
534  + sizeof(WCHAR)*lstrlenW(DeviceName) + 2
535  + sizeof(WCHAR)*lstrlenW(OutputPort) + 2
536  + sizeof(DEVNAMES);
537 
538  if(*hmem)
539  *hmem = GlobalReAlloc(*hmem, size, GMEM_MOVEABLE);
540  else
541  *hmem = GlobalAlloc(GMEM_MOVEABLE, size);
542  if (*hmem == 0)
543  return FALSE;
544 
545  pDevNamesSpace = GlobalLock(*hmem);
546  lpDevNames = (LPDEVNAMES) pDevNamesSpace;
547 
548  pTempPtr = (LPWSTR)((LPDEVNAMES)pDevNamesSpace + 1);
549  lstrcpyW(pTempPtr, DeviceDriverName);
550  lpDevNames->wDriverOffset = pTempPtr - pDevNamesSpace;
551 
552  pTempPtr += lstrlenW(DeviceDriverName) + 1;
553  lstrcpyW(pTempPtr, DeviceName);
554  lpDevNames->wDeviceOffset = pTempPtr - pDevNamesSpace;
555 
556  pTempPtr += lstrlenW(DeviceName) + 1;
557  lstrcpyW(pTempPtr, OutputPort);
558  lpDevNames->wOutputOffset = pTempPtr - pDevNamesSpace;
559 
560  GetDefaultPrinterW(bufW, &dwBufLen);
561  lpDevNames->wDefault = (lstrcmpW(bufW, DeviceName) == 0) ? 1 : 0;
562  GlobalUnlock(*hmem);
563  return TRUE;
564 }
struct tagDEVNAMES * LPDEVNAMES
#define TRUE
Definition: types.h:120
HGLOBAL NTAPI GlobalAlloc(UINT uFlags, SIZE_T dwBytes)
Definition: heapmem.c:368
WINBOOL WINAPI GetDefaultPrinterW(LPWSTR pszBuffer, LPDWORD pcchBuffer)
Definition: printers.c:409
HGLOBAL NTAPI GlobalReAlloc(HGLOBAL hMem, SIZE_T dwBytes, UINT uFlags)
Definition: heapmem.c:825
WORD wDefault
Definition: commdlg.h:300
__wchar_t WCHAR
Definition: xmlstorage.h:180
int WINAPI lstrcmpW(LPCWSTR lpString1, LPCWSTR lpString2)
Definition: lstring.c:170
WCHAR DeviceName[]
Definition: adapter.cpp:21
#define WCHAR
Definition: msvc.h:43
_In_ HCRYPTHASH _In_ BOOL _In_ DWORD _Inout_ DWORD _In_ DWORD dwBufLen
Definition: wincrypt.h:4243
#define lstrlenW
Definition: compat.h:407
DWORD DWORD
Definition: winlogon.h:84
#define FALSE
Definition: types.h:117
struct tagDEVNAMES DEVNAMES
WORD wDeviceOffset
Definition: commdlg.h:298
WORD wDriverOffset
Definition: commdlg.h:297
#define ARRAY_SIZE(A)
Definition: reg.h:24
GLsizeiptr size
Definition: glext.h:5919
LPVOID NTAPI GlobalLock(HGLOBAL hMem)
Definition: heapmem.c:755
WINE_UNICODE_INLINE WCHAR * strrchrW(const WCHAR *str, WCHAR ch)
Definition: unicode.h:254
#define lstrcpyW
Definition: compat.h:406
BOOL NTAPI GlobalUnlock(HGLOBAL hMem)
Definition: heapmem.c:1190
WORD wOutputOffset
Definition: commdlg.h:299
GLfloat GLfloat p
Definition: glext.h:8902
WCHAR * LPWSTR
Definition: xmlstorage.h:184
#define GMEM_MOVEABLE
Definition: winbase.h:291
static HGLOBAL PRINTDLG_GetDlgTemplateA ( const PRINTDLGA lppd)
static

Definition at line 2106 of file printdlg.c.

Referenced by PrintDlgA().

2107 {
2108  HRSRC hResInfo;
2109  HGLOBAL hDlgTmpl;
2110 
2111  if (lppd->Flags & PD_PRINTSETUP) {
2112  if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) {
2113  hDlgTmpl = lppd->hSetupTemplate;
2114  } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) {
2115  hResInfo = FindResourceA(lppd->hInstance,
2117  hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
2118  } else {
2119  hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32_SETUP",
2120  (LPSTR)RT_DIALOG);
2121  hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
2122  }
2123  } else {
2124  if(lppd->Flags & PD_ENABLEPRINTTEMPLATEHANDLE) {
2125  hDlgTmpl = lppd->hPrintTemplate;
2126  } else if(lppd->Flags & PD_ENABLEPRINTTEMPLATE) {
2127  hResInfo = FindResourceA(lppd->hInstance,
2128  lppd->lpPrintTemplateName,
2129  (LPSTR)RT_DIALOG);
2130  hDlgTmpl = LoadResource(lppd->hInstance, hResInfo);
2131  } else {
2132  hResInfo = FindResourceA(COMDLG32_hInstance, "PRINT32",
2133  (LPSTR)RT_DIALOG);
2134  hDlgTmpl = LoadResource(COMDLG32_hInstance, hResInfo);
2135  }
2136  }
2137  return hDlgTmpl;
2138 }
#define PD_ENABLEPRINTTEMPLATEHANDLE
Definition: commdlg.h:163
HANDLE HGLOBAL
Definition: windef.h:243
DECLSPEC_HIDDEN HINSTANCE COMDLG32_hInstance
Definition: cdlg32.c:42
HRSRC WINAPI FindResourceA(HMODULE hModule, LPCSTR name, LPCSTR type)
Definition: res.c:155
#define PD_ENABLESETUPTEMPLATEHANDLE
Definition: commdlg.h:164
LPCSTR lpSetupTemplateName
Definition: commdlg.h:481
char * LPSTR
Definition: xmlstorage.h:182
HANDLE hSetupTemplate
Definition: commdlg.h:483
HGLOBAL WINAPI LoadResource(HINSTANCE hModule, HRSRC hRsrc)
Definition: res.c:532
#define PD_ENABLEPRINTTEMPLATE
Definition: commdlg.h:161
#define RT_DIALOG
Definition: pedump.c:367
#define PD_PRINTSETUP
Definition: commdlg.h:153
LPCSTR lpPrintTemplateName
Definition: commdlg.h:480
#define PD_ENABLESETUPTEMPLATE
Definition: commdlg.h:162
HINSTANCE hInstance
Definition: commdlg.h:476
DWORD Flags
Definition: commdlg.h:470
HANDLE hPrintTemplate
Definition: commdlg.h:482
static HGLOBAL PRINTDLG_GetDlgTemplateW ( const PRINTDLGW lppd)
static

Definition at line 2140 of file printdlg.c.

Referenced by PrintDlgW().

2141 {
2142  HRSRC hResInfo;
2143  HGLOBAL hDlgTmpl;
2144  static const WCHAR xpsetup[] = { 'P','R','I','N','T','3','2','_','S','E','T','U','P',0};
2145  static const WCHAR xprint[] = { 'P','R','I','N','T','3','2',0};
2146 
2147  if (lppd->Flags & PD_PRINTSETUP) {
2148  if(lppd->Flags & PD_ENABLESETUPTEMPLATEHANDLE) {
2149  hDlgTmpl = lppd->hSetupTemplate;
2150  } else if(lppd->Flags & PD_ENABLESETUPTEMPLATE) {
2151  hResInfo = FindResourceW(lppd->hInstance,
2153  hDlgTmpl =