From: mfc on
Hi,


how is it possible to get the rectangle of an cedit control item in
the OnPaint() method to draw the image for this cedit control only in
the size of the cedit control? At the moment CSize is the size of the
bitmap but not of the cedit control in the DrawIndirect() method...

void CImageEdit::OnPaint()
{
CDC *pDC = GetDC();
pDC->SetBkColor(TRANSPARENT);

if(m_bLoaded)
m_ImageList.DrawIndirect(pDC , 0 ,
CPoint( m_rectBtn.left,m_rectBtn.top ),
CSize( m_bitmap.bmWidth , m_bitmap.bmHeight ),
CPoint( 0 , 0 ) ,
ILD_NORMAL);


ReleaseDC(pDC);
}

And which method do I have to use to set the background-color of the
cedit field to transparent? At the moment it is only transparent as
long as you enter no chars into the cedit field.

best regards
Hans
From: mfc on
On 29 Jun., 21:17, mfc <mfcp...(a)googlemail.com> wrote:
> Hi,
>
> how is it possible to get the rectangle of an cedit control item in
> the OnPaint() method to draw the image for this cedit control only in
> the size of the cedit control? At the moment CSize is the size of the
> bitmap but not of the cedit control in the DrawIndirect() method...
>
> void CImageEdit::OnPaint()
> {
>      CDC *pDC = GetDC();
>      pDC->SetBkColor(TRANSPARENT);
>
>       if(m_bLoaded)
>            m_ImageList.DrawIndirect(pDC , 0 ,
>          CPoint( m_rectBtn.left,m_rectBtn.top ),
>          CSize( m_bitmap.bmWidth , m_bitmap.bmHeight ),
>          CPoint( 0 , 0 ) ,
>          ILD_NORMAL);
>
>      ReleaseDC(pDC);
>
> }
>
> And which method do I have to use to set the background-color of the
> cedit field to transparent? At the moment it is only transparent as
> long as you enter no chars into the cedit field.
>
> best regards
> Hans

I`m using the CtlColor method to set the background color of the cedit
field to transparent -> it`s working but...
HBRUSH CImageEdit::CtlColor(CDC* pDC, UINT nCtlColor)
{
// TODO: Return a non-NULL brush if the parent's handler should
// not be called


pDC->SetBkMode(TRANSPARENT);
HBRUSH brush = (HBRUSH)GetStockObject(HOLLOW_BRUSH);

return brush;
}

if I add a second char to the cedit control, the control is not
painted again; and therefore the first char will be overwritten by the
"first and the second" char, because the cedit control will display
all chars in the center of the field.

Where do I have to call Invalidate() to paint the editbox (only
OnPaint() not the OnEraseBkgnd method?

best regards
Hans