Spiros Nikolopoulos
Guest
|
Hi,
I'm using the following code to change a TPageControl Tabposition but I get an exception in
TxwCMSDMSHub_Task(Instance).pages.Tabposition := tpLeft;
do you have any ideas?
procedure TAddInModule.AddInModuleTaskPanes0DockPositionStateChange(
Sender: TObject; Instance: TadxCustomTaskPaneInstance);
begin
if Instance.DockPosition in [adxCTPDockPositionRight,adxCTPDockPositionLeft] then
begin
TxwCMSDMSHub_Task(Instance).pages.Tabposition := tpLeft;
TxwCMSDMSHub_Task(Instance).Update;
end
else
begin
TxwCMSDMSHub_Task(Instance).pages.Tabposition := tpTop;
TxwCMSDMSHub_Task(Instance).Update;
end
end;
|
|
Dmitry Kostochko
Add-in Express team
Posts: 2875
Joined: 2004-04-05
|
Hi Spiros,
The Instance parameter cannot be directly type casted to your task pane's type. You need to use the Control property of the TadxCustomTaskPaneInstance class and work with your task pane instance using methods and properties declared in your type library. Please see the OnDockPositionStateChange event handler code below, I have added the UpdateTabPosition method to the ITaskPane1 interface:
procedure TAddInModule.AddInModuleTaskPanes0DockPositionStateChange(
Sender: TObject; Instance: TadxCustomTaskPaneInstance);
begin
if Instance.DockPosition in [adxCTPDockPositionRight,adxCTPDockPositionLeft] then
begin
(Instance.Control as ITaskPane1).UpdateTabPosition(SYSINT(tpLeft));
end
else begin
(Instance.Control as ITaskPane1).UpdateTabPosition(SYSINT(tpTop));
end;
end;
Here is the code of the UpdateTabPosition method:
procedure TTaskPane1.UpdateTabPosition(Position: SYSINT);
begin
Self.pages.Tabposition := TTabPosition(Position);
Self.Update();
end;
|
|
Spiros Nikolopoulos
Guest
|
|