-
Handles to Windows & Device Contexts
Anyone know how to get the handle for a window or a device context now,
given a form or control? (VB.NET Beta 2)
--
Roger Aikin
roger_aikin@nospamplease.fuse.net
(Remove the 'nospamplease.' for real address.)
-
Re: Handles to Windows & Device Contexts
Roger,
>Anyone know how to get the handle for a window or a device context now,
>given a form or control?
The control's Handle property will give you the window handle (HWND).
To get a HDC, do something like this
Dim gr As Graphics
Dim hdc As IntPtr
gr = YourControl.CreateGraphics()
hdc = gr.GetHdc()
....
gr.ReleaseHdc(hdc)
gr.Dispose()
Mattias
===
Mattias Sjögren (VB MVP)
mattias @ mvps.org
http://www.msjogren.net/dotnet/
-
Re: Handles to Windows & Device Contexts
Just an FYI:
The Handle property doesn't show in intellisense depending on your environment
settings. If you don't see it, go to Tools->Options, and then look in the
Text Editor\All Languages or Text Editor\Basic folder and uncheck the Hide
Advanced Members option.
-Rob
Mattias Sjögren <mattias.dont.want.spam@mvps.org> wrote:
>Roger,
>
>>Anyone know how to get the handle for a window or a device context now,
>>given a form or control?
>
>The control's Handle property will give you the window handle (HWND).
>
>To get a HDC, do something like this
>
>Dim gr As Graphics
>Dim hdc As IntPtr
>gr = YourControl.CreateGraphics()
>hdc = gr.GetHdc()
>....
>gr.ReleaseHdc(hdc)
>gr.Dispose()
>
>
>Mattias
>
>===
>Mattias Sjögren (VB MVP)
>mattias @ mvps.org
>http://www.msjogren.net/dotnet/
-
Re: Handles to Windows & Device Contexts
> The Handle property doesn't show in intellisense depending on your
environment
> settings. If you don't see it, go to Tools->Options, and then look in the
> Text Editor\All Languages or Text Editor\Basic folder and uncheck the Hide
> Advanced Members option.
I was relatively surprised to see some of the various object's Item's that
are actually hidden by intellisense when the "Hide Advanced Members" is
checked. One would think that "Name" would be a relatively safe one to use
but I noticed that it is considered an Advanced Member in a lot of
scenarios.
--
Regards,
Cal
-
Re: Handles to Windows & Device Contexts
G'day Rob.
> If you don't see it, go to Tools->Options, and then look in the
>Text Editor\All Languages or Text Editor\Basic folder and uncheck the Hide
>Advanced Members option.
Great! Thanks, mate - this has solved some annoying inconsistencies in my
IDE...
Some of these little things are so easy to overlook....
Cheers,
Paul
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
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks