在主窗体中添加Image1控件......
7.自汇状态栏
//设置状态栏面板对象的Style为OwnerDraw,并在状态栏对象的DrawPanel事件中书写以下代码:
procedure TForm1.StatusBar1DrawPanel(StatusBar: TStatusBar;
Panel: TStatusPanel; const Rect: Trect);
begin
with statusbar1.Canvas do begin
Brush.Color := clRed;
FillRect(Rect);
TextOut(Rect.Left, Rect.Top, "Panel "+IntToStr(Panel.Index));
end;
end;
8.一个具有超连接性质的Label(示范如何使控件具有鼠标进入与退出事件) //新建单元,创建以下类
uses Windows, Messages, Graphics, Controls, StdCtrls;
………..
TMyLabel = class(Tlabel)
Private
FMouseInPos : Boolean;
procedure CMMouseEnter(var Amsg: Tmessage); message CM_MOUSEENTER;
procedure CMMouseLeave(var Amsg: Tmessage); message CM_MOUSELEAVE;
protected
procedure Paint; override;
End;
//各事件代码
procedure TMyLabel.CMMouseEnter(var Amsg: Tmessage);
begin
FMouseInPos := True;
Refresh;
end;
procedure TMyLabel.CMMouseLeave(var Amsg: Tmessage);
begin
FMouseInPos := False;
Refresh;
end;
procedure TMyLabel.Paint;
begin
if FMouseInPos then
begin
Font.Color := clRed;
Font.Style := Font.Style + [fsUnderline];
end
else
begin
Font.Color := clBlue;
Font.Style := Font.Style - [fsUnderline];
end;
Inherited Paint;
end;
查看本文来源