Question

I creating a child window with CS_DROPSHADOW style, but the shadow is not displayed.
I tried to call SystemParametersInfo(SPI_SETDROPSHADOW, 0, (PVOID) TRUE, 0); but it also not helpful.
Can someone explain to me what's wrong?

    WNDCLASSEX wcex;

    HBRUSH bgBrush = CreateSolidBrush(RGB(171,181,201));

    wcex.cbSize = sizeof(WNDCLASSEX);
    wcex.style          = CS_DBLCLKS;
    wcex.lpfnWndProc    = KolmusProc;
    wcex.cbClsExtra     = 0;
    wcex.cbWndExtra     = 0;
    wcex.hInstance      = hInstance;
    wcex.hIcon          = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));
    wcex.hCursor        = LoadCursor(NULL, IDC_ARROW);
    wcex.hbrBackground  = bgBrush;
    wcex.lpszMenuName   = NULL;
    wcex.lpszClassName  = L"Kolmus";
    wcex.hIconSm        = LoadIconW(hInstance, MAKEINTRESOURCE(IDI_APPLICATION));

    RegisterClassEx(&wcex);

    wcex.style          = CS_DROPSHADOW;
    wcex.lpfnWndProc    = PageProc;
    wcex.hbrBackground  = (HBRUSH)(COLOR_WINDOW+1);
    wcex.lpszClassName  = L"Page";

    RegisterClassEx(&wcex);

    HWND hWnd = CreateWindow(L"Kolmus", L"Kolmus", WS_OVERLAPPEDWINDOW | WS_VISIBLE,
        CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, NULL, NULL, hInstance, NULL); 

    HWND PageWnd = CreateWindow(L"Page", L"", WS_CHILD | WS_VISIBLE, 30, 30, 200, 200, hWnd, NULL, hInstance, NULL);

    MSG msg;
    while (GetMessage(&msg, NULL, 0, 0))
    {
        TranslateMessage(&msg); 
        DispatchMessage(&msg);
    }

    return (int)msg.wParam;
Was it helpful?

Solution

Now I see it: I creating a child window ...

MSDN: http://msdn.microsoft.com/en-us/library/windows/desktop/ms632600(v=vs.85).aspx

WS_CHILD prevents CS_DROPSHADOW If you're hoping to make a temporary popup control in your window and want to use CS_DROPSHADOW to reinforce the fleeting nature of the popup, you can't use it with WS_CHILD -- it just ignores CS_DROPSHADOW. You'll need to make your control be WS_POPUP and then position it where you want it when it opens.

Nevertheless: Use rather HWND PageWnd = CreateWindowEx instead of HWND CreateWindow because of WNDCLASSEX wcex;

Its simple: WNDCLASS goes with CreateWindow, WNDCLASSEX goes with CreateWindowEx.

From MSDN: “The CreateWindowEx function creates an overlapped, pop-up, or child window with an extended window style; otherwise, this function is identical to the CreateWindow function.”

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top