Delphix (6) of Delphi and DirectX: enables tdximagelist to interact with conventional VCL

Source: Internet
Author: User
In this example, two problems are tested:
1. Can images loaded by other VCL be used by tdximagelist;
2. Can images in tdximagelist be used by other VCL instances.

In this example, the image is first loaded with tpicture and then added to tdximagelist;
Then draw the image on the form, instead of in tdxdraw.

Learn more about tdximagelist:
The tdximagelist control has only two attributes: dxdraw and items.
Dxdraw is the destination of the image, which is easy to understand;
Items is a collection of objects: tpicturecollection;
The tpicturecollection collection contains a set of tpicturecollectionitem objects;
The tpicturecollectionitem object has the picture attribute, which is compatible with tpicture in other VCL!

In this example, the tpicturecollectionitem object is used to test:


Code File:
Unit unit1; interfaceuses windows, messages, sysutils, variants, classes, graphics, controls, forms, dialogs, dxdraws, stdctrls; Type tform1 = Class (tform) dximagelist1: bytes; button1: tbutton; button2: tbutton; Procedure formcreate (Sender: tobject); Procedure button1click (Sender: tobject); Procedure button2click (Sender: tobject); end; var form1: tform1; implementation {$ R *. DFM} {borrow other VCL controls to load images} procedure tform1.formcreate (Sender: tobject); var PIC: tpicture; begin PIC: = tpicture. create; pic. loadfromfile ('C: \ temp \ test.bmp '); dximagelist1.items. add; dximagelist1.items [0]. picture. assign (PIC); pic. free; end; {This code looks simple, but the code prompts are not good} procedure tform1.button1click (Sender: tobject); Begin self. refresh; self. canvas. draw (0, 0, dximagelist1.items [0]. picture. graphic); end; {use the tpicturecollectionitem object to transfer and write it smoothly} procedure tform1.button2click (Sender: tobject); var picitem: tpicturecollectionitem; Begin self. refresh; picitem: = dximagelist1.items [0]; self. canvas. stretchdraw (clientrect, picitem. picture. graphic); end.
 
   
 

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.