Determine (ActiveX) ControlType by window handle 
Author Message
 Determine (ActiveX) ControlType by window handle

Hi people,

I want to know if it is possible to determine the type of control by it's
window handle. I know how to retrieve the window handle for the control, but
I need to find out what type of (ActiveX) control it is (eg. Treeview,
Listview, FlexGrid, ...)

Any ideas?

Sven De Bont



Sat, 08 May 2004 23:29:52 GMT  
 Determine (ActiveX) ControlType by window handle
On Tue, 20 Nov 2001 16:29:52 +0100, "Sven De Bont"

Quote:

>Hi people,

>I want to know if it is possible to determine the type of control by it's
>window handle. I know how to retrieve the window handle for the control, but
>I need to find out what type of (ActiveX) control it is (eg. Treeview,
>Listview, FlexGrid, ...)

>Any ideas?

>Sven De Bont

You could use the SetProp API function to add an identifier to each
control window when each of your forms initializes.  You could then
use the GetProp API function to retrieve the identifier.  Make sure
you delete the properties when you unload your forms.  For more info,
have a look at these functions in MSDN.

HTH,
Bryan
____________________________________________________________
New Vision Software            "When the going gets weird,"
Bryan Stafford                   "the weird turn pro."

Microsoft MVP-Visual Basic     Fear and Loathing in LasVegas



Sat, 08 May 2004 23:48:27 GMT  
 Determine (ActiveX) ControlType by window handle
Can you use Typeof? I'm not sure what your after but this
works

Private Function CtrlType(hWnd As Long) As String
    On Error Resume Next 'some controls do not have hWnd
    Dim Ctrl As Control
    For Each Ctrl In Controls
        If Ctrl.hWnd = hWnd Then
            If TypeOf Ctrl Is CommandButton Then
                CtrlType = "CommandButton"
            End If
        End If
    Next
End Function

Private Sub Command1_Click()
    Debug.Print CtrlType(Command1.hWnd)
End Sub

TypeName if even better:
debug.print TypeName(Command1)

HTH
-eric

Quote:
>-----Original Message-----
>Hi people,

>I want to know if it is possible to determine the type of
control by it's
>window handle. I know how to retrieve the window handle

for the control, but
Quote:
>I need to find out what type of (ActiveX) control it is
(eg. Treeview,
>Listview, FlexGrid, ...)

>Any ideas?

>Sven De Bont

>.



Sun, 09 May 2004 00:23:59 GMT  
 
 [ 3 post ] 

 Relevant Pages 

1. ActiveX control to handle mouseover event handling?

2. Window Handle based on Instance Handle???

3. How to Find a Window Handle Based on an Instance Handle

4. How to Find a Window Handle Based on an Instance Handle

5. error with controltype of a control on a form

6. How can I substitute ControlType property

7. Controltype in VB 5.0

8. Determining if Exe is running, window has closed down, window has opened

9. hWnd - Window Handle for hidden window

10. sendkeys to specific window / windows handle

11. Determining what Event is being handled

12. how to determine base address after using OpenProcess to get a handle to a ProcessID

 

 
Powered by phpBB® Forum Software