在主窗体中添加Image1控件......
4.用渐变色填充窗体
procedure TForm1.FormPaint(Sender: TObject);
var
Row, Ht: Word ;
begin
Ht := (ClientHeight + 255) div 256 ;
for Row := 0 to 255 do
with Canvas do begin
Brush.Color := RGB(Row, 0, 0) ;
FillRect(Rect(0, Row * Ht, ClientWidth, (Row + 1) * Ht)) ;
end ;
end;
5.实现Winamp形式窗口拖动的方法 //在窗体的Private节中作如下声明
procedure WmNCHitTest(var Msg: TWMNCHitTest); message WM_NCHITTEST;
//在实现部分写如下代码:
procedure TForm1.WmNCHitTest(var Msg: TWMNCHitTest);
begin
DefaultHandler(Msg);
if Msg.Result = HTCLIENT then
Msg.Result := HTCAPTION;
end;
6.通过设置窗体最大和最小尺寸防止控件显示比例失调现象 //在窗体的Private节中作如下声明
procedure WMGetMinMaxInfo(var MSG: Tmessage); message WM_GetMinMaxInfo;
//在实现部分写如下代码:
procedure TForm1.WMGetMinMaxInfo(var MSG: Tmessage);
Begin
inherited;
with PMinMaxInfo(MSG.lparam)^ do
begin
with ptMinTrackSize do
begin
X := 640;
Y := 480;
end;
with ptMaxTrackSize do
begin
X := 800;
Y := 600;
end;
end;
end;
查看本文来源