Results 1 to 10 of 10

Thread: Window class name "afxwnd42s"

  1. #1

    Thread Starter
    Junior Member
    Join Date
    Dec 2004
    Posts
    26

    Window class name "afxwnd42s"

    Parent Win class name is "#32770" and several buttons' class names are "afxwnd42s" (the only thing differentiating these buttons are the text). Anyone ever been in this situation? I just want to get the text of the buttons for now. Thanks

  2. #2
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Window class name "afxwnd42s"

    You should be able to do a FindWindow for the dialog window #32770. Then do a FindWindowEx passing
    the buttons classname and caption. Then you will have the handle to the button.
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  3. #3

    Thread Starter
    Junior Member
    Join Date
    Dec 2004
    Posts
    26

    Re: Window class name "afxwnd42s"

    I'm having trouble finding the parent window, since it's one of those funky #32770 class names. My API Spy says the parent is returning a text, but doesn't have a parent class name or handle.

  4. #4
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Window class name "afxwnd42s"

    Which Spy utility are you using? I only have M$ Spy++. If your getting the #32770 window, it should have a caption title?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  5. #5
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171

    Re: Window class name "afxwnd42s"

    A useful tool is the API Spy at www.patorjk.com


    Has someone helped you? Then you can Rate their helpful post.

  6. #6
    Admodistrator |2eM!x's Avatar
    Join Date
    Jan 2005
    Posts
    3,900

    Re: Window class name "afxwnd42s"

    here, i think this will help you find the form name easier:
    VB Code:
    1. Option Explicit
    2.  
    3. 'Functions, constants and types for the hook
    4. Private Declare Function SetWindowsHookEx Lib "user32" Alias "SetWindowsHookExA" ( _
    5.     ByVal idHook As Long, _
    6.     ByVal lpfn As Long, _
    7.     ByVal hmod As Long, _
    8.     ByVal dwThreadId As Long _
    9. ) As Long
    10.  
    11. Private Declare Function UnhookWindowsHookEx Lib "user32" ( _
    12.     ByVal hHook As Long _
    13. ) As Long
    14.  
    15. Private Declare Function CallNextHookEx Lib "user32" ( _
    16.     ByVal hHook As Long, _
    17.     ByVal ncode As Long, _
    18.     ByVal wParam As Long, _
    19.     lParam As Any _
    20. ) As Long
    21.  
    22. Public Const WH_MOUSE_LL = 14
    23.  
    24. Public Type POINTAPI
    25.         x As Long
    26.         y As Long
    27. End Type
    28.  
    29. Public Type MSLLHOOKSTRUCT
    30.     pt As POINTAPI
    31.     mouseData As Long
    32.     flags As Long
    33.     time As Long
    34.     dwExtraInfo As Long
    35. End Type
    36.  
    37. Private hHook As Long
    38. Public IsHooked As Boolean
    39.  
    40. 'functions for getting windows properties
    41. Private Declare Function GetWindowText Lib "user32" Alias "GetWindowTextA" ( _
    42.     ByVal hwnd As Long, _
    43.     ByVal lpString As String, _
    44.     ByVal cch As Long _
    45. ) As Long
    46.  
    47. Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" ( _
    48.     ByVal hwnd As Long, _
    49.     ByVal lpClassName As String, _
    50.     ByVal nMaxCount As Long _
    51. ) As Long
    52.  
    53. Private Declare Function WindowFromPoint Lib "user32" ( _
    54.     ByVal xPoint As Long, _
    55.     ByVal yPoint As Long _
    56. ) As Long
    57.  
    58. Sub GetWindowData(x As Long, y As Long)
    59.  Dim hWndFrm As Long
    60.  Dim lpClassName As String, lpString As String
    61.  lpClassName = Space(100)
    62.  lpString = Space(100)
    63.  'get handle to window
    64.  hWndFrm = WindowFromPoint(CLng(x), CLng(y))
    65.  If hWndFrm = 0 Then Exit Sub
    66.  'get window text (caption)
    67.  Call GetWindowText(hWndFrm, lpString, Len(lpString))
    68.  'get window class name
    69.  Call GetClassName(hWndFrm, lpClassName, Len(lpClassName))
    70.  
    71.  With Form1
    72.   .txthandle = Hex(hWndFrm)
    73.   .txtCaption = lpString
    74.   .txtClassName = lpClassName
    75.  End With
    76. End Sub
    77.  
    78. Public Sub SetMouseHook()
    79.     If IsHooked Then
    80.         MsgBox "Don't hook the MOUSE_LL hook twice or you'll be sorry."
    81.     Else
    82.         'This has to be set up as a system-wide hook
    83.         hHook = SetWindowsHookEx(WH_MOUSE_LL, AddressOf MouseProc, App.hInstance, 0)
    84.         IsHooked = True
    85.     End If
    86. End Sub
    87.  
    88. Public Sub RemoveMouseHook()
    89.     Dim temp As Long
    90.     temp = UnhookWindowsHookEx(hHook)
    91.     IsHooked = False
    92. End Sub
    93.  
    94.  
    95. Public Function MouseProc(ByVal uCode As Long, ByVal wParam As Long, lParam As MSLLHOOKSTRUCT) As Long
    96.     If uCode >= 0 Then
    97.         Call GetWindowData(lParam.pt.x, lParam.pt.y)
    98.     End If
    99.                 MouseProc = CallNextHookEx(hHook, uCode, wParam, lParam)
    100. End Function
    101.  
    102.  
    103.  
    104. Added this to a form:
    105.  
    106. visual basic code:Option Explicit
    107.  
    108. 'Always on top stuff
    109. Private Const HWND_TOPMOST = -1
    110. Private Const SWP_NOSIZE = &H1
    111. Private Const SWP_NOMOVE = &H2
    112. Private Const SWP_NOACTIVATE = &H10
    113. Private Const SWP_SHOWWINDOW = &H40
    114.  
    115. Private Declare Sub SetWindowPos Lib "user32" ( _
    116.     ByVal hwnd As Long, _
    117.     ByVal hWndInsertAfter As Long, _
    118.     ByVal x As Long, _
    119.     ByVal y As Long, _
    120.     ByVal cx As Long, _
    121.     ByVal cy As Long, _
    122.     ByVal wFlags As Long _
    123. )
    124.  
    125. Private Sub cmdStart_Click()
    126. 'make window always on top
    127.  SetWindowPos Me.hwnd, HWND_TOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE Or _
    128.     SWP_SHOWWINDOW Or SWP_NOMOVE Or SWP_NOSIZE
    129.  'set the system-wide low level mouse hook
    130.  Call SetMouseHook
    131. End Sub
    132.  
    133. Private Sub Form_QueryUnload(Cancel As Integer, UnloadMode As Integer)
    134.  Call RemoveMouseHook
    135. End Sub

    you need three textboxes named txthandle, txtCaption, txtClassName
    and a cmd button named cmdStart
    --
    Now, im having a similar problem. On the form there are 2 textboxes with teh same classname and caption, so i dont know how to send a message to one of them (it wont work just sending it)

  7. #7

    Thread Starter
    Junior Member
    Join Date
    Dec 2004
    Posts
    26

    Re: Window class name "afxwnd42s"

    Quote Originally Posted by RobDog888
    Which Spy utility are you using? I only have M$ Spy++. If your getting the #32770 window, it should have a caption title?
    I'm using PatorJK's API Spy. Weird thing is I can "Apply code" with it and it will click a button or whatever but the code itself is useless.

  8. #8
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Window class name "afxwnd42s"

    Can you post your code?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

  9. #9

    Thread Starter
    Junior Member
    Join Date
    Dec 2004
    Posts
    26

    Re: Window class name "afxwnd42s"

    Handle = FindWindow("#32770", vbNullString)
    B1 = FindWindowEx(Handle, 0&, "afxwnd42s", vbNullString)
    B2 = FindWindowEx(B1, 0&, "afxwnd42s", vbNullString)
    B3 = FindWindowEx(B2, 0&, "afxwnd42s", vbNullString)
    afxwnds = FindWindowEx(B3, 0&, "afxwnd42s", vbNullString)
    Call SendMessageLong(afxwnds, WM_LBUTTONDOWN, 0&, 0&)
    Call SendMessageLong(afxwnds, WM_LBUTTONUP, 0&, 0&)

  10. #10
    Ex-Super Mod RobDog888's Avatar
    Join Date
    Apr 2001
    Location
    LA, Calif. Raiders #1 AKA:Gangsta Yoda™
    Posts
    60,709

    Re: Window class name "afxwnd42s"

    You can also try using the PostMessage API with the BM_Click message instead of the SendMessageLong.
    Why not add the window caption in the parameters for the FindWindowEx? If they are buttons then they
    wont have any childern windows?

    Is that correct for the window class for the buttons (afxwnd42s)???
    Shouldnt the buttons class be "Button"?
    VB/Office Guru™ (AKA: Gangsta Yoda®)
    I dont answer coding questions via PM. Please post a thread in the appropriate forum.

    Microsoft MVP 2006-2011
    Office Development FAQ (C#, VB.NET, VB 6, VBA)
    Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
    If a post has helped you then Please Rate it!
    Reps & Rating PostsVS.NET on Vista Multiple .NET Framework Versions Office Primary Interop AssembliesVB/Office Guru™ Word SpellChecker™.NETVB/Office Guru™ Word SpellChecker™ VB6VB.NET Attributes Ex.Outlook Global Address ListAPI Viewer utility.NET API Viewer Utility
    System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6

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