Results 1 to 18 of 18

Thread: How to display form without losing focus

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Romania
    Posts
    81

    Cool How to display form without losing focus

    Hello everybody!
    Can somebody tell me how to display a form without setting focus on it? (a king of tool-tip window).
    Thanks in advance...
    Last edited by Bhairava; Jan 15th, 2005 at 02:21 AM.
    ...

  2. #2
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: How to display form without losing focus

    Can you ellaborate on what is it that you need to accomplish, please.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Romania
    Posts
    81

    Re: How to display form without losing focus

    Usually when you open a new form, it automatically gets the focus.
    I want to open a form, without losing focus from where it is.

    Example:
    The application I want to make will display an alarm message from 5 to 5 minutes. Whenever I display the form, it gets the focus, and this is pretty annoying when you write something or playing a game in another application.

    A good example of what I want is the window that appear in the right of the screen - from Yahoo Messenger or Windows Messenger. Those windows don't get my focus from where it is.


    Thanks.
    ...

  4. #4
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: How to display form without losing focus

    You may simply reset focus back to "calling" form so perhaps something like the following quick sample will work for you:
    VB Code:
    1. Private Sub Command2_Click()
    2.     Form2.Show , Me
    3.     Me.SetFocus
    4. End Sub

  5. #5

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Romania
    Posts
    81

    Re: How to display form without losing focus

    Thanks.
    ...

  7. #7
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: How to display form without losing focus

    You're welcome but which method worked for you - it's just out of curiosity.

  8. #8

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Romania
    Posts
    81

    Re: How to display form without losing focus

    setting the enabled property to false is what i wanted
    ...

  9. #9
    PowerPoster RhinoBull's Avatar
    Join Date
    Mar 2004
    Location
    New Amsterdam
    Posts
    24,132

    Re: How to display form without losing focus

    Oh, ok.

  10. #10

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Romania
    Posts
    81

    Re: How to display form without losing focus

    Sorry, after testing a little more, and made the executable file, it still gets the focus, even if the form which is displayed is not enabled .
    I'm thinking there must be some sort of API stuff to do it...
    ...

  11. #11
    Banned dglienna's Avatar
    Join Date
    Jun 2004
    Location
    Center of it all
    Posts
    17,901

    Re: How to display form without losing focus

    could you minimize it? did you try the other way?

  12. #12
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How to display form without losing focus

    Private Sub Command2_Click()
    Form2.Show , Me
    Me.SetFocus
    End Sub
    VB Code:
    1. Private Sub Command2_Click()
    2.     Form2.Show , Me
    3.     Me.Show
    4. End Sub




    pete


    oops you mean that this happens when some other prgram has focus, not your program???

  13. #13

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Romania
    Posts
    81

    Question Re: How to display form without losing focus

    It works indeed if I show the main form, but when it is not shown, the new form gets the focus.
    i've attached a sample of what i'm working at.
    Please see attached project.

    Thanks.
    Attached Files Attached Files
    ...

  14. #14
    PowerPoster
    Join Date
    Dec 2004
    Posts
    25,618

    Re: How to display form without losing focus

    i had a look at you program, looks very nice.

    appactivate immediately after showing the form work, but you will need to use api call to get title of top most window prior to showing your form

    rgds pete

    if the current application covers the location of your form then it will not actually be seen

    maybe if you set it to topmost and put it up into the caption bar area it will be out of the way
    Last edited by westconn1; Jan 15th, 2005 at 04:40 AM.

  15. #15

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Romania
    Posts
    81

    Re: How to display form without losing focus

    Nobody knows?
    ...

  16. #16
    Frenzied Member
    Join Date
    May 2003
    Location
    Sydney
    Posts
    1,123

    Re: How to display form without losing focus

    which os are u working with, exactly? your code gave me a big error message that made my vb crash. something in user32.dll

  17. #17

    Thread Starter
    Lively Member
    Join Date
    Jan 2002
    Location
    Romania
    Posts
    81

    Re: How to display form without losing focus

    i'm using WinXP prof. SP2
    That's strange with the error you have...
    ...

  18. #18
    Frenzied Member
    Join Date
    May 2003
    Location
    Sydney
    Posts
    1,123

    Re: How to display form without losing focus

    well, i am using win 98. so the error is expected.

    edit:
    note: i will have to get back home to see what can be done in xp. i will let u know if i can do anything about it.

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