void Ctest1Dlg::OnSettingOntop()
{
// TODO: 在此添加命令处理程序代码
SetWindowPos(&CWnd::wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE)//置顶
}
void Ctest1Dlg::OnSettingCancelontop()
{
// TODO: 在此添加命令处理程序代码
SetWindowPos(&CWnd::wndNoTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE)//不置顶
}
//可以添加一个系统菜单//在OnInitDialog()中添加菜单
pSysMenu->InsertMenu(MF_STRING,0,ID_TOP_MOST_SHOW, "总在最上面(&T)")
void CXXXDlg::OnSysCommand(UINT nID, LPARAM lParam)
{
if ((nID &0xFFF0) == IDM_ABOUTBOX)
{
CAboutDlg dlgAbout
dlgAbout.DoModal()
}
else if(nID == ID_TOP_MOST_SHOW)
{
UpdateData()
m_bTopMost=!m_bTopMost
if(m_bTopMost)
this->SetWindowPos(&CWnd::wndTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE)//置顶
else
this->SetWindowPos(&CWnd::wndNoTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE)//不置顶
CMenu* pSysMenu = GetSystemMenu(FALSE)
if(pSysMenu!=NULL)
{
HMENU menu=pSysMenu->GetSafeHmenu()
if(m_bTopMost)
::CheckMenuItem(menu,ID_TOP_MOST_SHOW,MF_CHECKED)//菜单勾上
else
::CheckMenuItem(menu,ID_TOP_MOST_SHOW,MF_UNCHECKED)//
}
}
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)