continuing the saga of the "perfect" viewport.

as anyone who has read my previous blog about the scrollable view port knows, if you start moving the parent window around, funky things happen. basically by using the api's to set one window as a child of the other, windows knows about this, but vfp does not. thus if you move the parent window, the child "appears" to move as well. but windows keeps this a secret and does not tell vfp. hence the clickable areas of the viewport are left behind. so if you move the parent window, you lose the ability to click anything in the viewport. if you move the window exactly back to where it was clicking returns. go figure.

read about it here

foxprow 2.6 has a command where you could open a window inside another:

show window child in window parent. however the vfp help files says that show window can be used only with windows defined using define window....bummer. how to do that with a visual class form?

but wait theres more...wink [;)]

there is a way to do this by specifying the name of the window.once you have set the name property of your form you can refer to it as any other object.

armed with this, there is only a couple more steps to do.since i have added my form class with the objects in it to the vfp toolbox, i right click on it in the toolbox and select the menu option create form. this creates a form for me based on my form class, complete with scroll bars and objects. i changed the property name = scroller and saved it.

one more thing to do. i opened my parent form and gave it too a name = scrollparent. i opened the init code and deleted all those api calls of set parent etc.

i added the following code in the init:

do form scroller noshow

show wundow scroller in window scrollparent

with scroller

   .top =

   .left = thisform.placeholder.left

   .height = thisform.placeholder.height

   .width = thisform.placeholder.width


thats all. i then ran my parent form and voila the viewport appeared. this time vfp knew about the new window acting as a child. i could move the main window and the child followed. i could even click. begone api's viva la foxpro.big smile [:d]

my friend malcolm greene has been providing me feedback and this encouraged me to dig deeper and try to fix the main clicking/moving problem. now i have a proper scrollable viewport. i can move the form and the clicks move with it. still one more problem to solve - the activate/deactivate of the parent gets fired if i switch to the viewport (that malcolm is persistent) 

for now, i can live with that in my app that uses this viewport. one can't have everything can one?



Leave a Reply

Your email address will not be published. Required fields are marked *