locked
Form not getting focus. RRS feed

  • Question

  • I have made an application in which a form opens at the beginning (most of the apps do have this, don't they). But my problem is when the form opens, sometimes the form doesn't get focus.
    Between opening and the form not getting focus, there are no other events like keyboard press, clicking etc.
    I tried to set the focus manually by writing this.Focus() in the form load event as well.
    I even tried calling SetForegroundWindow() Win32 function as well.
    But still I'm getting the same problem.
    Could anyone help?
    Thanks.
    Friday, June 29, 2007 8:46 AM

Answers

  • Thank you guys, for your effort.
    But I have solved the problem now.
    Previously I was hiding the calling form before I displayed the new form, so I was getting the problem I mentioned afore.
    But now as I hide the calling form only after the new form is shown, the problem is solved.

    I just posted this to help someone else who might be getting the same problem.
    Thursday, July 5, 2007 6:32 AM

All replies

  • Does this occur on oher machine that your development one?

     

    I suppose there is something else that cause this behaviour...

     

    Regards

    Friday, June 29, 2007 9:07 AM
  • We've around 50-60 machines in our office and it occurs in each one of 'em.
    Did I already mention, it doesn't always occur though.
    Friday, June 29, 2007 9:26 AM
  • Hi...

     

    try setting the 'Topmost' property to true. also try using  'this.setfocus()' in Form Shown event or Form activated event.

     

    I'm not sure if this can solve ur problem.... but it guess it can.

     

     

    Friday, June 29, 2007 12:39 PM
  • How does your app get started?
    Friday, June 29, 2007 5:50 PM
  • Thank you guys, for your effort.
    But I have solved the problem now.
    Previously I was hiding the calling form before I displayed the new form, so I was getting the problem I mentioned afore.
    But now as I hide the calling form only after the new form is shown, the problem is solved.

    I just posted this to help someone else who might be getting the same problem.
    Thursday, July 5, 2007 6:32 AM