如何在richedit上將文字上標 |
尚未結案
|
freshwang54
一般會員 發表:3 回覆:6 積分:1 註冊:2003-02-28 發送簡訊給我 |
各位前輩好
我想在richedit上將文字上標,在網路上找到一個例子 ,但是
有error ,試了兩個晚上還是不行 ,只好請前輩指點,謝謝 freshwang
程式如下 type
TCharacterFormat = (CFM_Superscript, CFM_Subscript, CFM_Normal);
type TCharFormat = record//這個record是我從本站copy下來的
cbSize: UINT;
dwMask: Longint;
dwEffects: Longint;
yHeight: Longint;
yOffset: Longint;
crTextColor: TColorRef;
bCharSet: Byte;
bPitchAndFamily: Byte;
szFaceName: array[0..LF_FACESIZE - 1] of AnsiChar;
end;
type
TForm1 = class(TForm)
Button1: TButton;
RichEdit1: TRichEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
procedure RE_SetCharFormat(RichEdit: TRichEdit; CharacterFormat: TCharacterFormat); end; var
Form1: TForm1; implementation {$R *.dfm} procedure tform1.RE_SetCharFormat(RichEdit: TRichEdit; CharacterFormat: TCharacterFormat);
var
Format: TCharFormat;
begin
FillChar(Format, SizeOf(Format), 0);
with Format do
begin
cbSize := SizeOf(Format);
dwMask := CFM_OFFSET;//無法通過compile
// Character offset, in twips, from the baseline.
// If the value of this member is positive,
// the character is a superscript;
// if it is negative, the character is a subscript.
case CharacterFormat of
CFM_Superscript: yOffset := 60;
CFM_Subscript: yOffset := -60;
CFM_Normal: yOffset := 0;
end;
end;
// The EM_SETCHARFORMAT message sets character formatting in a rich edit control.
// SCF_SELECTION: Applies the formatting to the current selection
Richedit.Perform(EM_SETCHARFORMAT, SCF_SELECTION, Longint(@Format));
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
RE_SetCharFormat(RichEdit1, CFM_Superscript);
end;
|
RedSnow
版主 發表:79 回覆:1322 積分:845 註冊:2003-12-15 發送簡訊給我 |
|
freshwang54
一般會員 發表:3 回覆:6 積分:1 註冊:2003-02-28 發送簡訊給我 |
本站聲明 |
1. 本論壇為無營利行為之開放平台,所有文章都是由網友自行張貼,如牽涉到法律糾紛一切與本站無關。 2. 假如網友發表之內容涉及侵權,而損及您的利益,請立即通知版主刪除。 3. 請勿批評中華民國元首及政府或批評各政黨,是藍是綠本站無權干涉,但這裡不是政治性論壇! |