olli1973
asked on
Convert OLE_HANDLE of a Bitmap to HBITMAP-Handle
Hi!
I´ve been on a long quest for answer til now (posted this question in round about 6 sites like this but got not a single reply!!) - so hopefully someone can help me here!
(And by the way - i don´t belive that my question is that difficult to answer...)
So what is my problem:
If got an ActiveX-Control where i implemented a Picture-Property. The bitmap is stored in a CPictureHolder (m_Picture). I want to create a Pattern-Brush from this to fill the background of the control.
So the problem is how to get a HBITMAP-handle for the CreatePatternBrush-functio n, because get_Handle returns only an OLE_HANDLE.
I´ve tried it this way:
////////////////////////// ////////// ////////// ////////
// CDrawPicCtrl::OnDraw - Drawing function
void CDrawPicCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
static HBRUSH PatternBrush=NULL;
if ((PatternBrush==NULL)&(PIC TYPE_BITMA P == m_Picture.GetType()))
{
HBITMAP hBitmap=NULL;
m_Picture.m_pPict->get_Han dle((OLE_H ANDLE FAR *) &hBitmap);
PatternBrush=CreatePattern Brush(hBit map);
}
FillRect((HDC)pdc,rcBounds ,PatternBr ush);
}
This didn´t work so I also tried it this way:
OLE_HANDLE hBitmap=NULL;
m_Picture.m_pPict->get_Han dle(&hBitm ap);
PatternBrush=CreatePattern Brush((HBR USH) hBitmap);
Either way i tried i didnt´t get a valid HBITMAP-handle.
Please help!
I´m really desperate - can´t belive that i can´t make that sh... work!!!
I´m using VC++ 6 and Win98.
If you need more information please ask!
Thanks a lot!
Olli.
I´ve been on a long quest for answer til now (posted this question in round about 6 sites like this but got not a single reply!!) - so hopefully someone can help me here!
(And by the way - i don´t belive that my question is that difficult to answer...)
So what is my problem:
If got an ActiveX-Control where i implemented a Picture-Property. The bitmap is stored in a CPictureHolder (m_Picture). I want to create a Pattern-Brush from this to fill the background of the control.
So the problem is how to get a HBITMAP-handle for the CreatePatternBrush-functio
I´ve tried it this way:
//////////////////////////
// CDrawPicCtrl::OnDraw - Drawing function
void CDrawPicCtrl::OnDraw(CDC* pdc, const CRect& rcBounds, const CRect& rcInvalid)
{
static HBRUSH PatternBrush=NULL;
if ((PatternBrush==NULL)&(PIC
{
HBITMAP hBitmap=NULL;
m_Picture.m_pPict->get_Han
PatternBrush=CreatePattern
}
FillRect((HDC)pdc,rcBounds
}
This didn´t work so I also tried it this way:
OLE_HANDLE hBitmap=NULL;
m_Picture.m_pPict->get_Han
PatternBrush=CreatePattern
Either way i tried i didnt´t get a valid HBITMAP-handle.
Please help!
I´m really desperate - can´t belive that i can´t make that sh... work!!!
I´m using VC++ 6 and Win98.
If you need more information please ask!
Thanks a lot!
Olli.
ASKER
Hi migel!
Thanks for your comment!
But rendering the picture is not the problem.
Of course the problem of filling the background with a pattern of the bitmap could be solved by rendering the bitmap several times in a matrix, but that´s really a hackaround!
I cant´t belive that this is such a big problem!
My first try to solve the problem is an excerp from a VC code sample called "DrawPic" that i downloaded from MSDN.
This of course doesn´t work on my system and i don´t know why.
This is really making me mad - all i want is just getting a damned HBITMAP-handle...
As you see i increased the number of points to 1000 so perhaps this shows how mad i´m getting...
Thanks for your comment!
But rendering the picture is not the problem.
Of course the problem of filling the background with a pattern of the bitmap could be solved by rendering the bitmap several times in a matrix, but that´s really a hackaround!
I cant´t belive that this is such a big problem!
My first try to solve the problem is an excerp from a VC code sample called "DrawPic" that i downloaded from MSDN.
This of course doesn´t work on my system and i don´t know why.
This is really making me mad - all i want is just getting a damned HBITMAP-handle...
As you see i increased the number of points to 1000 so perhaps this shows how mad i´m getting...
Hi!
What error messages you get when use DrawPic sample?
What error messages you get when use DrawPic sample?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks migel!
ASKER
Oh - Sorry - I´ve forgotten to mention that PatternBrush is a CBrush-type. With this type it worked.
Points refunded and moved to PAQ
** Mindphaser - Community Support Moderator **
** Mindphaser - Community Support Moderator **
try to create memory DC memory Bitmap and render that picture in that DC
I know that this sounds like a big hackaround but if nothing helps :-)