Jason Coley
Posts: 272
Joined: 2005-05-26
|
I have a commandbar, and if the commandbar is set to Enabled = False then when the procedure SetProperties runs it tries to SetVisible even if enabled is false.
I changed the procedure TadxCommandBar.SetProperties and added
if not FEnabled then Exit;
Please let me know if this is the correct way to handle this.
See below...
TadxCommandBar.SetProperties;
function IsChanged(const RegKey: string): boolean;
begin
Result := True;
with TRegistry.Create do
try
if OpenKey(RegKey, True) then begin
if ValueExists(FCommandBarName) then
Result := Longword(ReadInteger(FCommandBarName)) <> Self.FChanged;
CloseKey;
end;
finally
Free;
end;
end;
procedure ApplyChanges(const RegKey: string);
begin
with TRegistry.Create do
try
if OpenKey(RegKey, True) then begin
WriteInteger(Self.FCommandBarName, Self.FChanged);
CloseKey;
end;
finally
Free;
end;
end;
var
RegKey: string;
begin
RegKey := Owner.RegistryKey + '\CommandBars';
if Assigned(DefaultInterface) and (Temporary or IsChanged(RegKey)) then begin
SetEnabled(FEnabled);
if not FEnabled then Exit;
SetVisible(FVisible);
SetProtection(FProtection);
SetPosition(FPosition);
if FLeftPosition <> -1 then SetLeftPosition(FLeftPosition);
if FTopPosition <> -1 then SetTopPosition(FTopPosition);
if FRowIndex <> -1 then SetRowIndex(FRowIndex);
if not Temporary then ApplyChanges(RegKey);
end;
end; |
|
Dmitry Kostochko
Add-in Express team
Posts: 2887
Joined: 2004-04-05
|
Hi Jason,
MS Office Help says:
The Enabled property for a command bar must be set to True before the visible property is set to True.
So I can assume the Visible property of your command bar is set to True and you get the exception. I think you can avoid the exception by setting the Visible property to False.
|
|
Jason Coley
Posts: 272
Joined: 2005-05-26
|
well then your control needs to automaticallky change the visible to false if the enable is set to false, correct, at present you can set the enable to false and the visble to true
Jason |
|
Dmitry Kostochko
Add-in Express team
Posts: 2887
Joined: 2004-04-05
|
Hi Jason,
Thanks for your suggestion. We'll try to implement this in future versions.
|
|