Win32API之设置鼠标光标样式

太之初一 posted @ 2016年6月15日 16:37 in Windows with tags C C++ WIN32API 基础 , 6117 阅读

我目前还在做Windows程序设计的课程实验,开发一个编辑器。我尝试设置鼠标光标样式为IDC_IBEAM

SetCursor(LoadCursor(IDC_IBEAM));

但是没有什么作用,鼠标会在点击左键的时候消失一下,一移动又回来了,不过还是原来的光标。

在网上查到,需要在SetCursor之前先设置原来的光标不显示,设置之后再显示新的光标。

ShowCursor(FALSE);

SetCursor(LoadCursor(IDC_IBEAM));

ShowCursor(TRUE);

结果依然令人失望。幸运的是,我在网上找到了这样一个解答:

如果产生了鼠标消息,系统可能会用窗口的hcursor重新刷新光标,
所以用

SetClassLong(hwnd,GCL_HCURSOR,(long)LoadCursor(NULL,IDC_CROSS));

才能一直保持。

按这个方法尝试后,鼠标成功地变成了插入符,并且不受点击等鼠标操作影响。

Avatar_small
TNDGE Plus One Previ 说:
2022年8月16日 18:53

This board oversees a large number of schools in the state of Tamil Nadu, and it makes every effort to give its pupils access to a top-notch education. This board also held 11th-class exams during the current academic year in the state of Tamil Nadu, and all students who registered for those exams are currently awaiting the TN +1 Important Question Paper 2023. TNDGE Plus One Previous Paper 2023 The Directorate of Government Examinations, Tamil Nadu, released the TN 11th Question Paper 2023 for these examinations in May. Approximately 88.1% of the pupils that participated in the tests were successful.


登录 *


loading captcha image...
(输入验证码)
or Ctrl+Enter