|
-
Dec 30th, 2005, 02:44 PM
#1
Thread Starter
New Member
Applying Registry Settings In VB.Net
I am working on an application that allows the user to change the Mouse Properties Pointer Scheme to custom designed mouse pointers.
I have found a way to write the new mouse cursors to the registry using VB.Net and the registry location of HKEY_CURRENT_USER\Control Panel\Cursors.
The problem that I am having is that I do not know how to get Windows to re-read and apply these new registry settings without logging off and then back on or re-starting the computer.
If anyone know how to do this, I would really appreciate the advice.
Thanks
Mike
-
Dec 30th, 2005, 05:07 PM
#2
Re: Applying Registry Settings In VB.Net
I figured there was a way to do it in API, and after working with it, found out how to do it...
VB Code:
'API declarations (form level in test)
Declare Function SetSystemCursor Lib "user32.dll" ( _
ByVal hcur As Int32, _
ByVal id As Int32) As Int32
Declare Function LoadCursorFromFile Lib "user32.dll" Alias "LoadCursorFromFileA" ( _
ByVal lpFileName As String) As Int32
'constant for the "normal" cursor (main arrow graphic)
Private Const OCR_NORMAL As Int32 = 32512
'now in a sub, like button click...
SetSystemCursor((LoadCursorFromFile("C:\WINDOWS\Cursors\3dgarro.cur")), OCR_NORMAL)
This successfully changed my main arrow cursor to a bronze arrow (which is what 3dgarro is).
Notice the path to the file, that is the cursor directory on my machine, hard coded, used as a test. For your app I believe that you would have to get the windows folder path, since it wont always be "c:\windows". Also, this was tested on my XP machine, win2k might be different...
Also note that there are other "states" other than "OCR_NORMAL" that would have to be changed with other graphics as well if you wish to change all the states of the cursor. The one in this example was just the main arrow cursor.
Last edited by gigemboy; Dec 30th, 2005 at 05:11 PM.
-
Jan 1st, 2006, 01:52 PM
#3
Thread Starter
New Member
Re: Applying Registry Settings In VB.Net
Thank you!
That is a big help. But I am very new to VB.Net and don't understand how to change each of the 14 cursors that the system uses.
I have tried changing the path to the graphic to be used as the mouse icon, and that works with no problem. But when I try changing the type of mouse cursor, say I want to change the i-beam icon to a diffrent one.
I do a;
Private Const OCR_IBEAM As Int32 = 32512
And then place the IBEAM at the end of the line;
SetSystemCursor((LoadCursorFromFile("C:\WINDOWS\Cursors\3dgarro.cur")), OCR_IBEAM)
But each time it only changes the main cursor and the text (IBEAM) cursor which sould come up when I place the cursor over text, stays the same.
I know I must be missing something that is obviuos to an experienced programmer.
Your help is appreceiated.
Mike
-
Jan 1st, 2006, 02:25 PM
#4
Re: Applying Registry Settings In VB.Net
The value 32512 specifically indicates the OCR_NORMAL cursor. If you want to specify the other cursors then you need to find the constant values that correspond to them. I'd suggest that you do a Google search for each of the constant names listed on MSDN in the help topic for SetSystemCursor. You're almost certain to find some pages that will give you the appropriate values for each, probably all on one page.
-
Jan 1st, 2006, 04:02 PM
#5
Re: Applying Registry Settings In VB.Net
Here's the rest of the OCR_ constants, as listed in "ApiViewer 2004" (my choice of API lookup program, as it has a .NET mode with the .NET function declaration changes )
VB Code:
Const OCR_APPSTARTING As Int32 = 32650
Const OCR_CROSS As Int32 = 32515
Const OCR_HAND As Int32 = 32649
Const OCR_IBEAM As Int32 = 32513
Const OCR_ICOCUR As Int32 = 32647
Const OCR_ICON As Int32 = 32641
Const OCR_NO As Int32 = 32648
Const OCR_SIZE As Int32 = 32640
Const OCR_SIZEALL As Int32 = 32646
Const OCR_SIZENESW As Int32 = 32643
Const OCR_SIZENS As Int32 = 32645
Const OCR_SIZENWSE As Int32 = 32642
Const OCR_SIZEWE As Int32 = 32644
Const OCR_UP As Int32 = 32516
Const OCR_WAIT As Int32 = 32514
Last edited by gigemboy; Jan 1st, 2006 at 04:06 PM.
-
Jan 1st, 2006, 08:56 PM
#6
Thread Starter
New Member
Re: Applying Registry Settings In VB.Net
Fantastic! I have them all working now.
Can’t thank you enough for the help, this has been driving me nuts for weeks now. I will combine this with writing the information to the registry, to update the Mouse Properties, Pointers and Schemes in case the user looks at the settings there, and I have a good portion of what I needed!
Would you have any idea how to change the text cursor throughout the system?
Thanks again and have a good New Year.
Mike
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|