Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Kulwant Singh
  Where is Kulwant Singh?
 Shimla
 India
 Kulwant Singh
 To: Stefan Wuebbe
  Where is Stefan Wuebbe?
 Hamburg
 Germany
 Stefan Wuebbe
 Tags
Subject: RE: Set All for Methods
Thread ID: 248825 Message ID: 248843 # Views: 1 # Ratings: 0
Version: Visual FoxPro 9 Category: Classes and Objects
Date: Wednesday, December 23, 2009 6:12:32 PM         
   


> > Yes Sir,
> >
> > thats what I was looking for. I was going to ask Mr. Stefan for an example but then I thought ..Let me try first!
> > By the time I posted I got this solution from you. :-D
> >
> > Thanks!
> > kulwant
> > (Help Save the TIGER. Save Wildlife. Live & let Live)
>
> Actually I also thought an example might be useful, but was not sure yet how it might look like :-)
>
> BindEvent() is a great feature of course, and surely would work in your context. It's especially useful if you want to handle "unknown" objects at runtime, without having to get into the objects or even their classes at design time.
> The advantage of OOP inheritance in your case, where you have "known" objects, i.e. your buttons, would be simplified code, easier debugging, in my opinion.
>
> The following example uses Define Class / PRG syntax, so that it stands for a "visual" button class that you'd create in the Class Designer and store it in a library VCX.
>
> All particular settings / code that you want each concrete button instance to have are all in one place. While the derived objects on the form have just a few individual properties set. No dynamic code required at runtime:
>
>
>
> LOCAL oForm as Form
> oForm = CREATEOBJECT('TestForm')
> oForm.Show(1)
> RETURN
> 
> DEFINE CLASS TestForm as Form
> 	AutoCenter = .T.
> 
> 	ADD OBJECT Button1 as myClass WITH ;
> 		Left = 50, Top = 20, Caption = "First"
> 	ADD OBJECT Button2 as myClass WITH ;
> 		Left = 50, Top = 50, Caption = "Second"
> 	ADD OBJECT Button3 as myClass WITH ;
> 		Left = 50, Top = 80, Caption = "Third"
> 
> ENDDEFINE
> 
> DEFINE CLASS myClass as CommandButton
> 	Height = 24
> 	BackColor = RGB(0,255,0)
> 	ForeColor = RGB(255,255,255)
> 	SpecialEffect = 2 && Hot Tracking
> 
> 	PROCEDURE GotFocus()
> 		This.BackColor = RGB(255,0,0)
> 	ENDPROC
> 
> 	PROCEDURE LostFocus()
> 		This.ResetToDefault('BackColor')
> 	ENDPROC
> ENDDEFINE
> 

>
>
>
> hth
> -Stefan

Thank you Sir!

I was also ignorant of this method ....This.ResetToDefault('BackColor')

and

Thanks for the Example.

kulwant
(Help Save the TIGER. Save Wildlife. Live & let Live)

ENTIRE THREAD

Set All for Methods Posted by kulwant singh @ 12/23/2009 4:25:44 PM
RE: Set All for Methods Posted by Stefan Wuebbe @ 12/23/2009 4:34:23 PM
RE: Set All for Methods Posted by kulwant singh @ 12/23/2009 5:12:55 PM
RE: Set All for Methods Posted by Cesar @ 12/23/2009 5:12:07 PM
RE: Set All for Methods Posted by kulwant singh @ 12/23/2009 5:17:02 PM
RE: Set All for Methods Posted by Stefan Wuebbe @ 12/23/2009 5:39:27 PM
RE: Set All for Methods Posted by ho me @ 12/23/2009 5:50:15 PM
RE: Set All for Methods Posted by Stefan Wuebbe @ 12/23/2009 5:51:39 PM
RE: Set All for Methods Posted by kulwant singh @ 12/23/2009 6:12:32 PM
RE: Set All for Methods Posted by Stefan Wuebbe @ 12/24/2009 8:56:02 AM