|
-
November 29th, 2003, 02:04 AM
#1
how to Enable-Disable IE window
Hi all,
I am trying to enable or disable a particular IE window using EnableWindow win32 API using P/Invoke in my C# code.. This API requires to pass the handle of the window to be disabled or enabled. How can I get the Handle to a particular window?
I am trying to get all the processes running in my desktop using the Process.GetProcesses method and then by knowing the title of the window I am getting the handle of the process. but this handle to the process is changing every moment(I don't know why) and I think this handle to the process and hanle to the window is different thing. the code which I am using is as bellow :
Code:
private void button3_Click(object sender, System.EventArgs e)
{
Process [] allProcs = Process.GetProcessesByName("iexplore");
listBox1.Items.Clear() ;
foreach(Process ps in allProcs)
{
int index = listBox1.Items.Add( ps.ProcessName + " : " + ps.MainWindowTitle + " : " + ps.Handle) ;
}
}
private void button4_Click(object sender, System.EventArgs e)
{
if(listBox1.SelectedIndex <= 0)
{
return ;
}
int selIndex = listBox1.SelectedIndex ;
//get the handle of the selected item
string selItem = (string)listBox1.Items[selIndex] ;
MessageBox.Show(selItem) ;
string[] selProcessData = selItem.Split(new char[]{':'}) ;
int iHnadle = int.Parse( selProcessData[2].ToString().Trim()) ;
isProcessEnabled = EnableWindow((IntPtr)iHnadle, !(isProcessEnabled)) ;
}
}
I think I am much clear about the problem. Can anybody please help me...
thanks in advance...
Ashish Sheth
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
|