Multiple call od EnumChildWindows

E

Emilio

Good morning to everyone,

I've tested this "format" od this code to enumerate some controls in a
window and it works fine.

Private Delegate Function EnumChildProcDelegate _
(ByVal hWnd As IntPtr, _
ByVal lParam As Integer) As Boolean

Private Declare Function EnumChildWindows Lib "user32" _
(ByVal hWndParent As IntPtr, _
ByVal lpEnumFunc As EnumChildProcDelegate, _
ByVal lParam As Integer) As Boolean

.......... code ...... and, finally

EnumChildWindows(Me.Handle, AddressOf EnumChildProc, 0)


but what if I would declare more than one of enumeratione Function ?
For example, how can I do something like this:

Private Delegate Function EnumChildFIRSTDelegate (ByVal ....,
ByVal ....) As Boolean
Private Delegate Function EnumChildSECONDDelegate (ByVal ....,
ByVal ....) As Boolean
Private Delegate Function EnumChildTHIRDDelegate (ByVal ....,
ByVal ....) As Boolean

Private Declare Function EnumChildWindows Lib "user32" _
(ByVal ..., ByVal lpEnumFunc As EnumChildFIRSTDelegate,
ByVal ...) As Boolean

Private Declare Function EnumChildWindows Lib "user32" _
(ByVal ..., ByVal lpEnumFunc As EnumChildSECONDDelegate,
ByVal ...) As Boolean

Private Declare Function EnumChildWindows Lib "user32" _
(ByVal ..., ByVal lpEnumFunc As EnumChildTHIRDDelegate,
ByVal ...) As Boolean

.......... code ...... and, finally


EnumChildWindows(Me.Handle, AddressOf EnumChildFIRST, 0)
EnumChildWindows(Me.Handle, AddressOf EnumChildSECOND, 0)
EnumChildWindows(Me.Handle, AddressOf EnumChildTHIRD, 0)


Hoping my question is clear, I really thank you.
Emilio.
 
H

Herfried K. Wagner [MVP]

Emilio said:
I've tested this "format" od this code to enumerate some controls in a
window and it works fine.

Private Delegate Function EnumChildProcDelegate _
(ByVal hWnd As IntPtr, _
ByVal lParam As Integer) As Boolean

Private Declare Function EnumChildWindows Lib "user32" _
(ByVal hWndParent As IntPtr, _
ByVal lpEnumFunc As EnumChildProcDelegate, _
ByVal lParam As Integer) As Boolean

......... code ...... and, finally

EnumChildWindows(Me.Handle, AddressOf EnumChildProc, 0)


but what if I would declare more than one of enumeratione Function ?
For example, how can I do something like this:

Private Delegate Function EnumChildFIRSTDelegate (ByVal ....,
ByVal ....) As Boolean
Private Delegate Function EnumChildSECONDDelegate (ByVal ....,
ByVal ....) As Boolean
Private Delegate Function EnumChildTHIRDDelegate (ByVal ....,
ByVal ....) As Boolean

Private Declare Function EnumChildWindows Lib "user32" _
(ByVal ..., ByVal lpEnumFunc As EnumChildFIRSTDelegate,
ByVal ...) As Boolean

Private Declare Function EnumChildWindows Lib "user32" _
(ByVal ..., ByVal lpEnumFunc As EnumChildSECONDDelegate,
ByVal ...) As Boolean

Private Declare Function EnumChildWindows Lib "user32" _
(ByVal ..., ByVal lpEnumFunc As EnumChildTHIRDDelegate,
ByVal ...) As Boolean

......... code ...... and, finally


EnumChildWindows(Me.Handle, AddressOf EnumChildFIRST, 0)
EnumChildWindows(Me.Handle, AddressOf EnumChildSECOND, 0)
EnumChildWindows(Me.Handle, AddressOf EnumChildTHIRD, 0)

Delegate types are just masks for function headers. The name of the
callback function does not necessarily need to be the same as the delegate
type's name. So you can keep a single delegate type in the sample above,
write callback functions which differ in their name and pass them to the
second parameter of 'EnumChildWindows' with 'AddressOf'.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top