General discussion

Locked

Bernard's Thoughts

By gdalbr ·
Tags: Off Topic
blog root

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Thinking Outside the Box

by gdalbr In reply to Bernard's Thoughts

<P>Thanks to the urging by Craig Bailey and Eric kindly providing the web space, I've decided to bite the bullet and get blogging. </P>
<P>The projects at work are keeping me very busy since I am exploring new areas of VFP usage.</P>
<P>My explorations into the capabilities of the FOX have led me to some strange areas and have really made me think about things more "outside the box"</P>
<P>What I mean by that is mostly we approach vfp objects with a standard view. Previously this has led me to do things in a very staid way. But now I approach things very differently.</P>
<P>Here's an example of that.</P>
<P>As we all know VFP does not have native scroll bar objects, so if we want scroll bars we have to use other means. I have seen many implementations of a scrollable container. There are those that use VB ActiveX scroll bars, others that use the WIN API completely and still others like the one found at Craig Boyd's site - <A href="http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,df3cb71d-588f-4bc6-b63e-9c94017edd7f.aspx">http://www.sweetpotatosoftware.com/SPSBlog/PermaLink,guid,df3cb71d-588f-4bc6-b63e-9c94017edd7f.aspx</A> that uses VFP objects. </P>
<P>While all these are nice, they do have their own problems. You have to have the VB runtimes for the ActiveX, you have to have API's so the implementation is not very visual in the VFP Editor, and in Craig's case he has documented some shortcomings like objects ?bleeding? through the container into the main form, you can?t hold down the mouse on the scroll bars to get a repeated effect and sometimes the scrolling effect is jerky.</P>
<P>So this led me to think of other alternatives. Which objects in VFP have native scrollbar support and are also containers? The only two are a Grid and a form. I discounted the grid because it was a bit too difficult to manipulate easily and add objects. That left the form.</P>
<P>So I created a form and set the scrollbars property = 3 (both), removed the Title and set the border to 0. This gave me a scrollable container to which I could easily add objects.</P>
<P><STRONG>Base Scroll Class</STRONG></P>
<P><A HREF="/photos/bernardbout/picture1537.aspx" target=_blank></A></P>
<P><A HREF="/photos/bernardbout/picture1537.aspx" target=_blank><IMG src="/photos/bernardbout/images/1537/323x303.aspx" border=0></A></P>
<P> </P>
<P>I ran the form and scrolled about. So far so good. I then saved it as a class. Next I added it to my Toolbox and created a form from it.</P>
<P>To this form based on my original scroll form class I then added objects<SPAN>  </SPAN>as below. The scrollbars then appeared. I saved this too as a class. Now I could easily open this class and add/remove items etc. This form could be instantiated on its own as well. So much for the GUI part.</P>
<P><STRONG>Scroll Class + Objects</STRONG></P>
<P><A HREF="/photos/bernardbout/picture1538.aspx" target=_blank><IMG src="/photos/bernardbout/images/1538/574x334.aspx" border=0></A></P>
<P>Now if we try and add this class to a new form we get asked if we want to create a form set. I hate formsets so that is not the way to go. Also ADDOBJECT at runtime does not work in a form. If only?</P>
<P>Then I remembered reading somewhere/sometime on Foxite about the 2 Windows API?s<SPAN>  </SPAN>SetParent & GetParent and the with that the ideas flowed....</P>
<P>So I created a new form and added a shape as a place holder for my scrollable container, which would give me a visual representation of where the scrollable window would appear and its dimensions. Also the form has a custom property oScroller and a custom method<SPAN>  </SPAN>GetScroller</P>
<P>In the INIT of this form I added a call to the custom method ? GetScroller()</P>
<P>The code for GetScroller is here:</P>
<P class=MsoNormal><SPAN>DECLARE INTEGER </SPAN><SPAN>SetParent </SPAN><SPAN>IN </SPAN><SPAN>User32 </SPAN><SPAN>INTEGER HWND</SPAN><SPAN>, </SPAN><SPAN>INTEGER </SPAN><SPAN>ParenthWnd<o></o></SPAN></P>
<P class=MsoNormal><SPAN>DECLARE INTEGER </SPAN><SPAN>GetParent </SPAN><SPAN>IN </SPAN><SPAN>User32 </SPAN><SPAN>INTEGER HWND<o></o></SPAN></P>
<P class=MsoNormal><SPAN>DECLARE INTEGER </SPAN><SPAN>MoveWindow </SPAN><SPAN>IN </SPAN><SPAN>user32 </SPAN><SPAN>INTEGER HWND</SPAN><SPAN>, </SPAN><SPAN>INTEGER </SPAN><SPAN>X</SPAN><SPAN>, ;<o></o></SPAN></P>
<P class=MsoNormal><SPAN><SPAN>              </SPAN></SPAN><SPAN>INTEGER </SPAN><SPAN>Y</SPAN><SPAN>, </SPAN><SPAN>INTEGER </SPAN><SPAN>nWidth</SPAN><SPAN>, </SPAN><SPAN>INTEGER </SPAN><SPAN>nHeight</SPAN><SPAN>, </SPAN><SPAN>INTEGER </SPAN><SPAN>bRepaint<o></o></SPAN></P>
<P class=MsoNormal><SPAN>SET CLASSLIB TO </SPAN><SPAN>bbscroll </SPAN><SPAN>addit<o></o></SPAN></P>
<P class=MsoNormal><SPAN>thisForm</SPAN><SPAN>.</SPAN><SPAN>oScroller </SPAN><SPAN>= </SPAN><SPAN>CREATEOBJECT</SPAN><SPAN</SPAN><SPAN>"scrollobject"</SPAN><SPAN&gt<o></o></SPAN></P>
<P class=MsoNormal><SPAN>WITH thisForm</SPAN><SPAN>.</SPAN><SPAN>oScroller<o></o></SPAN></P>
<P class=MsoNormal><SPAN><SPAN>      </SPAN>SetParent</SPAN><SPAN.</SPAN><SPAN>hWnd</SPAN><SPAN>, </SPAN><SPAN>THISFORM</SPAN><SPAN>.</SPAN><SPAN>hWnd</SPAN><SPAN&gt<o></o></SPAN></P>
<P class=MsoNormal><SPAN>* this positions and refreshes the form<SPAN>   </SPAN><o></o></SPAN></P>
<P class=MsoNormal><SPAN>MoveWindow</SPAN><SPAN.</SPAN><SPAN>HWnd</SPAN><SPAN>, </SPAN><SPAN>ThisForm</SPAN><SPAN>.</SPAN><SPAN>Scrollplaceholder2</SPAN><SPAN>.</SPAN><SPAN>Left</SPAN><SPAN>, </SPAN><SPAN>ThisForm</SPAN><SPAN>.</SPAN><SPAN>Scrollplaceholder2</SPAN><SPAN>.</SPAN><SPAN>Top</SPAN><SPAN>,;<o></o></SPAN></P>
<P class=MsoNormal><SPAN>ThisForm</SPAN><SPAN>.</SPAN><SPAN>Scrollplaceholder2</SPAN><SPAN>.</SPAN><SPAN>width</SPAN><SPAN>, </SPAN><SPAN>ThisForm</SPAN><SPAN>.</SPAN><SPAN>Scrollplaceholder2</SPAN><SPAN>.</SPAN><SPAN>height </SPAN><SPAN>, </SPAN><SPAN>1</SPAN><SPAN&gt<o></o></SPAN></P>
<P class=MsoNormal><SPAN><SPAN>      </SPAN>.</SPAN><SPAN>visible </SPAN><SPAN>= </SPAN><SPAN>.T.<o></o></SPAN></P>
<P class=MsoNormal><SPAN>ENDWITH</SPAN></P>
<P>And that?s it. I now had a scrollable view port with none of the problems of the other classes, that was GUI enabled, editable, no bleed thru and was also ActiveX friendly.</P>
<P>Here?s<SPAN>  </SPAN>a look at the form running:</P>
<P><STRONG>Scroll Form</STRONG></P>
<P><A HREF="/photos/bernardbout/picture1539.aspx" target=_blank><IMG src="/photos/bernardbout/images/1539/399x336.aspx" border=0></A></P>
<P><A HREF="/photos/bernardbout/picture1540.aspx" target=_blank><IMG src="/photos/bernardbout/images/1540/404x309.aspx" border=0></A></P>
<P>I also created another subclass of the original form class and this time inserted an IMAGE object into it. Now I had a scrollable view port:</P>
<P><STRONG>An Image Viewport</STRONG></P>
<P><A HREF="/photos/bernardbout/picture1541.aspx" target=_blank><IMG src="/photos/bernardbout/images/1541/380x373.aspx" border=0></A></P>
<P>There is only 1 problem I see with this above class. <img src="/emoticons/emotion-6.gif" alt="Sad [:(]" /></P>
<P>It does <STRONG>NOT</STRONG> like being moved. You can see the effect by moving the form and then trying to scroll. I have still to come up with an elegant solution to counteract this but till then either you do not move the form or if you have to, then you can use BINDEVENTS and LockScreen to recreate the scroll object once the form has stopped moving.</P>
<P>Any ideas are very welcome. So are comments Till next time?</P><A HREF="/photos/bernardbout/picture1540.aspx" target=_blank></A><img src="http://weblogs.foxite.com/aggbug.aspx?PostID=1542" width="1" height="1"><p><div class="blogdisclaim"><a href="http://weblogs.foxite.com/bernardbout/archive/2006/05/17/FirstPost.aspx">This post originally appeared on an external website</a></div>

