gungadout
11-11-2010, 08:24
Hi Folks,
I have two questions about focus.
1. %EN_SETFOCUS not triggered.
When I first display a window, as I would expect, unless I issue a Control Set Focus command, none of the text boxes receives focus. If I issue the Control Set Focus command for a text box, the cursor starts blinking in that box and typing is permitted, but %EN_SETFOCUS seems not to be triggered.
If I don't issue the Control Set Focus command, but click on the text box to get focus, the %EN_SETFOCUS is triggered.
Is that the way it is supposed to happen?
How can I ensure that the %EN_SETFOCUS is triggered (if indeed it is not being)?
2. Loss and regain of window focus.
When the window loses focus then regains it (e.g. by clicking on the task bar icon), the text box that was already in focus has another %EN_SETFOCUS generated for it. This seems to be illogical, because the text box always had focus within the window; it was the overall window that lost focus.
The resulting problem is that sometimes %EN_SETFOCUS processing involves unrepeatable logic (say, incrementing an auditable control number, as a poor but simple example). So the multiple issuing of the %EN_SETFOCUS status could be troubling.
I guess I need to record the control that has current focus, and ignore any subsequent %EN_SETFOCUS statuses issued for that control.
Or is there a more elegant solution?
Regards,
Peter H.
I have two questions about focus.
1. %EN_SETFOCUS not triggered.
When I first display a window, as I would expect, unless I issue a Control Set Focus command, none of the text boxes receives focus. If I issue the Control Set Focus command for a text box, the cursor starts blinking in that box and typing is permitted, but %EN_SETFOCUS seems not to be triggered.
If I don't issue the Control Set Focus command, but click on the text box to get focus, the %EN_SETFOCUS is triggered.
Is that the way it is supposed to happen?
How can I ensure that the %EN_SETFOCUS is triggered (if indeed it is not being)?
2. Loss and regain of window focus.
When the window loses focus then regains it (e.g. by clicking on the task bar icon), the text box that was already in focus has another %EN_SETFOCUS generated for it. This seems to be illogical, because the text box always had focus within the window; it was the overall window that lost focus.
The resulting problem is that sometimes %EN_SETFOCUS processing involves unrepeatable logic (say, incrementing an auditable control number, as a poor but simple example). So the multiple issuing of the %EN_SETFOCUS status could be troubling.
I guess I need to record the control that has current focus, and ignore any subsequent %EN_SETFOCUS statuses issued for that control.
Or is there a more elegant solution?
Regards,
Peter H.