怎么将mfc对话框右上角的关闭按钮还原?

狰鸩的快乐 东北电力大学 2019-09-26 01:17:06
新手小白一枚,创建mfc对话框的时候不知道怎么把右上角关闭按钮弄没了,现在想加回来,不知道怎么办,求大佬帮助!用的VS2017
...全文
52 点赞 收藏 2
写回复
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
狰鸩的快乐 2019-09-26
引用 1 楼 schlafenhamster 的回复:

BOOL CMainFrame::ChangeDlgStyle(int resInt)
{
HINSTANCE hInst=AfxFindResourceHandle(MAKEINTRESOURCE(resInt),RT_DIALOG);
HRSRC hRes=::FindResource(hInst,MAKEINTRESOURCE(resInt),RT_DIALOG);
DWORD sz = ::SizeofResource(hInst, hRes);// 284
HGLOBAL hTemplate=::LoadResource(hInst,hRes);
DLGTEMPLATEEX *pTemplate=(DLGTEMPLATEEX *)LockResource(hTemplate);
HWND hDlg=0;
BYTE *pByte=new BYTE[sz];
//
if(pTemplate->signature==0xFFFF)
{//ex
DLGTEMPLATEEX *pNewTmp=(DLGTEMPLATEEX *)lpdwAlign((LPDWORD)pByte);
CopyMemory(pNewTmp,pTemplate,sz);
pNewTmp->style &= ~WS_CAPTION;
pNewTmp->style &= ~DS_MODALFRAME;
pNewTmp->style &= ~WS_POPUP;
pNewTmp->style &= ~WS_VISIBLE;
pNewTmp->style |= WS_BORDER;
pNewTmp->style |= WS_CHILD;
hDlg= CreateDialogIndirect(hInst, // handle to application instance
(const DLGTEMPLATE *)pNewTmp, // pointer to dialog box template
this->m_hWnd, // handle to owner window
0); // pointer to dialog box procedure
}
else
{//
DLGTEMPLATE *pNewTmp=(DLGTEMPLATE *)lpdwAlign((LPDWORD)pByte);
CopyMemory(pNewTmp,pTemplate,sz);
pNewTmp->style &= ~WS_CAPTION;
pNewTmp->style &= ~DS_MODALFRAME;
pNewTmp->style &= ~WS_POPUP;
pNewTmp->style &= ~WS_VISIBLE;
pNewTmp->style |= WS_BORDER;
pNewTmp->style |= WS_CHILD;
hDlg= CreateDialogIndirect(hInst, // handle to application instance
(const DLGTEMPLATE *)pNewTmp, // pointer to dialog box template
this->m_hWnd, // handle to owner window
0); // pointer to dialog box procedure
}
UnlockResource(hTemplate);
FreeResource(hTemplate);
delete [] pByte;
//
if(hDlg)
{
m_Dlg.SubclassWindow(hDlg);
CRect rc;
GetClientRect(&rc);
CRect tbRc;
m_wndToolBar.GetToolBarCtrl().GetWindowRect(&tbRc);// h=26
CRect sbRc;
m_wndStatusBar.GetStatusBarCtrl().GetWindowRect(&sbRc);// h=25
// view border 2
m_Dlg.MoveWindow(0,tbRc.Height()-1,rc.Width(),rc.Height()-tbRc.Height()-sbRc.Height()+1,FALSE);
m_Dlg.ShowWindow(SW_SHOW);
return TRUE;
}
return FALSE;
}



谢谢大佬,已经解决了,system menu不知道什么时候关了,打开就好了...
回复
schlafenhamster 2019-09-26

BOOL CMainFrame::ChangeDlgStyle(int resInt)
{
HINSTANCE hInst=AfxFindResourceHandle(MAKEINTRESOURCE(resInt),RT_DIALOG);
HRSRC hRes=::FindResource(hInst,MAKEINTRESOURCE(resInt),RT_DIALOG);
DWORD sz = ::SizeofResource(hInst, hRes);// 284
HGLOBAL hTemplate=::LoadResource(hInst,hRes);
DLGTEMPLATEEX *pTemplate=(DLGTEMPLATEEX *)LockResource(hTemplate);
HWND hDlg=0;
BYTE *pByte=new BYTE[sz];
//
if(pTemplate->signature==0xFFFF)
{//ex
DLGTEMPLATEEX *pNewTmp=(DLGTEMPLATEEX *)lpdwAlign((LPDWORD)pByte);
CopyMemory(pNewTmp,pTemplate,sz);
pNewTmp->style &= ~WS_CAPTION;
pNewTmp->style &= ~DS_MODALFRAME;
pNewTmp->style &= ~WS_POPUP;
pNewTmp->style &= ~WS_VISIBLE;
pNewTmp->style |= WS_BORDER;
pNewTmp->style |= WS_CHILD;
hDlg= CreateDialogIndirect(hInst, // handle to application instance
(const DLGTEMPLATE *)pNewTmp, // pointer to dialog box template
this->m_hWnd, // handle to owner window
0); // pointer to dialog box procedure
}
else
{//
DLGTEMPLATE *pNewTmp=(DLGTEMPLATE *)lpdwAlign((LPDWORD)pByte);
CopyMemory(pNewTmp,pTemplate,sz);
pNewTmp->style &= ~WS_CAPTION;
pNewTmp->style &= ~DS_MODALFRAME;
pNewTmp->style &= ~WS_POPUP;
pNewTmp->style &= ~WS_VISIBLE;
pNewTmp->style |= WS_BORDER;
pNewTmp->style |= WS_CHILD;
hDlg= CreateDialogIndirect(hInst, // handle to application instance
(const DLGTEMPLATE *)pNewTmp, // pointer to dialog box template
this->m_hWnd, // handle to owner window
0); // pointer to dialog box procedure
}
UnlockResource(hTemplate);
FreeResource(hTemplate);
delete [] pByte;
//
if(hDlg)
{
m_Dlg.SubclassWindow(hDlg);
CRect rc;
GetClientRect(&rc);
CRect tbRc;
m_wndToolBar.GetToolBarCtrl().GetWindowRect(&tbRc);// h=26
CRect sbRc;
m_wndStatusBar.GetStatusBarCtrl().GetWindowRect(&sbRc);// h=25
// view border 2
m_Dlg.MoveWindow(0,tbRc.Height()-1,rc.Width(),rc.Height()-tbRc.Height()-sbRc.Height()+1,FALSE);
m_Dlg.ShowWindow(SW_SHOW);
return TRUE;
}
return FALSE;
}
回复
发帖
界面
创建于2007-09-28

1.5w+

社区成员

VC/MFC 界面
申请成为版主
帖子事件
创建了帖子
2019-09-26 01:17
社区公告
暂无公告