Collapse -

I'm blogging at last "- outside the box"

by gdalbr In reply to Bernard's Thoughts

<P>Thanks to the urging by Craig Bailey and Eric kindly providing the web space, I've decided to bite the bullet and get blogging. </P>
<P>The projects at work are keeping me very busy since I am exploring new areas of VFP usage.</P>
<P>My explorations into the capabilities of the FOX have led me to some strange areas and have really made me think about things more "outside the box"</P>
<P>What I mean by that is mostly we approach vfp objects with a standard view. Previously this has led me to do things in a very staid way. But now I approach things very differently.</P>
<P><A HREF="/bernardbout/archive/2006/05/17/FirstPost.aspx">Here's an example of that.</A></P>
<P> </P><img src="http://weblogs.foxite.com/aggbug.aspx?PostID=1546" width="1" height="1"><p><div class="blogdisclaim"><a href="http://weblogs.foxite.com/bernardbout/archive/2006/05/18/1546.aspx">This post originally appeared on an external website</a></div>

Collapse -

The Scrollable Viewport Part II - I dump the API's. Look Mama I can Click!

by gdalbr In reply to Bernard's Thoughts

<P>Continuing the saga of the "perfect" viewport. </P>
<P>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. </P>
<P><A HREF="/bernardbout/archive/2006/05/17/1542.aspx">Read about it here</A></P>
<P>Foxprow 2.6 has a command where you could open a window INSIDE another:</P>
<P><FONT color=#008000>SHOW WINDOW child IN WINDOW Parent.</FONT> 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?</P>
<P>But wait theres more...<img src="/emoticons/emotion-5.gif" alt="Wink [;)]" /></P>
<P>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.</P>
<P>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 <STRONG>Create Form</STRONG>. This creates a form for me based on my form class, complete with scroll bars and objects. I changed the property <STRONG>Name = scroller</STRONG> and saved it.</P>
<P>One more thing to do. I opened my parent form and gave it too a <STRONG>name = ScrollParent</STRONG>. I opened the <STRONG>INIT</STRONG> code and deleted all those API calls of Set Parent etc. </P>
<P>I added the following code in the INIT:</P>
<P><FONT face="Courier New" color=#006400>DO FORM scroller NOSHOW</FONT></P>
<P><FONT face="Courier New" color=#006400>SHOW WUNDOW scroller IN WINDOW scrollparent</FONT></P>
<P><FONT face="Courier New" color=#006400>With Scroller</FONT></P>
<P><FONT face="Courier New" color=#006400>   .Top = ThisForm.Placeholder.Top</FONT></P>
<P><FONT face="Courier New" color=#006400>   .Left = ThisForm.Placeholder.Left</FONT></P>
<P><FONT face="Courier New" color=#006400>   .Height = ThisForm.Placeholder.Height</FONT></P>
<P><FONT face="Courier New" color=#006400>   .Width = ThisForm.Placeholder.Width</FONT></P>
<P><FONT face="Courier New" color=#006400>ENDWITH</FONT></P>
<P>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. <STRONG><FONT size=4>I could even click</FONT></STRONG>. Begone API's Viva la Foxpro.<img src="/emoticons/emotion-2.gif" alt="Big Smile [:D]" /></P>
<P>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) </P>
<P>For now, I can live with that in my app that uses this viewport. One can't have everything can one?</P>
<P>Later..</P>
<P> </P><img src="http://weblogs.foxite.com/aggbug.aspx?PostID=1564" width="1" height="1"><p><div class="blogdisclaim"><a href="http://weblogs.foxite.com/bernardbout/archive/2006/05/23/1564.aspx">This post originally appeared on an external website</a></div>

