PC Review


Reply
Thread Tools Rate Thread

Application->ProcessMessages() from COM add-in?

 
 
Eric
Guest
Posts: n/a
 
      5th Nov 2003
Anyone have any comments about calling VCL's (Delphi/Builder)
Application->ProcessMessages() function from within a COM add-in, like
inside of the OnDisconnect event to make sure any modeless VCL forms
are destroyed and all messages processed before Outlook unloads the
add-in? As a general practice I don't like to run my own message loop
like that, because any custom processing Outlook's internal message
loop does, would be skipped, but I've done a bit of testing and it
doesn't seem to cause problems so far...

Also, I'm going to be doing some long processes sometimes and I'd like
to make this as transparent as possible to the Outlook user. Is this
also a good place to call ProcessMessages(), or run a PeekMessages()
loop, or is there some other method which lets me yield to Outlook?
Or do I even need to worry about this, since Outlook seems to run a
seperate thread for COM add-ins anyway?

I'm developing for Outlook 2000, 2002, and 2003. Thanks for any
advise!
 
Reply With Quote
 
 
 
 
Dmitry Streblechenko
Guest
Posts: n/a
 
      5th Nov 2003
No, Outlook COM addins run in the main Outlook thread. You can however run
your code in your own threads.
Why do you need to run a message loop and wait for the modeless VCL forms to
be closed? Why can't you close them programmatically? Or better yes, make
your forms children of the Outlook explorers/inspectors (so that they don't
get their own task bar buttons) and close them whenever the parent Outlook
window closes - see uParentedWnd.pas in the Babelfish addin source code on
my site.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Eric" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Anyone have any comments about calling VCL's (Delphi/Builder)
> Application->ProcessMessages() function from within a COM add-in, like
> inside of the OnDisconnect event to make sure any modeless VCL forms
> are destroyed and all messages processed before Outlook unloads the
> add-in? As a general practice I don't like to run my own message loop
> like that, because any custom processing Outlook's internal message
> loop does, would be skipped, but I've done a bit of testing and it
> doesn't seem to cause problems so far...
>
> Also, I'm going to be doing some long processes sometimes and I'd like
> to make this as transparent as possible to the Outlook user. Is this
> also a good place to call ProcessMessages(), or run a PeekMessages()
> loop, or is there some other method which lets me yield to Outlook?
> Or do I even need to worry about this, since Outlook seems to run a
> seperate thread for COM add-ins anyway?
>
> I'm developing for Outlook 2000, 2002, and 2003. Thanks for any
> advise!



 
Reply With Quote
 
Eric
Guest
Posts: n/a
 
      5th Nov 2003
I do call TForm::Close() to close the form when Outlook closes, or
more specificly when the explorer or inspector closes, or my add-in is
unloaded. TForm::Close() doesn't free the object until the remove
message is processed though. I guess I could just use PeekMessage()
to only process the remove message, or maybe it is safe to use the
delete opperator on a TForm, but I've never tried that. I could
probably have to call Close() first, and then delete, so the window
handles get destroyed?

But before I get way off-topic for this group (oops too late), and
into a VCL group topic, I'm still wondering if I can process messages
during these other lengthy processes which might take several seconds
to complete. I'd rather not use seperate threads, mostly because most
COM add-ins I see don't do it, and I don't want to be making the
add-in that flushes out all the bugs/issues related to this. I will
be using purely Extended MAPI during these processes, so I guess
another thread is an option still, I'm just gun-shy when it comes to
calling MAPIInitialize() myself, because 75% of the error messages
reported by users have been that the call to MAPIInitialize() fails,
even though they are quick to point out "Outlook is working just fine,
and it initializes MAPI, how come your application can't".

Thanks!

