2

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?

JOG
  • 5,590
  • 7
  • 34
  • 54

2 Answers2

5

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!

JOG
  • 5,590
  • 7
  • 34
  • 54
1

You might be able to retain the frame style but respond to WM_NCCALCSIZE to have the client cover the entire window, effectively making the border zero width.

Mark Ransom
  • 299,747
  • 42
  • 398
  • 622
  • I tried manipulating the `NCCALCSIZE_PARAMS` in an `OnNcCalcSize` method. But if I inflate the rect (`lpncsp->rgrc`) the client either just gets smaller if decreased, or just gets a white frame when increased. The shadow is unchanged. How should I go about this? – JOG Aug 08 '12 at 14:03
  • @JOG, sorry that's the only idea I have for now. I've never tried to do this, but I know that trying to achieve something that Microsoft never conceived is always difficult. Sorry it didn't work out. – Mark Ransom Aug 08 '12 at 14:28