我的对话框是无边框的:
我映射了WM_NCHITTEST消息,在里面检测鼠标是否在对话框边缘,若是,则返回HT_BORDER(自定义的);
映射WM_NCLBUTTONDOWN消息,在里面将bool型变量m_down设为真;
映射WM_NCMOUSEMOVE,判断(nHitTest == HT_BORDER && m_down),若是,则说明鼠标在对话框边缘且鼠标被按下并拖动了,接着应该怎么办?
或者各位有更好办法?
我映射了WM_NCHITTEST消息,在里面检测鼠标是否在对话框边缘,若是,则返回HT_BORDER(自定义的);
映射WM_NCLBUTTONDOWN消息,在里面将bool型变量m_down设为真;
映射WM_NCMOUSEMOVE,判断(nHitTest == HT_BORDER && m_down),若是,则说明鼠标在对话框边缘且鼠标被按下并拖动了,接着应该怎么办?
或者各位有更好办法?
解决方案 »
- 用createprocess()建立子进程,父进程想结束掉子进程,为何结束不掉?
- c语言 加入一个动态库
- 彩色图像需要先灰度变换才能小波变换么?
- 关于滚动条刷新屏幕的问题,高手请进!
- 怎样通过MyDC的句柄得到指向MyDC的指针?
- 我想写个程序可以给手机发短信息,不知谁有这方面的信息或者例子?分不够可以再加!
- 谁装了2000 server,帮我考个文件好吗?
- 谁能告诉我,VC和C++那一个好? 现在学C的话,是不是应该学VC.NET了?
- 怎么制作透明对话框?
- 如何编写浏览器的插件??
- 想了好久,没解决,郁闷!请教各位大虾,win32程序中怎样才能将菜单加进自己创建的窗口中去?
- Borland C++程序转换为VC++程序时*.dll的问题?
要例子,留下mail?
void CMyDlg::OnMouseMove(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
if(m_nMyHitTest == 20)//当鼠标没有选择拖动类型的时候改变鼠标状态
{
CRect rect;
CRect staticRect;
this->GetWindowRect(&rect);
ScreenToClient(&rect);
HCURSOR hCursor;
if(point.x > rect.left && point.x < rect.right &&
point.y > rect.top-FRAME_SPACE && point.y < rect.top+FRAME_SPACE)//上边框区域
{
hCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZENS);
SetCursor(hCursor);
}
else if(point.x > rect.left && point.x < rect.right &&
point.y > rect.bottom-FRAME_SPACE && point.y < rect.bottom+FRAME_SPACE)
{
hCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZENS);
SetCursor(hCursor);
}
else if(point.y > rect.top && point.y < rect.bottom &&
point.x > rect.left-FRAME_SPACE && point.x < rect.left+FRAME_SPACE)
{
hCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZEWE);
SetCursor(hCursor);
}
else if( point.y > rect.top && point.y < rect.bottom &&
point.x > rect.right-FRAME_SPACE && point.x < rect.right+FRAME_SPACE)
{
hCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZEWE);
SetCursor(hCursor);
}
GetDlgItem(IDC_STATIC_SIZE)->GetWindowRect(&staticRect);
ScreenToClient(staticRect);
if(staticRect.PtInRect(point))
{
hCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZENWSE);
SetCursor(hCursor);
}
}
CDialog::OnMouseMove(nFlags, point);
}
{
// TODO: Add your message handler code here and/or call default
CRect rect;
CRect staticRect;
this->GetWindowRect(&rect);
ScreenToClient(&rect);
HCURSOR hCursor;
if(point.x > rect.left && point.x < rect.right &&
point.y > rect.top-FRAME_SPACE && point.y < rect.top+FRAME_SPACE)//上边框区域
{
hCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZENS);
SetCursor(hCursor);
SetCapture();
m_bChangeSize = TRUE;
m_nMyHitTest = HTTOP;
}
else if(point.x > rect.left && point.x < rect.right &&
point.y > rect.bottom-FRAME_SPACE && point.y < rect.bottom+FRAME_SPACE)
{
hCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZENS);
SetCursor(hCursor);
SetCapture();
m_bChangeSize = TRUE;
m_nMyHitTest = HTBOTTOM;
}
else if(point.y > rect.top && point.y < rect.bottom &&
point.x > rect.left-FRAME_SPACE && point.x < rect.left+FRAME_SPACE)
{
hCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZEWE);
SetCursor(hCursor);
SetCapture();
m_bChangeSize = TRUE;
m_nMyHitTest = HTLEFT;
}
else if( point.y > rect.top && point.y < rect.bottom &&
point.x > rect.right-FRAME_SPACE && point.x < rect.right+FRAME_SPACE)
{
hCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZEWE);
SetCursor(hCursor);
SetCapture();
m_bChangeSize = TRUE;
m_nMyHitTest = HTRIGHT;
}
GetDlgItem(IDC_STATIC_SIZE)->GetWindowRect(&staticRect);
ScreenToClient(staticRect);
if(staticRect.PtInRect(point))
{
hCursor = AfxGetApp()->LoadStandardCursor(IDC_SIZENWSE);
SetCursor(hCursor);
SetCapture();
m_bChangeSize = TRUE;
m_nMyHitTest = HTBOTTOMRIGHT;
}
CDialog::OnLButtonDown(nFlags, point);
}void CMyDlg::OnLButtonUp(UINT nFlags, CPoint point)
{
// TODO: Add your message handler code here and/or call default
BOOL bChangeStatic = TRUE;
// TODO: Add your message handler code here and/or call default
if(m_bChangeSize)
{
m_bChangeSize = FALSE;
TRACE("OnLButtonUp\n");
::ReleaseCapture();
CPoint CurPoint;
CRect DlgRect;
GetCursorPos(&CurPoint);
GetWindowRect(DlgRect);
CRect rectTemp,rectTemp1;
GetDlgItem(IDC_STATIC_SIZE)->GetWindowRect(&rectTemp);
GetDlgItem(IDC_STATIC_SIZE)->GetWindowRect(&rectTemp1);
ScreenToClient(rectTemp1);
bChangeStatic = rectTemp1.PtInRect(point);
int RightWidth = DlgRect.right - rectTemp.right;
int BottomWidth = DlgRect.bottom - rectTemp.bottom;
int Width = rectTemp.right -rectTemp.left;
int Hight = rectTemp.bottom - rectTemp.top;
if(m_nMyHitTest == HTLEFT)
{
if(abs(DlgRect.left - CurPoint.x) > FRAME_SPACE)
DlgRect.left = CurPoint.x;
}
else if(m_nMyHitTest == HTRIGHT)
{
if(abs(DlgRect.right - CurPoint.x) > FRAME_SPACE)
DlgRect.right = CurPoint.x;
}
else if(m_nMyHitTest == HTTOP)
{
if(abs(DlgRect.top - CurPoint.y) > FRAME_SPACE)
DlgRect.top = CurPoint.y;
}
else if(m_nMyHitTest == HTTOPLEFT)
{
DlgRect.top = CurPoint.y;
DlgRect.left = CurPoint.x;
}
else if(m_nMyHitTest == HTTOPRIGHT)
{
DlgRect.top = CurPoint.y;
DlgRect.right = CurPoint.x;
}
else if(m_nMyHitTest == HTBOTTOM)
{
if(abs(DlgRect.bottom - CurPoint.y) > FRAME_SPACE)
DlgRect.bottom = CurPoint.y;
}
else if(m_nMyHitTest == HTBOTTOMLEFT)
{
DlgRect.bottom = CurPoint.y;
DlgRect.left = CurPoint.x;
}
else if(m_nMyHitTest == HTBOTTOMRIGHT)
{
if(!bChangeStatic)
{
DlgRect.bottom = CurPoint.y;
DlgRect.right = CurPoint.x;
}
}
MoveWindow(DlgRect);
SetRedrawArea(DlgRect);
if(!bChangeStatic)
{
rectTemp.right = DlgRect.right - RightWidth;
rectTemp.left = rectTemp.right - Width;
rectTemp.bottom = DlgRect.bottom - BottomWidth;
rectTemp.top = rectTemp.bottom - Hight;
ScreenToClient(rectTemp);
GetDlgItem(IDC_STATIC_SIZE)->MoveWindow(rectTemp);
}
m_nMyHitTest = 20; //恢复鼠标为未选择拖动状态
}
CDialog::OnLButtonUp(nFlags, point);
}
麻烦vcleaner(我没做大哥已经很久了.......)发一个给我,谢谢