Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Bill von Valtier
 Bill von Valtier
Subject: Adding objects and event code programmatically
Thread ID: 22293 Message ID: 22293 # Views: 37 # Ratings: 0
Version: Visual FoxPro 6 Category: Forms
Date: Monday, April 14, 2003 10:39:54 PM         

Hello friends,

My question is how to create multiple similar objects (images, in this case) on a form at run time *while* at the same time including some necessary event code with each object.

THE PROJECT: is to build a highly customized photo editor and organizer which will handle up to 28 photos on one screen (though in actual use it will be 3 to 10). It will provide for re-ordering the photos, naming and numbering the series after rearranged, deleting or storing individual photos when asked, toggling size, comparing any two side by side, etc.

Since the number of image objects to be handled will be variable, the form must be built and arranged at run time. And this is definitely a giant step for me in getting from FXP2.6 to VFP6. :-o

The overall plan is to provide user-defined methods in the ParentForm code for each special function, and then call the method with a passed parameter of the index-number of the calling image object, with something like
PROCEDURE Image1.Click		&& or RightClick, or DoubleClick
	DO THISFORM.MyClickMethod WITH [index number of the image]

And, that is where I run into my problem.

THE PROBLEM: I have successfully gotten as far as adding the variable number of image objects and displaying them using the AddObject method (placed in the Form's Init event). But apparently the AddObject method doesn't allow for including procedures with each added object (or does it?). So I am looking at using the Define Class ... EndDefine command which permits procedures to be included. But for this route, I don't see how to make the new image objects members of the parent Form Class.

This is probably pretty basic to you guys, but it's clear as mud to me at this point. Any points in the right direct will be appreciated.



Adding objects and event code programmatically Posted by Bill von Valtier @ 4/14/2003 10:39:54 PM
RE: Adding objects and event code programmatically Posted by Jamie Osborn @ 4/15/2003 11:52:58 AM
RE: Thanks, Jamie Posted by Bill von Valtier @ 4/15/2003 10:10:06 PM
RE: Thanks, Jamie Posted by Andy Rice @ 4/16/2003 1:02:28 AM
RE: Thanks, Jamie Posted by Jamie Osborn @ 4/16/2003 1:31:54 AM