Handles to Windows & Device Contexts


DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: Handles to Windows & Device Contexts

  1. #1
    Roger Aikin Guest

    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.)



  2. #2
    Mattias Sjögren Guest

    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/

  3. #3
    Rob Teixeira Guest

    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/



  4. #4
    Cali LaFollett Guest

    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



  5. #5
    Paul Mc Guest

    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
  •  
HTML5 Development Center
 
 
FAQ
Latest Articles
Java
.NET
XML
Database
Enterprise
Questions? Contact us.
C++
Web Development
Wireless
Latest Tips
Open Source


   Development Centers

   -- Android Development Center
   -- Cloud Development Project Center
   -- HTML5 Development Center
   -- Windows Mobile Development Center