TOptionPage how to intercept outlook OK/Cancel/Apply actions ?

Add-in Express™ Support Service
That's what is more important than anything else

TOptionPage how to intercept outlook OK/Cancel/Apply actions ?
 
stephane




Posts: 15
Joined: 2009-11-13
Hello,

I've created an new OptionPage (a new tab in outlook options) but I don't know how to be notified when the user clicks on the OK/Cancel/Apply default buttons at the bottom of the page.

Is there a way to hide / disable those buttons or at least to know what action the user performed ?
I just know that "Apply" button is linked to FDirty flag but not much more.

Thanks !
Posted 22 Apr, 2011 04:35:52 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Stephane,

Please have a look at the Apply method of your options page. This method is called when the user clicks OK or Apply button.

Also, it is impossible to hide or disable these standard buttons (OK/Cancel/Apply).
Posted 22 Apr, 2011 07:24:10 Top
stephane




Posts: 15
Joined: 2009-11-13
Thanks !

I have tried TOptionPage.Apply function and indeed when I click on Apply or OK, the function is called.

But there is a little issue: if I click on OK I cannot abort the op?ration (if the user didn't fill the edits as an example) : I tried Result:=S_FALSE, FDirty:=true , but the options window always closes after my error warning.

What should I do/return in this function so that this window remains open ?
Posted 22 Apr, 2011 08:28:25 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Stephane,

You need to return an error code, for example E_FAIL:


function TCoOptionsPage1.Apply: HResult;
begin
  if YOUR_CONDITION then begin
    ShowMessage(ErrorWarningMsg);
    Result := E_FAIL;
    Exit;
  end;
  // ...

Posted 22 Apr, 2011 10:03:12 Top
stephane




Posts: 15
Joined: 2009-11-13
Thanks it works ! ;)

Just two last questions:

* is there an easy way to obtain same look and feel in our custom option page compared to the others tabs of options in outlook ? (same font, same colors ...)

* why with outlook2003, when my addin is registered, if I quit outlook , outlook.exe remains in memory , if I unregister the addin then all is fine when quitting ?
Posted 22 Apr, 2011 11:09:48 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Stephane,

* is there an easy way to obtain same look and feel in our custom option page compared to the others tabs of options in outlook ? (same font, same colors ...)


I am afraid there is no "easy" way, and there cannot be any, because option pages of different Outlook versions have a different size, background color and font.

* why with outlook2003, when my addin is registered, if I quit outlook , outlook.exe remains in memory , if I unregister the addin then all is fine when quitting ?


It looks like you don't release all Outlook interfaces used in your code. This issue may be also caused by third-party components.
Posted 22 Apr, 2011 11:54:44 Top
stephane




Posts: 15
Joined: 2009-11-13
What is the best way to release an interface in Delphi ?

InterfaceObject:=nil; is enough ?
Posted 22 Apr, 2011 13:50:47 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Stephane,

Yes, you can release an interface variable by assigning nil to it.
Posted 25 Apr, 2011 05:18:42 Top