Delphi and DirectX Delphix (6)

Source: Internet
Author: User

Delphi and DirectX Delphix (6): Allow Tdximagelist to interact with regular VCL

This example tests two questions:

1, other VCL loaded pictures can be used for tdximagelist;

2, tdximagelist in the picture can give other VCL use.

In the example, first load the picture with Tpicture, then give the tdximagelist;

The picture is then drawn on the form, not in the Tdxdraw.

Continue to understand point tdximagelist:

The Tdximagelist control has only two properties: Dxdraw and Items.

Dxdraw is the destination of the image, very well understood;

Items are a collection of objects: tpicturecollection;

The Tpicturecollection collection contains a set of Tpicturecollectionitem objects;

The Tpicturecollectionitem object has a picture property, which is compatible with tpicture in other VCL!

This example uses the Tpicturecollectionitem object, the test effect diagram:

Code files:

Unit Unit1
Interface
uses
Windows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms ,
Dialogs, Dxdraws, Stdctrls;   
Type
TForm1 = Class (Tform)
Dximagelist1:tdximagelist;
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 pictures}
Procedure Tform1.formcreate (Sende R: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 hints bad}
procedure Tform1.button1click (sender:tobject);
begin
Self.refresh;
Self.Canvas.Draw (0, 0, Dximagelist1.items[0]. Picture.graphic);
End;
{Use the Tpicturecollectionitem object for a relay, write it more smoothly}
procedure Tform1.button2click (sender:tobject);  
var
picitem:tpicturecollectionitem
Begin
Self.refresh
Picitem: = Dximagelist1.items[0];
Self.Canvas.StretchDraw (Clientrect, picItem.Picture.Graphic);
End;
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.