Click here to Skip to main content
16,005,552 members
Home / Discussions / C#
   

C#

 
QuestionPropertyGrid: Problem viewing arrays Pin
mitul198319-Mar-06 0:22
mitul198319-Mar-06 0:22 
AnswerRe: PropertyGrid: Problem viewing arrays Pin
mitul198319-Mar-06 2:10
mitul198319-Mar-06 2:10 
QuestionFloating panes Pin
deepscyberpulse18-Mar-06 21:48
deepscyberpulse18-Mar-06 21:48 
AnswerRe: Floating panes Pin
Shiby19-Mar-06 1:57
Shiby19-Mar-06 1:57 
QuestionPath of current project. Pin
deepscyberpulse18-Mar-06 21:45
deepscyberpulse18-Mar-06 21:45 
AnswerRe: Path of current project. Pin
cbhkenshin18-Mar-06 22:17
cbhkenshin18-Mar-06 22:17 
AnswerRe: Path of current project. Pin
Ed.Poore18-Mar-06 22:32
Ed.Poore18-Mar-06 22:32 
QuestionCapture events of running instance of IE Pin
Mario Williams18-Mar-06 20:06
Mario Williams18-Mar-06 20:06 
I would like to capture the specific events of running instances of IE. I am using the ShellWindows to get all the running instances of IE. I can get the some of the events to fire, such as OnTitleChange. But, I cannot get the WindowSetLeft event to fire. I am trying to use this event so that I know when the user is moving one of the IE windows on the screen. I need to know the position of each IE window when it changes. Thanks for the help in advance.





using System;
using System.IO;
using SHDocVw;
using System.Text;
using System.Drawing;
using System.Collections;
using System.Windows.Forms;
using System.ComponentModel;
using System.Collections.Generic;
using System.Runtime.InteropServices;




namespace JTCG.JWS.Browse.BrowseTOC
{
public class ActivityMonitor
{

[DllImport("User32.Dll")]
public static extern void GetWindowText(int h, StringBuilder s, int nMaxCount);

//variable declaration
private SHDocVw.InternetExplorer browser;
private SHDocVw.ShellWindows shellWindows;
private ArrayList Current_IE_Handles;



#region Constructor

public ActivityMonitor()
{
Current_IE_Handles = new ArrayList();
shellWindows = new SHDocVw.ShellWindowsClass();
shellWindows.WindowRegistered += new SHDocVw.DShellWindowsEvents_WindowRegisteredEventHandler(shellWindows_WindowRegistered);
shellWindows.WindowRevoked += new SHDocVw.DShellWindowsEvents_WindowRevokedEventHandler(shellWindows_WindowRevoked);
}

#endregion


// THIS EVENT IS FIRED WHEN THE A NEW BROWSER IS CLOSED
private void shellWindows_WindowRevoked(int z)
{
//variable declaration
string filnam;
ArrayList Closed_IE;
StringBuilder sb;

//variable initialization
Closed_IE = new ArrayList();
sb = new StringBuilder(1024);


foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
filnam = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();

if (filnam.Equals("iexplore"))
{
Closed_IE.Add(ie.HWND.ToString());
}
}

for (int i=0; (i< this.Current_IE_Handles.Count); i++)
{
bool check = false;

for (int j=0; (j<Closed_IE.Count); j++)
{
if (Convert.ToInt32(this.Current_IE_Handles[i]) == Convert.ToInt32(Closed_IE[j]))
check = true;
}
//IE handle not in ArrayList
if (check == false)
{
this.Current_IE_Handles.RemoveAt(i);
break;
}
}
}




// THIS EVENT IS FIRED WHEN THE A NEW BROWSER IS OPEN
private void shellWindows_WindowRegistered(int z)
{
//variable declaration
string filnam;
StringBuilder sb;

//variable initialization
sb = new StringBuilder(1024);

//loop through all windows in shell
foreach (SHDocVw.InternetExplorer ie in shellWindows)
{
filnam = Path.GetFileNameWithoutExtension(ie.FullName).ToLower();

if (filnam.Equals("iexplore"))
{
browser = ie;

bool check = true;

for (int i=0; (i<Current_IE_Handles.Count); i++)
{
if (Current_IE_Handles[i].ToString() == browser.HWND.ToString())
{
check = false;
break;
}
}

if (check == true)
{
Current_IE_Handles.Add(browser.HWND.ToString());
//-----------------------------------------------------------------
//-------------------My code below---------------------------------


IWebBrowserApp m_WebBrowserApp = (IWebBrowserApp)browser;


//set up events may want to make below code a method
if (m_WebBrowserApp != null)
{
//Application.DoEvents();

DWebBrowserEvents2_WindowSetLeftEventHandler DSetLeft = new DWebBrowserEvents2_WindowSetLeftEventHandler(WindowSetLeft);
browser.WindowSetLeft += DSetLeft;

DWebBrowserEvents2_TitleChangeEventHandler DTitleChangeE = new DWebBrowserEvents2_TitleChangeEventHandler(OnTitleChange);
browser.TitleChange += DTitleChangeE;
}

//-----------------------END of my code----------------------------
}
}
}
}


static void OnTitleChange(String Text)
{
MessageBox.Show("Title changes to " + Text);
}


static void WindowSetLeft(int Left)
{
MessageBox.Show("set left : " + Left.ToString());
}
}
}


