Results 1 to 3 of 3

Thread: For Each frm in Forms, with api?

  1. #1

    Thread Starter
    Member
    Join Date
    Jul 1999
    Location
    Oak Park, IL, USA
    Posts
    43

    Question For Each frm in Forms, with api?

    I need to use the API to do a loop through every form of an application, that my activex is sitting in.

    It is an mdi task bar style activex. I need to go through each form in the application its sitting in, and IF the form (window) is a MDI child, with the ShowInTaskBar set to true, then do something with it.

    Anyone have any code to do something like this?

  2. #2

    Thread Starter
    Member
    Join Date
    Jul 1999
    Location
    Oak Park, IL, USA
    Posts
    43

    solved it myself

    For anyone else that might want to know:

    Public Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWndParent As Long, _
    ByVal hwndChildAfter As Long, ByVal lpszClass As String, ByVal lpszWindow As String) As Long

    Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long

    Dim hwnd As Long
    Dim hWndStart As Long
    Dim hWndClient As Long
    Dim sClassName As String ' receives the name of the class
    Dim lLen As Long ' length of the string retrieved

    ' note, this is being done inside a usercontrol that will be
    ' placed on an mdi parent form. thats why we do the
    ' usercontrol.parent.hwnd. you can use whatever
    ' mdi parent form's hwnd you want.
    hWndClient = FindWindowEx(UserControl.Parent.hwnd, 0, "MDIClient", vbNullString)
    hwnd = FindWindowEx(hWndClient, 0, vbNullString, vbNullString)
    hWndStart = hwnd

    Do Until hwnd = 0
    If IsChild(hWndClient, hwnd) Then
    sClassName = Space(255)
    lLen = GetClassName(hwnd, sClassName, 255)
    sClassName = Trim(Left(sClassName, lLen))
    If sClassName = "ThunderFormDC" Then
    ' do whatever you want to the child form here.

    End If
    End If
    hwnd = FindWindowEx(hWndClient, hwnd, vbNullString, vbNullString)
    If hwnd = hWndStart Then
    Exit Do
    End If
    Loop

  3. #3

    Thread Starter
    Member
    Join Date
    Jul 1999
    Location
    Oak Park, IL, USA
    Posts
    43

    forgot this one

    Public Declare Function IsChild Lib "user32" (ByVal hWndParent As Long, ByVal hwnd As Long) As Long

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