How to disable a TadxRibbonGroup or TadxRibbonButton in Outlook 2010

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

How to disable a TadxRibbonGroup or TadxRibbonButton in Outlook 2010
Changing the "Visible" or "Enabled" properties does not have any effect 
Olaf H




Posts: 19
Joined: 2008-10-21
Dear Sirs,

I am using Outlook 2010 and Add-in Expres 2010 for VCL with Delphi 2009. I have successfully added a "TadxRibbonGroup" with one "TadxRibbonButton" to the "Home" ribbon in the Outlook 2010 main window. The group shows up at the expected position, so that's OK.

I now want to programmatically hide and show the button, but this does not work -- the button is always visible. I use the following code:

with RG.Controls.Items [0].AsRibbonGroup.Controls [0].AsRibbonButton do
Visible := bVisible;

"bVisible" can be true or false.
"RG" is of type TadxRibbonTab

The same happens when I use the "Enabled" property instead of "Visible": The button stays enabled all of the time, no matter whether I set "Enabled" to "true" or "false".

Any help on this issue would be very much appreciated.

Thanks & regards,
Olaf
Posted 16 Sep, 2010 13:50:23 Top
Andrei Smolin


Add-in Express team


Posts: 18817
Joined: 2006-05-11
Hi Olaf,

With Add-in Express 2010 for Office and VCL 6.1.754, the code below works fine in Outlook 2010 Explorers:

procedure TAddInModule.adxRibbonTab4Controls0Controls1Click(
  Sender: TObject; const RibbonControl: IRibbonControl);
var
  RG: TadxRibbonTab;
begin
  bVisible := not bVisible;
  RG := adxRibbonTab4;
  with RG.Controls.Items [0].AsRibbonGroup.Controls [0].AsRibbonButton do
    Visible := bVisible;
end;


object adxRibbonTab4: TadxRibbonTab
Caption = 'adxRibbonTab4'
Controls = <
item
Id = 'adxRibbonGroup1B7A5DBB60E1452D8B5D70C126AC46C7'
Caption = 'adxRibbonGroup8'
Ribbons = [msrOutlookMailRead, msrOutlookMailCompose, msrOutlookExplorer]
Ribbons2010 = [msrOutlookExplorer2010]
ControlTypes = {020000000700000007000000}
Controls_ = <
item
Id = 'adxRibbonButtonBDD1C2B0B83B4E9FA3F1FD17CCBA5DF7'
Caption = 'adxRibbonButton7'
Ribbons = [msrOutlookMailRead, msrOutlookMailCompose, msrOutlookExplorer]
Ribbons2010 = [msrOutlookExplorer2010]
end
item
Id = 'adxRibbonButtonF055D2616114464892CFDAC933238420'
OnClick = adxRibbonTab4Controls0Controls1Click
Caption = 'adxRibbonButton8'
Ribbons = [msrOutlookMailRead, msrOutlookMailCompose, msrOutlookExplorer]
Ribbons2010 = [msrOutlookExplorer2010]
end>
end>
Id = 'adxRibbonTab6C32998FB1B44F1B9CE5C895F4861311'
Left = 264
Top = 298
Ribbons = [msrOutlookMailRead, msrOutlookMailCompose, msrOutlookExplorer]
Ribbons2010 = [msrOutlookExplorer2010]
end



Andrei Smolin
Add-in Express Team Leader
Posted 17 Sep, 2010 08:29:38 Top
Olaf H




Posts: 19
Joined: 2008-10-21
Hi Andrei,

thanks for your reply.

As your code looks exactly like mine, it made me think, and I finally found the error: My "TadxRibbonTab" was the copy of one which I used in a [msrOutlookMailRead] ribbon. The problem was that I copied the control instead of creating a new one.

Once I created the RibbonTab & button from scratch, everything started working as expected.

Thanks again for making me look at the issue from a different angle!

Have a nice weekend,
Olaf
Posted 17 Sep, 2010 09:36:58 Top