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.)
Printable View
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.)
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/
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/
> 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
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