CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3
  1. #1
    Join Date
    Dec 2005
    Posts
    445

    Transperent background

    Hi all,

    I have a picture control (bmp) and inside f it I have a static control that displays the current time and gets refreshed every second.

    I want to make the static control transperant so that the bmp will be the background

    I've tried the following:

    Code:
    ...
    
    m_BrushSol.CreateStockObject(HOLLOW_BRUSH); 
    ...
    
    HBRUSH CMyDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor)
    {
        HBRUSH hbr = __super::OnCtlColor(pDC, pWnd, nCtlColor);
    
        if ( pWnd->GetDlgCtrlID() == IDC_TIME ) 
      {
    	pDC->SetBkMode(TRANSPARENT);
    	return m_BrushSol;
       }
    }
    That works BUT... when I update the time (every second) , the new time is merging with the old time so I get one big mess after few seconds.

    How can I avoid it??

    Please help!

  2. #2
    Join Date
    Jan 2007
    Location
    Italy
    Posts
    156

    Re: Transperent background

    You could save a rectangular bmp which is that occupied by the clock... When you need to refresh it, you can erase the clock background with the original image partial bitmap (overriding the CStatic OnEraseBkgnd() ), and then superpose the new clock.

    Sorry, can't think anything more right now...
    Last edited by Buzzyous; February 10th, 2009 at 09:05 AM.
    - Buzzyous -

  3. #3
    Join Date
    Apr 1999
    Posts
    3,585

    Re: Transperent background

    If, by "one big mess", you mean the numbers continue to appear on top of each other until they are unreadable, then, try setting the static control to blanks before updating the time.
    Gort...Klaatu, Barada Nikto!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured