Re: Outlook form is not always maximized



You could try using the Explorer.WindowState property which uses an enum: olMaximized, olMinimized and olNormalWindow if you want to try to force the main Outlook window display. Inspectors also have the same property so you can try that.

I've found that when Outlook is minimized that child windows also open minimized. The only solution I've tried that works is to use the Win32 API function SetForegroundWindow, using the hWnd of the new form (window).

I use code something like this (VB):

With NewWindow
ShowWindow .hWnd, SW_NORMAL
SetForegroundWindow .hWnd
.Move (Screen.Width - .Width) \ 2, ((Screen.Height - .Height) \ 2) - 100
End With

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


"Alex" <Alex.Avid@xxxxxxxxxxxxxxxxx> wrote in message news:ezm5jN$ZGHA.4144@xxxxxxxxxxxxxxxxxxxxxxx
Hi,
I am hoping this is the right forum for this question; if not, please let me know where it would be more appropriate.

I am using Outlook Object Model in C# to create a Task or an Appointment object and pre-fill it with user information. Once all the info is setup, I pop up the Outlook form for the user to complete, and save (or cancel) into their outlook. This is what the code looks like:

Outlook.ApplicationClass oApp = null;

Outlook.MAPIFolder oTaskFolder = null;

Outlook.TaskItemClass oTask = null;

try {

// setup outlook objects

oApp = new Outlook.ApplicationClass();

oTaskFolder = (Outlook.MAPIFolder)oApp.GetNamespace( "MAPI" ).GetDefaultFolder( Outlook.OlDefaultFolders.olFolderTasks);

oTask = (Outlook.TaskItemClass)oTaskFolder.Items.Add( "IPM.Task" );

// setup task properties

oTask.Subject = "Call ";

oTask.StartDate = DateTime.Now.AddDays(1);

oTask.DueDate = oTask.StartDate.AddMinutes(15);

// Reminders off by default.

oTask.ReminderSet = false;

// Set Outlook properties, if not available, create the property, then set it.

try {

oTask.UserProperties.Item( "ACTIVITYCODE" ).Value = iCode.ToString();

}

catch {

oTask.UserProperties.Add( "ACTIVITYCODE", Outlook.OlUserPropertyType.olNumber, System.Reflection.Missing.Value, System.Reflection.Missing.Value );

oTask.UserProperties.Item( "ACTIVITYCODE" ).Value = iCode;

}

try {

oTask.UserProperties.Item("ACCOUNTID").Value = strAccountID;

oTask.UserProperties.Item("CONTACTID").Value = strContactID;

oTask.UserProperties.Item("OPPORTUNITYID").Value = strOpportunityID;

}

catch{}


}

oTask.Display( false );



The problem is that sometimes, if Outlook is minimized, the form doesn't "pop-up" but stays minimized, and flashes in the task bar. I need to force it to always pop-up. Using Windows API is not helping:

// attempt to locate outlook window and focus on it.

string sText = oTask.Subject + " - Task ";

IntPtr hwnd = FindWindow( null, sText );

ShowWindow( hwnd, 9);



Is there anything I can do to guarantee that the window will be placed on top and activated?



TIA

Alex



.



Relevant Pages

  • Re: How to add button on Mail editor which is not outlook.??
    ... Dim hwnd As Long ... Outlook editor the window class name is "rctrl_renwnd32". ... the main Outlook Explorer window while your form is open, ...
    (microsoft.public.office.developer.outlook.vba)
  • Using Outlook with Lotus Notes R7
    ... running Lotus Notes R5, and I've been succesfully running the Microsoft- ... provided Outlook Connector for IBM Lotus Domino. ... In the Control Panel's Mail window, I created a new profile named Outlook, ...
    (microsoft.public.outlook.interop)
  • Re: please help. I cannot connect to my outlook express 6
    ... Right click in the command window and choose Select All, ... Ethernet adapter Local Area Connection: ... If the router is off and you start OE, does OE send and receive email? ... Settings in Outlook Express at Tools>Accts>Mail> ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)
  • Re: Using Outlook with Lotus Notes R7
    ... provided Outlook Connector for IBMLotusDomino. ... unsuccesful in getting myLotusNotes email and calendar to display in ... On the Server Type page of the wizard, ... closed the Mail window. ...
    (microsoft.public.outlook.interop)
  • Re: A Major Problem - IE - OE - Outlook - MS Exchange
    ... Description of the Fixmapi.exe Tool Included with Internet Explorer 5 ... > I have a problem with either IE, OE, Outlook, or MS Exchange and I am ... > Outlook Express 6 which I use for mail and newsgroups ... > little window that says "Choose Profile". ...
    (microsoft.public.windows.inetexplorer.ie6_outlookexpress)