Results 1 to 8 of 8

Thread: Active

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Feb 2010
    Posts
    120

    Active

    Hey please help i need to set the active window in vb.net
    so please tell me how to do it??

  2. #2
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Active

    Please provide a full and clear description. Do you mean a form within your app or a window outside your app?
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  3. #3
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: Active

    If you need to set another application's active window u must use API.
    Stuff like:
    GetWindow
    setForegroundWindow
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

  4. #4

    Thread Starter
    Lively Member
    Join Date
    Feb 2010
    Posts
    120

    Re: Active

    i want window outside my app

    Quote Originally Posted by sapator View Post
    If you need to set another application's active window u must use API.
    Stuff like:
    GetWindow
    setForegroundWindow
    i found out on google but they are not working they are for vb6
    and have many errors in vb.net

  5. #5
    Super Moderator jmcilhinney's Avatar
    Join Date
    May 2005
    Location
    Sydney, Australia
    Posts
    111,221

    Re: Active

    VB6 declarations are often OK as is except that you need to change any Long type to Integer. There may be other changes required to. If you go to PInvoke.net then you can find .NET declarations for many Windows APIs.
    Why is my data not saved to my database? | MSDN Data Walkthroughs
    VBForums Database Development FAQ
    My CodeBank Submissions: VB | C#
    My Blog: Data Among Multiple Forms (3 parts)
    Beginner Tutorials: VB | C# | SQL

  6. #6

    Thread Starter
    Lively Member
    Join Date
    Feb 2010
    Posts
    120

    Re: Active

    Please Can you give me how can i set a window
    i have working codes for finding it
    Code:
    Private Declare Function FindWindow Lib "user32" _
           Alias "FindWindowA" _
           (ByVal lpClassName As String, _
           ByVal lpWindowName As String) As Long
        Private Declare Function GetClassName Lib "user32" _
           Alias "GetClassNameA" _
           (ByVal hWnd As Long, _
           ByVal lpClassName As String, _
           ByVal nMaxCount As Long) As Long
    
        Public Sub GetClassNameFromTitle()
            Dim sInput As String
            Dim hWnd As Long
            Dim lpClassName As String
            Dim nMaxCount As Long
            Dim lresult As Long
            ' pad the return buffer for GetClassName
            nMaxCount = 256
            lpClassName = Space(nMaxCount)
            ' Note: must be an exact match
            sInput = InputBox("Enter the exact window title:")
            ' No validation is done as this is a debug window utility
            hWnd = FindWindow(vbNullString, sInput)
            ' Get the class name of the window, again, no validation
            lresult = GetClassName(hWnd, lpClassName, nMaxCount)
            Debug.Print("Window: " & sInput)
            Debug.Print("Class name: " & VB.Left(lpClassName, lresult))
    
        End Sub

  7. #7

    Thread Starter
    Lively Member
    Join Date
    Feb 2010
    Posts
    120

    Re: Active

    Anyone???
    Please

  8. #8
    King of sapila
    Join Date
    Oct 2006
    Location
    Greece
    Posts
    6,763

    Re: Active

    Did you ready my post?
    SetForegroundWindow
    ἄνδρα μοι ἔννεπε, μοῦσα, πολύτροπον, ὃς μάλα πολλὰ
    πλάγχθη, ἐπεὶ Τροίης ἱερὸν πτολίεθρον ἔπερσεν·

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