AHow to access a control on a TaskPane in Outlook

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

AHow to access a control on a TaskPane in Outlook
 
George Spears




Posts: 79
Joined: 2010-05-06
Hello,

I have created a 2 Taskpanes (The first one called TaskPane1), which has a Memo Control on it (called PMLog) on it.
My TAddInModule is in the variable adxMyTimeClass.

How do I access the Memo? The closest I can get is
(adxMyTimeClass.OutlookApp.ActiveExplorer.Panes(0).Item[0] as TPlusMemo).Lines.Add('MyTime Version 1.0');

But I just can't get the syntax right. How do I call the methods in the PlusMemo control. If you could please change my example, as opposed to saying "cast this as that" etc, since I am kinda slow at figuring this out... <grin>

Thanks,
George Spears
Posted 07 May, 2010 13:11:28 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hi George,

If Taskpanes are of the ADXOlForms type, then you access such a form via TadxOlFormsManager.Items[i].GetCurrentForm(efsActive), then you need to cast it to the actual form type and here you are.


Andrei Smolin
Add-in Express Team Leader
Posted 07 May, 2010 13:53:00 Top
George Spears




Posts: 79
Joined: 2010-05-06
Unfortunately, it is not of type TadxOlFormsManager. I created this app via the Wizard. The pane was automatically create as
...
TTaskPane1 = class(TActiveForm, ITaskPane1)

How then do I access objects on this pane?

Thanks,
George Spears
Posted 07 May, 2010 14:06:22 Top
Andrei Smolin


Add-in Express team


Posts: 18829
Joined: 2006-05-11
Hi George,

In the code below, AddLineToMemo was added to the ITaskPane1 (View | Type Library) and implemented in TTaskPane1.

procedure TAddInModule.adxOlExplorerCommandBar1Controls0Click(Sender: TObject);
var
  CTP: TadxCustomTaskPane;
  Instance: TadxCustomTaskPaneInstance;
  Form: ITaskPane1;
begin
  CTP := Self.TaskPanes[0];
  Instance := CTP.Instances.Items[OutlookApp.ActiveWindow()];
  Form := Instance.Control as ITaskPane1;
  Form.AddLineToMemo('Test');
end;



Andrei Smolin
Add-in Express Team Leader
Posted 10 May, 2010 11:23:33 Top