Delphi Pages Forums  

Go Back   Delphi Pages Forums > Delphi Forum > Tools

Lost Password?

Reply
 
Thread Tools Display Modes
  #1  
Old 11-10-2004, 05:04 AM
Jasser Jasser is offline
Moderator
 
Join Date: Jan 2005
Location: Saudi Arabia
Posts: 5,060
Default Toolbar

Using Toolbar, is there a way to save the settings of it (like: the number of buttons, captions of buttons, font, etc)?

Regards,
Abdulaziz Jasser
Reply With Quote
  #2  
Old 11-10-2004, 06:00 AM
jdg jdg is offline
Senior Member
 
Join Date: Sep 2003
Posts: 1,063
Default RE: Toolbar

You can save the properties in the registry, or a file of your choosing. Here's a code excerpt that I use to save the visible tool bars and position of them in a cool band. The buttons and font's are saved as part of the form, but, if you're giving your user a chance to change them, you could easily add thier properties in here.

This should give you a starting place.

In my usage, I've created a class to handle my toolbars and coolbands called TToolBars.

Code:
procedure TToolBars.SaveProperties;
// RegKey should be like 'Software\AppName\Toolbars'
// That key will have subkeys like 'Software\AppName\Toolbars\CoolBarMain' << CoolRegKey
// That key will have subkeys like 'Software\AppName\Toolbars\CoolBarMain\0' <<BarRegKey
// where "0" is the index of the coolbar band.values saved here.
var
  // RegKey is global
  Reg: TRegistry;
  KeyGood: boolean;
  CoolRegKey,
  BarRegKey: string;
  i: integer;
begin // SaveProperties
  Reg := TRegistry.Create;
  CoolRegKey := RegKey + '\Toolbars\' + CoolBar.Name;
  try
    for i := 0 to CoolBar.Bands.Count -1 do begin
      BarRegKey := CoolRegKey + '\' + IntToStr(i);
      KeyGood := Reg.OpenKey(BarRegKey, true);
      if KeyGood then begin
        Reg.WriteString('Control',CoolBar.Bands[i].Control.Name);
        Reg.WriteBool('Break', CoolBar.Bands[i].Break);
        Reg.WriteInteger('Width', CoolBar.Bands[i].Width);
        Reg.WriteBool('Visible', CoolBar.Bands[i].Visible);
        Reg.WriteInteger('Left', CoolBar.Bands[i].Control.Left);
      end; // if KeyGood
      Reg.CloseKey;
    end; // for i
  finally
    Reg.free;
  end; // try finally
end; // SaveProperties
Good luck

jdg

I love this forum. Your generosity is wonderful.
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 05:44 PM.


Powered by vBulletin® Version 3.8.8
Copyright ©2000 - 2019, vBulletin Solutions, Inc.