Another idea: It might work. Partial code for simplicity. In the code below, you will first get a handle to an already registered style. I assume that you can delete and reassign the pointer from the one you loaded from the file. I believe that an exception is shown only when trying to apply a style, and not when loading it. Forgive me if I am wrong.
var StyleName: String; Style : TStyleManager.TStyleServicesHandle; FileName : String; begin StyleName := 'Obsidian'; // or another style name FileName := 'obsidian.vsf'; // or any other valid style file name Style := TStyleManager.Style[ StyleName]; if Assigned( Style) then // style already registered begin TStyleManager.TrySetStyle( StyleName); // insert other processing here end else // style not registered begin if TStyleManager.IsValidStyle( FileName) then begin Style := TStyleManager.LoadFromFile( FileName); if Assigned( Style) then begin // insert other processing here, such as // TStyleManager.SetStyle( Style); end; end; end; end;
Anthony streets
source share