You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何移除Windows 10对话框标题栏并保留可调整大小属性?

How to Remove the Title Bar from a Resizable Modal Dialog

I’ve run into this exact issue before—trying to make a resizable dialog without a title bar can be tricky because of how Windows handles dialog styles by default. Let’s fix this step by step:

1. Correct the Dialog Style in Your RC File

The key is to explicitly set the dialog to use WS_POPUP alongside WS_THICKFRAME, and ensure no caption-related styles are present. Here’s your modified RC code:

IDD_ABOUTBOX DIALOGEX 100, 100, 600,300
STYLE WS_POPUP | WS_THICKFRAME
// Keep these lines commented out to avoid adding title bar elements
//CAPTION "About WindowsProject2"
//FONT 8, "MS Shell Dlg"
BEGIN
DEFPUSHBUTTON "OK",IDOK,300,100,50,14,WS_GROUP
END
  • WS_POPUP tells Windows this is a pop-up window (not an overlapped window which defaults to a title bar)
  • WS_THICKFRAME preserves the resizable border
  • We leave WS_CAPTION, WS_SYSMENU, and the CAPTION line commented out to eliminate the title bar entirely

2. Fallback: Manually Adjust Styles in Code

If the RC change alone doesn’t work (some frameworks like MFC might auto-add styles during initialization), you can force the style update in the dialog’s WM_INITDIALOG handler:

BOOL CALLBACK AboutDialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    switch (message)
    {
        case WM_INITDIALOG:
            // Get current window style
            LONG windowStyle = GetWindowLongPtr(hDlg, GWL_STYLE);
            // Remove caption style, keep resizable border
            windowStyle &= ~WS_CAPTION;
            windowStyle |= WS_THICKFRAME;
            SetWindowLongPtr(hDlg, GWL_STYLE, windowStyle);
            // Refresh the window to apply style changes
            SetWindowPos(hDlg, NULL, 0, 0, 0, 0, SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
            return TRUE;
        // Handle other messages here...
        case WM_COMMAND:
            if (LOWORD(wParam) == IDOK || LOWORD(wParam) == IDCANCEL)
            {
                EndDialog(hDlg, LOWORD(wParam));
                return TRUE;
            }
            break;
    }
    return FALSE;
}

This code directly modifies the window’s style after creation and triggers a frame refresh to apply the changes immediately.

Why This Works

By default, DIALOGEX uses a set of implicit styles that include a title bar. By explicitly defining WS_POPUP | WS_THICKFRAME, we override those defaults to create a window that’s resizable but has no title bar. The code fallback ensures that any auto-added styles are stripped out post-creation.

内容的提问来源于stack exchange,提问作者Hiroyuki

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.28 06:13:44