Procedure Save and Load columns the DBGrid in Registry,
but this not functioning.
Some suggestion?
procedure TForm1.SaveClick(Sender: TObject);
var
Colunas: TMemoryStream;
Reg: TRegistry;
begin
Colunas := TMemoryStream.Create;
try
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
Reg.OpenKey('Software\Aplicativo\Grade\', True);
Colunas.Position := 0;
DBGrid1.Columns.SaveToStream(Colunas);
Reg.WriteBinaryData('FormGrade', Colunas, Colunas.Size);
finally
Reg.CloseKey;
Reg.Free;
end;
finally
Colunas.Free;
end;
end;
procedure TForm1.LoadClick(Sender: TObject);
var
Colunas: TMemoryStream;
Reg: TRegistry;
begin
Colunas := TMemoryStream.Create;
try
Reg := TRegistry.Create;
try
Reg.RootKey := HKEY_CURRENT_USER;
Reg.OpenKey('Software\Aplicativo\Grade\', True);
if Reg.ValueExists('FormGrade') then
begin
Reg.ReadBinaryData('FormGrade', Colunas, 10000);
Colunas.Position := 0;
DBGrid1.Columns.LoadFromStream(Colunas);
end;
finally
Reg.CloseKey;
Reg.Free;
end;
finally
Colunas.Free;
end;
end;
Thanks,
Paulo Geloramo
There in SMDBGrid.pas you may extract the SaveGridToRegistry and
LoadGridFromRegistry functions and use for your grid
--
With best regards, Mike Shkolnik
Scalabium Software
http://www.scalabium.com
mshk...@scalabium.com
"Alibi" <noe...@nospam.com.br> wrote in message
news:46bd...@newsgroups.borland.com...
[DCC Warning] SMCVersInfo.pas(108): W1002 Symbol 'Win32Check' is specific to
a platform
[DCC Warning] AngleLbl.pas(220): H2077 Value assigned to 'OldFontHandle'
never used
[DCC Warning] AngleLbl.pas(237): H2077 Value assigned to 'OldFontHandle'
never used
[DCC Warning] charmap.pas(240): W1024 Combining signed and unsigned types -
widened both operands
[DCC Warning] SMCnst.pas(29): W1014 String constant truncated to fit
STRING[33]
[DCC Warning] Edittype.pas(866): W1024 Combining signed and unsigned types -
widened both operands
[DCC Warning] Limitfrm.pas(259): W1000 Symbol 'MakeObjectInstance' is
deprecated
[DCC Warning] Limitfrm.pas(284): W1000 Symbol 'FreeObjectInstance' is
deprecated
[DCC Warning] RunText.pas(44): H2219 Private symbol 'GetTransparent'
declared but never used
[DCC Warning] RunText.pas(45): H2219 Private symbol 'SetTransparent'
declared but never used
[DCC Warning] SMDBComb.pas(808): W1000 Symbol 'DisposeStr' is deprecated
[DCC Warning] SMDBComb.pas(824): W1000 Symbol 'NewStr' is deprecated
[DCC Warning] SMDBComb.pas(843): W1000 Symbol 'NewStr' is deprecated
[DCC Warning] SMDBComb.pas(850): W1000 Symbol 'NewStr' is deprecated
[DCC Warning] SMDBComb.pas(168): H2219 Private symbol 'CenterStr' declared
but never used
[DCC Error] SMDBCtrl.pas(296): E2003 Undeclared identifier: 'SImportName'
[DCC Error] SMDBCtrl.pas(296): E2026 Constant expression expected
[DCC Error] SMDBCtrl.pas(301): E2003 Undeclared identifier: 'SImportRecord'
[DCC Error] SMDBCtrl.pas(301): E2026 Constant expression expected
[DCC Error] SMCmpntD2007.dpk(116): F2063 Could not compile used unit
'SMDBCtrl.pas'
Just use the English reources or copy these SImportName/SImportRecord
strings from original unit with English strings
--
With best regards, Mike Shkolnik
Scalabium Software
http://www.scalabium.com
mshk...@scalabium.com
"Alibi" <noe...@nospam.com.br> wrote in message
news:46c06bf0$1...@newsgroups.borland.com...
something like
Reg.WriteBinaryData('FormGrade',Colunas.Data,colunas.Size);
may work here - you need to pass the pointer to the actual memory
in the stream, not the object. Code is not tested - don't have Delphi on
this PC.
cheers,
Chris