更改光标(不在我的表单中)。 [英] Changing cursor(Not in my form only).

查看:72
本文介绍了更改光标(不在我的表单中)。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想不仅在我的表单中更改光标。当我完成后我想把它改回来。

任何帮助?!



提前致谢:)



从下面的评论中复制的附加内容

我试过这段代码:

I want to change the cursor not only in my form. And when i finish i want to change it back as it was.
Any help?!

Thanks in advance :)

additonal content copied from comment below
I tried this code:

Private Const OCR_NORMAL As UInteger = 32512
<DllImport("user32.dll")> _
Private Shared Function LoadCursorFromFile _
                        (ByVal lpFileName As String) _
                        As IntPtr
End Function
<DllImport("user32.dll")> _
Private Shared Function SetSystemCursor _
                        (ByVal hCursor As IntPtr, _
                        ByVal id As Integer) _
                        As Boolean
End Function
<DllImport("user32.dll")> _
Public Shared Function LoadCursor(ByVal hInstance As IntPtr, _
                                  ByVal id As UInteger) _
                                  As IntPtr
End Function
Private Sub frm_Load(ByVal sender As System.Object, _
                               ByVal e As System.EventArgs) _
                               Handles MyBase.Load
   Dim cursor As IntPtr = LoadCursorFromFile("C:\cursor.cur")
   SetSystemCursor(cursor, OCR_NORMAL)
End Sub
Private Sub btn_Click(ByVal sender As System.Object, _
                      ByVal e As System.EventArgs) _
                      Handles btn.Click
    SetSystemCursor(LoadCursor(IntPtr.Zero, OCR_NORMAL), OCR_NORMAL)
End Sub



------------------------------- --------------------------------------------------

此代码用于更改光标,但它没有返回它:(


---------------------------------------------------------------------------------
This code worked for changing the cursor, but it didnt return it back :(

推荐答案

在设置自定义光标之前,你有将当前光标写入应用程序的某个变量(不是像GetSystemCursor这样的函数吗?),以及当应用程序停止时(例如在FormClosing事件中,您将其设置回上面存储的原始值。
Before you set your custom Cursor, you have to write the current cursor into some variable of your application (isn't there a function like GetSystemCursor?), and when your application stops (e.g. in the FormClosing event), you set it back to the original value which you stored above.


这篇关于更改光标(不在我的表单中)。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