12 个解决方案
#1
-_-#
#2
听得糊涂……
#3
啊?简而言之,就是想把Memo控件的字体信息,比如字号,颜色等等以流的的形式保存到INI文件中
#4
#5
那就用rtf格式吧
如果要写成文本文件的话,就用xml
如果要写成文本文件的话,就用xml
#6
直接保存,读入 memo控件 也可以啊
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Buttons, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
ColorBox1: TColorBox;
BitBtn1: TBitBtn;
ColorBox2: TColorBox;
edit1: TMemo;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure ColorBox1Change(Sender: TObject);
procedure ColorBox2Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const
dir='pp.dat'; //保存memo的文件
var
Form1: TForm1;
pr:TMemoryStream;
implementation
{$R *.dfm}
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
pr.Destroy;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
pr:=TMemoryStream.Create;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
pr.Clear;
pr.WriteComponent(Edit1);
pr.SaveToFile(dir); 保存
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
pr.Clear;
pr.LoadFromFile(dir);
pr.ReadComponent(Edit1) ; //读入
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
edit1.Width:=edit1.Width+2;
edit1.Height:=edit1.Height+2;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
edit1.Width:=edit1.Width-2;
edit1.Height:=edit1.Height-2;
end;
procedure TForm1.ColorBox1Change(Sender: TObject);
begin
edit1.Font.Color:=ColorBox1.Selected;
end;
procedure TForm1.ColorBox2Change(Sender: TObject);
begin
edit1.Color:=ColorBox2.Selected;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Buttons, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
ColorBox1: TColorBox;
BitBtn1: TBitBtn;
ColorBox2: TColorBox;
edit1: TMemo;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure ColorBox1Change(Sender: TObject);
procedure ColorBox2Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const
dir='pp.dat'; //保存memo的文件
var
Form1: TForm1;
pr:TMemoryStream;
implementation
{$R *.dfm}
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
pr.Destroy;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
pr:=TMemoryStream.Create;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
pr.Clear;
pr.WriteComponent(Edit1);
pr.SaveToFile(dir); 保存
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
pr.Clear;
pr.LoadFromFile(dir);
pr.ReadComponent(Edit1) ; //读入
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
edit1.Width:=edit1.Width+2;
edit1.Height:=edit1.Height+2;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
edit1.Width:=edit1.Width-2;
edit1.Height:=edit1.Height-2;
end;
procedure TForm1.ColorBox1Change(Sender: TObject);
begin
edit1.Font.Color:=ColorBox1.Selected;
end;
procedure TForm1.ColorBox2Change(Sender: TObject);
begin
edit1.Color:=ColorBox2.Selected;
end;
end.
#7
什么流的形式,直接savetofile不久可以了吗?
#8
不行,因为单独保存的一个文件中的话,就不能保存别的内容了。因为我想保存到INI文件,这个INI文件中还有其他内容,我想用 TIniFile 类的 WriteBinaryStream 方法保存。但是不会......
#9
顶上去
#10
自己写个加解密算法把Memo.Text加密成不是回车的字符串就可以了!
#11
Text的内容已经成功的转换成流写入INI文件了,也能成功读取了,现在是想保存它的字体信息
#12
var
ms:TMemoryStream;
buffer:pchar;
size:integer;
begin
ms.WriteComponent(Memo1);
size:=ms.size;
getmem(buffer,size);
ms.readbuffer(buffer,size);
把buffer内容读到ini文件中
ms:TMemoryStream;
buffer:pchar;
size:integer;
begin
ms.WriteComponent(Memo1);
size:=ms.size;
getmem(buffer,size);
ms.readbuffer(buffer,size);
把buffer内容读到ini文件中
#1
-_-#
#2
听得糊涂……
#3
啊?简而言之,就是想把Memo控件的字体信息,比如字号,颜色等等以流的的形式保存到INI文件中
#4
#5
那就用rtf格式吧
如果要写成文本文件的话,就用xml
如果要写成文本文件的话,就用xml
#6
直接保存,读入 memo控件 也可以啊
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Buttons, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
ColorBox1: TColorBox;
BitBtn1: TBitBtn;
ColorBox2: TColorBox;
edit1: TMemo;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure ColorBox1Change(Sender: TObject);
procedure ColorBox2Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const
dir='pp.dat'; //保存memo的文件
var
Form1: TForm1;
pr:TMemoryStream;
implementation
{$R *.dfm}
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
pr.Destroy;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
pr:=TMemoryStream.Create;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
pr.Clear;
pr.WriteComponent(Edit1);
pr.SaveToFile(dir); 保存
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
pr.Clear;
pr.LoadFromFile(dir);
pr.ReadComponent(Edit1) ; //读入
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
edit1.Width:=edit1.Width+2;
edit1.Height:=edit1.Height+2;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
edit1.Width:=edit1.Width-2;
edit1.Height:=edit1.Height-2;
end;
procedure TForm1.ColorBox1Change(Sender: TObject);
begin
edit1.Font.Color:=ColorBox1.Selected;
end;
procedure TForm1.ColorBox2Change(Sender: TObject);
begin
edit1.Color:=ColorBox2.Selected;
end;
end.
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls, ComCtrls, Buttons, ExtCtrls;
type
TForm1 = class(TForm)
Button1: TButton;
Button2: TButton;
Button3: TButton;
ColorBox1: TColorBox;
BitBtn1: TBitBtn;
ColorBox2: TColorBox;
edit1: TMemo;
procedure FormClose(Sender: TObject; var Action: TCloseAction);
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure Button3Click(Sender: TObject);
procedure BitBtn1Click(Sender: TObject);
procedure ColorBox1Change(Sender: TObject);
procedure ColorBox2Change(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
const
dir='pp.dat'; //保存memo的文件
var
Form1: TForm1;
pr:TMemoryStream;
implementation
{$R *.dfm}
procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction);
begin
pr.Destroy;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
pr:=TMemoryStream.Create;
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
pr.Clear;
pr.WriteComponent(Edit1);
pr.SaveToFile(dir); 保存
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
pr.Clear;
pr.LoadFromFile(dir);
pr.ReadComponent(Edit1) ; //读入
end;
procedure TForm1.Button3Click(Sender: TObject);
begin
edit1.Width:=edit1.Width+2;
edit1.Height:=edit1.Height+2;
end;
procedure TForm1.BitBtn1Click(Sender: TObject);
begin
edit1.Width:=edit1.Width-2;
edit1.Height:=edit1.Height-2;
end;
procedure TForm1.ColorBox1Change(Sender: TObject);
begin
edit1.Font.Color:=ColorBox1.Selected;
end;
procedure TForm1.ColorBox2Change(Sender: TObject);
begin
edit1.Color:=ColorBox2.Selected;
end;
end.
#7
什么流的形式,直接savetofile不久可以了吗?
#8
不行,因为单独保存的一个文件中的话,就不能保存别的内容了。因为我想保存到INI文件,这个INI文件中还有其他内容,我想用 TIniFile 类的 WriteBinaryStream 方法保存。但是不会......
#9
顶上去
#10
自己写个加解密算法把Memo.Text加密成不是回车的字符串就可以了!
#11
Text的内容已经成功的转换成流写入INI文件了,也能成功读取了,现在是想保存它的字体信息
#12
var
ms:TMemoryStream;
buffer:pchar;
size:integer;
begin
ms.WriteComponent(Memo1);
size:=ms.size;
getmem(buffer,size);
ms.readbuffer(buffer,size);
把buffer内容读到ini文件中
ms:TMemoryStream;
buffer:pchar;
size:integer;
begin
ms.WriteComponent(Memo1);
size:=ms.size;
getmem(buffer,size);
ms.readbuffer(buffer,size);
把buffer内容读到ini文件中