A Native TreeView (Part IV-a)

Version: 1.00.10 - Last Update: Tuesday the 29th, September 2009 - 11:20:00

Previous ChapterComplex Controls Home (TOC)Next Chapter

FoxPro Rocks! This is all about how to create complex controls using native VFP only!


In part three we explored a couple of Grid related oddities and created some workarounds. We talked about the different types of item objects our Node will be made of and the static and dynamic aspects of the underlying item classes. We talked about the states a Node can have and setup a list of these. Finally we realized a working font selection Grid list with almost no coding!

Today we will extend our driver table and create our Node's item classes. After that I will show you how to create some cool looking resources like gif images with alpha transparency and how to use them the right way. Finally we will start assembling our shortcut menu. Figure #1 below shows the result (not that bad!:-).

Figure#1: Let’s go!

The little demo above (without audio, sorry) shows a first prototype implementation running our shortcut menu hooked onto VFP's _SCREEN. I created a CUSTOM class-based "click monitor" class that you can instantiate like so:

oClickmoitor1 = NEWOBJECT("clickmonitor", ;

After that, right-clicking VFP's desktop will launch the default menu.

To get this demo up and running you have to download the sources from here: Alpha-Version of ShortcutMenu.Zip first. Then unzip the archive file preserving the directory structures! Next step is very important: Within VFP go to your Task Pane Manager and create a new environment (via the "Manage Environments" link on top of the pane). It is important that you set the default directory and (at least) two search paths to point to the proper locations on your hard drive.
The default directory should point to the ShortCutMenu's ROOT directory (that's where the STYLES.DBF and SHORTCUT.DBF and the PJX are located). One search path should point to the RESOURCE sub-directory and the other should point to the SOURCE sub directory like shown in the screen shot below.


Figure #2: Don't get confused by my wacky "AAAAA"-naming convention :-) Its just my own "special" way to get important projects sorted starting at the top of the list.

Of course you can add other search paths if you need them later on. I like to include one to my VFP's home directory in almost every environment I'm setting up. In addition to that it is a good idea to also include the PJX reference (on the "Associated Projects" tab), and a one-liner on the "Environment Settings" tab in the "Run script after env... is loaded:" textbox like
       _INCLUDE =  "<your path>\dynashortcut.h".
New classes you're adding during development always will have the right H-file reference then.

Well, now you should be able to run the "ShortCutHost" Form from the DynaShortCut project. Try the different right-clicks like Simple-RightClick, Shift-RightClick and Ctrl-RightClick. If you get an error, you should re-check your search path settings! If everything went fine, you can try to launch the desktop right click monitor from your command window like so:
oCMon = NEWOBJ("clickmonitor","dynashortcut.vcx").

But hey, WAIT !!

As I've always told you: this is an Alpha-Version - maybe even more: some kind of pre-alpha version :-) There are a lot of things still under construction and the rest may change very soon. So, if you are looking through my code, always keep in mind that most of the things that look bizarre are there just for testing! Never forget: <This is work in progress to be continued...>

In the last part (Part V) of this Shortcut Menu series I like to talk about all the little oddities I found while trying to get the whole thing up and running and behave like the real thing ;-)

Be prepared - and let me know what you think! Any ideas, comments and suggestions are welcome!

Previous ChapterComplex Controls Home (TOC)Next Chapter


  1. I watched the video demo. Is there an audio portion?

    Looking forward to reading your update.

  2. I was watching your demo. Is there audio with this presentation?

    Looking forward to your next post.

  3. Fantastic sample! I've played with BackStyle_Access for a few things and it's very powerful.


  4. Hi,
    Sory, no audio part there :-(
    Thanx 4 your comments!

  5. I m waiting for your treeview class

  6. That's great. But how to save edited values, when a textbox is used in the container?

  7. Hi everyone!
    Thanx 4 your comments. “Anonymous” asked “…how to save edited values, when a textbox is used in the container?”

    Well, pardon me not being able to check it out directly, but my first thoughts (not having my VFP development environment at hand) are as follows:

    I would try to use the backstyle_access hook described earlier in this blog. As you should have red, this hook is called every time the record pointer of the underlying controlling table changes. But, watch out! This is not the only scenario VFP refreshes grids! Thus, the access_hook gets called more than once and more often than maybe necessary for your purpose.

    Anyway, you should be able to compare the textbox’s value to the current row/column value of your driving table you want to hold your textbox content. If there is a change (your textbox.value is “dirty”) you should be able to REPLACE the field content on the fly.
    In other words: maybe you should create some kind of a special access/assign functionality for your textbox implemented within my backstyle_access hook-method.

    Pls let me know if that does the trick for you ;-)