"Dmitry Streblechenko" <(E-Mail Removed)> wrote in message news:<(E-Mail Removed)>...
> No, Outlook COM addins run in the main Outlook thread. You can however run
> your code in your own threads.
> Why do you need to run a message loop and wait for the modeless VCL forms to
> be closed? Why can't you close them programmatically? Or better yes, make
> your forms children of the Outlook explorers/inspectors (so that they don't
> get their own task bar buttons) and close them whenever the parent Outlook
> window closes - see uParentedWnd.pas in the Babelfish addin source code on
> my site.
>
> Dmitry Streblechenko (MVP)
> http://www.dimastr.com/
> OutlookSpy - Outlook, CDO
> and MAPI Developer Tool
>

 
Reply With Quote
 
Dmitry Streblechenko
Guest
Posts: n/a
 
      5th Nov 2003
Destroying the form will hide and completely release all its resources,
there is absolutely no reason to close it first.
Nothing's wrong with using your own threads in Outlook add-ins/extensions, I
do it all the time.
You do not need to call MAPIInitialize() if you are in the main Outlook
thread, your own threads are your responsibility, so you do need to
initialize MAPI, but I never had any problems with MAPIInitialize() in my
own threads.

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy - Outlook, CDO
and MAPI Developer Tool


"Eric" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> I do call TForm::Close() to close the form when Outlook closes, or
> more specificly when the explorer or inspector closes, or my add-in is
> unloaded. TForm::Close() doesn't free the object until the remove
> message is processed though. I guess I could just use PeekMessage()
> to only process the remove message, or maybe it is safe to use the
> delete opperator on a TForm, but I've never tried that. I could
> probably have to call Close() first, and then delete, so the window
> handles get destroyed?
>
> But before I get way off-topic for this group (oops too late), and
> into a VCL group topic, I'm still wondering if I can process messages
> during these other lengthy processes which might take several seconds
> to complete. I'd rather not use seperate threads, mostly because most
> COM add-ins I see don't do it, and I don't want to be making the
> add-in that flushes out all the bugs/issues related to this. I will
> be using purely Extended MAPI during these processes, so I guess
> another thread is an option still, I'm just gun-shy when it comes to
> calling MAPIInitialize() myself, because 75% of the error messages
> reported by users have been that the call to MAPIInitialize() fails,
> even though they are quick to point out "Outlook is working just fine,
> and it initializes MAPI, how come your application can't".
>
> Thanks!
>
> "Dmitry Streblechenko" <(E-Mail Removed)> wrote in message

news:<(E-Mail Removed)>...
> > No, Outlook COM addins run in the main Outlook thread. You can however

run
> > your code in your own threads.
> > Why do you need to run a message loop and wait for the modeless VCL

forms to
> > be closed? Why can't you close them programmatically? Or better yes,

make
> > your forms children of the Outlook explorers/inspectors (so that they

don't
> > get their own task bar buttons) and close them whenever the parent

Outlook
> > window closes - see uParentedWnd.pas in the Babelfish addin source code

on
> > my site.
> >
> > Dmitry Streblechenko (MVP)
> > http://www.dimastr.com/
> > OutlookSpy - Outlook, CDO
> > and MAPI Developer Tool
> >



 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
appdata-local-Application Data-Application Data-Application Data infinitum ad nauseum. WHY keepout@yahoo.com.invalid Windows Vista General Discussion 15 16th Sep 2007 01:50 AM
Is there a ProcessMessages in .net? Rob Pollard Microsoft C# .NET 5 19th Oct 2006 08:37 PM
ProcessMessages Tomer Microsoft Dot NET Compact Framework 2 3rd Feb 2005 11:10 AM
Fail in operating my hardware in web application , makes other windows application startup failure. Ryan.ZhYin Microsoft C# .NET 0 25th Jan 2005 08:34 AM
Making more memory available to application?Im making a memory intense application, the application is supposed to open a prettylarge image (about 9200*10200 in 300Dpi) yosh@liquidzone.net Microsoft Dot NET Framework Forms 0 6th Dec 2004 07:16 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:06 PM.