Outlook know pane

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

Outlook know pane
 
calou_33 calou_33


Guest


Hello,

I use adxRibbonContextMenu in order to have event on right clic.
How could i do to know if i am in contact, calendar, mail... when the adxRibbonContextMenuClick is fired?

Thanks
Posted 17 Oct, 2017 10:52:41 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello,

There's no event that occurs when you right-click anything. You can use the fact that a Ribbon component produces the PropertyChanging event before it is being shown; check sections "Updating Ribbon Controls at Run-Time" and "Determining a Ribbon Control's Context" in the Add-in Express manual - see the PDF file in {Add-in Express installation folder}\Docs.


Andrei Smolin
Add-in Express Team Leader
Posted 18 Oct, 2017 06:34:35 Top
calou_33 calou_33


Guest


Hello,

This is not easy for me, i am a beginner with office automation.
I have try this code for test but outlook crash :


procedure TAddInModule.adxRibbonContextMenuControls1Controls0PropertyChanging(
Sender: TObject; PropertyType: TadxRibbonControlPropertyType;
var Value: OleVariant; const Context: IDispatch);
var
typeinfo:ITypeInfo;
s1,s2,s3:string;
i:integer;
begin
try
Context.GetTypeInfo(0,0,typeinfo);
typeinfo.GetDocumentation(-1,PWideString(s1),PWideString(s2),PlongInt(i),PWideString(s3))
finally
end;
end;

Thanks for help

Regards
Posted 18 Oct, 2017 08:23:21 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello,

If you debug this call, you'll find that this event occurs several times for a given Ribbon control; each time for a different PropertyType value. You need your code to work only once e.g. when PropertyType is rcptVisible.

The context object provided to the event procedure is an object from the Outlook object model or nil. Say, if the context object is Outlook2000.Explorer, you can get Explorer.CurrentFolder. 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.

A starting point to the Outlook object model studying is https://msdn.microsoft.com/vba/vba-outlook.


Andrei Smolin
Add-in Express Team Leader
Posted 18 Oct, 2017 09:49:38 Top
calou_33 calou_33


Guest


Hello,

I am sorry but i am not able to do a code which works good on delphi.
Would it be possible to have the delphi code for your example here ? : https://www.add-in-express.com/forum/read.php?FID=5&TID=11097&ACTION=TOPIC_SUBSCRIBE

I don't find the equivalent of ADXRibbonPropertyChangingEventArgs

Thanks
Posted 19 Oct, 2017 03:51:50 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
Hello,

If you open the visual designer of the Ribbon context menu component and select the button you create, the Properties window shows the PropertyChanging event (you need to switch to events in the Properties window). Is this the case for you?

calou_33 calou_33 writes:
I don't find the equivalent of ADXRibbonPropertyChangingEventArgs


In your previous post I see this function definition:

procedure TAddInModule.adxRibbonContextMenuControls1Controls0PropertyChanging(
Sender: TObject; PropertyType: TadxRibbonControlPropertyType;
var Value: OleVariant; const Context: IDispatch);

In the Add-in Express VCL edition there's no equivalent for the ADXRibbonPropertyChangingEventArgs class (from the .NET edition). But note the parameters passed to the event procedure above: they correspond to the properties that the .NET class provides.


Andrei Smolin
Add-in Express Team Leader
Posted 19 Oct, 2017 06:45:50 Top
calou_33 calou_33


Guest


To be more precise here is what i would want to do:

If i am in outlook inbox, when a user right clic on one mail, the adxRibbonButton2 is disabled
If i am in outlook contact and one contact, when a user right clic on one of them the adxRibbonButton2 is disabled

If i could have a small example it could be great

Thanks a lot

Regards
Posted 19 Oct, 2017 06:46:10 Top
calou_33 calou_33


Guest


Here is the code i have done.

procedure TAddInModule.adxRibbonContextMenuControls1PropertyChanging(Sender: TObject; PropertyType: TadxRibbonControlPropertyType;var Value: OleVariant; const Context: IDispatch);
var
  btn:TadxRibbonButton;
begin
  if (PropertyType=rcptVisible) and (context<>nil) then
  begin
    btn:=(Sender as TadxRibbonMenu).Controls[1].AsRibbonButton;
    btn.visible:=FALSE;
  end;
end;


This code works good. My problem is that i am not able to know if i am in outlook contact or outlook inbox. I need this piece of code in Delphi

Regards
Posted 19 Oct, 2017 07:28:23 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
When the component in question raises the PropertyChanging event *and* the property type being changed is rcptVisible, your code should cast the context object to the Outlook2000._Explorer interface from the Outlook object model and study the properties that the interface provides. Note that you should also take into account properties of the objects that the _Explorer interface's properties return; an example of such an object is the Selection object that the _Explorer.Selection property returns (see https://msdn.microsoft.com/en-us/VBA/Outlook-VBA/articles/explorer-selection-property-outlook). The result of that study is a boolean value that you use to return in the Value parameter of the adxRibbonContextMenuControls1Controls0PropertyChanging method above; the Ribbon button will be visible if you return True; return False to get the button hidden.


Andrei Smolin
Add-in Express Team Leader
Posted 19 Oct, 2017 07:39:55 Top
Andrei Smolin


Add-in Express team


Posts: 18825
Joined: 2006-05-11
The PropertyChanging event is a way for you to let the Ribbon know what value to assign to a given property of a Ribbon control; to provide such a value, you assign it to the Value parameter.

I strongly recommend that you re-check section "Updating Ribbon Controls at Run-Time" in the Add-in Express manual - see the PDF file in {Add-in Express installation folder}\Docs.


Andrei Smolin
Add-in Express Team Leader
Posted 19 Oct, 2017 07:43:58 Top