Enabling/disabling controls on Initialization

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

Enabling/disabling controls on Initialization
 
Phillippe Allen




Posts: 30
Joined: 2005-11-07
I have written an Addin that provides various bits of different functionality. The user pays for which piece(s) they want. What i would like to do is have the addin controls check the user's registration mode and enable/disable themselves accordingly. So if the user has paid for the functionality behind Controls[1] then it will be enabled otherwise it will be disabled. The problem is that I have got the controls to disable themselves by default on Initilization but if the user then goes ahead and signs themselves up for the appropriate module(s), the addins wont enable the corresponding controls even though the checking code returns true. To get the controls to enable themselves correctly, I need to unload the Addin and reregister it.
For example if I use the following code, even when "Registered" returns true, the controls will not be enabled.

procedure TAddInModule.adxCOMAddInModuleAddInInitialize(Sender: TObject);
var
Registered : boolean;
begin
Registered := false;
Application.Handle := GetActiveWindow;
if (OgSpecialCode1.CheckCode(false) = ogValidCode) then
begin
Registered := Globfile.IsAllowedOption(m_Modules[m_ClientFolders].l_menu);
end;
adxWord.Controls[1].Enabled := Registered;
end

Is there any way that this can be done on the fly without resorting to unloading the addin?

Regards
Phil
Posted 16 Jan, 2006 21:39:57 Top
Dmitry Kostochko


Add-in Express team


Posts: 2875
Joined: 2004-04-05
Hi Phil,

Try to move your code from the OnAddInInitialize event handler to the OnAddInStartupComplete one.

Posted 17 Jan, 2006 07:26:36 Top
Phillippe Allen




Posts: 30
Joined: 2005-11-07
Dmitry

Thanks - that did the trick.

Regards
Phil
Posted 22 Jan, 2006 14:40:48 Top