怎样在MFC中拦截最小化消息

eastwind 2004-06-11 05:55:38
各位大侠好,我想在用户点最小化按钮的时候显示一段信息


请问在CMainFrame中怎样拦截这个消息
谢谢


...全文
975 11 打赏 收藏 转发到动态 举报
写回复
用AI写文章
11 条回复
切换为时间正序
请发表友善的回复…
发表回复
marckle 2004-07-19
  • 打赏
  • 举报
回复
CMainFrame类有OnSysCommand成员函数么?响应什么消息?我怎么找不到?
Kudeet 2004-06-12
  • 打赏
  • 举报
回复
OnSysCommand( UINT nID, LPARAM lParam );

nID : SC_MINIMIZE
kvw3000 2004-06-12
  • 打赏
  • 举报
回复
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
  if (nID == SC_MINIMIZE)
//add your handle code here;
  CFrameWnd::OnSysCommand(nID, lParam);
}
Wenxy1 2004-06-12
  • 打赏
  • 举报
回复
学习
halk 2004-06-11
  • 打赏
  • 举报
回复
呵呵……回来学习!
薛定谔之死猫 2004-06-11
  • 打赏
  • 举报
回复
学习
zhangnanonnet 2004-06-11
  • 打赏
  • 举报
回复
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
  if (nID == SC_MAXIMIZE)
return; // 拦截
  CFrameWnd::OnSysCommand(nID, lParam);
}
赖勇浩 2004-06-11
  • 打赏
  • 举报
回复
楼上的正解.
Kudeet 2004-06-11
  • 打赏
  • 举报
回复
判断IsIconic()不知道函数名错了没!大体差不多吧!
halk 2004-06-11
  • 打赏
  • 举报
回复
最大化、最小化、恢复的时候都要产生WM_SIZE消息。响应WM_SIZE消息的是OnSize,所以可以重载此函数来处理最小化的时候要做的操作。
afx_msg void OnSize( UINT nType, int cx, int cy );

Parameters

nType

Specifies the type of resizing requested. This parameter can be one of the following values:

SIZE_MAXIMIZED Window has been maximized.


SIZE_MINIMIZED Window has been minimized.


SIZE_RESTORED Window has been resized, but neither SIZE_MINIMIZED nor SIZE_MAXIMIZED applies.


SIZE_MAXHIDE Message is sent to all pop-up windows when some other window is maximized.


SIZE_MAXSHOW Message is sent to all pop-up windows when some other window has been restored to its former size.
cx

Specifies the new width of the client area.

cy

Specifies the new height of the client area.

Remarks

The framework calls this member function after the window’s size has changed.

If the SetScrollPos or MoveWindow member function is called for a child window from OnSize, the bRedraw parameter of SetScrollPos or MoveWindow should be nonzero to cause the CWnd to be repainted.

Note This member function is called by the framework to allow your application to handle a Windows message. The parameters passed to your function reflect the parameters received by the framework when the message was received. If you call the base-class implementation of this function, that implementation will use the parameters originally passed with the message and not the parameters you supply to the function.

Example

// Resize the list control contained in the view to
// fill the entire view when the view's window is
// resized. CMyView is a CView derived class.
void CMyView::OnSize(UINT nType, int cx, int cy)
{
CView::OnSize(nType, cx, cy);
// Resize list to fill the whole view.
m_List.MoveWindow (0, 0, cx, cy);
}

jennifergiant 2004-06-11
  • 打赏
  • 举报
回复
void CMainFrame::OnSysCommand(UINT nID, LPARAM lParam)
{
  if (nID == SC_MAXIMIZE)
........;
  CFrameWnd::OnSysCommand(nID, lParam);
}

15,979

社区成员

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

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