Link to home
Start Free TrialLog in
Avatar of jcwiatr
jcwiatrFlag for Australia

asked on

VB6.0, get the handle of an activex control on a form

Hello,

I have a form with an ActiveX control on it for a html editor window.  The activex control does not have an inbuilt hWnd property.

How do I find the handle of thso control so I can pass it to a spellchecker etc that requires the handle.

Code samples would be appreciated.

Thank-you.
Avatar of SiddharthRout
SiddharthRout
Flag of India image

Use FindWindow API to get the hwnd of the form and then either use FindwindowEx API or EnumWindows API to get the hwnd of the activex control.

If you are unable to do it then upload the form.

Sid

ps: If you are an API fan like me, then I would suggest you to bookmark this page :)

http://allapi.mentalis.org/agnet/apiguide.shtml
Avatar of aikimark
have you tried iterating through the CONTROLS collection?  If not mistaken, most controls should have an hwnd property.
Dim ctlThing As Control
For Each ctlThing In Me.Controls
  If ctlThing.Name = "the activex control you are seeking" Then
    Debug.Print ctlThing.Name, ctlThing.hWnd
  End If
Next

Open in new window

Avatar of jcwiatr

ASKER

hi aikimark - sounds easy - on testing the statement -
For Each ctlThing In Me.Controls

generates an error on me.controls..

method or data method not found
Avatar of jcwiatr

ASKER

aikimark, my mistake, i got it working and am getting the name of the control but when I add, ctlThing.hwnd I am getting the error Object does not support this property or method.  This makes sense I guess given there is no internal hWnd for this control.  I will give the API calls a go.
Can you upload your userform?

Sid
Also what type of control is it?

Sid
Avatar of jcwiatr

ASKER

just a basic form at this stage with an ActiveX control pinedit.ocx which is a html editor control.  I need the handle so I can bind a spell checker to it.

I have uploaded the form and control.  The file pinedit.txt in the archive needs to be renamed to pinedit.ocx and registerd.

Cheers. Form1.zip
ASKER CERTIFIED SOLUTION
Avatar of SiddharthRout
SiddharthRout
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I wonder if the ActiveX control is merely a container and might not be capable of handling messages, so doesn't have hWnd.
Yeah, seems like it is. It definitely has IE in it.

Sid
Avatar of jcwiatr

ASKER

Thanks guys. I think you are right about the container.  Points awarded based on code to get the handle.  But I dont think i will be able to bind our spellchecker to it because of its internals.
Thanks for all the input.