How to create an array of a certain type

  • Thread starter Thread starter garyusenet
  • Start date Start date
G

garyusenet

I am writing a programme that when run will list the current internet
explorer windows open, and allow the user to choose which one they
would like to work with. At the moment I have managed to get as far as
finding open windows, and detecting which ones are internet explorer
windows, but I do not know how to store the ones that are internet
explorer windows and reference them later.

My idea was that I could create an array of type ShellWindows and store
those windows that matched the following check: -

Int32 iLocation = ie.FullName.IndexOf("iexplore");
if (iLocation >= 0)

The check works ok, but i don't know how to store the windows that pass
this check into an array for future use.

Any assistance would be useful.

Gary.



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SHDocVw;



namespace InternetExplorerInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private void Form1_Load(object sender, EventArgs e)
{


foreach (InternetExplorer ie in new ShellWindows())
{

Int32 iLocation = ie.FullName.IndexOf("iexplore");
if (iLocation >= 0)

{
MessageBox.Show(ie.LocationName);
MessageBox.Show(ie.LocationURL);
}


}

}
}
}
 
I am writing a programme that when run will list the current internet
explorer windows open, and allow the user to choose which one they
would like to work with. At the moment I have managed to get as far as
finding open windows, and detecting which ones are internet explorer
windows, but I do not know how to store the ones that are internet
explorer windows and reference them later.

My idea was that I could create an array of type ShellWindows and
store those windows that matched the following check: -

Int32 iLocation = ie.FullName.IndexOf("iexplore");
if (iLocation >= 0)
The check works ok, but i don't know how to store the windows that
pass this check into an array for future use.

Any assistance would be useful.

Try this:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using SHDocVw;

namespace InternetExplorerInterface
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}

private List<InternetExplorer> ieList = new List<InternetExplorer>();

private void Form1_Load(object sender, EventArgs e)
{
foreach (InternetExplorer ie in new ShellWindows())
{
Int32 iLocation = ie.FullName.IndexOf("iexplore");
if (iLocation >= 0)
ieList.Add(ie);
}
}
}
}


Best Regards,
Dustin Campbell
Developer Express Inc
 
Back
Top