Font 如何存起來? |
答題得分者是:zhouying82
|
alvin26
初階會員 發表:24 回覆:41 積分:28 註冊:2005-04-12 發送簡訊給我 |
|
zhouying82
高階會員 發表:150 回覆:272 積分:189 註冊:2004-03-16 發送簡訊給我 |
|
zhouying82
高階會員 發表:150 回覆:272 積分:189 註冊:2004-03-16 發送簡訊給我 |
[code delphi] [code cpp] var filedir:string; ini:Tinifile; MStyles:TFontStyles; MStylespoint:pointer; const MColor='Color'; MFontName='FontName'; MFontSize='Size'; MFontColor='FontColor'; MFontStyle='FontStyle'; procedure TForm1.FormCreate(Sender: TObject); //取执行文件目录 begin getdir(0,filedir); end; procedure TForm1.Button1Click(Sender: TObject); //写 begin ColorDialog1.Execute; with Memo1 do begin Color:=ColorDialog1.Color; end; FontDialog1.Execute; with Memo1 do begin Font:=FontDialog1.Font; end; Ini:=TIniFile.Create(filedir '\Font_Color.ini'); with Memo1 do begin Ini.WriteInteger(name,MColor,Color); Ini.WriteString(name,MFontName,Font.Name); Ini.WriteInteger(name,MFontSize,Font.Size); Ini.WriteInteger(name,MFontColor,Font.Color); MStyles:=Font.Style; MStylespoint:=@MStyles; Ini.WriteInteger(name,MFontStyle,integer(MStylespoint^)); end; Ini.Free; end; procedure TForm1.Button2Click(Sender: TObject); // 写 var a:integer; begin Ini:=TIniFile.Create(filedir '\Font_Color.ini'); try with Memo1 do begin Color:=Ini.ReadInteger(name,MColor,Color); Font.Name:=Ini.ReadString(name,MFontName,Font.Name); Font.Size:=Ini.ReadInteger(name,MFontSize,Font.Size); Font.Color:=Ini.ReadInteger(name,MFontColor,Font.Color); a:=Ini.ReadInteger(name,MFontStyle,0); MStylespoint:=@a; Font.Style:=TFontStyles(MStylespoint^); end; finally end; Ini.Free; end; [/code] [/code] [code cpp] var filedir:string; ini:Tinifile; MStyles:TFontStyles; MStylespoint:pointer; const MColor='Color'; MFontName='FontName'; MFontSize='Size'; MFontColor='FontColor'; MFontStyle='FontStyle'; procedure TForm1.FormCreate(Sender: TObject); //取执行文件目录 begin getdir(0,filedir); end; procedure TForm1.Button1Click(Sender: TObject); //写 begin ColorDialog1.Execute; with Memo1 do begin Color:=ColorDialog1.Color; end; FontDialog1.Execute; with Memo1 do begin Font:=FontDialog1.Font; end; Ini:=TIniFile.Create(filedir '\Font_Color.ini'); with Memo1 do begin Ini.WriteInteger(name,MColor,Color); Ini.WriteString(name,MFontName,Font.Name); Ini.WriteInteger(name,MFontSize,Font.Size); Ini.WriteInteger(name,MFontColor,Font.Color); MStyles:=Font.Style; MStylespoint:=@MStyles; Ini.WriteInteger(name,MFontStyle,integer(MStylespoint^)); end; Ini.Free; end; procedure TForm1.Button2Click(Sender: TObject); // 写 var a:integer; begin Ini:=TIniFile.Create(filedir '\Font_Color.ini'); try with Memo1 do begin Color:=Ini.ReadInteger(name,MColor,Color); Font.Name:=Ini.ReadString(name,MFontName,Font.Name); Font.Size:=Ini.ReadInteger(name,MFontSize,Font.Size); Font.Color:=Ini.ReadInteger(name,MFontColor,Font.Color); a:=Ini.ReadInteger(name,MFontStyle,0); MStylespoint:=@a; Font.Style:=TFontStyles(MStylespoint^); end; finally end; Ini.Free; end; [/code]
------
断断续续的学了几年,还是一个初学者,永远支持Delphi !
編輯記錄
|
zhouying82
高階會員 發表:150 回覆:272 積分:189 註冊:2004-03-16 發送簡訊給我 |
|
pceyes
尊榮會員 發表:70 回覆:657 積分:1140 註冊:2003-03-13 發送簡訊給我 |
[code delphi] procedure TForm1.FormCreate(Sender: TObject); begin memo1.Font.Name := '新細明體'; end; procedure TForm1.FormClose(Sender: TObject; var Action: TCloseAction); var fontname:string; begin fontname := memo1.Font.Name; end; [/code]
------
努力會更接近成功 |
chkkevin
一般會員 發表:34 回覆:64 積分:19 註冊:2007-05-17 發送簡訊給我 |
|
alvin26
初階會員 發表:24 回覆:41 積分:28 註冊:2005-04-12 發送簡訊給我 |
------
弟子規,聖人訓,首孝悌,次謹信,泛愛眾,而親仁,有餘力,則學文。 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |