Board index » Visual Studio » Using DC with stdpicture

Using DC with stdpicture

Visual Studio105
Hello,



I was wondering whether it is possible to convert a DC that i've

created from "CreateCompatibleBitmap" which is stored as a Long into a

Stdpicture, like used in Picture1.PaintPicture as I obvious have

"drawn" my picture into a DC but then might want to freedraw it with

something like PaintPicture instead of using bitblt



Is this possible??



Thanks



David


-
 

Re:Using DC with stdpicture

Quote
I was wondering whether it is possible to convert a DC that i've

created from "CreateCompatibleBitmap" which is stored as a Long into a

Stdpicture, like used in Picture1.PaintPicture as I obvious have

"drawn" my picture into a DC but then might want to freedraw it with

something like PaintPicture instead of using bitblt



CreateCompatibleBitmap() returns an HBITMAP rather than an HDC, however you may be using CreateCompatibleDC() to create

your DC if that's what you're working from.

The StdPicture object simply wraps a GDI object, in the case of Bitmaps it will wrap a HBITMAP and optionally take

ownership of it (i.e. whether you or OLE will be terminating the GDI resource when the object is destroyed.) You can

use the OLEPicture library on my site to do this for you, you simply pass it your HBITMAP and it returns you the

StdPicture object.

If you are working from a DC and don't have the HBITMAP handle, then you should select a new Bitmap into your DC using

SelectObject(), which will return the previously selected Bitmap handle.

Hope this helps,



Mike





- Microsoft Visual Basic MVP -

E-Mail: EDais@mvps.org

WWW: EDais.mvps.org/





-