CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 3 of 3

Threaded View

  1. #1
    Join Date
    Sep 1999
    Posts
    66

    Angry Black painted if SetLayeredWindowAttributes is called.

    Hi,

    well I have a usual dialog based application with a resizable dialog. Because I have some regions which gonna be transparent, I make in the OnInitDialog the following call:

    Code:
      const COLORREF crTransparent  = RGB( 255,   0,   0 );
      LONG dwNewLong = GetWindowLong(m_hWnd, GWL_EXSTYLE) | WS_EX_LAYERED;
      SetWindowLong(m_hWnd, GWL_EXSTYLE, dwNewLong);
      SetLayeredWindowAttributes( crTransparent, 0, LWA_COLORKEY);
    The MFC (or whoever) makes a not so funny black painting of the region which will be bigger then the initial dialog. Without calling 'SetLayeredWindowAttributes' the black painting is not happend.

    I tried to override the erase of background like this:

    Code:
    BOOL CBlaBlaTestDlg::OnEraseBkgnd(CDC* pDC)
    {
          CRect rect;
          GetWindowRect(&rect);     // Erase the area needed
          ScreenToClient(&rect);
          pDC->FillSolidRect(&rect, RGB(0,255,0));
          return TRUE;
    }
    but ... no chance, they are ... almighty. First apears the black painting, then my green solid rect.
    Has anyone, any idea how can I avoid this black painting ???
    Thanks in advance!

    Best regards,
    Emil
    Last edited by ovidiucucu; May 9th, 2006 at 06:48 AM. Reason: added [code]...[/code] tags

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