选择显示字体大小

delphi控件,我们也可以(4)

下面是我的代码:

unit lxtouchlabel;

interface

uses

windows, messages, sysutils, classes, controls, stdctrls, graphics;

type

ttouchlabel = class(tlabel)

private

{ private declarations }

fcolor : tcolor;

ftouchcolor : tcolor;

ftempcolor : tcolor;

ftouchfont : tfont;

ftempfont : tfont;

isstoretouchfont : boolean;

function gettouchbkcolor : tcolor;

function isstoretouchbkcolor : boolean;

procedure settouchbkcolor(acolor : tcolor);

procedure settouchfont(afont : tfont);

procedure cmmouseenter(var message : tmessage); message cm_mouseenter;

procedure cmmouseleave(var message : tmessage); message cm_mouseleave;

protected

{ protected declarations }

public

{ public declarations }

constructor create(aowner: tcomponent); override;

destructor destroy; override;

published

{ published declarations }

property color;

property parentcolor;

property parentfont;

property touchbkcolor : tcolor read gettouchbkcolor write settouchbkcolor

stored isstoretouchbkcolor default clwindow;

property touchfont : tfont read ftouchfont write settouchfont

stored isstoretouchfont;

property changewhiletouch : boolean read isstoretouchfont

write isstoretouchfont default true;

end;


procedure register;

implementation

procedure register;

begin

registercomponents('lx', [ttouchlabel]);

end;

{ ttouchlabel }

constructor ttouchlabel.create(aowner: tcomponent);

begin

inherited;

ftempcolor := clwindow;

ftempfont := tfont.create;

ftouchfont := tfont.create;

isstoretouchfont := true;

end;


destructor ttouchlabel.destroy;

begin

ftempfont.free;

ftouchfont.free;

inherited;

end;



function ttouchlabel.gettouchbkcolor: tcolor;

begin

result := ftouchcolor;

end;


procedure ttouchlabel.settouchfont(afont: tfont);

begin

ftouchfont.assign(afont);

isstoretouchfont := true;

end;


procedure ttouchlabel.cmmouseenter(var message: tmessage);

begin

inherited;

if not changewhiletouch then exit;

if fcolor <> ftouchcolor then

begin

ftempcolor := color;

color := touchbkcolor;

end;


ftempfont.assign(font);

font.assign(touchfont);

end;


procedure ttouchlabel.cmmouseleave(var message: tmessage);

begin

inherited;

if not changewhiletouch then exit;

if fcolor <> ftouchcolor then

color := ftempcolor;

font.assign(ftempfont);

end;


procedure ttouchlabel.settouchbkcolor(acolor: tcolor);

begin

ftouchcolor := acolor;

end;


function ttouchlabel.isstoretouchbkcolor: boolean;

begin

result := (fcolor <> ftouchcolor);

end;

end.


///////////////////////////////////////////////////////////////////////

unit qlxtouchlable;

interface

uses

windows, messages, sysutils, classes, qcontrols, qstdctrls, qgraphics;

type

ttouchlable = class(tlabel)

private

{ private declarations }

fcolor : tcolor;

ftouchcolor : tcolor;

ftempcolor : tcolor;

ftouchfont : tfont;

ftempfont : tfont;

isstoretouchfont : boolean;

function gettouchcolor : tcolor;

function isstoretouchcolor : boolean;

procedure settouchcolor(acolor : tcolor);

procedure settouchfont(afont : tfont);

procedure mouseenter(acontrol: tcontrol); override;

procedure mouseleave(acontrol: tcontrol); override;

protected

{ protected declarations }

public

{ public declarations }

constructor create(aowner: tcomponent); override;

destructor destroy; override;

published

{ published declarations }

property color;

property parentcolor;

property parentfont;

property touchcolor : tcolor read gettouchcolor write settouchcolor

stored isstoretouchcolor default clwindow;

property touchfont : tfont read ftouchfont write settouchfont

stored isstoretouchfont;

property changewhiletouch : boolean read isstoretouchfont

write isstoretouchfont default true;

end;


procedure register;

implementation

procedure register;

begin

registercomponents('lx', [ttouchlable]);

end;


{ ttouchlable }

constructor ttouchlable.create(aowner: tcomponent);

begin

inherited;

ftempcolor := clwindow;

ftempfont := tfont.create;

ftouchfont := tfont.create;

isstoretouchfont := true;

end;


destructor ttouchlable.destroy;

begin

ftempfont.free;

ftouchfont.free;

inherited;

end;


function ttouchlable.gettouchcolor: tcolor;

begin

result := ftouchcolor;

end;


function ttouchlable.isstoretouchcolor: boolean;

begin

result := (fcolor <> ftouchcolor);

end;


procedure ttouchlable.mouseenter(acontrol: tcontrol);

begin

inherited;

if not changewhiletouch then exit;

if fcolor <> ftouchcolor then

begin

ftempcolor := color;

color := touchcolor;

end;


ftempfont.assign(font);

font.assign(touchfont);

end;


procedure ttouchlable.mouseleave(acontrol: tcontrol);

begin

inherited;

if not changewhiletouch then exit;

if fcolor <> ftouchcolor then

color := ftempcolor;

font.assign(ftempfont);

end;


procedure ttouchlable.settouchcolor(acolor: tcolor);

begin

ftouchcolor := acolor;

end;


procedure ttouchlable.settouchfont(afont: tfont);

begin

ftouchfont.assign(afont);

isstoretouchfont := true;

end;

end.


 


关键字 本文所属关键字

相关 与本文相关文章

分类 所有文章关键字导航

源码编程相关

Java   Asp   PHP   .Net   XML   C/C++   CGI   VB   Jsp   J2ee   J2se   J2me   EJB   Servlet   Tomcat   Resin   Struts   Weblogic   Eclipse   ANT   GUI   JMS   Web servise   IDEA   Webphere   Hibernate   Spring   Jboss   Applet   Swing   Socket   Javamail   Perl   Ajax   P2P   安全   模式   框架   测试   开源   游戏

SQL数据库相关

My-SQL   Ms-SQL   Access   DB2   Oracle   Sybase   SQLserver   索引   存储过程   加密   数据库   分页   视图  

手机无线相关

3G   Wap   CDMA   GRPS   GSM   IVR   彩信   短信   无线   增值业务

网页设计制作相关

HTML   CSS   网页配色   网页特效   Javascript   VBscript   Dreamweaver   Frontpage   JS   Web   网站设计

网站建设推广相关

建站经验   网站优化   网站排名   推广   Alexa

操作系统/服务器相关

Windows XP   Windows 2000   Windows 2003   Windows Me   Windows 9.x   Linux   UNIX   注册表   操作系统   服务器   应用服务器

图形图像多媒体相关

Photoshop   Fireworks   Flash   Coreldraw   Illustrator   Freehand   Photoimpact   多媒体   图形图像

标准 网站致力的规范

Valid CSS!

无不良内容,无不良广告,无恶意代码

Valid XHTML 1.0 Transitional

creativecommons