1

我用 CS_DROPSHADOW 样式创建了一个子窗口,但不显示阴影。
我试图打电话SystemParametersInfo(SPI_SETDROPSHADOW, 0, (PVOID) TRUE, 0);,但它也没有帮助。
有人可以向我解释有什么问题吗?

    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;
4

1 回答 1

3

现在我看到了:I creating a child window ...

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

WS_CHILD 阻止 CS_DROPSHADOW 如果您希望在您的窗口中创建一个临时弹出控件并希望使用 CS_DROPSHADOW 来增强弹出的短暂性,您不能将它与 WS_CHILD 一起使用——它只是忽略 CS_DROPSHADOW。您需要将控件设置为 WS_POPUP,然后在打开时将其放置在您想要的位置。

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.”</p>

于 2013-02-11T13:11:09.613 回答