VC界面最前端显示
//显示在最前端
m_pMainWnd->SetWindowPos(&CWnd::wndTopMost, 0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
if (m_pMainWnd->GetExStyle()&WS_EX_TOPMOST)
{
m_pMainWnd->SetWindowPos(&CWnd::wndNoTopMost,0,0,0,0,SWP_NOMOVE|SWP_NOSIZE);
}
活动以及最小化恢复
void CMainFrame::OnActivate(UINT nState, CWnd* pWndOther, BOOL bMinimized)
{
CFrameWnd::OnActivate(nState, pWndOther, bMinimized);
if (nState==WA_INACTIVE)
{
ShowWindow(SW_SHOWNORMAL);
SetActiveWindow();
SetForegroundWindow();
}
}
AttachThreadInput(GetWindowThreadProcessId(::GetForegroundWindow(),NULL), GetCurrentThreadId(),TRUE);
SetForegroundWindow();
SetFocus();
AttachThreadInput(GetWindowThreadProcessId(::GetForegroundWindow(),NULL), GetCurrentThreadId(),FALSE);
重载的PreTranslateMessage函数中屏蔽回车和ESC的消息:
BOOL CxxxDlg::PreTranslateMessage(MSG* pMsg)
{
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_ESCAPE) return TRUE;
if(pMsg->message==WM_KEYDOWN && pMsg->wParam==VK_RETURN) return TRUE;
else
return CDialog::PreTranslateMessage(pMsg);
}