about add components dynamically

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

about add components dynamically
 
golden scale


Guest


Hi,
i want to add components dynamically,like this:

type
TMSOIDCONTROLINFO = record
idMso: WideString;
ConMask: DWORD;
end;

const
//maybe more
WORD2007CONIDS : array[1..3] of TMSOIDCONTROLINFO =
(
//Quick Access Toolbar
(idMso: 'FileSave'; ConMask: 1),
(idMso: 'FilePrintQuick'; ConMask: 2),
(idMso: 'FileSaveAs'; ConMask: 4)
);

procedure adxrbncmndcomAction (Sender: TObject;
const Pressed: Boolean; var Cancel: Boolean);
begin
if (((Sender as TadxRibbonCommand).Tag and $01)<>0) then
begin
Cancel:=True;
end;
end;

procedure TAddInModule.adxCOMAddInModuleAddInInitialize(Sender: TObject);
var
inum:Integer;
tmpcrib:TadxRibbonCommand;
begin
for inum := 1 to High(WORD2007CONIDS) do
begin
tmpcrib:=TadxRibbonCommand.Create(Self);

tmpcrib.IdMso:=WORD2007CONIDS[inum].idMso;
tmpcrib.Tag:=WORD2007CONIDS[inum].ConMask;
tmpcrib.Name:='WORD2007CONIDS'+inttostr(inum);
tmpcrib.ControlType:=adxAddIn.Button;
@tmpcrib.OnAction:=@adxrbncmndcomAction;
Self.InsertComponent(tmpcrib);
end;
end;

But it does not work.

BTW,i use Add-in Express 2009 for Office and VCL, Premium package,Release 2009.5.2.505,
Office 2007(word 2007 for test),Delphi 2010.And i changed some source code in create operation
of TadxRibbonCommand for create id(FID) in the non-design mode.

  Can you help me?
thank you!!
Posted 18 Jul, 2010 21:46:15 Top
golden scale


Guest


I have solved the problem. Thank you!
Posted 18 Jul, 2010 23:03:02 Top
Andrei Smolin


Add-in Express team


Posts: 18793
Joined: 2006-05-11
Hi,

Thank you for letting us know. I think you've found that you need to use OnRibbonBeforeCreate
instead of OnAddinInitialize, correct?


Andrei Smolin
Add-in Express Team Leader
Posted 19 Jul, 2010 04:25:37 Top
golden scale


Guest


Hi,
yes!
 Thank you! i'm sorry i forgot your work hours are different from ours.
 thanks again!
Posted 19 Jul, 2010 07:51:04 Top