|
-
Jan 3rd, 2002, 02:32 PM
#1
Thread Starter
New Member
Missing: control handles and function addresses
Currently on the .NET milk carton are control handles and function addresses. I feel as if I've lost two children.
I have started using VB.NET, and I can not find how to get control handles and function addresses. Does anybody know where they are located?
Johnny's Quest for the Control Handles
When attempting some API calls, I came across being unable to get a control's handle first. I had a button on my form (let's just call it btnButton), and tried to access it's hWnd property from code, but discovered that there is no hWnd property for controls or the form anymore. I (after a ridiculous amount of research) found Handle(), which gives me the hWnd of a window, which apparently has replaced Me.hWnd. So, windows handles are still retrievable, but where are control handles?
After ignorantly pressing F2 a few times as a result of my VB6 brain, I eventually found the Object Browser through the menu. I had looked in some .NET documentation just before, and found that hWnd had been replaced with "Handle", so I searched for "Handle". Immediately, I found the property under [B]System.Windows.Forms.Control[\B]. This property is "Public NotOverridable ReadOnly Property". I also found that the button class inherits the buttonbase class which inherits the System.Windows.Forms.Control class. In fact, all usual controls inherit the System.Windows.Forms.Control class! But no matter what I put on the form, I could not find a handle property. I researched some more, found an article that claimed a picturebox had a easy-breezy handle property, found out that it actually wasn't true, stared blankly at the screen, and exploded. Why is old friend Object Explorer lying to me? Is this some sort of a bug?
More importantly, In VB6, getting a control handle was as simple as saying btnButton.hWnd. What is VB.NET's equivalent?
Johnny's Quest for Function addresses
In order to try to catch a system-wide keypress event, I figured the only way was to use subclassing. The APIs I am trying to use require a callback function pointer. In VB6, I could say "AddressOf MyCallbackFunction", but now I'm apparently required to use delegates. I was able to create a delegate for my callback function, but that still isn't what the API is asking for anyway. Any documentation I find on delegates only deals with linking events together and such, not for passing function addresses to APIs so that they may function as callbacks. There may be a delegate property that I'm not aware of. Has anybody found out how to get function addresses in VB.NET?
--Johnny
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|