"can't show a non modal form when modal form is displayed"

T

tomer

Hi,

As i understood there is some problems displaying modal dialogs from
outlook,
So my add in uses modeless dialog

while outlook propeties dialog was opened,my add in tried to display a
modeless dialog
and i get the following error:

"can't show a non modal form when modal form is displayed"

What can i do inorder to solve the problem? can i detect whenever a modal
form is opened?


Thanks in advance
 
K

Ken Slovak - [MVP - Outlook]

There are problems when displaying an Inspector modally, I use modal
VB forms in my addins and also from Outlook property pages. It depends
on whether I want the form code to run before any other code that
follows the call to the form. You will have to provide more
information about what you are doing and how.
 
T

tomer

Thanks ken.

Here is what I am doing:

When a new message arrived to the inbox ,I am moving it to a different
folder,than I display
a VB modeless form, from my add in ,without setting it's
'OwnerForm'(myForm.Show) ,waiting for user input.

it works fine until the VB Form was displayed while I was changing account
properties
(tool->accounts->properties)

I don't need to display Inspector modally.
as a matter of fact I prefer using Modal forms so i can wait for user input
before farther processing,but as I explained, I thought it make problems.


thanks in advance
 
K

Ken Slovak - [MVP - Outlook]

Tools, Accounts? You are working in Outlook 2000 Internet only mode?

The only thing I can think of to suggest is to handle any error that
occurs and if there's an error then don't show your form.
 
J

John Covert

Tomer,

I think maybe you could kick around the idea of trapping an error on
MyForm.Show and then looping to retry every, say, 10 seconds until it
works...

On Error Resume Next
MyForm.Show
If Err.Number <> 0 Then
mystarttimevar = Time
Do While True
myendtimevar = Time
if myendvartime - mystarttimevar > 10 then ' ten seconds has
passed
MyForm.Show
If Err.Number= 0 then ' THE FORM WAS DISPLAYED
Exit Do
End if
' START TEN SECOND COUNT ALL OVER AGAIN
mystarttimevar = Time
end if
Loop
End if

I think that's not how one computes the difference between two times.
Maybe you could toss a MsgBox in there if ten seconds elapses just to let
the user know something is happening that they can't see.

John
 
T

tomer

Thanks john and ken,
What about using MODAL VB Form,will this work for me?

Thanks in advance.
 
K

Ken Slovak - [MVP - Outlook]

A modal form also cannot be displayed when another modal form is being
displayed by the same process. Since Outlook COM addins run in-process
with Outlook the situation would be the same except if the custom form
was displayed the Outlook property sheet couldn't be displayed by the
user, they would get an error.
 
T

tomer

Thanks ken,you helped me a lot.
What about CBT_Hook ? do you think it can help me?
I will hook into the process of the window creation and will not display my
form as long as there are windows still opened
(either modal like option,or modeless like inpsectors) in outlook process.


Thanks again.

Btw:i tried to display my form as MODAL,it did not raise any exception,but
since i didnot set it's parent(i will do it soon)
the form was behind outlook.
 
K

Ken Slovak - [MVP - Outlook]

I'm not familiar with CBT_Hook.

You can control how the form is displayed by setting its ZOrder.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top