Results 1 to 4 of 4

Thread: Focus problem [RESOLVED]

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Granby, Qc, Canada
    Posts
    602

    Focus problem [RESOLVED]

    In my program, in the Form_Unload event, I use shell to open another application, the problem is that the application open but stay in the taskbar. How can I give the focus to this application ?
    Last edited by Gensor; Feb 2nd, 2005 at 09:08 AM.

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Use ShellExecute Instead Of Shell

    VB Code:
    1. Private Declare Function ShellExecute Lib "shell32.dll" Alias "ShellExecuteA" (ByVal hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal lpParameters As String, ByVal lpDirectory As String, ByVal nShowCmd As Long) As Long
    2.  
    3. Private Const SW_SHOWNORMAL = 1
    4.  
    5. Private Sub Command1_Click()
    6.        ShellExecute Me.hwnd, vbNullString, "YourFileName", vbNullString, "C:\", SW_SHOWNORMAL
    7. End Sub

  3. #3
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Focus problem

    Or use the vbNormalFocus parameter :

    VB Code:
    1. Shell "YourApplication", [b]vbNormalFocus[/b]


    Has someone helped you? Then you can Rate their helpful post.

  4. #4

    Thread Starter
    Fanatic Member
    Join Date
    May 2004
    Location
    Granby, Qc, Canada
    Posts
    602

    Re: Focus problem

    Thanks, it is working!

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