Collapse -

The Scrollable Viewport Part III - Malcolm keeps me on my toes

by gdalbr In reply to Bernard's Thoughts

<P>After solving the problem of the funky behaviour of the scroll bar in <A href="/bernardbout/archive/2006/05/22/1564.aspx">this post</A> I was ready for new pastures. But my pal Malcolm would not let up. </P>
<P><EM>How is your scrollbar class handling the following challenges:<BR><BR>1. Parent form Deactivate/Active events fired when scrollable container (window and/or window scrollbars) get focus.<BR><BR>2. Having your scrollable container have a working .Anchor property so it can automatically shift and resize as its parent form is resized.<BR></EM></P>
<P>he fired back at me. </P>
<P>Well a form does NOT have an anchor property but that should not stop us. </P>
<P>Although I have not exactly done as requested, I have a solution. Remember the invisible ScrollViewport <STRONG>placeholder</STRONG>? It's still on the form and is still an object that VFP can see, although you can't because it's VISIBLE = .F.</P>
<P>So open the parent form and set the Anchor property of the placeholder to (you have upgraded to VFP9 I hope) :</P>
<P>Anchor = 15</P>
<P>One more thing to do. Bind the child form to the anchors of the viewport. To do this we need a reference. Create a custom property of the parent form called <STRONG>oChild</STRONG>. Add the following line after the original code in the I<STRONG>NIT</STRONG> so that it looks now:</P>
<P><FONT face="Courier New" color=#006400>DO FORM scroller NOSHOW</FONT></P>
<P><FONT face="Courier New" color=#006400>SHOW WUNDOW scroller IN WINDOW scrollparent</FONT></P>
<P><FONT face="Courier New" color=#006400>With Scroller</FONT></P>
<P><FONT face="Courier New" color=#006400>   .Top = ThisForm.Placeholder.Top</FONT></P>
<P><FONT face="Courier New" color=#006400>   .Left = ThisForm.Placeholder.Left</FONT></P>
<P><FONT face="Courier New" color=#006400>   .Height = ThisForm.Placeholder.Height</FONT></P>
<P><FONT face="Courier New" color=#006400>   .Width = ThisForm.Placeholder.Width</FONT></P>
<P><FONT face="Courier New" color=#006400>ENDWITH</FONT></P>
<P><FONT face="Courier New" color=#006400><STRONG>ThisForm.oChild = scroller</STRONG></FONT></P>
<P><FONT face="Courier New" color=#006400><FONT face="Times New Roman" color=#000000>Finally in the RESIZE of the parent form add this smidgen of code:</FONT></FONT></P>
<P><FONT face="Courier New" color=#006400>WITH ThisForm.oChild</FONT></P>
<P><FONT face="Courier New" color=#006400>   .Top = ThisForm.Placeholder.Top</FONT></P>
<P><FONT face="Courier New" color=#006400>   .Left = ThisForm.Placeholder.Left</FONT></P>
<P><FONT face="Courier New" color=#006400>   .Height = ThisForm.Placeholder.Height</FONT></P>
<P><FONT face="Courier New" color=#006400>   .Width = ThisForm.Placeholder.Width</FONT></P>
<P><FONT face="Courier New" color=#006400>ENDWITH</FONT></P>
<P>And that's that for the Anchor where the Anchor = 15</P>
<P>Next task is to get this code in the Scroll Class iteslf. This should be trivial. Just move the above code from the resize event of the parent into a custom method of the child and add code to BIND EVENTS () of the Parent Resize to the custom resize of the child, based on a property. Also this is for an anchor of 15 so if you wanted to handle all the other Anchor settings then a case statement is the go.</P>
<P>#1 I still haven't solved (yet) but it should only be a matter of time.</P>
<P>Bring it on Mal.</P>
<P> </P>
<P>Later...</P><img src="http://weblogs.foxite.com/aggbug.aspx?PostID=1568" width="1" height="1"><p><div class="blogdisclaim"><a href="http://weblogs.foxite.com/bernardbout/archive/2006/05/23/1568.aspx">This post originally appeared on an external website</a></div>

