Clipping cursor
Hello, I launch a few processes from my application. This application clips mouse cursor. The problem is when process becomes an active window clipping doesn't work. I want to set Cursor.Clip for all child processes. Does anybody know how to do this ?
AlexandrPosted Sep 9, 2008, 2:07 AM
Hello, thank you for your answer. This is a part of code that does launching and clipping.
private void SomeApp_Load(object sender, EventArgs e)
{
....
Cursor.Clip = new Rectangle(x, y, width, height);
....
}
void SomeBtn_Click(object sender, EventArgs e)
{
switch(settingName)
{
case "ADM":
string CommandLine = "Rundll32.exe Shell32.dll,Control_RunDLL timedate.cpl";
PROCESS_INFORMATION pInfo = new PROCESS_INFORMATION();
STARTUPINFO sInfo = new STARTUPINFO();
sInfo.dwFlags = STARTF_USEPOSITION;
sInfo.dwX = (uint)(Bounds.X + Width/5);
sInfo.dwY = (uint)(Bounds.Y + Height/5);
SECURITY_ATTRIBUTES pSec = new SECURITY_ATTRIBUTES();
SECURITY_ATTRIBUTES tSec = new SECURITY_ATTRIBUTES();
pSec.length = Marshal.SizeOf(pSec);
tSec.length = Marshal.SizeOf(tSec);
bool retValue = CreateProcess(null, CommandLine, ref pSec, ref tSec, false, 0,
IntPtr.Zero, null, ref sInfo, out pInfo);
Process dialogProcess = Process.GetProcessById((int)pInfo.dwProcessId);
dialogProcess.WaitForInputIdle(2000);
bool p = SetForegroundWindow(dialogProcess.MainWindowHandle);
Cursor.Clip = new Rectangle(x, y, width, height);
break;
}
}
Bechir BejaouiPosted Sep 8, 2008, 12:55 PM