VB调用标准DLL里面的鼠标图标
在VC++里面建立一个资源DLL,里面有字符串,图片和ICON,这些怎么调用在网上都有说明,却没有介绍怎么调用鼠标的光标.
大家都知道VB6本身不支持动画光标和彩色的,如果需要可以用API,我可以实现这个功能.但如果要访问DLL里面就没有办法了.不知道
哪位高手知道..指点一二?
[解决办法]
用DrawIcon或者是更高级的DrawIconEx,然后好像还要配合ExtractIcon用
Public Declare Function DrawIcon Lib "user32" Alias "DrawIcon" (ByVal hdc As Long, ByVal x As Long, ByVal y As Long, ByVal hIcon As Long) As Long
Public Declare Function DrawIconEx Lib "user32" Alias "DrawIconEx" (ByVal hdc As Long, ByVal xLeft As Long, ByVal yTop As Long, ByVal hIcon As Long, ByVal cxWidth As Long, ByVal cyWidth As Long, ByVal istepIfAniCur As Long, ByVal hbrFlickerFreeDraw As Long, ByVal diFlags As Long) As Long
Public Declare Function ExtractIcon Lib "shell32.dll" Alias "ExtractIconA" (ByVal hInst As Long, ByVal lpszExeFileName As String, ByVal nIconIndex As Long) As Long
别人有个介绍,我就是在这里面看的http://blog.csdn.net/tanaya/article/details/120362
[解决办法]
但是想用动画ANI那就得用很复杂的东西……我也是找了很久才找到
http://www.vbaccelerator.com/home/vb/code/libraries/graphics_and_gdi/animated_cursors_in_vb/vbaccelerator_animated_cursor_classes_sample.asp
上面这个是示例,我现在用的就是这个,代码太多了,我都不知道可以删掉那些无用的……(VB新人)
不过这个代码不支持exe和dll,我自己手动给cAniCursor.cls里面的“LoadFromFile”子程序仿照前面那个简单的修改了下,把原先的
m_hCur = LoadImageString(App.hInstance, sFileName, IMAGE_CURSOR, 0, 0, lFlags)
改成了下面这个,就能在加载时也读取exe或dll的了(需要加入其没有的ExtractIcon的生明和那两个存文件地址和图标编号的变量)
If InStr(sFileName, ".exe,") <> 0 Then
dll_path = Left(sFileName, InStr(sFileName, ".exe,") + 3)
dll_ico_num = Right(sFileName, Len(sFileName) - InStr(sFileName, ".exe,") - 4)
m_hCur = ExtractIcon(App.hInstance, dll_path, dll_ico_num)
ElseIf InStr(sFileName, ".dll,") <> 0 Then
dll_path = Left(sFileName, InStr(sFileName, ".dll,") + 3)
dll_ico_num = Right(sFileName, Len(sFileName) - InStr(sFileName, ".dll,") - 4)
m_hCur = ExtractIcon(App.hInstance, dll_path, dll_ico_num)
Else
m_hCur = LoadImageString(App.hInstance, sFileName, IMAGE_CURSOR, 0, 0, lFlags) '一般
End If