LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,726
Default Window Class of UserForm controls

Here is a way to get the hWnd of userfcorm controls.

First create a class, I call it clsHWnd, with this simple code

Option Explicit

Public Name As String
Public hWnd As Long

Then in the userform, declare a couple of APIs and a collection

Private Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Private Declare Function GetFocus Lib "user32" () As Long

Private ListBoxCollection As Collection

and load it in the initialize event; add this

Private Sub Userform_Initialize()
Dim ctl As msforms.Control
Dim listHWnd As clshWnd
Dim meHWnd As Long
Dim res As Long

meHWnd = FindWindow("ThunderDFrame", Me.Caption)
If meHWnd = 0 Then
Exit Sub
End If

Set ListBoxCollection = New Collection
For Each ctl In UserForm1.Controls
ctl.SetFocus
Set listHWnd = New clshWnd
listHWnd.hWnd = GetFocus
listHWnd.Name = ctl.Name
ListBoxCollection.Add Item:=listHWnd, Key:=listHWnd.Name
Next ctl

End Sub

You can just get hWnd from the collection, like so

MsgBox ListBoxCollection("ListBox1").hWnd

--

HTH

Bob Phillips

(replace xxxx in the email address with gmail if mailing direct)

"Martin" wrote in message
...
Can anyone tell me the API Window Class of controls in a userform? Or,

even
better, point me to a definitive list of the window classes in MS Office?

I'm trying to find a way to to identify the hWnd of the active control

(not
easy in VBA) so I can use context sensitive help.



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
putting often-used combinations of controls in a class NickHK Excel Programming 0 December 4th 06 04:15 AM
Duplicated code window and userform window problem Zhu Excel Programming 3 November 8th 06 05:09 AM
IS 'RANGE WINDOW CLASS' AVAILABLE ? halim Excel Programming 1 July 15th 06 06:58 AM
IS 'RANGE WINDOW CLASS' AVAILABLE ? halim Excel Programming 1 July 15th 06 06:46 AM
Disable app window controls JC[_7_] Excel Programming 0 November 25th 03 09:52 PM


All times are GMT +1. The time now is 10:41 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"