Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

I would like to learn about handles (hWnd) I know nothing about it and would like to hear if anyone knows of any papers that would help me get started.

 

Thanks.

  • *Experts*
Posted

The object doesn't necessarily need to be on the screen. It's the

pointer to an object that is loaded into memory; it can be a button,

a form; anything that Windows classifies as a "window" will have

an hWnd (a Window Handle, the Handle property in .NET).

 

There isn't as much need to use it in .NET, but it is still required for

many APIs for which there are no .NET replacements.

Posted

Ok, thanks for your help.

 

>> Heiko: glad you lot aren't supporting that bloody war. It's nice to see that someone has the balls to stand up to the US.

Posted
VolteFace - that's what I thought, but when I try to use the GetWindow API call to get the child windows of a form I get nothing returned, even though that form has buttons and textboxes on it.

TT

(*_*)

 

There are 10 types of people in this world;

those that understand binary and those that don't.

  • *Experts*
Posted

I believe the API you want is [api]EnumChildWindows[/api]. However,

I don't know how to make API callbacks work in .NET, if they are not

the same way as in VB6. You should be able to get the information

you need from AllAPI (linked above) and MSDN.

  • *Gurus*
Posted

Public Delegate Function CallBack( _
   ByVal hwnd As Integer, _
   ByVal lParam As IntPtr) As Boolean

Public Declare Function EnumChildWindows Lib "user32" ( _
   ByVal hwnd As Integer, _
   ByVal lpEnumFunc As CallBack, _
   ByVal lParam As Integer) As Integer

Public Shared Function ReceiveWindowHandles(ByVal hwnd As Integer, ByVal lParam As IntPtr) As Boolean
   'Receive handles here
End Function

'Call EnumChildWindows as such:
EnumChildWindows(Me.Handle.ToInt32, AddressOf Me.ReceiveWindowHandles, 0)

 

Note: I used integers above instead of .NET's IntPtr type for the window handles. Either way, it works fine, as IntPtrs will simply be converted into 32-bit values anyway. Also, most of what's above is off the top of my head, so don't sue me if it doesn't work perfectly.

Posted
Thanks Derek - I'll have a play with that over the weekend. I don't understand how you can use a function as a parameter type like that but I'll take your word for it. :)

TT

(*_*)

 

There are 10 types of people in this world;

those that understand binary and those that don't.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...