对话框最小化消息 的发送与接收

// 发送

SendMessage(WM_SYSCOMMAND, SC_MINIMIZE);

 

 

 

 

// 接收

VC 如何捕捉窗口的最大化、最小化消息

三种方法:
1.在WM_SIZE的响应函数中添加:
void CMyFrameWnd::OnSize(UINT nType, int cx, int cy)
{
CFrameWnd::OnSize(nType, cx, cy);

if (nTpye==SIZE_MAXIMIZED)
{
                            MessageBox( "ok ");  
                   }

}

CWnd::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.

2.重载OnSysCommand函数
void CMyFrameWnd::OnSysCommand(UINT uId,LPARAM lParam)
{
if(lParam==SC_MAXIMIZE)
{
                MessageBox( "ok ");  
        }
else
CWnd::OnSysCommand(uId,lParam)
}

CWnd::OnSysCommand

afx_msg void OnSysCommand( UINT nID, LPARAM lParam );

Parameters

nID

Specifies the type of system command requested. This parameter can be any one of the following values:

  • SC_CLOSE    Close the CWnd object.
  • SC_HOTKEY    Activate the CWnd object associated with the application-specified hot key. The low-order word of lParam identifies the HWND of the window to activate.
  • SC_HSCROLL    Scroll horizontally.
  • SC_KEYMENU    Retrieve a menu through a keystroke.
  • SC_MAXIMIZE (or SC_ZOOM)    Maximize the CWnd object.
  • SC_MINIMIZE (or SC_ICON)    Minimize the CWnd object.
  • SC_MOUSEMENU    Retrieve a menu through a mouse click.
  • SC_MOVE    Move the CWnd object.
  • SC_NEXTWINDOW    Move to the next window.
  • SC_PREVWINDOW    Move to the previous window.
  • SC_RESTORE    Restore window to normal position and size.
  • SC_SCREENSAVE    Executes the screen-saver application specified in the [boot] section of the SYSTEM.INI file.
  • SC_SIZE    Size the CWnd object.
  • SC_TASKLIST    Execute or activate the Windows Task Manager application.
  • SC_VSCROLL    Scroll vertically.

lParam

If a Control-menu command is chosen with the mouse, lParam contains the cursor coordinates. The low-order word contains the x coordinate, and the high-order word contains the y coordinate. Otherwise this parameter is not used.

  • SC_HOTKEY    Activate the window associated with the application-specified hot key. The low-order word of lParam identifies the window to activate.
  • SC_SCREENSAVE    Execute the screen-save application specified in the Desktop section of Control Panel.
    3.重载WindowProc函数:
    LRESULT CMyFrameWnd::WindowProc(UINT msg,WPARAM wParam,LPARAM lParam)
    {
    LRESULT lr=CFrameWnd::WindowProc(msg,wParam,lParam);
    if(wParam==SC_MAXIMIZE)
    {
                      MessageBox( "ok ");      }
    return lr;
    }

 

 

http://hi.baidu.com/eyoung000/blog/item/1017b1ac9875f8074a36d6e9.html

 

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值