Simulating modal window

J

Jeff Mowatt

I'm trying to find a way to get around a minor problem with an application
which is opened within
my custom form. It's a custom application I developed and I therefore have
control of the
modal/nonmodal settings of the windows used within it.

Here's a simplified code example:

Function MyButton_Click()
set myApp = createobject("MyAutoServer.Application")
'Open a modal or non modal window until window is closed and new record
stored
MyApp.Show()
nresult=MyApp.GetResultKey()
mylistbox.list=Myapp.RecordArray(nresult)
End Function


This application presents a window and allows me to store records in an
SQLServer database.

When the data has been stored and the window has been closed, I can retrieve
the record
content from SQL passing it as a listbox array back to Outlook. My custom
form will then be
able to display the contents.

Everything works perfectly if I make MyApp.Show() a modal window but the one
problem is that
the window is iconized.

I can get around this problem by making the window non modal and forcing the
window to show by
effectively showing it twice.

Unfortunately, now that it's non modal Outlook doesn't wait for my
application to complete
and attempts to show the results before they have been stored.

Ideally I'd like to find a way to force a modal window over the top of the
Outlook form,
it can be done once the window has been opened for the first time.

Otherwise I could get around this new problem with a non modal window if
there was a way to force
an event such that I could notify completion of the database activity with
the event handler then
firing off the code to display the results in my listbox.

Could anyone suggest a way forward? A complete rewrite is not out of the
question:-(

TIA

Jeff Mowatt
 
J

Jeff Mowatt

Jeff Mowatt said:
I'm trying to find a way to get around a minor problem with an application
which is opened within
my custom form. It's a custom application I developed and I therefore have
control of the
modal/nonmodal settings of the windows used within it.

Just for the record, I found a solution to this and I might as well post it
for those like me who come along months or years later to find the same
unanswered question all over the place.

The resolution of my problem makes use of the SetWindowPos() API call in the
instantiation of the modal version of the window within my custom object .
It only seems to work if the Show() method is within the vbscript code
rather than the object itself. This API call places the window "on top" and
hence any other window opened in the process will also need to be set "on
top" prior to opening.

Jeff Mowatt
 

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