Solved

Print.Debug Whnd....

Posted on 2008-10-21
5
141 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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
Familiarize people with the process of utilizing SQL Server views 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 Access…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.

947 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

18 Experts available now in Live!

Get 1:1 Help Now