Mario Williams
Systems Analyst (DoD)
Eglin Air Force Base, FL
QuestionHow to replace a control in designer ? Pin
chloh18-Mar-06 19:21
chloh18-Mar-06 19:21 
AnswerRe: How to replace a control in designer ? Pin
leppie18-Mar-06 19:30
leppie18-Mar-06 19:30 
GeneralRe: How to replace a control in designer ? Pin
chloh18-Mar-06 20:26
chloh18-Mar-06 20:26 
QuestionHow to write a flat menu and toolbar like VS2005? Pin
Newlad18-Mar-06 17:47
Newlad18-Mar-06 17:47 
AnswerRe: How to write a flat menu and toolbar like VS2005? Pin
Ravi Bhavnani18-Mar-06 17:57
professionalRavi Bhavnani18-Mar-06 17:57 
QuestionGUI Similare Musicmatch, itune or Windows Media Manager. Pin
temp555618-Mar-06 17:27
temp555618-Mar-06 17:27 
AnswerRe: GUI Similare Musicmatch, itune or Windows Media Manager. Pin
Ravi Bhavnani18-Mar-06 18:01
professionalRavi Bhavnani18-Mar-06 18:01 
AnswerAlso... Pin
Ravi Bhavnani18-Mar-06 18:07
professionalRavi Bhavnani18-Mar-06 18:07 
QuestionSimple question(i hope) about ComboBox Pin
e-laj18-Mar-06 11:24
e-laj18-Mar-06 11:24 
AnswerRe: Simple question(i hope) about ComboBox Pin
Ed.Poore18-Mar-06 12:49
Ed.Poore18-Mar-06 12:49 
GeneralRe: Simple question(i hope) about ComboBox Pin
e-laj18-Mar-06 13:25
e-laj18-Mar-06 13:25 
AnswerRe: Simple question(i hope) about ComboBox Pin
Guffa18-Mar-06 14:19
Guffa18-Mar-06 14:19 
GeneralRe: Simple question(i hope) about ComboBox Pin
e-laj18-Mar-06 14:31
e-laj18-Mar-06 14:31 
GeneralRe: Simple question(i hope) about ComboBox Pin
Ed.Poore18-Mar-06 22:26
Ed.Poore18-Mar-06 22:26 
GeneralRe: Simple question(i hope) about ComboBox Pin
e-laj19-Mar-06 2:57
e-laj19-Mar-06 2:57 
GeneralRe: Simple question(i hope) about ComboBox Pin
e-laj19-Mar-06 3:21
e-laj19-Mar-06 3:21 
GeneralRe: Simple question(i hope) about ComboBox Pin
Ed.Poore19-Mar-06 7:08
Ed.Poore19-Mar-06 7:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.