|
-
June 8th, 2012, 06:13 AM
#1
Aero effect Shadow, and transparency goes away if Rgn APIs are used
hello,
i have a Default MFC Application, and i have an imaginary Rectangle(larger then MFC Apps) in the Desktops,
i want to clip the MFC applications when it moves beyond that rectangle. here is what i have been doing
i used SetWindowRgn() with the offset rects, and i am able to clip it.
Code:
if ( pRect->right > 800)
{
int delta = pRect->right - 800;
HRGN hgn = CreateRectRgn(0,0, rc.Width() -delta, rc.Height());
HRGN hrgntemp = CreateRectRgn(0,0,0,0);
int regionType = GetWindowRgn(hrgntemp);
if (regionType != ERROR)
{
DeleteObject(hrgntemp);
SetWindowRgn(hgn, TRUE);
}
else
{
SetWindowRgn(hgn, TRUE);
}
}
but for some unknown reason, the tranperency and shadow effect goes away when i am using SetWindowRgn, is there any way to keep transperance and Shodow effect.
then i dug more that found that there is a message(WM_DWMNCRENDERINGCHANGED fRenderingEnabled:False) that is sent to my widnow when i apply region API, and when i delete it same message with true (WM_DWMNCRENDERINGCHANGED fRenderingEnabled:True) is sent. looks windows itself is doing it, is there any way to prevent it?
i added a message handle on WM_DWMNCRENDERINGCHANGED message and then try to re-enable it, but strangly for the first time it works multiple tries it does not work.
Code:
LRESULT CMonitorTestAppDlg::OndwmncRenderingChanged(WPARAM wp, LPARAM lp)
{
if(wp == TRUE)
{
OutputDebugString(L"Nc Rendereing Enabled\n");
}
else
{
OutputDebugString(L"Nc Rendereing disabled\n");
EnableNCRendering(m_hWnd);
}
return 0;
}
HRESULT EnableNCRendering(HWND hwnd)
{
HRESULT hr = S_OK;
DWMNCRENDERINGPOLICY ncrp = DWMNCRP_ENABLED;
// Disable non-client area rendering on the window.
hr = DwmSetWindowAttribute(hwnd, DWMWA_NCRENDERING_POLICY, &ncrp, sizeof(ncrp));
if (SUCCEEDED(hr))
{
// Do work here.
}
return hr;
}
Any clue when using region deactivates Aero Effects, is there any way to fix it
regards
Deepak
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
|