All articles| All Pictures| All Softwares| All Video| Go home page| Write articles| Upload pictures

Reading number is top 10 articles
PHP编程常用技巧四则_php资料_编程技术
Atlas快速入门之实战Atlas_.net资料_编程技术
几种个人网页里常用到的特效代码介绍_JavaScript技术_编程技术
PHP中路径问题的解决方案_php资料_编程技术
ASP.NET,MVC,Framework体验(4):控制器_[Asp.Net教程]
C#中利用process类调用外部程序以及执行dos命令_.net资料_编程技术
php中session使用简介_php资料_编程技术
asp.net读excle的数据类型不统一取出空值问题_.net资料_编程技术
C#图像放大问题解决方法_.net资料_编程技术
PHP实例:PHP生成带有雪花背景的网站验证码_[PHP教程]
Reading number is top 10 pictures
夕阳下的北京街道
Fierce! China's special forces training the devil2
Steal to eat bacon bird
Absolutely shocked. National geographic 50 animal photographys4
含苞欲放的素颜美少女1
战场废物2
Born After 90 Beijing sports university campus flower photos1
9.3阅兵全景图4-陸海空现代化兵种方阵梯队
Shandong jinan is about to dismantle a one hundred-year history of the building
Forced sex girl living abroad1
Download software ranking
matrix1
虚拟机汉化软件
C++教程第四版
Boxer's Top ten classic battle5
Boxer Classic video3
WebService在.NET中的实战应用教学视频 → 第3集
The cock of the Grosvenor LTD handsome
Boxer vs Yellow4
C#编程思想
Unix video tutorial6
aaa published in(发表于) 2014/7/19 0:08:45 Edit(编辑)
delphiDelphi多彩的菜单实例

delphiDelphi多彩的菜单实例

delphiDelphi多彩的菜单实例

Delphi多彩的菜单

实例说明

网上的许多应用程序都具有漂亮的菜单。默认情况下,使用Delphi提供的TMainMenu组件只能设置标准的Windows风格菜单,如何能够自定义菜单呢?本实例演示如何自定义菜单,效果如图1.5所示。



1.5Delphi多彩的菜单

技术要点

在Delphi中重新绘制TMainMenu组件,首先需要将OwnerDraw属性设置为True,然后双击TMainMenu组件打开菜单编辑器,添加菜单项。选中菜单项,在对象观察器中编写OnAdvancedDrawItem事件处理过程,OnAdvancedDrawItem事件在菜单项(OwnerDraw属性设置为True)需要绘制时触发。

实现过程

1.新建一个工程,将主窗口命名为Form1。

2.在Form1窗体上放置TImage、TmainMenu和TStatusBar等组件。设置TImage组件的Picture属性,为其加载一幅图像。双击TMainMenu组件,打开菜单编辑窗口,想TMainMenu组件中添加菜单项。

3.程序代码如下:

procedure TForm1.N3AdvancedDrawItem(Sender: TObject; ACanvas: TCanvas;

ARect: TRect; State: TOwnerDrawState);

begin

ACanvas.Brush.Color := clwhite;

if odSelected in State then

begin

ACanvas.Font.Color := clRed;

ACanvas.Pen.Color := clBlue;

ACanvas.Rectangle(Rect(1,(TMenuItem(Sender).Tag-1)*20,ARect.Right-1,(TMenuItem(Sender).Tag-1)*20+15));

NotifyMessage(TMenuItem(Sender).Caption);

end

else

begin

ACanvas.Font.Color := clBlack;

ACanvas.Pen.Color := clWhite;

ACanvas.Rectangle(Rect(1,(TMenuItem(Sender).Tag-1)*20,ARect.Right-1,(TMenuItem(Sender).Tag-1)*20+15));

end;

ACanvas.TextOut(4,(TMenuItem(Sender).Tag-1)*20+2,TMenuItem(Sender).Caption);

end;


procedure TForm1.N1AdvancedDrawItem(Sender: TObject; ACanvas: TCanvas;

ARect: TRect; State: TOwnerDrawState);

begin

SetBkMode(ACanvas.Handle,TRANSPARENT);

if odSelected in State then

begin

ACanvas.Font.Color := clRed;

ACanvas.Pen.Color := clBlue;

ACanvas.Brush.Color := Color;

ACanvas.Rectangle(Rect(TMenuItem(Sender).Tag-2,32,ARect.Right-5,47));

end

else

begin

ACanvas.Font.Color := clBlack;

ACanvas.Pen.Color := Color;

ACanvas.Brush.Color := Color;

ACanvas.Rectangle(Rect(TMenuItem(Sender).Tag-2,32,ARect.Right-5,47));

end;

ACanvas.TextOut(TMenuItem(Sender).Tag,34,TMenuItem(Sender).Caption);

end;




添加到del.icio.us 添加到新浪ViVi 添加到百度搜藏 添加到POCO网摘 添加到天天网摘365Key 添加到和讯网摘 添加到天极网摘 添加到黑米书签 添加到QQ书签 添加到雅虎收藏 添加到奇客发现 diigo it 添加到饭否 添加到飞豆订阅 添加到抓虾收藏 添加到鲜果订阅 digg it 貼到funP 添加到有道阅读 Live Favorites 添加到Newsvine 打印本页 用Email发送本页 在Facebook上分享


Disclaimer Privacy Policy About us Site Map

If you have any requirements, please contact webmaster。(如果有什么要求,请联系站长)
Copyright ©2011-
uuhomepage.com, Inc. All rights reserved.