示例#1
0
        IntPtr CreatePrinterDC(ref PAGESETUPDLGSTRUCT lppsd)
        {
            // Create managed structure for DEVNAMES
            DEVNAMES dn = new DEVNAMES();

            Marshal.PtrToStructure(lppsd.hDevNames, dn);

            // Get base address of native structure
            int iBase = (int)lppsd.hDevNames;

            // Get pointer to driver name.
            IntPtr iptrDriver = (IntPtr)(iBase + dn.wDriverOffset);
            string strDriver  = Marshal.PtrToStringUni(iptrDriver);

            // Get pointer to device name.
            IntPtr iptrDevice = (IntPtr)(iBase + dn.wDeviceOffset);
            string strDevice  = Marshal.PtrToStringUni(iptrDevice);

            // Get pointer to output port.
            IntPtr iptrOutput = (IntPtr)(iBase + dn.wOutputOffset);
            string strOutput  = Marshal.PtrToStringUni(iptrOutput);

            IntPtr hdc = CreateDC(iptrDriver, iptrDevice, iptrOutput,
                                  lppsd.hDevMode);

            return(hdc);
        }
示例#2
0
 void InitDlgStruct(
     ref PAGESETUPDLGSTRUCT psd,
     IntPtr hwndParent)
 {
     psd.lStructSize = Marshal.SizeOf(psd);
     psd.Flags       = 0;
     psd.hwndOwner   = hwndParent;
 }
示例#3
0
 void Close(ref PAGESETUPDLGSTRUCT lppsd)
 {
     if (lppsd.hDevMode != IntPtr.Zero)
     {
         NativeHeap.LocalFree(lppsd.hDevMode);
     }
     if (lppsd.hDevNames != IntPtr.Zero)
     {
         NativeHeap.LocalFree(lppsd.hDevNames);
     }
 }
示例#4
0
        string QueryOutputPort(ref PAGESETUPDLGSTRUCT lppsd)
        {
            // Create managed structure for DEVNAMES
            DEVNAMES dn = new DEVNAMES();

            Marshal.PtrToStructure(lppsd.hDevNames, dn);

            // Get base address of native structure
            int iBase = (int)lppsd.hDevNames;

            // Get pointer to output port.
            IntPtr iptrOutput = new IntPtr(iBase + dn.wOutputOffset);
            string strOutput  = Marshal.PtrToStringUni(iptrOutput);

            return(strOutput);
        }
示例#5
0
 int ShowDialog(ref PAGESETUPDLGSTRUCT psd)
 {
     return(PageSetupDlgW(ref psd));
 }
示例#6
0
 int PageSetupDlgW(ref PAGESETUPDLGSTRUCT lppsd);