Windows 10, Win32 classic application: I want to use DwmSetWindowAttribute to create a rounded-corner window, but the function did not work, why?
MainWindow = CreateWindow(wxex.lpszClassName, WindowTitle, WS_OVERLAPPEDWINDOW,
0, 0, nWidth, nHeight, NULL, NULL hin, NULL);
DWM_WINDOW_CORNER_PREFERENCE pef = DWMWCP_ROUND;
DwmSetWindowAttribite(MainWindow, DWMWA_WINDOW_CORNER_PREFERENCE, &pef, sizeof(pef));
ShowWindow(MainWindow, SW_SHOW);
You say you're using Windows 10, but DWMWA_WINDOW_CORNER_PREFERENCE
is supported only starting with Windows 11 Build 22000 as official doc says:
DWMWA_WINDOW_CORNER_PREFERENCE
Use withDwmSetWindowAttribute
. Specifies the rounded corner preference for a window. ThepvAttribute
parameter points to a value of typeDWM_WINDOW_CORNER_PREFERENCE
.This value is supported starting with Windows 11 Build 22000.