Hdc Fro StdPicture.Handle?

Hdc Fro StdPicture.Handle?

Post by Joel Paul » Wed, 21 Apr 1999 04:00:00



How can I get the HDC (Device Context Handle) from a HBitmap (Bitmap
Handle).

I need to get the HDC of a StdPicture and the only .Handle it has is a
bitmap handle...

Please help.

Thanks.

 _____________________
 JOEL PAULA
 "why he did not crane out to see
 what lay beneath was perhaps because
 the window was not made to open
 or because he could or would not open it."
 - Samuel Beckett - "stirrings still"

 
 
 

Hdc Fro StdPicture.Handle?

Post by BeeZ » Thu, 22 Apr 1999 04:00:00


Joel,

A bitmap musn't neccessarily be selected into a device context, so I
don't think you can do that. If you explain more about what you are
trying to, maybe someone can help you find another way to solve it.

Mattias

On Tue, 20 Apr 1999 23:58:29 +0100, "Joel Paula"


>How can I get the HDC (Device Context Handle) from a HBitmap (Bitmap
>Handle).

>I need to get the HDC of a StdPicture and the only .Handle it has is a
>bitmap handle...

>Please help.

>Thanks.

> _____________________
> JOEL PAULA
> "why he did not crane out to see
> what lay beneath was perhaps because
> the window was not made to open
> or because he could or would not open it."
> - Samuel Beckett - "stirrings still"

________________________________________________
Mattias "BeeZo" Sj?gren    Visual Basic f?r Alla


 
 
 

Hdc Fro StdPicture.Handle?

Post by Pieter Philippaert » Sat, 24 Apr 1999 04:00:00


You have to create your own hDC, and select the bitmap into that hdc, like
this:

Private Declare Function CreateCompatibleDC Lib "gdi32" (ByVal hdc As Long)
As Long
Private Declare Function SelectObject Lib "gdi32" (ByVal hdc As Long, ByVal
hObject As Long) As Long

    Dim MyPic As StdPicture, MyPicDC As Long
    Set MyPic = LoadPicture("myfile.bmp")
    MyPicDC = CreateCompatibleDC(0)
    SelectObject MyPicDC, MyPic.Handle

HTH,
Pieter Philippaerts
http://users.turboline.be/btl10148/


Quote:>How can I get the HDC (Device Context Handle) from a HBitmap (Bitmap
>Handle).

>I need to get the HDC of a StdPicture and the only .Handle it has is a
>bitmap handle...

>Please help.

>Thanks.

 
 
 

1. Replace HDC (devicecontext handle) with Bitmap.Canvas.Handle ??

I use WinAPI function DrawText to render some text.
DrawText requires a HDC - handle to a devicecontext.
However, I would like to render the text in memory, so I would like to use a TBitmap.Canvas.Handle
instead. Is that safe?
--
Yours

Poul Bak
(Remove NOSPAM from my e-mail address to answer directly)

Life is too short to reinvent the wheel just because you don't like the color - use a hub cap and
get on with your life!

2. "Specular" lighting in Direct3d

3. getting a StdPicture (BMP) for a HICON (Icon Handle)

4. Compaq and Packard No Go!

5. Metafile from hDC (handle to device context)

6. CreateDIBSection with file mapping object

7. Handle / Hdc?

8. Faster 2D Backface Culling

9. Get hDc for controls that don't expose hDc property

10. How get a hDC for a stdPicture object in VB?

11. Get DIB handle from DC handle ?

12. Where to drawlines on Printer.Handle or Printer.Canvas.Handle

13. stdPicture Icon to File