Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Adding code to every form/WriteMethod
Message
From
27/03/1998 09:54:11
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
 
 
To
26/03/1998 20:15:58
General information
Forum:
Visual FoxPro
Category:
Forms & Form designer
Miscellaneous
Thread ID:
00087353
Message ID:
00087661
Views:
29
>>>I added some code to the Init method of my form class and now I want to make sure this code is executed for all forms. The hard way would be to open up every form and add a DODEFAULT() to every Init method that has other code. Is there an easier way? Can I use WriteMethod to do this? What exactly does WriteMethod do and how is it used at design time?
>>
>>Writemethod is for designtime. You can use readmethod and writemethod in conjunction. You could call following code to write some code to objects another. Select some controls on form first ie: textboxes.
>>
nMembers = aselobj(aObjects)
>>for ix = 1 to nMembers
>>	aObjects[ix].writemethod("Click","wait window [Don't click me !]")
>>endfor
>>It's good for builders.
>>But to work with it you need forms open in design mode. Instead a small prg recursively using each form.scx and adding dodefault() to init method is more flexible.
>>cetin
>
>Well, actually want to use to write:
>
>grid1.column[iX].text1.writemethod("GotFocus","This.ImeMode = 2")
>
>I think it would be more flexible to assign method code by Writemethod.
>Especially to use when addobject()
well Justok,
Be careful it's for designtime and RO at runtime. For your case it would be better to make a grid class. Try the following code for a nasty effect (Watch backcolor and forecolor for textboxes in grid - be sure to click in grid to see effect):
*Form.init
this.setall("Backcolor",rgb(255,0,0),"Textbox") && All textboxes bc red
*Grid.init
this.setall("forecolor",rgb(255,255,0),"textbox")
this.setall("fontbold",.t.,"textbox")
*this.setall("Imemode",2) && For your imemode
But if you want to write code to a method or event quickly at design time then code would be like this (select grid(s) in designer, goto command window and run the prg - pls notice no check if it's not a grid or not text1 exist) :
*PokeImeMode.prg
nMembers = aselobj(aObjects)
for ix = 1 to nMembers
 for iy = 1 to aObjects[ix].columncount
    aObjects[ix].columns(iy).text1.writemethod(;
       "GotFocus","This.ImeMode = 2")
 endfor
endfor
Cetin
Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Previous
Reply
Map
View

Click here to load this message in the networking platform