unit Main;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, ExtCtrls, fcImgBtn, StdCtrls, fcButton;
type
TMainFrm = class(TForm)
Image6: TImage;
Panel1: TPanel;
Image7: TImage;
Panel2: TPanel;
Panel3: TPanel;
Panel4: TPanel;
Image1: TImage;
Image3: TImage;
Image2: TImage;
Image4: TImage;
Image5: TImage;
Image8: TImage;
Label1: TLabel;
fcImageBtn1: TfcImageBtn;
fcImageBtn3: TfcImageBtn;
fcImageBtn2: TfcImageBtn;
Panel5: TPanel;
Panel6: TPanel;
Image9: TImage;
Panel7: TPanel;
Panel8: TPanel;
Image14: TImage;
Image10: TImage;
procedure fcImageBtn3Click(Sender: TObject);
procedure fcImageBtn2Click(Sender: TObject);
procedure fcImageBtn1Click(Sender: TObject);
procedure Image2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Image2MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
procedure Image2MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
private
{ Private declarations }
procedure WmNCHitTest(var Msg: TWMNCHitTest);
public
{ Public declarations }
//procedure CreateParams(var Params:TCreateParams);override;
end;
var
MainFrm: TMainFrm;
CanMove:Boolean;
oldPoint:TPoint;
implementation
{$R *.dfm}
{让窗口可以改变大小
procedure TMainFrm.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.Style:=WS_THICKFRAME or WS_POPUP or WS_BORDER;
end; }
procedure TMainFrm.WmNCHitTest(var Msg: TWMNCHitTest);
const v=10; //border width
var p:TPoint;
begin
p:=Point(Msg.XPos,Msg.YPos);
p:=ScreenToClient(p);
if PtInRect(Rect(0,0,v,v),p) then
Msg.Result:=HTTOPLEFT
else if PtInRect(Rect(Width-v,Height-v,Width,Height),p) then
Msg.Result:=HTBOTTOMRIGHT
else if PtInRect(Rect(Width-v,0,Width,v),p) then
Msg.Result:=HTTOPRIGHT
else if PtInRect(Rect(0,Height-v,v,Height),p) then
Msg.Result:=HTBOTTOMLEFT
else if PtInRect(Rect(v,0,Width-v,v),p) then
Msg.Result:=HTTOP
else if PtInRect(Rect(0,v,v,Height-v),p) then
Msg.Result:=HTLEFT
else if PtInRect(Rect(Width-v,v,Width,Height-v),p) then
Msg.Result:=HTRIGHT
else if PtInRect(Rect(v,Height-v,Width-v,Height),p) then
Msg.Result:=HTBOTTOM;
Inherited;
end;
procedure TMainFrm.fcImageBtn3Click(Sender: TObject);
begin
AppLication.Minimize;
end;
procedure TMainFrm.fcImageBtn2Click(Sender: TObject);
begin
Close;
end;
procedure TMainFrm.fcImageBtn1Click(Sender: TObject);
begin
//弹出系统菜单
end;
procedure TMainFrm.Image2MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
if (Button = mbleft) and not CanMove then
begin
CanMove := True;
oldPoint.X:=x;
oldPoint.Y:=y;
end;
end;
procedure TMainFrm.Image2MouseUp(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: Integer);
begin
CanMove:=False;
end;
procedure TMainFrm.Image2MouseMove(Sender: TObject; Shift: TShiftState; X,
Y: Integer);
begin
if CanMove then
begin
//移动窗口
MainFrm.Left:=MainFrm.Left+X-oldPoint.x;
MainFrm.Top:=MainFrm.Top+Y-oldPoint.y;
end;
end;
end.