⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 index162.htm

📁 一本不错的VC编程的参考书
💻 HTM
字号:
<html>
<style type="text/css"><!--
.p9 {  font-family: "宋体"; font-size: 9pt}a        {text-transform: none; text-decoration: none;}
a:hover {text-decoration: underline; color: #FF0000;}
--></style>
<body background="../di2001.jpg">
<h3 align="center"><font COLOR="#AOAO99"></font></h3>
<table width="100%" border="1" cellspacing="1">
<tr><td><p align="center"><font color="#FF0000">关于使用SetClassLong和SetCapture问题</font></td></tr>
<tr><td><p>
</Br>
我用SetClassLong设置对话框光标时遇到了一些问题,当我使用SetCapture捕获鼠标时,<Br>
</Br>
光标形状并没有变化时,以下为原代码:<Br>
</Br>
void CMouseMoveSimDlg::OnLButtonDown(UINT nFlags, CPoint point)<Br>
{<Br>
&nbsp;&nbsp;myDragging = TRUE;<Br>
</Br>
&nbsp;&nbsp;myhPrevCursor = (HCURSOR)SetClassLong( m_hWnd, GCL_HCURSOR,<Br>
&nbsp;&nbsp;&nbsp;(long)LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_SELECTCURSOR )));<Br>
</Br>
&nbsp;&nbsp;SetCapture(m_hWnd);<Br>
&nbsp;CDialog::OnLButtonDown(nFlags, point);<Br>
}<Br>
如果移去SetCapture这一行,光标就会正确的设置,但它就不能正确的捕获鼠标消息.那儿出问题了(环境NT4.0 VC6.0)?<Br>
</Br>
1).如果我没有记错的话,SetClassLong只影响调用它以后的建立的窗口.可以使用 SetWindowLong来改变已存在的窗口的属性.(为什么要用SetClassLong来改变光标形状, 为什么不在消息WM_SETCURSOR中替换.)<Br>
2).我也不清楚问题出在那儿,但下面的方法可以克服SetCapture带来的问题,它是从我的程序里面提出来的:<Br>
</Br>
</Br>
void CScribbleView::OnLButtonDown(UINT nFlags, CPoint point)<Br>
{<Br>
&nbsp;&nbsp;&nbsp;&nbsp;........<Br>
&nbsp;&nbsp;&nbsp;&nbsp;SetCapture(); // Capture the mouse until button up<Br>
</Br>
&nbsp;&nbsp;&nbsp;&nbsp;myhPrevCursor = (HCURSOR)SetClassLong( m_hWnd, GCL_HCURSOR,<Br>
</Br>
(long)LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_CURSOR1)));<Br>
</Br>
SetCursor(LoadCursor(AfxGetInstanceHandle(),MAKEINTRESOURCE(IDC_CURSOR1)));<Br>
&nbsp;&nbsp;&nbsp;&nbsp;........<Br>
}<Br>
</Br>
void CScribbleView::OnLButtonUp(UINT nFlags, CPoint point)<Br>
{<Br>
&nbsp;&nbsp;&nbsp;&nbsp;if( GetCapture() != this )<Br>
&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;return;<Br>
&nbsp;&nbsp;&nbsp;&nbsp;........<Br>
&nbsp;&nbsp;&nbsp;&nbsp;ReleaseCapture();<Br>
&nbsp;&nbsp;&nbsp;&nbsp;SetClassLong( m_hWnd, GCL_HCURSOR, (long)myhPrevCursor);<Br>
&nbsp;&nbsp;&nbsp;&nbsp;return;<Br>
}<Br>
</Br>
</p></td></tr>
</table>
</body></html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -