Controls Property and Inheritance Tshape class (using Tshape can solve many graphics problems)

Source: Internet
Author: User

This example:


Code files:

UnitUnit1;InterfaceusesWindows, Messages, sysutils, variants, Classes, Graphics, Controls, Forms, Dialogs, Stdctrls, Extctrls;typeTmyshape =class(Tshape)protected procedureCmmouseenter (varMessage:tmessage);messageCm_mouseenter;procedureCmmouseleave (varMessage:tmessage);messageCm_mouseleave;End; TForm1 =class(Tform)    Panel1:tpanel;    Button1:tbutton; Button2:tbutton;procedureButton1Click (Sender:tobject);procedureButton2click (Sender:tobject);End;varForm1:tform1;Implementation{$R *.DFM}procedureTform1.button1click (Sender:tobject);ConstW = -; H = -;varShape:tmyshape;beginShape: = Tmyshape.create (self); Shape.  Parent: = Panel1; Shape.  Width: = W; Shape.  Height: = H;  Randomize; Shape.  Left: = Random (PANEL1.CLIENTWIDTH-W); Shape.  Top: = Random (panel1.clientheight-h); Shape. Brush.color: = Random ($FFFFFF);End;procedureTform1.button2click (Sender:tobject);varI:integer;begin ifPanel1.controlcount =0  ThenExit;  Randomize; I: = Random (Panel1.controlcount-1); Panel1.controls[i]. Free;End;{Tmyshape}procedureTmyshape.cmmouseenter (varMessage:tmessage);Consts =' The color value for the current%s is:%.6x ';varWctrl:twincontrol;beginWctrl: = Parent; whileWctrl.hasparent DoWctrl: = wctrl.parent;ifWctrl isTform ThenTform (Wctrl). Caption: = Format (S, [Classname,brush.color]);inherited;End;procedureTmyshape.cmmouseleave (varMessage:tmessage);Consts =' Form1 ';varWctrl:twincontrol;beginWctrl: = Parent; whileWctrl.hasparent DoWctrl: = wctrl.parent;ifWctrl isTform ThenTform (Wctrl). Caption: = s;inherited;End;End.

Http://www.cnblogs.com/del/archive/2008/10/23/1317926.html

Controls Property and Inheritance Tshape class (using Tshape can solve many graphics problems)

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.