المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : Cursor apply registry changes [modified]



C# Programming
09-19-2009, 04:52 PM
I am working on a screen capture project that uses a global mouse hook. It works great.
currently when the user holds the right mouse button down for a time the cursor changes to a hand.
see below

[DllImport("user32.dll")]
static extern IntPtr LoadCursor(IntPtr hInstance, int lpCursorName);
private int IDC_HAND = 32649; /// IDC_HAND = 32649;///IDC_UPARROW=32516///IDC_CROSS=32515
private const uint OCR_NORMAL = 32512;

on event

private void setcursor()
{
IntPtr hcursor = LoadCursor(IntPtr.Zero, IDC_HAND);/// IDC_HAND/// IDC_UPARROW//IDC_CROSS
bool ret_val = SetSystemCursor(hcursor, OCR_NORMAL);
}
What I need is a LARGE CROSS
so I made these changes

DllImport("user32.dll")]
static extern IntPtr LoadCursor(IntPtr hInstance, int lpCursorName);
private int IDC_CROSS=32515; /// IDC_HAND = 32649;///IDC_UPARROW=32516///IDC_CROSS=32515
private const uint OCR_NORMAL = 32512;

private void Form1_Load(object sender, EventArgs e)
{
RegistryKey loadcursor = Registry.CurrentUser.OpenSubKey("Control Panel\\Cursors", true);
loadcursor.SetValue("Crosshair","%SYSTEMROOT%\\Cursors\\lcross.cur");
loadcursor.Close();
}

on event
private void setcursor()
{
IntPtr hcursor = LoadCursor(IntPtr.Zero, IDC_CROSS);/// IDC_HAND/// IDC_UPARROW//IDC_CROSS
bool ret_val = SetSystemCursor(hcursor, OCR_NORMAL);
}
am changing the poiter of the crosshair cursor the crude way !
dont now how to make it apply the rgistry changes. so that you dont
have re boot to make changes apply.
I would do it in the private void setcursor(),
but there is no system "large crosshair cursor".
only lcross.cur in windows/cursors.

AM I MESSED UP OR WHAT?
Thanks,
Regards.

P.S.
here is a link to the published project
it works great. Just want to put a little polish on it.
www.softsourcesolutions.com/nabit.zip

modified on Friday, September 18, 2009 10:33 PM