SetLayeredWindowAttribute() fails when theme is changed from Aero theme to basic theme

amr123

Well-Known Member
#1
Hello,

I am using Windows 7 Enterprise OS (32 bit). I have an mfc application which uses SetLayeredWindowAttribute() api to display fading effect for a window. The window to be displayed is popup window created with attributes WS_EX_TOOLWINDOW | WS_EX_LAYERED and parent NULL. The problem is when I switch from Aero theme to windows basic theme, SetLayeredWindowAttribute() fails with error code 317. When I again switch back to Aero, the application works fine. This happens only when I restart the system and switch from aero to basic theme.

I have checked if changing theme to basic removes WS_EX_LAYERED attributes of all windows, but the attribute is still present.
How to solve this problem?

Thanks & Regards,
Amrapali.
 


#2
Hi Amrapali,
I am having the same issue for a layered pop-up window. It works well if Windows theme is set to Aero but when I change the theme to basic then the call to SetLayeredWindowAttribute() fails with the error code 317.

Did you get any solution or workaround for it? Please let me know if any. Any help will be highly appreciated.

Thanks & Regards
Shivkant.
 


amr123

Well-Known Member
#3
Hi,

I solved the issue by removing and resetting WS_EX_LAYERED attribute on receiving WM_DWMCOMPOSITIONCHANGED message.

Code:
void CMyWindow::OnCompositionChanged()
{
  BOOLEAN bRet;
  bRet = IsCompositionEnabled();
  if (FALSE == bRet)
  {
    ModifyStyleEx(WS_EX_LAYERED, 0);
    ModifyStyleEx(0, WS_EX_LAYERED);
    //  SetLayeredWindowAttributes()
  }
  CWnd::OnCompositionChanged();
}

For IsCompositionEnabled(), check http://weblogs.asp.net/kennykerr/ar...Part-3-_1320_-The-Desktop-Window-Manager.aspx

Regards,
Amrapali.
 


#4
Hi Amrapali,

Thanks for the reply.
But the given solution didn't solve my problem. After handling the WM_DWMCOMPOSITIONCHANGED message for the layered window, I am still getting the error 317 for the SetLayeredWindowAttribute() call. However, when I debugged it, I found that my layered window never received the message WM_DWMCOMPOSITIONCHANGED. That's why, I am wondering, how this message handling going to affect anything for my layered window.

Any further help will be highly appreciated.

Thanks & Regards
Shivkant
 


#5
Hi Amrapali,..I am having the same issue for a layered pop-up window. It works well if Windows theme is set to Aero but when I change the theme to basic then the call to Set Layered Window Attribute() fails with the error code 317.please any body help me..
 


kemical

Windows Forum Admin
Staff member
Premium Supporter
#6
DO NOT and I repeat DO NOT report posts or threads that you want answered. This feature is there to report unwanted spam and the like.
 


This website is not affiliated, owned, or endorsed by Microsoft Corporation. It is a member of the Microsoft Partner Program.
Top