Sunday, September 10, 2006

Why must you (VFP) setfocus to it?

I have a Visual Promatrix framework based application. It has few simple forms that consist of label_, textbox_ and textbox_output control(It is a textbox control that set readonly and return false in when event)

If user click new button followed by restore in some of my forms that contains more than ONE textbox_output controls, VFP will fall into "infinite loop".

There are many actions run while new and restore button clicked. Generally, it has common actions such as enable/disable controls during new/restore state.

During debugging, I found that when restore button clicked, all texboxes are disabled. Current active control.lostfocus will be fired. VFP will then try to setfocus to other controls. If the target control is textbox_output (e.g. txtEmployee_Name), VFP will not able to do that since textbox_output.When() always return False. Therefore, VFP would setfocus to next textbox_output control (if any). Of course VFP will fail to do that so. This action keeps happen to the rest of textbox_output controls and back to the txtEmployee_Name again and so on. VFP then falled into hang state.

I debugged other forms that also contains more than one textbox_output controls also but never face this strange behavour. I found that they are fine because the control VFP tried to setfocus is not textbox_output.

My current workaround is set all textbox_output.enabled = .F. However I feel curious on how VFP decide which control to setfocus? It doesn't follow tabindex nor record sequence in .scx.

Anyone can give me some ideas?

0 Comments:

Post a Comment

<< Home