Hello guys!
# begin streams
I need to save and read many data types (numbers (int, float), records, arrays and strings) in one file. Problem is with strings. Currently I'm using TStringStream:
Example write:
Delphi-Quellcode:
Buffer := Length(AValue);
AStream.Write(Buffer, 4);
AString.Clear;
AString.WriteString(AValue);
AStream.CopyFrom(AString, 0);
Example read:
Delphi-Quellcode:
Strings := TStringStream.Create;
try
P := AStream.Position;
AStream.Position := 0;
Strings.CopyFrom(AStream, FHeaderSize);
AStream.Position := P;
for I := 1 to 8 do
begin
AStream.Position := P;
AStream.Read(buff32, 4);
Strings.Position := AStream.Position;
buffS := Strings.ReadString(buff32);
// ...
AStream.Position := Strings.Position;
P := AStream.Position;
end;
finally
Strings.Free;
end;
1st at all strings inside file are not
Unicode (compiled on D2010). How to make it
unicode?
2nd: my method looks very lame, is better method to store strings next to the binary data?
# end streams
# begin shortcuts
2nd my problem is with shortcuts in dynamically created menu items:
Delphi-Quellcode:
if Item.Tag in [1..9] then
Item.ShortCut := ShortCut(48 + Item.Tag, [ssCtrl, ssAlt])
;
When press Ctrl+Alt+[num 1-9] program starts executing OnClick for ever... Why?
# end shortcuts