Solved

Print.Debug Whnd....

Posted on 2008-10-21
5
138 Views
Last Modified: 2013-11-27
From Access 2003 environment, I want to execute some code to

Print.Debug Whnd

for all the window handles currently open?

Question: What is the code to do this?

Thank you
0
Comment
Question by:Mike Eghtebas
  • 3
  • 2
5 Comments
 
LVL 75

Accepted Solution

by:
DatabaseMX (Joe Anderson - Access MVP) earned 500 total points
ID: 22769922
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 22770759
MX,

The code in this link didn't help. But, I was able to locate the solution in that site:

see:

                Debug.Print "Whnd = " & lngx & ", Class = " & fGetClassName(lngx),
                Debug.Print "Caption = " & fGetCaption(lngx)

Private Declare Function apiGetClassName Lib "user32" Alias _

                "GetClassNameA" (ByVal Hwnd As Long, _

                ByVal lpClassname As String, _

                ByVal nMaxCount As Long) As Long

Private Declare Function apiGetDesktopWindow Lib "user32" Alias _

                "GetDesktopWindow" () As Long

Private Declare Function apiGetWindow Lib "user32" Alias _

                "GetWindow" (ByVal Hwnd As Long, _

                ByVal wCmd As Long) As Long

Private Declare Function apiGetWindowLong Lib "user32" Alias _

                "GetWindowLongA" (ByVal Hwnd As Long, ByVal _

                nIndex As Long) As Long

Private Declare Function apiGetWindowText Lib "user32" Alias _

                "GetWindowTextA" (ByVal Hwnd As Long, ByVal _

                lpString As String, ByVal aint As Long) As Long

Private Const mcGWCHILD = 5

Private Const mcGWHWNDNEXT = 2

Private Const mcGWLSTYLE = (-16)

Private Const mcWSVISIBLE = &H10000000

Private Const mconMAXLEN = 255
 

Function fEnumWindows()

Dim lngx As Long, lngLen As Long

Dim lngStyle As Long, strCaption As String

    

    lngx = apiGetDesktopWindow()

    'Return the first child to Desktop

    lngx = apiGetWindow(lngx, mcGWCHILD)

    

    Do While Not lngx = 0

        strCaption = fGetCaption(lngx)

        If Len(strCaption) > 0 Then

            lngStyle = apiGetWindowLong(lngx, mcGWLSTYLE)

            'enum visible windows only

            If lngStyle And mcWSVISIBLE Then

                Debug.Print "Whnd = " & lngx & ", Class = " & fGetClassName(lngx),

                Debug.Print "Caption = " & fGetCaption(lngx)

            End If

        End If

        lngx = apiGetWindow(lngx, mcGWHWNDNEXT)

    Loop

End Function

Private Function fGetClassName(Hwnd As Long) As String

    Dim strBuffer As String

    Dim intCount As Integer

   

    strBuffer = String$(mconMAXLEN - 1, 0)

    intCount = apiGetClassName(Hwnd, strBuffer, mconMAXLEN)

    If intCount > 0 Then

        fGetClassName = Left$(strBuffer, intCount)

    End If

End Function
 

Private Function fGetCaption(Hwnd As Long) As String

    Dim strBuffer As String

    Dim intCount As Integer
 

    strBuffer = String$(mconMAXLEN - 1, 0)

    intCount = apiGetWindowText(Hwnd, strBuffer, mconMAXLEN)

    If intCount > 0 Then

        fGetCaption = Left$(strBuffer, intCount)

    End If

End Function

Open in new window

0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 22770775
Thank you.

Mike
0
 
LVL 75
ID: 22770818
Yes ... I guess I grabbed the wrong link.  Glad you found it.

What is the correct link?

mx
0
 
LVL 33

Author Comment

by:Mike Eghtebas
ID: 22770836
0

Featured Post

Threat Intelligence Starter Resources

Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

Join & Write a Comment

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now