Results 1 to 9 of 9

Thread: [RESOLVED] Main form focus

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337

    Resolved [RESOLVED] Main form focus

    I have an application that just stores shortcuts to most used applications on users desktops. My problem is that when the machine loads after they login the app window looses focus and sometimes doesn't show in the taskbar. I tried to use Me.Focus() but that just gives the treeview focus and not the form itself. I mean the parent has focus in the treeview but the form is not highlighted, I can then click on the form and it gets selected.

    What is a good way to get the whole form focus? I used me.focus in the form load too.

    any ideas?

  2. #2
    Super Moderator dday9's Avatar
    Join Date
    Mar 2011
    Posts
    12,398

    Re: Main form focus

    I'm assuming this happens beause the Me.Focus is in the form_load event. Try switching it to the form_shown event.
    "Code is like humor. When you have to explain it, it is bad." - Cory House
    VbLessons | HtmlLessons | CssLessons | Code Tags | Sword of Fury - Jameram

  3. #3
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: Main form focus

    try this:

    vb Code:
    1. Me.Activate()

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337

    Re: Main form focus

    Thanks paul, that "appears" like it will work. I will have to test for a couple of days or lots of reboots.

    If not I will try yours dday9, thank you

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337

    Re: Main form focus

    Thank you guys, Me.Activate seems to do the trick, just have to play with the timing. I have it set to 30 seconds after the form comes up to then Activate. So all looks good from here

  6. #6
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: [RESOLVED] Main form focus

    dday was right about using the form_shown event too...

  7. #7

    Thread Starter
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337

    Re: [RESOLVED] Main form focus

    so you think I should put it there and not have a timeset on it? Will it work the same no matter what the timing is on the desktop?

  8. #8
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,424

    Re: [RESOLVED] Main form focus

    the form_shown event doesn't fire until the form is fully loaded + visible

  9. #9

    Thread Starter
    Frenzied Member
    Join Date
    Nov 1999
    Posts
    1,337

    Re: [RESOLVED] Main form focus

    Thanks again guys. It is better than what it use to be. At least it has more of a chance to load than the other way. I used the form_shown event. It still depends on the machine but it's still an big improvement.

Posting Permissions

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



Click Here to Expand Forum to Full Width