📄 subject_57091.htm
字号:
<p>
序号:57091 发表者:苗秦 发表日期:2003-10-22 20:02:12
<br>主题:谁有“点不到我”的代码
<br>内容:谁有在一个对话框上有两个按钮,一个不能点到,另外一个能点到的
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
回复者:小灿 回复日期:2003-10-22 21:09:44
<br>内容:自己编一个,<BR>响应OnMouseMove<BR>MoveWindow(...);<BR>在按钮的派生类
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:丁丁当当 回复日期:2003-10-23 11:00:58
<br>内容:点不到<BR><BR>void CMyButton::OnMouseMove(UINT nFlags, CPoint point) <BR>{<BR> // TODO: Add your message handler code here and/or call default<BR> CWnd* pParent = GetParent();<BR><BR> if(!pParent)pParent = GetDesktopWindow();<BR><BR> CRect ParentRect;<BR> pParent->GetClientRect(ParentRect);<BR> ClientToScreen(&point);//鼠标的位置<BR> pParent->ScreenToClient(&point);<BR><BR> CRect ButtonRect;//按钮大小<BR> GetWindowRect(ButtonRect);<BR> pParent->ScreenToClient(ButtonRect);<BR><BR> CPoint Center = ButtonRect.CenterPoint();//按钮中心位置<BR> CSize CriticalSize(ButtonRect.Width()/6,ButtonRect.Height()/6);<BR> CRect NewButtonRect = ButtonRect;//按钮新的位置<BR><BR> if(point.x - CriticalSize.cx > Center.x)//若鼠标在按钮中心位置的右边<BR> {<BR> if(ButtonRect.left > ParentRect.left + ButtonRect.Width() + m_nJumpDistance)<BR> NewButtonRect -= CSize(ButtonRect.right - point.x + m_nJumpDistance,0);<BR> else<BR> NewButtonRect += CSize(point.x - ButtonRect.left + m_nJumpDistance,0);<BR> }<BR> else if(point.x + CriticalSize.cx < Center.x)//若鼠标在按钮中心位置的左边<BR> {<BR> if(ButtonRect.right < ParentRect.right - ButtonRect.Width() - m_nJumpDistance)<BR> NewButtonRect += CSize(point.x - ButtonRect.left + m_nJumpDistance,0);<BR> else<BR> NewButtonRect -= CSize(ButtonRect.right - point.x + m_nJumpDistance,0);<BR> }<BR><BR> if(point.y - CriticalSize.cy > Center.y)//若鼠标在按钮中心位置的下边<BR> {<BR> if(ButtonRect.top >ParentRect.top + ButtonRect.Height() + m_nJumpDistance)<BR> NewButtonRect -= CSize(0,ButtonRect.bottom - point.y + m_nJumpDistance);<BR> else<BR> NewButtonRect += CSize(0,point.y - ButtonRect.top + m_nJumpDistance);<BR> }<BR> else if(point.y + CriticalSize.cy < Center.y)//若鼠标在按钮中心位置的上边<BR> {<BR> if(ButtonRect.bottom < ParentRect.bottom - ButtonRect.Height() - m_nJumpDistance)<BR> NewButtonRect += CSize(0,point.y - ButtonRect.top + m_nJumpDistance);<BR> else<BR> NewButtonRect -= CSize(0,ButtonRect.bottom - point.y + m_nJumpDistance);<BR> }<BR><BR> MoveWindow(NewButtonRect);//移动按钮<BR> <BR> RedrawWindow();//重画窗体<BR><BR><BR> CButton::OnMouseMove(nFlags, point);<BR>}<BR><BR>
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -