ESC退出全屏(求助)

华亭真人 2008-12-02 02:55:21
按ESC不能退出全屏 相关代码如下,请高手帮忙
void CMainFrame::OnFullscreen() 
{
// TODO: Add your command handler code here
GetWindowPlacement(&m_OldWndPlacement);
CRect WindowRect;
GetWindowRect(&WindowRect);
CRect ClientRect;
RepositionBars(0,0xffff,AFX_IDW_PANE_FIRST,reposQuery,&ClientRect);
ClientToScreen(&ClientRect);
int nFullWidth=GetSystemMetrics(SM_CXSCREEN);
int nFullHeight=GetSystemMetrics(SM_CYSCREEN);
m_FullScreenRect.left=WindowRect.left-ClientRect.left;
m_FullScreenRect.right=WindowRect.right-ClientRect.right+nFullWidth;
m_FullScreenRect.top=WindowRect.top-ClientRect.top;
m_FullScreenRect.bottom=WindowRect.bottom-ClientRect.bottom+nFullHeight;
m_bFullScreen=TRUE;
WINDOWPLACEMENT wndpl;
wndpl.length=sizeof(WINDOWPLACEMENT);
wndpl.flags=0;
wndpl.showCmd=SW_SHOWNORMAL;
wndpl.rcNormalPosition=m_FullScreenRect;
SetWindowPlacement(&wndpl);

}

void CMainFrame::OnGetMinMaxInfo(MINMAXINFO FAR* lpMMI)
{
// TODO: Add your message handler code here and/or call default
if(m_bFullScreen)
{
lpMMI->ptMaxSize.x=m_FullScreenRect.Width();
lpMMI->ptMaxSize.y=m_FullScreenRect.Height();
lpMMI->ptMaxPosition.x=m_FullScreenRect.Width();
lpMMI->ptMaxPosition.y=m_FullScreenRect.Height();
lpMMI->ptMaxTrackSize.x=m_FullScreenRect.Width();
lpMMI->ptMaxTrackSize.y=m_FullScreenRect.Height();
}

CFrameWnd::OnGetMinMaxInfo(lpMMI);
}

void CMainFrame::EndFullScreen()
{
if(m_bFullScreen)
{
ShowWindow(SW_HIDE);
SetWindowPlacement(&m_OldWndPlacement);
}

}

void CMainFrame::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
// TODO: Add your message handler code here and/or call default
if(nChar==VK_ESCAPE)
{
CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;
pFrame->EndFullScreen();
}

CFrameWnd::OnKeyDown(nChar, nRepCnt, nFlags);
}
...全文
95 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
aqqwrpggame 2008-12-02
  • 打赏
  • 举报
回复
来点简单的,设个加速键,响应加速键的事件。
ccpaishi 2008-12-02
  • 打赏
  • 举报
回复
楼上的正解,自己要把消息泵函数写出来。也有实现组合键的类,楼主也可以自己找一下。
孤客天涯 2008-12-02
  • 打赏
  • 举报
回复
在这个消息函数中加
BOOL CMainFrame::PreTranslateMessage(MSG* pMsg)
{
if (WM_KEYDOWN == pMsg->message)
{
switch(pMsg->wParam)
{

case VK_ESCAPE:
{
CMainFrame *pFrame=(CMainFrame*)AfxGetApp()->m_pMainWnd;
pFrame->EndFullScreen();

}break;
}
}
return CMDIFrameWnd::PreTranslateMessage(pMsg);
}

15,979

社区成员

发帖
与我相关
我的任务
社区描述
VC/MFC 界面
社区管理员
  • 界面
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