Tags: api, call, control, excel, findwindow, handle, identifier, microsoft, msdn, msforms, object, return, software, thewindow, thunderdframe, tom, userform, vba, vbnullstring, win32

MSForms UserForm Control Identifier - Win32 API Call from VBA

On Microsoft » Microsoft Excel

2,389 words with 0 Comments; publish: Sat, 07 Jun 2008 22:11:00 GMT; (30662.50, « »)

Many thanks Tom,

FindWindow("ThunderDFrame", vbNullString) works just great to return the

window handle of the MSForms UserForm object. (As does GetActiveWindow() -

xl2003, WinXP Pro).

However, I'm still having some trouble obtaining the control identifier of

the relevant controls on that MSForms UserForm. (Maybe this might be what you

meant by 'windowless controls'?). GetDlgCtrlID is simply another Win32 API

function declared as follows:

Declare Function GetDlgCtrlID Lib "user32" (ByVal hWnd As Long) As Long

Where hWnd is the handle of the window (or control) for which you want the

control identifier returned. Works perfectly on Access and Windows Forms.

Logically enough, passing the window handle of an MSForms UserForm to

GetDlgCtrlID returns 0 (null) - it doesn't have a control identifier because

it is not a 'control'.

So what I need to do (if it is even possible, or unless there is another way

that you or one of the other gurus here can advise) is obtain the window

handle of each control on the MSForms UserForm that I want to add

context-sensitive help to so that I can pass that to GetDlgCtrlID and obtain

the control identifier to pass to HtmlHelp. (Phew!). Do MSForms userform

controls (ListBox, CommandButton etc.) also have class names (as for


I'm continuing to search and poke around, but any further assistance or tips

that you or anyone else here can provide *very* gratefully received.

Thanks again, Sean.

"Tom Ogilvy" wrote:

> the class name for the form is ThunderXFrame or ThunderDFrame depending on

> the version of Excel. So you can use findwindow with that. The MSforms 2.0

> controls are windowless controls, so I don't know if your GetDlgCtrlID API

> function will work or not since I don't know anything about it.

> --

> Regards,

> Tom Ogilvy


> "Sean Connolly" <Sean_Connolly(SpamAway).excel.todaysummary.com.auna.com.(DoNotSpam)> wrote in

> message news:019AF3E6-8CA2-4820-B066-9F8D0EC5752A.excel.todaysummary.com.microsoft.com...

> name

> UserForm

> the

> help

> Help

> of

> on

> to

> available,

> in

> spent

> methods

> know



All Comments

Leave a comment...