Dynamic change custom print paper in CB Program

Source: Internet
Author: User
Tags textout

Because the online only Delphi example I used to write when the CB found that there are some examples can not be used, so the whole life of the gas to simply check the data themselves wrote, afraid of netizens in programming with this kind of situation, immediately passed up.

void __fastcall Tform1::bitbtn1click (tobject *sender)
{
Char *adevice, *adriver, *aport;
Thandle Devicemode;
Pdevicemode DevMode;
int length,width;
length=1400;
width=2410;//sets the size unit of the custom paper to 0.1 mm
Adevice =new char[100];
Adriver =new char[100];
Aport =new char[100];
Get printer
Printer ()->getprinter (Adevice, Adriver, Aport,devicemode);
Get pDevMode structure
DevMode = (_devicemodea*) GlobalLock ((void *) devicemode);
Set values 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 print
Printer ()->begindoc ();
TextOut (Printer ()->handle, 0, 0, "-----------------", 17);
Printer ()->newpage ();
TextOut (Printer ()->handle, 0, 0, "++++++++++++++++++", 18);
Printer ()->newpage ();
Printer ()->enddoc ();
}

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.