Collapse -

With VFP its Perception - Make it cool.

by gdalbr In reply to Bernard's Thoughts

Craig Bailey on his blog talks about how to make VFP look cool. As he says, its all in the mind ? perception - VFP is xbase and is old technology, VFP controls look dated etc. We need to change that.This is a must read...(<a href="http://weblogs.foxite.com/bernardbout/archive/2006/06/06/1659.aspx">read more</a&gt<img src="http://weblogs.foxite.com/aggbug.aspx?PostID=1659" width="1" height="1"><p><div class="blogdisclaim"><a href="http://weblogs.foxite.com/bernardbout/archive/2006/06/06/1659.aspx">This post originally appeared on an external website</a></div>

Collapse -

Recreating OneNoteTabs in VFP9

by gdalbr In reply to Bernard's Thoughts

The techniques involved with making these tabs are simple and straight forward. Since I use no API?s , to achieve the gradient effect requires a bitmap, one for each colour used. The techniques used here are my own. Opinions may vary but this is how I do it....(<a href="http://weblogs.foxite.com/bernardbout/archive/2006/06/07/1704.aspx">read more</a&gt<img src="http://weblogs.foxite.com/aggbug.aspx?PostID=1704" width="1" height="1"><p><div class="blogdisclaim"><a href="http://weblogs.foxite.com/bernardbout/archive/2006/06/07/1704.aspx">This post originally appeared on an external website</a></div>

Collapse -

Visual Foxpro does Glass!

by gdalbr In reply to Bernard's Thoughts

The Windows Vista CPT is out and is being downloaded desperately by whoever has the bandwidth. One of the "eye candy" items of Vista themes is something called Glass Forms. When applied, it gives an effect that the form is transparent - like glass.
However don't rush out and set this up since your current graphics card may not support its requirements. Also it is a huge resource hog and recommendations are that only a small part of the window should be glassed.
So what should we others do then?...(<a href="http://weblogs.foxite.com/bernardbout/archive/2006/06/15/1838.aspx">read more</a&gt<img src="http://weblogs.foxite.com/aggbug.aspx?PostID=1838" width="1" height="1"><p><div class="blogdisclaim"><a href="http://weblogs.foxite.com/bernardbout/archive/2006/06/15/1838.aspx">This post originally appeared on an external website</a></div>

Back to After Hours Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums