New Explorer Window not resizing

  • Thread starter Thread starter hazyblur
  • Start date Start date
H

hazyblur

I am building a C# Outlook add-in. When a new explorer window is
launched I subscribe to the event and resize the window. However, the
window refuses to resize and remains the same size as it was launched
initially. The initial size is the same as the initial explorer size
when outlook is opened for the first time.

Is there a way to resize the explorer windows appropriately? I am not
facing a problem with inspector windows.

I am ensuring that before resizing is done the Window state is set to
olNormalized and is not in the Maximized or Minimized state.

I am pasting snippet of my code here

Outlook.Explorers _exp;
Outlook.Inspectors _ins;

private void ThisApplication_Startup(object sender, System.EventArgs
e)
{
if (this.ActiveExplorer().WindowState ==
Microsoft.Office.Interop.Outlook.OlWindowState.olMaximized)
{

this.ActiveExplorer().WindowState =
Microsoft.Office.Interop.Outlook.OlWindowState.olNormalWindow;
}

_exp = this.Explorers;
_ins = this.Inspectors;


_exp.NewExplorer +=new
Microsoft.Office.Interop.Outlook.ExplorersEvents_NewExplorerEventHandler(_exp_NewExplorer);
_ins.NewInspector += new
Microsoft.Office.Interop.Outlook.InspectorsEvents_NewInspectorEventHandler(_ins_NewInspector);



}

void _exp_NewExplorer(Microsoft.Office.Interop.Outlook.Explorer
Explorer)
{

Explorer.Width = 400;
Explorer.Height = 400;
Explorer.Top = 50;
Explorer.Left = 50;

}


Please help.
 
NewExplorer isn't firing in this case because the Explorer is already there
when you subscribe to the NewExplorer event. That's obvious because you've
already accessed ActiveExplorer. Do your initial resizing in
ThisApplication_Startup.
 
Back
Top