"NickHK" wrote in message
You
also need the help file entered in ToolsVBA Project PropertiesHelp File
Name.
I tend not to use the HelpFile property because its path must be absolute.
Application.Help doesn't support relative paths. If you distribute the
workbook or add-in to a user and he stores it in a folder with a different
name, ThisWorkbook.VBProject.HelpFile will point to the wrong location.
I usually do any one of three things (I generally provide a real Help File
only for add-ins):
1) Set the HelpFile property to an unqualified file name, mandate that the
help file reside in the same directory as the XLA, and call it with
Application.Help ThisWorkbook.Path & Application.PathSeparator & _
ThisWorkbook.VBProject.HelpFile
2) Store the location of help file in the Registry.
Dim HelpFile As String
HelpFile = GetRegistry("HelpFile")
Application.Help HelpFile
where GetRegistry is part of a library of registry-related functions I
wrote to manage registry entries for an application.
3) Use the HTMLHelp API function with the HelpFile name stored in the
Registry. Using the HTMLHelp API is by far the preferred method since you
can control what is displayed.
--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com
(email address is on the web site)
"NickHK" wrote in message
...
Bob,
With your code, I get the same the same handle for all standard controls
(except a list view, etc) as that returned for the form's client area
using;
ContHwnd = FindWindowEx(FindWindow("ThunderDFrame", Me.Caption), 0, "F3
Server 02950000", vbNullString)
which in a way seems correct, as I understodd these controls to be
windowless, drawn on the form.
Martin,
Here's an old MS article on showing Tool Tips. Not what you want, but..
http://support.microsoft.com/default...b;en-us;119991
Otherwise, each control has the HelpContextID property that you can set.
You
also need the help file entered in ToolsVBA Project PropertiesHelp File
Name.
Ivan's site has a Excel/VBA equivalent of Spy++, which will tell all you
need, if it is exposed.
http://www.xcelfiles.com/API_06.html
NickHK
"Bob Phillips" wrote in message
...
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.