Exemple #1
0
        private int ConfigureSmart50(int nres)
        {
            SmartComm2.SMART_DEVMODE smdm;
            IntPtr smdm_ptr;

            // alloc
            smdm_ptr = Marshal.AllocHGlobal(Marshal.SizeOf(typeof(SmartComm2.SMART_DEVMODE)));

            // get current printer settings...
            if (nres == SmartComm2.SM_SUCCESS)
            {
                nres = SmartComm2.SmartComm_GetPrinterSettings((long)hsmartprinterid, (int)smdm_ptr);
            }
            // set to both printing...
            smdm = (SmartComm2.SMART_DEVMODE)Marshal.PtrToStructure(smdm_ptr, typeof(SmartComm2.SMART_DEVMODE));
            smdm.dmDevmode.dmOrientation = DMORIENT_LANDSCAPE;       // set landscape printing...
            smdm.dmOemdev.dwDocPrintSide = SmartComm2.SMART_PRINTSIDE_BOTH;
            Marshal.StructureToPtr(smdm, smdm_ptr, true);
            // change printer settings...
            if (nres == SmartComm2.SM_SUCCESS)
            {
                nres = SmartComm2.SmartComm_SetPrinterSettings((long)hsmartprinterid, (int)smdm_ptr);
            }

            // free smart printer
            Marshal.FreeHGlobal(smdm_ptr);
            return(nres);
        }