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

Discussion in 'Windows 7 Graphics' started by amr123, Oct 22, 2010.

  1. amr123

    amr123 Well-Known Member

    Joined:
    Oct 22, 2010
    Messages:
    3
    Likes Received:
    2
    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.
     
    sajawatevents likes this.
  2. Shivkant Jaiswal

    Shivkant Jaiswal New Member

    Joined:
    Jul 30, 2013
    Messages:
    2
    Likes Received:
    0
    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.
     
  3. amr123

    amr123 Well-Known Member

    Joined:
    Oct 22, 2010
    Messages:
    3
    Likes Received:
    2
    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/archive/2006/08/10/Windows-Vista-for-Developers-_1320_-Part-3-_1320_-The-Desktop-Window-Manager.aspx

    Regards,
    Amrapali.
     
    sajawatevents likes this.
  4. Shivkant Jaiswal

    Shivkant Jaiswal New Member

    Joined:
    Jul 30, 2013
    Messages:
    2
    Likes Received:
    0
    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. jamesharry

    jamesharry Well-Known Member

    Joined:
    Sep 11, 2013
    Messages:
    6
    Likes Received:
    0
    Hello Friends,
    I am new on this website.

    "Service Pack 1 " Question?

    I just got a windows 7 OS. it says: "Windows 7 SP1 ALL IN ONE 32/64-bit"

    Also says: * Windows 7 Starter 32-bit
    * Windows 7 Home Basic 32/64-bit
    * Windows 7 Home Premium 32/64-bit
    * Windows 7 Professional 32/64-bit
    * Windows 7 Enterprise 32/64-bit
    * Windows 7 Ultimate 32/64-bit

    Does this mean it runs both 32 and 64 bits?
    And has all windows seven versions running same time?

    I intend to install it on a vmware to help me with some school programs for laboratory works which wont run on my 64 bit windows 8.

    Please, dont stray from the question. give direct answers

    Thanks guys
    ____________________________________
     
    #5 jamesharry, Sep 11, 2013
    Last edited by a moderator: Nov 11, 2016
  6. sajawatevents

    sajawatevents New Member

    Joined:
    Jul 30, 2015
    Messages:
    2
    Likes Received:
    0
    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..
     
  7. kemical

    kemical Windows Forum Admin
    Staff Member Premium Supporter Microsoft MVP

    Joined:
    Aug 28, 2007
    Messages:
    31,849
    Likes Received:
    1,569
    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.
     
  8. jamesharry

    jamesharry Well-Known Member

    Joined:
    Sep 11, 2013
    Messages:
    6
    Likes Received:
    0
    I will follow above instructions and not try to do spam.
     
    #8 jamesharry, Nov 8, 2016
    Last edited by a moderator: Nov 11, 2016

Share This Page

Loading...