请问如何在delphi中作出镂空的字体显示(100分)

  • 主题发起人 主题发起人 DUDU
  • 开始时间 开始时间
D

DUDU

Unregistered / Unconfirmed
GUEST, unregistred user!
思路方面想不通,大侠指点一下
 
用图片好了。
要不用两个LABEL盖在一起,一个大,一个小。。。。
 
同意label+label
背景:绿色
label1:红色,24
label2:绿色,12
 
使用 WindowNT GUI 的 Path 的功能即可!具体查看 MSDN 吧!
 
begin
canvas.Font.Name := 'Times New Roman';
canvas.Font.size := 72;
canvas.Font.style := [fsItalic,fsBold];
beginpath(canvas.handle);
SetBkMode(Canvas.Handle, TRANSPARENT );
canvas.Polygon([Point(0,0),Point(Width,0),
Point(Width,Height),Point(0,Height),
Point(0,0)]);
canvas.TextOut(20,40,'OLDCAT');
endpath(canvas.handle);
SetWindowRgn( Handle, PathToRegion(canvas.Handle), true );
end;


begin
canvas.Font.Name := 'Times New Roman';
canvas.Font.size := 72;
canvas.Font.style := [fsItalic,fsBold];
beginpath(canvas.handle);
canvas.TextOut(20,40,'OLDCAT');
endpath(canvas.handle);
SetWindowRgn( Handle, PathToRegion(canvas.Handle), true );
end;
 
var
m: LOGFONT;
hdc1: HDC;
N,O: HGDIOBJ;
s: string;
x, y: integer;
begin
m.lfHeight := -80;
m.lfWidth := 0;
m.lfEscapement := 450;
m.lfOrientation := 0;
m.lfWeight := FW_HEAVY;
m.lfItalic := 0;
m.lfUnderline := 0;
m.lfStrikeOut := 0;
m.lfCharSet := GB2312_CHARSET;
m.lfOutPrecision := OUT_STROKE_PRECIS;
m.lfClipPrecision := CLIP_STROKE_PRECIS;
m.lfQuality := DRAFT_QUALITY ;
m.lfPitchAndFamily := VARIABLE_PITCH + FF_MODERN;
StrPCopy(m.lfFaceName, '楷体_GB2312');
s := '汉字';
x := 13;
y := 103;
hdc1 := GetDC(Self.Handle);
N := CreateFontIndirect(m);
O := SelectObject(hdc1, N);
SetBKMode(hdc1, TRANSPARENT);
SetTextColor(hdc1, GetSysColor(COLOR_3DDKSHADOW));
TextOut(hdc1, x+2, y-2, PChar(s), Length(s));
TextOut(hdc1, x+2, y+2, PChar(s), Length(s));
SetTextColor(hdc1, GetSysColor(COLOR_HIGHLIGHT));
TextOut(hdc1, x+1, y-2, PChar(s), Length(s));
TextOut(hdc1, x-2, y+1, PChar(s), Length(s));
TextOut(hdc1, x-2, y-2, PChar(s), Length(s));
SetTextColor(hdc1, GetSysColor(COLOR_3DSHADOW));
TextOut(hdc1, x-1, y+1, PChar(s), Length(s));
TextOut(hdc1, x+1, y-1, PChar(s), Length(s));
TextOut(hdc1, x+1, y+1, PChar(s), Length(s));
SetTextColor(hdc1, GetSysColor(COLOR_3DLIGHT));
TextOut(hdc1, x, y-1, PChar(s), Length(s));
TextOut(hdc1, x-1, y, PChar(s), Length(s));
TextOut(hdc1, x-1, y-1, PChar(s), Length(s));
BeginPath(hdc1);
TextOut(hdc1, x, y, PChar(s), Length(s));
EndPath(hdc1);
SetPolyFillMode(hdc1, WINDING);
StrokeAndFillPath(hdc1);
N:=SelectObject(hdc1, O);
DeleteObject(N);
end;
 
shaofun的做出好看哦。
 
是不是就是把边缘取出来?
俺用vc做过
 
能不能写在一幅位图上,在用image.picture.savefile存为文件
hdc1 := GetDC(Self.Handle); 变为GetDc(Image1.Canvas.handle);
我试了一下,好像不行。另外,字体的颜色是否可以变化
 

Similar threads

D
回复
0
查看
930
DelphiTeacher的专栏
D
D
回复
0
查看
871
DelphiTeacher的专栏
D
D
回复
0
查看
945
DelphiTeacher的专栏
D
D
回复
0
查看
777
DelphiTeacher的专栏
D
D
回复
0
查看
867
DelphiTeacher的专栏
D
后退
顶部