System menu of Win32 dialog uses classic (unthemed) style and acts weird

111 Views Asked by At

I'm opening a dialog with DialogBoxW and for whatever reason, its system menu (the titlebar menu) uses the classic theme (unthemed) style and acts weird. The menu items in it only actually perform the actions half the time, and the rest of the time, it just reopens the menu again. Here's my DlgProc.

void DlgProc(
    HWND   hWnd,
    UINT   uMsg,
    WPARAM wParam,
    LPARAM lParam
)
{
    switch (uMsg)
    {
        case WM_CLOSE:
            DestroyWindow(hWnd);
            break;
        case WM_DESTROY:
            PostQuitMessage(0);
            break;
        case WM_INITDIALOG:
        {
            HWND hFileLabel = GetDlgItem(hWnd, IDD_OPENWITH_FILE);
            SetWindowTextW(hFileLabel, szFileName);
            break;
        }
        default:
            DefWindowProcW(hWnd, uMsg, wParam, lParam);
            break;
    }
}

I've added the Common Controls 6.0 dependency and the dialog itself is themed so I don't know why this is happening.

1

There are 1 best solutions below

2
On

That's not a valid dialog procedure. A dialog procedure must have this signature:

INT_PTR Dlgproc(
  HWND unnamedParam1,
  UINT unnamedParam2,
  WPARAM unnamedParam3,
  LPARAM unnamedParam4
)

The dialog manager uses the return value for various things. Since your "dialog procedure" doesn't return a value, the dialog manager is operating on indeterminate values. The behavior is thus undefined.