Graphics (canvas in The VCL system) has four methods to obtain graphics:
1. Get through the window handle;
2. Get it through canvas. handle in the window;
3. Get the togpgraphics method added to some VCL objects through gdiplus using helper technology;
4. Obtain the image object.
In this example:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, stdctrls; Type tform1 = Class (tform) button1: tbutton; button2: tbutton; button3: tbutton; button4: tbutton; Procedure submit (Sender: tobject ); end; var form1: tform1; implementation {$ R *. DFM} uses gdiplus, gdiplushelpers; // obtain the javastform1.button1click (Sender: tobject) from the window handle; var graphics: igpgraphics; pen: igppen; begin graphics: = tgpgraphics. create (handle); pen: = tgppen. create (tgpcolor. red, 2); graphics. drawellipse (pen, 20, 10,150, 40); end; // obtain igpgraphicsprocedure tform1.button2click (Sender: tobject) from HDC; var graphics: igpgraphics; pen: igppen; begin graphics: = tgpgraphics. create (canvas. handle); pen: = tgppen. create (tgpcolor. green, 2); graphics. drawellipse (pen, 20, 40,150, 40); end; // use the togpgraphics method added to the canvas by gdiplushelpers to obtain javastform1.button3click (Sender: tobject); var graphics: igpgraphics; pen: igppen; begin graphics: = canvas. togpgraphics; pen: = tgppen. create (tgpcolor. blue, 2); graphics. drawellipse (pen, 20, 70,150, 40); end; // create igpgraphicsprocedure tform1.button4click (Sender: tobject) from the image; var graphicsimg: igpgraphics; pen: igppen; Image: igpimage; begin image: = tgpbitmap. create (152, 42); graphicsimg: = tgpgraphics. create (image); pen: = tgppen. create (tgpcolor. fuchsia, 2); graphicsimg. drawellipse (pen, 0, 0, image. width-2, image. height-2); canvas. togpgraphics. drawimage (image, 20,100); end.