CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4

Thread: SAKYA

  1. #1
    Join Date
    Jun 2000
    Posts
    104

    SAKYA

    How can i get the handles of all the open windows?
    Thanks in advance to any replies.


  2. #2
    Join Date
    Jun 2000
    Location
    Nepal
    Posts
    108

    Re: SAKYA

    EnumWindows()


  3. #3
    Join Date
    May 2000
    Location
    New York, NY, USA
    Posts
    2,878

    Re: SAKYA

    Here the code how to find window by part of it caption. Use wild card and it will find all the open windows

    '---Bas module code------


    Private Declare Function EnumWindows& Lib "user32" (ByVal lpEnumFunc As Long, ByVal lParam As Long)
    Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" (ByVal hwnd As Long, ByVal lpString As String, ByVal cch As Long) As Long
    Private Declare Function IsWindowVisible& Lib "user32" (ByVal hwnd As Long)
    Private Declare Function GetParent& Lib "user32" (ByVal hwnd As Long)
    Dim sPattern As String, hFind As Long


    Function EnumWinProc(ByVal hwnd As Long, ByVal lParam As Long) As Long
    Dim k As Long, sName As String


    If IsWindowVisible(hwnd) And GetParent(hwnd) = 0 Then
    sName = Space$(128)
    k = GetWindowText(hwnd, sName, 128)


    If k > 0 Then
    sName = Left$(sName, k)
    If lParam = 0 Then sName = UCase(sName)


    If sName Like sPattern Then
    hFind = hwnd


    EnumWinProc = 0
    Exit Function
    End If
    End If
    End If


    EnumWinProc = 1
    End Function


    Public Function FindWindowWild(sWild As String, Optional bMatchCase As Boolean = True) As Long
    sPattern = sWild
    If Not bMatchCase Then sPattern = UCase(sPattern)


    EnumWindows AddressOf EnumWinProc, bMatchCase
    FindWindowWild = hFind
    End Function


    '----Using (Form code)----


    Private Sub Command1_Click()
    Debug.Print FindWindowWild("*Mi??OSoFt In[s-u]ernet*", False)
    End Sub



    Iouri Boutchkine
    [email protected]
    Iouri Boutchkine
    [email protected]

  4. #4
    Join Date
    Jul 2000
    Location
    Milano, Italy
    Posts
    7,726

    Re: SAKYA

    Excelent!

    Special thanks to Lothar "the Great" Haensler. Come back soon, you Guru.
    ...at present time, using mainly Net 4.0, Vs 2010



    Special thanks to Lothar "the Great" Haensler, Chris Eastwood , dr_Michael, ClearCode, Iouri and
    all the other wonderful people who made and make Codeguru a great place.
    Come back soon, you Gurus.

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

Featured