Search code examples
c++mfcdropshadowcdialog

How to apply CS_DROPSHADOW to a subclass of CDialog


I have a c++ class, MyDialog, deriving from CDialog, where I have removed the Windows frame and thereby the Windows generated shadow.

I would like to add the shadow again, without adding the frame. I have found there is a class style CS_DROPSHADOW that can be applied. But I cannot find how to apply it.

I have found a method ModifyStyle but it only modifies the WS_... styles, not the CS_... styles.

How do I apply the class style CS_DROPSHADOW?


Solution

  • My colleague helped me to register a class with the class style like this:

        WNDCLASS wndClass;
        GetClassInfo(NULL, WC_DIALOG, &wndClass);
        wndClass.style |= CS_DROPSHADOW;
        wndClass.lpszClassName = TEXT("MyDialog");
        RegisterClass(&wndClass); 
    

    where WC_DIALOG is the class for the regular CDialog.

    This class is then used in the resource file where my dialog is defined:

    IDD_MYDIALOGEX 54, 22, 264, 95
    STYLE DS_SETFONT | DS_CENTER | WS_POPUP
    CLASS "MyDialog"
    FONT 8, "Microsoft Sans Serif", 0, 0, 0x0
    BEGIN
        // Contents ...
    END
    

    This added a shadow, which is good. But not the aero shadow I was looking for though. enter image description here

    More answers welcome!