Kreij
Senior Monkey Moderator
- Joined
- Feb 6, 2007
- Messages
- 13,817 (2.07/day)
- Location
- Cheeseland (Wisconsin, USA)
I'm using P/Invoke to accesss the SystemParametersInfo method in the user32.dll and trying to set the mouse hover time (the time that elapses before a hover event is triggered).
The above code has exactly zero effect on the hover delay (visually), even though the first message box reports the delay to be 50ms and the second one shows it has changed to 2000ms.
When I display the return value from SystemParametersInfo, it returns true.
Anyone have any working code for changing this in SystemParameters, or perhaps pointing out something I'm doing wrong?
Thanks!
Code:
[[COLOR="Teal"]DllImport[/COLOR]([COLOR="Red"]"user32.dll"[/COLOR], EntryPoint=[COLOR="Red"]"SystemParametersInfo"[/COLOR], SetLastError = [COLOR="Blue"]true[/COLOR])]
[[COLOR="Blue"]return[/COLOR]: [COLOR="Teal"]MarshalAs[/COLOR]([COLOR="Teal"]UnmanagedType[/COLOR].Bool)]
[COLOR="Blue"]public static extern bool [/COLOR]SystemParametersInfo([COLOR="blue"]uint [/COLOR]action, [COLOR="blue"]uint [/COLOR]param, [COLOR="blue"]uint [/COLOR]vparam, [COLOR="blue"]uint [/COLOR]init);
[COLOR="blue"]private const uint[/COLOR] SPI_SETMOUSEHOVERTIME = 103;
[COLOR="blue"]private const uint [/COLOR]SPIF_UPDATEINIFILE = 0x01;
[COLOR="blue"]private const uint [/COLOR]SPIF_SENDCHANGE = 0x02;
[COLOR="blue"]public [/COLOR]Form1()
{
InitializeComponent();
SetAccesses();
[COLOR="Teal"]MessageBox[/COLOR].Show([COLOR="Teal"]SystemInformation[/COLOR].MouseHoverTime.ToString());
SystemParametersInfo(SPI_SETMOUSEHOVERTIME, ([COLOR="blue"]uint[/COLOR])2000, ([COLOR="blue"]uint[/COLOR])0, SPIF_UPDATEINIFILE | SPIF_SENDCHANGE);
[COLOR="Teal"]MessageBox[/COLOR].Show([COLOR="Teal"]SystemInformation[/COLOR].MouseHoverTime.ToString());
}
The above code has exactly zero effect on the hover delay (visually), even though the first message box reports the delay to be 50ms and the second one shows it has changed to 2000ms.
When I display the return value from SystemParametersInfo, it returns true.
Anyone have any working code for changing this in SystemParameters, or perhaps pointing out something I'm doing wrong?
Thanks!