|
-
May 9th, 2006, 05:51 AM
#1
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
-
May 9th, 2006, 01:57 PM
#2
Re: Black painted if SetLayeredWindowAttributes is called.
You mean you see the window temporary being drawn in black and then in the right color? If so, I'm afraid there is not much you can do. Are you calling SetLayeredWindowAttributes before the window is shown?
-
May 10th, 2006, 12:36 AM
#3
Re: Black painted if SetLayeredWindowAttributes is called.
Try:
Code:
SetWindowLong(m_hWnd, GetWindowLong(m_hWnd, GWL_EXSTYLE) | WS_EX_LAYERED);
const COLORREF crTransparent = RGB( 0, 0, 0 );
SetLayeredWindowAttributes(crTransparent, 0, LWA_COLORKEY);
Also in OnEraseBkgnd, make sure you paint your "transparent" region of the window with "crTransparent". Still, you may repaint the client area in OnPaint, or parts of it if you have child windows (ex: MDI client is also a child of MDI frame), but otherwise, you should get transparency wherever your window has pixel values equal to crTransparent.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|