明经CAD社区

 找回密码
 注册

QQ登录

只需一步,快速开始

搜索
查看: 1630|回复: 1

vba里面可以控制鼠标的形状吗?

[复制链接]
发表于 2003-12-1 11:52:00 | 显示全部楼层 |阅读模式
发表于 2003-12-1 12:41:00 | 显示全部楼层
下面的是一个VB的示例,供参考吧。

  1. Private Declare Function LoadCursor Lib "user32" Alias "LoadCursorA" (ByVal hInstance As Long, ByVal lpCursorName As Long) As Long
  2. Private Declare Function SetClassWord Lib "user32" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal wNewWord As Long) As Long
  3. Private Declare Function LoadCursorFromFile Lib "user32" Alias "LoadCursorFromFileA" (ByVal lpFileName As String) As Long
  4. Private Declare Function DestroyCursor Lib "user32" (ByVal hCursor As Long) As Long
  5. Const GCW_HCURSOR = (-12)
  6. Const IDC_SIZEALL = 32646&
  7. Dim SysCursHandle As Long, Curs1Handle As Long, Curs2Handle As Long
  8. Private Sub Form_Load()
  9.     'KPD-Team 1999
  10.     'URL: http://www.allapi.net/
  11.     'E-Mail: KPDTeam@Allapi.net
  12.     'Load a default cursor
  13.     Curs1Handle = LoadCursor(ByVal 0&, IDC_SIZEALL)
  14.     'Load a cursor from a file
  15.     Curs2Handle = LoadCursorFromFile("C:\Windows\Cursors\pen_1.cur")
  16.     'Set the form's mouse cursor
  17.     SysCursHandle = SetClassWord(Me.hwnd, GCW_HCURSOR, Curs1Handle)
  18.     'Set the button's cursor
  19.     SysCursHandle = SetClassWord(Command1.hwnd, GCW_HCURSOR, Curs2Handle)
  20. End Sub
  21. Private Sub Form_Unload(Cancel As Integer)
  22.     'Set the form's cursor back to the original cursor
  23.     SetClassWord Me.hwnd, GCW_HCURSOR, SysCursHandle
  24.     'Clean up
  25.     DestroyCursor Curs1Handle
  26.     DestroyCursor Curs2Handle
  27. End Sub
您需要登录后才可以回帖 登录 | 注册

本版积分规则

小黑屋|手机版|CAD论坛|CAD教程|CAD下载|联系我们|关于明经|明经通道 ( 粤ICP备05003914号 )  
©2000-2023 明经通道 版权所有 本站代码,在未取得本站及作者授权的情况下,不得用于商业用途

GMT+8, 2024-11-28 13:50 , Processed in 0.156257 second(s), 24 queries , Gzip On.

Powered by Discuz! X3.4

Copyright © 2001-2021, Tencent Cloud.

快速回复 返回顶部 返回列表