Some years ago we developed an ActiveX component called CaptionX (CaptionX Home Page). It allows the developers to place custom clickable graphical buttons into the window title bar. All works fine in any Windows except Vista and Windows 7 when Aero Glass is turned on - the title bar with our custom icons is drawn as if we used the Windows Basic theme without the transparency effect for the window borders.
People would like to use CaptionX in the latest versions of the OS, but we cannot make it working. All searches in the Internet tell us we need to enable Aero Glass when we use custom drawing in the window title using the DwmSetWindowAttribute API call with the DWMWA_NCRENDERING_POLICY attribute, but we have not managed to make it working.
Our code that draws on the window's non-client surface looks like this (sorry - it's the old VB6 :):
Friend Function WindowProc(ByVal lPrevWndProc As Long, ByVal hwnd As Long, ByVal iMsg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long
Select Case iMsg
Case WM_NCPAINT
DoNCPaint lPrevWndProc, wParam
WindowProc = 0
Exit Function
Case WM_...
' Other message handlers
End Select
WindowProc = CallWindowProc(lPrevWndProc, hwnd, iMsg, wParam, lParam)
End Function
We added the following call
DwmSetWindowAttribute m_hwnd, DWMWA_NCRENDERING_POLICY, DWMNCRP_ENABLED, 4
to many places in our code, but it does not have any effect. We can disable the Aero Glass effect if it is used by default in a window using DwmSetWindowAttribute, but cannot enable it.
What are we doing wrong? Do we need to add more API calls to our code, and if so where?