DevX Home    Today's Headlines   Articles Archive   Tip Bank   Forums   

Results 1 to 5 of 5

Thread: How to get HDC of StdPicture object?

  1. #1
    Val Guest

    How to get HDC of StdPicture object?


    Hi,

    I have StdPicture object in my VB program. How can I get its HDC to work
    with it using API?

    Thanks,

    Val

  2. #2
    Matthew Curland Guest

    Re: How to get HDC of StdPicture object?

    In windows, a bitmap can only be selected into one DC at a time. In general,
    the bitmap is only selected in when it is drawn to, but there are
    occasionally cases where it remains selected. The question of getting the
    HDC from the StdPicture object then is actually a little misguided because
    you have two objects: the picture, and the device context. The two objects
    visit each other, but they are not married. In general, you will pass an hdc
    to the StdPicture object, not obtain one from it. You can get an hDC from a
    Form, UserControl, PictureBox, etc.

    If you're doing a lot of work with a StdPicture, you might want to use the
    IPicture interface (obtained through a Set statement) instead of Picture to
    operate on it. To see this interface in IntelliSense, make sure you have
    'OLE Automation' referenced in your project and 'Show Hidden Members'
    checked in the Object Browser context member'. For example, Render through
    IPicture actually works, but Render through Picture doesn't. Render is also
    a hassle because it uses HiMetric scale, which is a little awkward (the
    DrawItem sample in my book uses Render if you have that around and need a
    sample). There is also some MSDN explanation of my first paragraph for the
    IPicture methods (SelectPicture, CurDC, etc).

    -Matt

    >
    > Hi,
    >
    > I have StdPicture object in my VB program. How can I get its HDC to work
    > with it using API?
    >
    > Thanks,
    >
    > Val




  3. #3
    Matthew Curland Guest

    Re: How to get HDC of StdPicture object?

    In windows, a bitmap can only be selected into one DC at a time. In general,
    the bitmap is only selected in when it is drawn to, but there are
    occasionally cases where it remains selected. The question of getting the
    HDC from the StdPicture object then is actually a little misguided because
    you have two objects: the picture, and the device context. The two objects
    visit each other, but they are not married. In general, you will pass an hdc
    to the StdPicture object, not obtain one from it. You can get an hDC from a
    Form, UserControl, PictureBox, etc.

    If you're doing a lot of work with a StdPicture, you might want to use the
    IPicture interface (obtained through a Set statement) instead of Picture to
    operate on it. To see this interface in IntelliSense, make sure you have
    'OLE Automation' referenced in your project and 'Show Hidden Members'
    checked in the Object Browser context member'. For example, Render through
    IPicture actually works, but Render through Picture doesn't. Render is also
    a hassle because it uses HiMetric scale, which is a little awkward (the
    DrawItem sample in my book uses Render if you have that around and need a
    sample). There is also some MSDN explanation of my first paragraph for the
    IPicture methods (SelectPicture, CurDC, etc).

    -Matt

    >
    > Hi,
    >
    > I have StdPicture object in my VB program. How can I get its HDC to work
    > with it using API?
    >
    > Thanks,
    >
    > Val




  4. #4
    Karl E. Peterson Guest

    Re: How to get HDC of StdPicture object?

    Hi Val --

    > I have StdPicture object in my VB program. How can I get its HDC to work
    > with it using API?


    Like Matt said, you don't. There are, nonetheless, lots of times when it'd be nice
    to! See the MemoryDC.zip and CustomBlt.zip samples on my site for classes that fake
    this capability for you.

    Later... Karl
    --
    http://www.mvps.org/vb



  5. #5
    Karl E. Peterson Guest

    Re: How to get HDC of StdPicture object?

    Hi Val --

    > I have StdPicture object in my VB program. How can I get its HDC to work
    > with it using API?


    Like Matt said, you don't. There are, nonetheless, lots of times when it'd be nice
    to! See the MemoryDC.zip and CustomBlt.zip samples on my site for classes that fake
    this capability for you.

    Later... Karl
    --
    http://www.mvps.org/vb



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