Jump to content

About changing theme at run-time


tappatappa

Recommended Posts

In MegaDemo

procedure TMainForm.ThemeClick(Sender: TObject);
begin
  if UniApplication<>nil then
  begin
    UniServerModule.Lock;
    try
      case TComponent(Sender).Tag of
        1 : UniServerModule.CurrentTheme:='blue';
        2 : UniServerModule.CurrentTheme:='gray';
        3 : UniServerModule.CurrentTheme:='classic';
        4 : UniServerModule.CurrentTheme:='xp';
        5 : UniServerModule.CurrentTheme:='vista';
      end;
    finally
      UniServerModule.UnLock;
    end;
    TUniGUIApplication(UniApplication).Restart;
  end;
end;

Is it possible to implement a similar feature without changing UniServerModule and restarting the Application?

Link to comment
Share on other sites

Hi,

You can use swapStyleSheet function.   Try something like this (used to work in old versions of uniGUI, not tested in newer versions) :

UniSession.AddJS('Ext.util.CSS.swapStyleSheet(''/ext-4.2.1.883/resources/css/ext-all-gray.css'',''/ext-4.2.1.883/resources/css/ext-all.css'');');

UniSession.AddJS('Ext.util.CSS.swapStyleSheet(''/ext-4.2.1.883/resources/ext-theme-gray/ext-theme-gray-all.css'',''/ext-4.2.1.883/resources/ext-theme-classic/ext-theme-classic-all.css'');');

UniSession.AddJS('Ext.util.CSS.swapStyleSheet(''/uni-0.94.0.1024/css/uni-xtheme-gray.css'',''/uni-0.94.0.1024/css/uni-xtheme-blue.css'');');

UniSession.AddJS('Ext.util.CSS.swapStyleSheet(''/myApplication.dll/ext-4.2.1.883/resources/css/ext-all-gray.css'',''/myApplication.dll/ext-4.2.1.883/resources/css/ext-all.css'');');

UniSession.AddJS('Ext.util.CSS.swapStyleSheet(''/myApplication.dll/ext-4.2.1.883/resources/ext-theme-gray/ext-theme-gray-all.css'',''/myApplication.dll/ext-4.2.1.883/resources/ext-theme-classic/ext-theme-classic-all.css'');');

UniSession.AddJS('Ext.util.CSS.swapStyleSheet(''/myApplication.dll/ext-4.2.1.883/uni-0.94.0.1024/css/uni-xtheme-gray.css'',''/myApplication.dll/ext-4.2.1.883/uni-0.94.0.1024/css/uni-xtheme-blue.css'');');

UniSession.AddJS('Ext.util.CSS.swapStyleSheet(''/myApplication.dll/uni-0.94.0.1024/css/uni-xtheme-gray.css'',''/myApplication.dll/uni-0.94.0.1024/css/uni-xtheme-blue.css'');');

You'll need to adapt the code with newest ExtJS Path, uniGUI Path, dll name and the name of the theme you want to use.

Link to comment
Share on other sites

Hello ZigZig,

 

I am trying. Is not remotely as easy as I hoped :) Moreover, I guess I have to make it more flexible by retrieving the uniGUI/extjs version from ServerModule.

 

How do I have to change the path in Stand Alone Server mode (I see you refer to the dll in the paths)?

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...