1. 建立一个窗体
2. 放一个combobox和listbox
3. 改变component的style为csownerdrawvariable和listbox的style为lbownerdrawvariable。
4. 声明5个tbitmap的全局变量
5. 覆盖form的oncreate.
6. 覆盖combobox的ondraw.
7. 覆盖combobox的onmeasureitem.
8. 释放资源在form的onclose.
unit ownerdrw;
interface
uses
sysutils, wintypes, winprocs, messages, classes, graphics, controls,
forms, dialogs, stdctrls;
type
tform1 = class(tform)
combobox1: tcombobox;
listbox1: tlistbox;
procedure formcreate(sender: tobject);
procedure formclose(sender: tobject; var action: tcloseaction);
procedure combobox1drawitem(control: twincontrol; index: integer;
rect: trect; state: townerdrawstate);
procedure combobox1measureitem(control: twincontrol; index: integer;
var height: integer);
procedure listbox1drawitem(control: twincontrol; index: integer;
rect: trect; state: townerdrawstate);
procedure listbox1measureitem(control: twincontrol; index: integer;
var height: integer);
private
{ private declarations }
public
{ public declarations }
end;
var
form1: tform1;
thebitmap1, thebitmap2, thebitmap3, thebitmap4,
thebitmap5 : tbitmap;
implementation
{$r *.dfm}
procedure tform1.formcreate(sender: tobject);
begin
thebitmap1 := tbitmap.create;
thebitmap1.loadfromfile('c:\delphi\images\buttons\globe.bmp');
thebitmap2 := tbitmap.create;
thebitmap2.loadfromfile('c:\delphi\images\buttons\video.bmp');
thebitmap3 := tbitmap.create;
thebitmap3.loadfromfile('c:\delphi\images\buttons\gears.bmp');
thebitmap4 := tbitmap.create;
thebitmap4.loadfromfile('c:\delphi\images\buttons\key.bmp');
thebitmap5 := tbitmap.create;
thebitmap5.loadfromfile('c:\delphi\images\buttons\tools.bmp');
combobox1.items.addobject('bitmap1: globe', thebitmap1);
combobox1.items.addobject('bitmap2: video', thebitmap2);
combobox1.items.addobject('bitmap3: gears', thebitmap3);
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 安全 模式 框架 测试 开源 游戏
Windows XP Windows 2000 Windows 2003 Windows Me Windows 9.x Linux UNIX 注册表 操作系统 服务器 应用服务器