Re: Outlook form is not always maximized
- From: "Ken Slovak - [MVP - Outlook]" <kenslovak@xxxxxxxx>
- Date: Tue, 25 Apr 2006 09:40:39 -0400
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
.
- Follow-Ups:
- Re: Outlook form is not always maximized
- From: Alex
- Re: Outlook form is not always maximized
- References:
- Outlook form is not always maximized
- From: Alex
- Outlook form is not always maximized
- Prev by Date: Re: HOWTO: Remove parenthesis for phone numbers in Outlook
- Next by Date: Re: Outlook form is not always maximized
- Previous by thread: Outlook form is not always maximized
- Next by thread: Re: Outlook form is not always maximized
- Index(es):
Relevant Pages
|