Outlook know pane

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

Outlook know pane
 
Subscribe
calou_33 calou_33




Posts: 23
Joined: 2017-10-13
I have read it and re read it. I have been working on this problem (which seems to be so simple) since 2 days but i can't make it to work.
If you are not able to send me a little Delphi example, i leave this subject and perhaps the library :(

Regards
Posted 19 Oct, 2017 08:08:43 Top
Andrei Smolin


Add-in Express team


Posts: 14129
Joined: 2006-05-11
Here's an Excel-related example:

procedure TAddInModule.adxRibbonTab1Controls0Controls0PropertyChanging(
  Sender: TObject; PropertyType: TadxRibbonControlPropertyType;
  var Value: OleVariant; const Context: IDispatch);
var
  Wnd: Excel2000.Window;
begin
  if context <> nil then begin
    if PropertyType = rcptCaption then begin
      OutputDebugString(PAnsiChar('!!! ' + String(Value))); // here's how I know the current value of a property
      Wnd := Context as Excel2000.Window;
      if Wnd <> nil then
        Value := string(Wnd.Caption)  // here's how I provide a value for the Caption property
      else
        Value := 'nil';
    end;
  end;
end;


The above demonstrates showing different button captions in different Excel windows. On the same way you modify the visibility of your button.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 19 Oct, 2017 09:43:44 Top
calou_33 calou_33




Posts: 23
Joined: 2017-10-13
Thanks.

I have adapted your code and i have the same bugs like my lot of tests!


procedure TAddInModule.adxRibbonContextMenuControls1PropertyChanging(Sender: TObject; PropertyType: TadxRibbonControlPropertyType;
  var Value: OleVariant; const Context: IDispatch);
var
  expl1:Outlook2000.Explorer;
begin
  if Context<>nil then
  begin
    if (PropertyType=rcptVisible) then
    begin
      //showmessage(string(Value));
      expl1:=Context as Outlook2000.Explorer;
      Showmessage(expl1.Caption);      
    end;
    end;
  end;
end;


"the add in has fired an exception. Interface not supported"

Regards
Posted 19 Oct, 2017 11:18:45 Top
Andrei Smolin


Add-in Express team


Posts: 14129
Joined: 2006-05-11
What context menu are you testing? What code line produces the exception?

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 20 Oct, 2017 04:14:14 Top
calou_33 calou_33




Posts: 23
Joined: 2017-10-13
The context is Outlook.Explorer.ContextMenuMailItem
The code line is : expl1:=Context as Outlook2000.Explorer;

Regards
Posted 20 Oct, 2017 04:27:28 Top
Andrei Smolin


Add-in Express team


Posts: 14129
Joined: 2006-05-11
The issue was: the interface supplied was *not* Outlook2000.Explorer. It was Outlook2000.Selection instead. Sorry for pointing you to a wrong direction.

Note however that in another post I wrote: "If the context object is Outlook2000.Selection, you can try to use Selection.Parent to get to the Explorer object in which the selection was created." Other context objects are possible; at the moment I remember MAPIFolder and AttachmentSelection. nil is possible as well.

The code below modifies the caption of the button for which the PropertyChanging event is raised; the caption reflects the number of selected items.

procedure TAddInModule.adxRibbonContextMenu1Controls0PropertyChanging(
  Sender: TObject; PropertyType: TadxRibbonControlPropertyType;
  var Value: OleVariant; const Context: IDispatch);
var
  sel: Outlook2000.Selection;
begin
  if Context<>nil then
  begin
    if (PropertyType=rcptCaption) then
    begin
     sel := Context as Outlook2000.Selection;
     OutputDebugString(PAnsiChar('!!! Selection.Count=' + intTostr(sel.Count)));
     Value := 'Selected are ' + intTostr(sel.Count) + ' items';
    end;
  end;
end;


Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 20 Oct, 2017 07:15:01 Top
calou_33 calou_33




Posts: 23
Joined: 2017-10-13
THANK YOU !!! It works good! I can hide the button. That was missing in my spirit it is the property rcptxxxx. It permits to control the ribbon. You have explained it but it was not clear for me. Perhaps it will be good to document it in the pdf with example.
Posted 20 Oct, 2017 09:43:51 Top
Andrei Smolin


Add-in Express team


Posts: 14129
Joined: 2006-05-11
calou_33 calou_33 writes:
You have explained it but it was not clear for me. Perhaps it will be good to document it in the pdf with example.


Yes, this is a really good point. Every case of a developer misunderstanding me was actually caused by my wording and way of explaining this or that idea. Clearly, a sample code illustrating some words adds an extra value to the words and minimize misunderstanding. Sorry that it took me that long to understand this.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 20 Oct, 2017 09:55:51 Top