Prod.: Engine, ver.: 6019, ID: 60001382, Wish : Get Set printer properties using WIN32 DEVNAMES and DEVMODE structure for vdPrint object with vdraw.ocx wrapper componet

Wish : Get Set printer properties using WIN32 DEVNAMES and DEVMODE structure for vdPrint object with vdraw.ocx wrapper componet

Article60001382
TypeWish
ProductEngine
Version6019
Date Added4/21/2011
FixedYes [4/27/2011]
Submitted bydainius ceponis
Keywords

Subject

Get Set printer properties using WIN32 DEVNAMES and DEVMODE structure for vdPrint object with vdraw.ocx wrapper componet

Summary

Get/Set printer properties using WIN32 DEVNAMES and DEVMODE structure for vdPrint object with vdraw.ocx wrapper componet

Solution

In version 6020 a new methods was added.

1.GetDevMode

Returns a pointer to a global movable memory that reference to a WIN32 DEVMODEW data structure contains information about the initialization and environment of selected printer.

It works only on Windows NT, Windows 2000, Windows XP, and the Windows Server 2003 platforms.

The return structure represents the Unicode Version DEVMODEW

2. DevNames

Returns a pointer to a global movable memory that reference to a WIN32 DEVNAMESW data structure contains strings that identify the driver, device, and output port names for a printer.

It works only on Windows NT, Windows 2000, Windows XP, and the Windows Server 2003 platforms.

The return structure represents the Unicode Version DEVNAMESW

3. SelectPrinterDeviceDefaults(int hDevNames, int hDevMode)

Change the selected printer properties passing pointers to a global movable memory that reference to a WIN32 DEVNAMESW and DEVMODEW data structure.

hDevNames represents a global movable memory that reference to a WIN32 DEVNAMESW UNICODE version structure.</param>

hDevMode represents a global movable memory that reference to a WIN32 DEVMODEW UNICODE version structure.</param>

It works only on Windows NT, Windows 2000, Windows XP, and the Windows Server 2003 platforms.

Example in VC++ 6 :

//Description
 
 //We use the default VectorDraw printer method PrinterSetup  to select a printer and its properties.
 //Then we get the DEVNAMES and DEVMODE for the selected printer and pass these values to a WIN32 API PRINTDLG
 //We change the printer properties using the WIN32 API PrintDlg method
 //and we passed the changes back to VectorDraw Printer.
 //finally we print out the document to the selected printer device.
 
        CvdPrint print = m_draw.GetActiveDocument().GetPrinter();
 print.PrinterSetup();
 
 long hDevMode = print.GetDevMode();
 long hDevNames = print.GetDevNames();
 
 PRINTDLGW pd;
 
 // Initialize PRINTDLG
 ZeroMemory(&pd, sizeof(pd));
 pd.lStructSize = sizeof(pd);
 pd.hwndOwner   = this->GetSafeHwnd();
 pd.hDevMode    = (HANDLE)hDevMode;     // Don't forget to free or store hDevMode.
 pd.hDevNames   = (HANDLE)hDevNames;     // Don't forget to free or store hDevNames.
 pd.Flags       = PD_PRINTSETUP;
 pd.nCopies     = 1;
 pd.nFromPage   = 0xFFFF;
 pd.nToPage     = 0xFFFF;
 pd.nMinPage    = 1;
 pd.nMaxPage    = 0xFFFF;
 
 if (IDOK != ::PrintDlgW(&pd))
 {
  return;
 }
 
 
 print.SelectPrinterDeviceDefaults((long)pd.hDevNames,(long)pd.hDevMode);
 ::GlobalFree(pd.hDevNames);
 ::GlobalFree(pd.hDevMode);
 
 print.PrintExtends();
 print.PrintScaleToFit();
 
 print.PrintOut();