Board index » delphi » Creating New Image / Event Runtime

Creating New Image / Event Runtime

I'm sure this is quite easy but can someone give me an example of how to create
a TImage during runtime and then create an event for MouseOver?  I need to
create more than one so how can I name each one such as Image1, Image2, etc.?

I always add them during design and not runtime in the past.

Thank you,

GoneApe...@aol.com

 

Re:Creating New Image / Event Runtime


In article <20000320114519.15547.00006...@ng-de1.aol.com>, GoneApeCom
(goneape...@aol.com) says...

Quote
> I'm sure this is quite easy but can someone give me an example of how to create
> a TImage during runtime and then create an event for MouseOver?  I need to
> create more than one so how can I name each one such as Image1, Image2, etc.?

var
  ti : TImage;
begin
  ti := TImage.Create(Form1);  // or whatever
  ti.Parent := Form1; // or whatever
  // set size and other properties.
  ti.OnMouseOver := Form1.OnImageMouseOver;
  ti.Name := 'Image' + IntToStr(ImageCounter);
  Inc(ImageCounter);
  //...
end;

OnImageMouseOver is just like any other MouseOver-method.

If you need to keep track of the images, either loop through the forms
Components list (or the Controls list of whatever's the parent (in this
case, also the form)), or put the images in a TList.

M.

--
ROOTS 2000, Bergen, April 27-28
{*word*19}burn, Coplien, Fowler, Groven, Reenskaug, Reich, Nygaard
Patterns, Use Cases, Refactoring, XP, UML, OO ++
http://roots.dnd.no

Other Threads