sharpe Posted February 12, 2003 Posted February 12, 2003 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. Quote
Heiko Posted February 12, 2003 Posted February 12, 2003 Basically, a Handle is a pointer to an object thats on the screen. With that knowledge I have come along for about 6 yrs now :-) Quote .nerd
*Experts* Volte Posted February 12, 2003 *Experts* Posted February 12, 2003 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. Quote
sharpe Posted February 13, 2003 Author Posted February 13, 2003 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. Quote
TechnoTone Posted February 13, 2003 Posted February 13, 2003 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. Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
*Experts* Volte Posted February 13, 2003 *Experts* Posted February 13, 2003 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. Quote
*Gurus* Derek Stone Posted February 14, 2003 *Gurus* Posted February 14, 2003 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. Quote Posting Guidelines
*Experts* Volte Posted February 14, 2003 *Experts* Posted February 14, 2003 Great. Thanks for that Derek. :) Quote
*Gurus* Derek Stone Posted February 14, 2003 *Gurus* Posted February 14, 2003 In case anyone is interested you can learn more about platform invoke and the Win32 API in the following article: http://www.elitevb.com/content/01,0075,01/ Quote Posting Guidelines
TechnoTone Posted February 14, 2003 Posted February 14, 2003 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. :) Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
*Gurus* divil Posted February 14, 2003 *Gurus* Posted February 14, 2003 Don't take his word for it ;) [mshelp]ms-help://MS.VSCC/MS.MSDNVS/cpguide/html/cpconusingcallbackfunctions.htm[/mshelp] Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
TechnoTone Posted February 14, 2003 Posted February 14, 2003 That link doesn't work Divil. Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
*Gurus* divil Posted February 14, 2003 *Gurus* Posted February 14, 2003 Click on the little caret at the end of the link to be taken to the online MSDN version of it. Quote MVP, Visual Developer - .NET Now you see why evil will always triumph - because good is dumb. My free .NET Windows Forms Controls and Articles
TechnoTone Posted February 14, 2003 Posted February 14, 2003 Thanks. That one is going straight into my ".NET Tips" library. Quote TT (*_*) There are 10 types of people in this world; those that understand binary and those that don't.
Recommended Posts