Hi all,

I wrote a simple clock that shows the time over bitmap as follows:

Code:
void CMyClock::OnPaint()
{
    CRect rect;
    GetClientRect(&rect);

    CPaintDC dc(this); // device context for painting

    CDC memDC;
    memDC.CreateCompatibleDC(&dc);
    memDC.SelectObject(m_bmpMyPic);

    memDC.TextOut(10,5, m_szCurrentTime);

    dc.BitBlt(0, 0 , 130, 39, &memDC, 0,0, SRCCOPY);
}


void CMyClock::OnTimer(UINT nIDEvent)
{
    ....
    szCurrentTime = // The current time as a string
    Invalidate();       // Show the new time  
}
Everything works fine expect that I have white background border around my clock so I've modifyed the code (the change is bold):

Code:
void CMyClock::OnPaint()
{
    CRect rect;
    GetClientRect(&rect);

    CPaintDC dc(this); // device context for painting

    CDC memDC;
    memDC.CreateCompatibleDC(&dc);
    memDC.SelectObject(m_bmpMyPic);

     pDC->SetBkMode(TRANSPARENT); 
    memDC.TextOut(10,5, m_szCurrentTime);

    dc.BitBlt(0, 0 , 130, 39, &memDC, 0,0, SRCCOPY);
}
Now I got rid off the white border but everytime I draw a text it write on top of the previous text so after few seconds everything is a mess and the time is no longer readable.

Can anyone please tell me what am I doing wrong?