FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour MAPISendMail forcing calling FWH app MODAL
Posts: 59
Joined: Tue Oct 11, 2005 01:39 AM
MAPISendMail forcing calling FWH app MODAL
Posted: Thu May 31, 2007 06:45 PM

Hello all.

We have a rather ugly situation. We have an application that uses MAPISendMail() to open the composer window from the default email client on a users PC (for now lets assume this email client is Outlook).

As soon as Outlook's "composer" window (or whatever it's called) is up if I can't return to my FWH app because this window has made it in effect MODAL. I have to either finish entering the mail and send it, or cancel it to be able to return to my FWH app.

You can imagine this isn't going well with users who don't expect to be forced to send the email before being able to get back to our app. Usually the might want to look up additional info they might want to add to the email.

So the million dollar question is: can MAPISendMail() be instructed to behave MODLESS instead of forcing the calling app to remain MODAL till it's done?

I noticed (in mapi.c) that the call to mapisendmail uses GetActiveWindow() as one of it's parameters. From our app I tried doing a SetActiveWindow() to Outlook's hWnd (which I already know and I'm positive is the right one) but either SetActiveWindow() is broken and doesn't actually set the current active window (a subsecuent call to GetActiveWindow() shows that my FWH app remains the current active window, not Outlook).

I tried calling SetForegroundWindow() and BringWindowToFront() but that makes no difference either.

Any help in how to make MAPISendMail() behave nicely is very much appreciated!

Luis Krause.

"May the Source be with GNU"
Posts: 44162
Joined: Thu Oct 06, 2005 05:47 PM
MAPISendMail forcing calling FWH app MODAL
Posted: Thu May 31, 2007 07:00 PM
Luis,

From the Windows API docs:

ulUIParam
[in] Parent window handle or zero, indicating that if a dialog box is displayed, it is application modal. If the ulUIParam parameter contains a parent window handle, it is of type HWND (cast to a ULONG). If no dialog box is displayed during the call, ulUIParam is ignored.

Its explained at:
http://msdn2.microsoft.com/en-us/library/ms527908.aspx

Maybe its as simple as provide it a zero :-)
regards, saludos

Antonio Linares
www.fivetechsoft.com
Posts: 59
Joined: Tue Oct 11, 2005 01:39 AM
MAPISendMail forcing calling FWH app MODAL
Posted: Thu May 31, 2007 07:18 PM

Antonio:

Don't know if those docs refer to a MAPI logon dlg or similar, because
passing a 0 instead of GetActiveWindow() (or even passing Outlook's hWnd) makes no difference.

Or the docs are wrong, or MS is screwing us up!

Thanks!

Luis

"May the Source be with GNU"
Posts: 59
Joined: Tue Oct 11, 2005 01:39 AM
MAPISendMail forcing calling FWH app MODAL
Posted: Thu May 31, 2007 07:24 PM

Antonio:

Guess what?

If I change the default email client to Netscape Mail (without changing anything to mapi.c), it works as expected: I can go back and forth between Netscape's composer window and my FWH app!

Guess the answer is MS is screwing us up :evil:

Luis

"May the Source be with GNU"

Continue the discussion