Suppose there are several buttons on which you can change the skins and for example the skin will be "WEB2" and when I want to change the skin to another (for example MacOS2) it will change me, but if I exit the program and enter again, the same "WEB2" will return . So how to change the skin so that the next time it comes, it remains in the program by default?

sSkinManager1.active:=true; sSkinManager1.SkinName:='MacOS2 (internal)'; 
  • four
    write the program settings somewhere and load them the next time you start by applying the appropriate skin settings. - teran

1 answer 1

For example:

 <...> iniFile:TIniFile; <...> procedure TForm1.FormCreate(Sender: TObject); begin iniFile := TIniFile.Create(ExtractFilePath(Application.ExeName)+'config.ini'); // ΠΈΠ½ΠΈΡ†ΠΈΠ°Π»ΠΈΠ·ΠΈΡ€ΡƒΠ΅ΠΌ ΠΎΠ±ΡŠΠ΅ΠΊΡ‚, связанный с настройками ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΡ‹, ΠΊΠΎΡ‚ΠΎΡ€Ρ‹Π΅ записаны Π² Ρ‚ΠΎΠΉ ΠΆΠ΅ ΠΏΠ°ΠΏΠΊΠ΅, Π³Π΄Π΅ Π»Π΅ΠΆΠΈΡ‚ ΠΏΡ€ΠΎΠ³Ρ€Π°ΠΌΠΌΠ°, Π² Ρ„Π°ΠΉΠ»Π΅ config.ini sSkinManager1.Active:=false; // Π²Ρ€Π΅ΠΌΠ΅Π½Π½ΠΎ ΠΎΡ‚ΠΊΠ»ΡŽΡ‡Π°Π΅ΠΌ ΠΌΠ΅Π½Π΅Π΄ΠΆΠ΅Ρ€ ΠΎΠ±ΠΎΠ»ΠΎΡ‡Π΅ΠΊ sSkinManager1.SkinName:= iniFile.readString('Skins','SkinName', '');// Π·Π°Π³Ρ€ΡƒΠΆΠ°Π΅ΠΌ ΠΈΠ½Ρ„ΠΎΡ€ΠΌΠ°Ρ†ΠΈΡŽ ΠΎ послСднСй использованной/Π·Π°Ρ€Π°Π½Π΅Π΅ Π·Π°Π΄Π°Π½Π½ΠΎΠΉ ΠΎΠ±ΠΎΠ»ΠΎΡ‡ΠΊΠ΅ sSkinManager1.Active:=true; // Π²ΠΊΠ»ΡŽΡ‡Π°Π΅ΠΌ ΠΎΠ±ΠΎΠ»ΠΎΡ‡ΠΊΡƒ end; procedure TForm1.FormDestroy(Sender: TObject); begin iniFile.writeString('Skins','SkinName', sSkinManager1.SkinName); // сохраняСм ΠΏΡ€ΠΈ Π²Ρ‹Ρ…ΠΎΠ΄Π΅, какая ΠΎΠ±ΠΎΠ»ΠΎΡ‡ΠΊΠ° Π±Ρ‹Π»Π° использована послСднСй iniFile.Free; end; 

Of course, it is also necessary to make a handler in case the ini-file does not detect information about the shell when loading, as well as in the absence of the ini-file itself.