Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Save and Load Columns DBgrid in Registry

476 views
Skip to first unread message

Alibi

unread,
Aug 11, 2007, 8:18:52 AM8/11/07
to
Hi,

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


Mike Shkolnik

unread,
Aug 11, 2007, 4:29:14 PM8/11/07
to
You may download our SMDBGrid: http://www.scalabium.com/smdbgrid.htm

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...

Alibi

unread,
Aug 13, 2007, 10:34:02 AM8/13/07
to
In Delphi 2007, up 1, in install ocurr 5 error:

[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'


Mike Shkolnik

unread,
Aug 13, 2007, 4:04:32 PM8/13/07
to
Seems you used the non-English resources (Brazilian Portuguese?) for package
and translator didn't translate all strings

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...

Chris Morgan

unread,
Aug 15, 2007, 8:42:38 AM8/15/07
to
> Reg.WriteBinaryData('FormGrade', Colunas, Colunas.Size);

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

0 new messages