2024年4月28日发(作者:)

如何去掉CMainframe系统标题栏

1、首先在xxxApp文件中的InitInstance()

// 初始化窗体

INITCOMMONCONTROLSEX InitCtrls;

= sizeof(InitCtrls);

= ICC_WIN95_CLASSES;

// 注册窗口

SetRegistryKey(_T("Local

Applications"));

// 创建主窗口

CMainFrame* pFrame = new CMainFrame;

if (!pFrame)

return FALSE;

CRect rect;

::SystemParametersInfo(SPI_GETWORKAREA, 0, &rect, 0);

*= 0.8;

*= 0.8;

*= 0.9;

*= 0.9;

pFrame->CreateEx(0,

m_pMainWnd = pFrame;

pFrame->ShowWindow(SW_SHOW);

pFrame->CenterWindow();

_T("xxxx"), _T("xxxx"),

WS_OVERLAPPEDWINDOW, rect, NULL, NULL);

AppWizard-Generated

pFrame->UpdateWindow();

pFrame->MaxSize();

pFrame->BringWindowToTop();

2、在CMainFrame中添加PreCreateWindow

设置窗体属性

BOOL CMainFrame::PreCreateWindow(CREATESTRUCT& cs)

{

if( !CAsbCtrlContainer::PreCreateWindow(cs) )

return FALSE;

WNDCLASS wndcls;

ZeroMemory(&wndcls, sizeof(wndcls));

= CS_DBLCLKS;

dProc = ::DefWindowProc;

nce = AfxGetInstanceHandle();

r =

AfxGetApp()->LoadStandardCursor(IDC_ARROW);

assName = ass;

=

AfxGetApp()->LoadIcon(IDR_MAINFRAME);

kground = 0;

AfxRegisterClass(&wndcls);

return TRUE;

}

3、在OnCreate中设置窗口模式

ModifyStyle(WS_CAPTION, 0, SWP_FRAMECHANGED);