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

// 发送

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

 

你可能感兴趣的:(windows,manager,command,application,scroll,menu)