locked
Giving focus to a form RRS feed

  • Question

  • In VFP9, I can get a form to display, but I can't get it to automatically have focus: another form is still in focus, and the user has to manually click on the new form to give it focus.

    I launch it in the following way:
    DO FORM x_alertwin
    MOVE WINDOW x_alertwin CENTER
    ACTIVATE WINDOW x_alertwin TOP

    What can I do to make it automatically have focus?

    Thanks.

    Thursday, September 19, 2019 11:35 AM

Answers

  • Hi Rupster,

    what kind of a form is it, that you have to center and activate it manually?

    Usually, there is a form property thats called .AutoCenter and as soon as this prop is set to .T. the form will center itself automatically.

    If the form then doesn't have focus, you should check on how you start the main form. Is that a modeless form? (see Form.WindowType = 0 (Modeless) | 1 (Modal).

    If your main form is modeless then take care that you alert form is 1(Modal). That way the main form will be deactivated and the alert form will get the focus and has to be closed before the main form can be used again.

    HTH


    Gruss / Best regards
    -Tom
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible,
    you are, by definition, not smart enough to debug it. 010101100100011001010000011110000101001001101111011000110110101101110011

    • Marked as answer by The Rupster Thursday, September 19, 2019 1:02 PM
    Thursday, September 19, 2019 12:09 PM
    Answerer

All replies

  • Hi Rupster,

    what kind of a form is it, that you have to center and activate it manually?

    Usually, there is a form property thats called .AutoCenter and as soon as this prop is set to .T. the form will center itself automatically.

    If the form then doesn't have focus, you should check on how you start the main form. Is that a modeless form? (see Form.WindowType = 0 (Modeless) | 1 (Modal).

    If your main form is modeless then take care that you alert form is 1(Modal). That way the main form will be deactivated and the alert form will get the focus and has to be closed before the main form can be used again.

    HTH


    Gruss / Best regards
    -Tom
    Debugging is twice as hard as writing the code in the first place.
    Therefore, if you write the code as cleverly as possible,
    you are, by definition, not smart enough to debug it. 010101100100011001010000011110000101001001101111011000110110101101110011

    • Marked as answer by The Rupster Thursday, September 19, 2019 1:02 PM
    Thursday, September 19, 2019 12:09 PM
    Answerer
  • Both the .AutoCenter and .WindowType setting changes worked. Thanks.

    Thursday, September 19, 2019 1:00 PM