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-> dmfieldsdm_papersize;
Devmode-> dmfields = devmode-> dmfieldsdm_paperlength;
Devmode-> dmfields = devmode-> dmfieldsdm_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 ();
}