Tip: Controls on Forms

If you have ever tried to design heavily graphical layout forms that use a lot of containers or controls, you may have run into a problem where VFP appears to hang.
 
This problem likely occurs if you are designing forms that have a lot of graphics or controls on them. For example, I was building a form that would allow users to drag and drop a graphical depiction of a trailer into a loading dock. There were to be 150 trailers on the screen. I created a control class that only contained labels and images. This is where I ran into the problem.
 
When VFP runs a form, it wants to find a place to rest focus. If it can't find one but the form contains a number of containers, it appears to go into an endless loop in its attempt to find one.
 
The solution is to put a control onto the form that looks for focus (like a textbox or a command button) and make it visible. This way, VFP will see the control and stop searching for a place to put the focus.
 
You can get around this two ways: one way is not to use control classes but simply images or labels. The better solution is to put a box on the form that can receive focus (like a textbox or command button).
 
 
 

Comments

Popular Posts