Dynamic Modification of custom printing paper in C ++ Builder

Source: Internet
Author: User
Tags textout
In C ++ Builder, We dynamically change the custom printing paper-Linux general technology-Linux programming and kernel information. The following is a detailed description. Because only Delphi examples are provided on the Internet and some examples are unavailable when CB is used for compiling, I simply searched the information and wrote it myself, I am afraid that the netizens will encounter this kind of situation when programming, so they will immediately upload it.

Void _ fastcall TForm1: BitBtn1Click (TObject * Sender)
{
Char * ADevice, * ADriver, * APort;
THandle DeviceMode;
PDeviceMode DevMode;
Int length, width;
Length = 1400;
Width = 2410; // set the size of the Custom paper to 0.1mm
ADevice = new char [100];
ADriver = new char [100];
APort = new char [100];
// Obtain the printer
Printer ()-> GetPrinter (ADevice, ADriver, APort, DeviceMode );
// Obtain the PDevMode Structure
DevMode = (_ devicemodeA *) GlobalLock (void *) DeviceMode );
// Set the value that can be modified
DevMode-> dmFields = DevMode-> dmFields | DM_PAPERSIZE;
DevMode-> dmFields = DevMode-> dmFields | DM_PAPERLENGTH;
DevMode-> dmFields = DevMode-> dmFields | DM_PAPERWIDTH;
// Set the value to be modified
DevMode-> dmPaperSize = DMPAPER_USER; // set as custom paper
DevMode-> dmPaperLength = length;
DevMode-> dmPaperWidth = width;

// Test and print
Printer ()-> BeginDoc ();
TextOut (Printer ()-> Handle, 0, 0, "-----------------", 17 );
Printer ()-> NewPage ();
TextOut (Printer ()-> Handle, 0, 0, "++", 18 );
Printer ()-> NewPage ();
Printer ()-> EndDoc ();
}
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.