Results 1 to 3 of 3

Thread: Questions About Focus

  1. #1

    Questions About Focus

    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.
    Thought for the day (in a broad Australian accent):<br />First of all yer gungadin. Afterwards yer gungadout.

  2. #2
    thinBasic author ErosOlmi's Avatar
    Join Date
    Sep 2004
    Location
    Milan - Italy
    Age
    57
    Posts
    8,781
    Rep Power
    10
    A preliminar question: how do you create your main window? MODAL or MODELESS?

    If MODAL, it will have automatic behave driven by Windows. Modal windows are like message box windows.

    If MODELESS, you will have more precise control and more precise events will occur.

    Ciao
    Eros
    www.thinbasic.com | www.thinbasic.com/community/ | help.thinbasic.com
    Windows 10 Pro for Workstations 64bit - 32 GB - Intel(R) Xeon(R) W-10855M CPU @ 2.80GHz - NVIDIA Quadro RTX 3000

  3. #3
    Hi Eros,

    The window is created MODAL.

    It needs to be MODAL because the menu window that activates it must remain inactive until the invoked dialog window is destroyed.

    So I'll just have to live with whatever Windows decides to throw at me, and learn how to construct the necessary work-arounds.

    I assume that the solution I have in mind for Problem 2 is practical, unless you or someone can suggest a better idea.

    To overcome Problem 1, I guess I could move my %EN_SETFOCUS logic to a separate function and call that function whenever %EN_SETFOCUS is entered. Then, after triggering the first Control Set Focus action, I could send a command to discretely trigger the associated %EN_SETFOCUS function logic. (In the absence of a more elegant method, that is.)

    (I have yet to test whether or not Control Set Focus triggers %EN_SETFOCUS as a general case. If %EN_SETFOCUS is not so triggered, my above solution could be used to handle that situation as well.)

    Thanks for your help,

    Peter H.
    Thought for the day (in a broad Australian accent):<br />First of all yer gungadin. Afterwards yer gungadout.

Similar Threads

  1. Control Set Focus
    By Michael Clease in forum Fixed or cleared errors in help material
    Replies: 1
    Last Post: 07-02-2010, 13:10

Members who have read this thread: 0

There are no members to list at the moment.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •