MFC 窗口的最大化处理、最小化

CWnd::SetWindowPlacement

CWnd::GetWindowPlacement

CWnd::RepositionBars

 

CWnd::OnSysCommand

 

AfxGetApp

AfxGetInstanceHandle

AfxGetMainWnd

CWnd::GetWindow
CWnd::RedrawWindow

CWnd::OnShowWindow

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
如果想让MFC窗口去掉边框,可以使用以下代码: 1. 在窗口类的头文件中添加以下代码: ```cpp afx_msg void OnNcLButtonDown(UINT nHitTest, CPoint point); afx_msg void OnNcMouseMove(UINT nHitTest, CPoint point); afx_msg void OnNcLButtonUp(UINT nHitTest, CPoint point); ``` 2. 在窗口类的源文件中添加以下代码: ```cpp void CMyWnd::OnNcLButtonDown(UINT nHitTest, CPoint point) { // 获取窗口的位置和大小 CRect rect; GetWindowRect(rect); // 获取鼠标相对于窗口的坐标 ScreenToClient(&point); // 判断鼠标是否在窗口的边框上 if (point.y < 5) { // 拖动窗口 SendMessage(WM_NCLBUTTONDOWN, HTCAPTION, 0); } else if (point.y > rect.Height() - 5) { // 关闭窗口 SendMessage(WM_SYSCOMMAND, SC_CLOSE, 0); } else if (point.x < 5) { // 最小化窗口 SendMessage(WM_SYSCOMMAND, SC_MINIMIZE, 0); } else if (point.x > rect.Width() - 5) { // 最大化窗口 SendMessage(WM_SYSCOMMAND, SC_MAXIMIZE, 0); } } void CMyWnd::OnNcMouseMove(UINT nHitTest, CPoint point) { // 改变鼠标样式 CRect rect; GetWindowRect(rect); ScreenToClient(&point); if (point.y < 5) { SetCursor(LoadCursor(NULL, IDC_SIZEALL)); } else if (point.y > rect.Height() - 5) { SetCursor(LoadCursor(NULL, IDC_HAND)); } else if (point.x < 5) { SetCursor(LoadCursor(NULL, IDC_APPSTARTING)); } else if (point.x > rect.Width() - 5) { SetCursor(LoadCursor(NULL, IDC_ARROW)); } else { SetCursor(LoadCursor(NULL, IDC_ARROW)); } } void CMyWnd::OnNcLButtonUp(UINT nHitTest, CPoint point) { // do nothing } ``` 这段代码会响应窗口的非客户区鼠标事件,实现窗口的拖动、最大化最小化和关闭。同时,它还会改变鼠标的样式,使得鼠标在窗口边缘时可以更好地交互。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值