码迷,mamicode.com
首页 > 其他好文 > 详细

无边框缩放

时间:2014-05-27 18:08:42      阅读:394      评论:0      收藏:0      [点我收藏+]

标签:c   class   http   ext   a   int   

实现效果需要处理以下这三个消息:

WM_NCHITTEST WM_SETCURSOR WM_NCLBUTTONDOWN

很多人在问三个函数是做什么用的,下面我大概介绍一下:

OnNcHitTest(UINT nHitTest, CPoint point)是用来测试鼠标的位置,Nc表示非客户区

OnSetCursor(HWND hWnd, UINT nHitTest, UINT message) 是用来设置鼠标状态

OnNcLButtonDown(UINT nHitTest, CPoint point)是用来处理非客户区的鼠标左键点击

有不懂的可以留言交流一下,希望本文章对大家有所帮助

消息处理函数:

bubuko.com,布布扣UINT CXXXDlg::OnNcHitTest(UINT nHitTest, CPoint point)
bubuko.com,布布扣bubuko.com,布布扣...{
bubuko.com,布布扣 CRect rect;
bubuko.com,布布扣 GetWindowRect(&rect);
bubuko.com,布布扣if(point.x<=rect.left+3)
bubuko.com,布布扣    returnHTLEFT;
bubuko.com,布布扣elseif(point.x>=rect.right-3)
bubuko.com,布布扣    returnHTRIGHT;
bubuko.com,布布扣elseif(point.y<=rect.top+3)
bubuko.com,布布扣    returnHTTOP;
bubuko.com,布布扣elseif(point.y>=rect.bottom-3)
bubuko.com,布布扣    returnHTBOTTOM;
bubuko.com,布布扣elseif(point.x<=rect.left+10&&point.y<=rect.top+10)
bubuko.com,布布扣    returnHTTOPLEFT;
bubuko.com,布布扣elseif(point.x>=rect.right-10&&point.y<=rect.top+10)
bubuko.com,布布扣    returnHTTOPRIGHT;
bubuko.com,布布扣elseif(point.x<=rect.left+10&&point.y>=rect.bottom-10)
bubuko.com,布布扣    returnHTBOTTOMLEFT;
bubuko.com,布布扣elseif(point.x>=rect.right-10&&point.y>=rect.bottom-10)
bubuko.com,布布扣    returnHTBOTTOMRIGHT;

bubuko.com,布布扣 else

bubuko.com,布布扣    return CDialog::OnNcHitTest(point);
bubuko.com,布布扣}
bubuko.com,布布扣
bubuko.com,布布扣
bubuko.com,布布扣BOOL CXXXDlg::OnSetCursor(HWND hWnd, UINT nHitTest, UINT message)
bubuko.com,布布扣bubuko.com,布布扣...{
bubuko.com,布布扣    if(nHitTest==HTCAPTION||nHitTest==HTSYSMENU||
bubuko.com,布布扣        nHitTest==HTMENU||nHitTest==HTCLIENT)
bubuko.com,布布扣bubuko.com,布布扣   ...{
bubuko.com,布布扣        SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW)));
bubuko.com,布布扣    }
bubuko.com,布布扣   elseif(nHitTest==HTTOP||nHitTest==HTBOTTOM)
bubuko.com,布布扣bubuko.com,布布扣   ...{
bubuko.com,布布扣        SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENS)));
bubuko.com,布布扣    }
bubuko.com,布布扣   elseif(nHitTest==HTLEFT||nHitTest==HTRIGHT)
bubuko.com,布布扣bubuko.com,布布扣   ...{
bubuko.com,布布扣        SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZEWE)));
bubuko.com,布布扣    }
bubuko.com,布布扣   elseif(nHitTest==HTTOPLEFT||nHitTest==HTBOTTOMRIGHT)
bubuko.com,布布扣bubuko.com,布布扣   ...{
bubuko.com,布布扣        SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENWSE)));
bubuko.com,布布扣    }
bubuko.com,布布扣   elseif(nHitTest==HTTOPRIGHT||nHitTest==HTBOTTOMLEFT)
bubuko.com,布布扣bubuko.com,布布扣   ...{
bubuko.com,布布扣        SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_SIZENESW)));
bubuko.com,布布扣    }
bubuko.com,布布扣   else
bubuko.com,布布扣bubuko.com,布布扣   ...{
bubuko.com,布布扣        SetCursor(LoadCursor(NULL, MAKEINTRESOURCE(IDC_ARROW)));
bubuko.com,布布扣     }
bubuko.com,布布扣}
bubuko.com,布布扣
bubuko.com,布布扣
bubuko.com,布布扣voidCXXXDlg::OnNcLButtonDown(UINT nHitTest, CPoint point)
bubuko.com,布布扣bubuko.com,布布扣...{
bubuko.com,布布扣   if(nHitTest==HTTOP)
bubuko.com,布布扣        SendMessage( WM_SYSCOMMAND, SC_SIZE|WMSZ_TOP, MAKELPARAM(point.x, point.y));
bubuko.com,布布扣   elseif(nHitTest==HTBOTTOM)
bubuko.com,布布扣        SendMessage( WM_SYSCOMMAND, SC_SIZE|WMSZ_BOTTOM, MAKELPARAM(point.x, point.y));
bubuko.com,布布扣   elseif(nHitTest==HTLEFT)
bubuko.com,布布扣        SendMessage( WM_SYSCOMMAND, SC_SIZE|WMSZ_LEFT, MAKELPARAM(point.x, point.y));
bubuko.com,布布扣   elseif(nHitTest==HTRIGHT)
bubuko.com,布布扣        SendMessage( WM_SYSCOMMAND, SC_SIZE|WMSZ_RIGHT, MAKELPARAM(point.x, point.y));
bubuko.com,布布扣   elseif(nHitTest==HTTOPLEFT)
bubuko.com,布布扣        SendMessage( WM_SYSCOMMAND, SC_SIZE|WMSZ_TOPLEFT, MAKELPARAM(point.x, point.y));
bubuko.com,布布扣   elseif(nHitTest==HTTOPRIGHT)
bubuko.com,布布扣        SendMessage( WM_SYSCOMMAND, SC_SIZE|WMSZ_TOPRIGHT, MAKELPARAM(point.x, point.y));
bubuko.com,布布扣   elseif(nHitTest==HTBOTTOMLEFT)
bubuko.com,布布扣        SendMessage( WM_SYSCOMMAND, SC_SIZE|WMSZ_BOTTOMLEFT, MAKELPARAM(point.x, point.y));
bubuko.com,布布扣   elseif(nHitTest==HTBOTTOMRIGHT)
bubuko.com,布布扣        SendMessage(WM_SYSCOMMAND, SC_SIZE|WMSZ_BOTTOMRIGHT, MAKELPARAM(point.x, point.y));
bubuko.com,布布扣}

无边框缩放,布布扣,bubuko.com

无边框缩放

标签:c   class   http   ext   a   int   

原文地址:http://www.cnblogs.com/cavehubiao/p/3752916.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!