Welcome to Foxite.COM Community Weblog Sign in | Join | Help

Bernard Bout

May the Fox be with you...

<March 2007>
SuMoTuWeThFrSa
25262728123
45678910
11121314151617
18192021222324
25262728293031
1234567

Post Categories

Navigation

Some VFP links

Others...

Archives

Who links to this site?

Hey There!!!

Syndication




OzFox2007 - Get(Objx) more productive

I am back from an extremely intense OzFox 2007 and I must say it was very well organised by Craig Bailey of Talman. It was great to meet other VFP users from Australia and overseas and put faces to names.

One of the sessions was Get moreProductive with VFP by Rick Schummer where he did an interactive session on enhancements we can create ourselves to make our development life easier. There were a lot of ideas brought up that were really timesavers and really cool and Rick did a really good job of describing them and the various techniques where we can save a lot of effort and time. 

How many of us have these forms with objects buired deep in them. Like this sample form below:

One of the things Rick showed was how you can open a code window and Right-Click in it to bring up the menu and select "Object List" to bring up the window as shown below, where clicking on the object inserts the complete path to that object into your code.

Now while this is fine when there are a few objects it becomes very much more difficult when there are literally a thousand objects in that list. Even a few hundred would make searching that list a nightmare and make it faster to use intellisense and type in the code.

I have a solution I would like to share, that takes away all these problems and works in an instant. That is my GetObj.PRG file. In my VFPStart.prg I call this program and it resides in my VFP root folder. This hooks into the CTRL+H key combination, but you can easily change that. The code is shown below:

ON KEY LABEL CTRL+H do getobjX in c:\vfp9\getobj.prg

* you can use HOME() if you wish

RETURN

FUNCTION getobjX

LOCAL bb,cc,cStr,cStrX,oldclip

bb = SYS(1270)

cStr = bb.name

cStrx = ""

IF PEMSTATUS(bb,"Value",5)

     cStrx = ".Value"

ENDIF

DO WHILE .T.

     bb = bb.parent

     cc=bb.name

     IF bb.baseclass = "Form"

        cStr="ThisForm."+cStr

        EXIT

     ENDIF

     cStr = cc+"."+cStr

ENDDO

oldclip = _Cliptext

_cliptext = cStr+cStrx

KEYBOARD '{CTRL+V}'

_Cliptext = oldclip

RETURN

With this simple program loaded to trap the "CTRL+H" key all I have to do is

1. Click in my code window (Command, Screen/Class Code or PRG) to set the insertion point.

2. Hover the mouse over the object on the form I am interested in

3. Press "CTRL+H" to insert the code to that object wherever my insertion point was set to.

So if I had my mouse hovering over the option1. Radio button I would have this inserted into my code window in a flash:

ThisForm.Container1.Pageframe1.Page1.Optiongroup1.Option1.Value

That is all. Takes a fraction of a second and no searching through lists or even intellisense. How cool is that?

Thanks Rick for an excellent session.

OzFox 2007 Rocked!

Published Friday, March 02, 2007 12:23 PM by bbout

Comments

# re: OzFox2007 - Get(Objx) more productive @ Friday, March 02, 2007 10:54 PM

I like it!  I'm going to use this.

I might suggest one tiny change.  I was having trouble with the KEYBOARD '{CTRL+V}' command.  It wasn't actually pasting the updated clipboard.

Instead I simulate a click on the "Paste" menu item using: SYS(1500,'_MED_PASTE','_MEDIT')

There you go two tips for the price of one. Drill down and activate a system menu. Thanks for that tip.

sweatyb

# re: OzFox2007 - Get(Objx) more productive @ Friday, March 02, 2007 11:00 PM

Cool tip Bernard and you are welcome for the session. It was nice meeting you in person and appreciate your participation during my discussions.

Rick Schummer

# re: OzFox2007 - Get(Objx) more productive @ Tuesday, March 06, 2007 4:37 AM

Great tip - very useful. BTW I expanded mine slightly. Changed:

IF PEMSTATUS(bb,"Value",5)
    cStrx = ".Value"
ENDIF

to:

If PEMSTATUS(bb,"Value",5)
cStrX = ".Value"
Else
If bb.BaseClass = 'Column'
cStrX= "."+bb.CurrentControl+".Value"
Endif
Endif


Yup. Code is there for the changing.

Cyril Baskir

New Comments to this post are disabled
Powered by Community Server, by Telligent Systems