unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Windows, Classes, SysUtils, Forms, Controls, Graphics, StdCtrls;
type
TForm1 = class(TForm)
Memo1: TMemo;
Button1: TButton;
procedure FormCreate(Sender: TObject);
procedure Button1Click(Sender: TObject);
procedure Memo1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: integer);
private
public
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
procedure CutWnd(hForm: HWND);
var
arrPts: array[0..12] of TPoint;
RGN: HRGN;
begin
// cut off everything outside the polygon !!!
// Point 1
arrPts[0].X := 0;
arrPts[0].Y := 0;
// Point 2
arrPts[1].X := 0;
arrPts[1].Y := 100;
// Point 3
arrPts[2].X := 350;
arrPts[2].Y := 100;
arrPts[3].X := 350;
arrPts[3].Y := 200;
arrPts[4].X := 50;
arrPts[4].Y := 200;
arrPts[5].X := 50;
arrPts[5].Y := 100;
arrPts[6].X := 0;
arrPts[6].Y := 100;
arrPts[7].X := 0;
arrPts[7].Y := 220;
arrPts[8].X := 250;
arrPts[8].Y := 220;
arrPts[9].X := 250;
arrPts[9].Y := 260;
arrPts[10].X := 150;
arrPts[10].Y := 260;
arrPts[11].X := 150;
arrPts[11].Y := 220;
arrPts[12].X := 0;
arrPts[12].Y := 220;
// setup window
RGN := CreatePolygonRgn(arrPts, 13, Winding);
SetWindowRgn(hForm, RGN, True);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
BorderStyle := bsNone;
Width := 400;
Height := 300;
Position := poDesktopCenter;
Color := clGray; // only to see the difference !
Memo1.SetBounds(50, 100, 300, 100);
Memo1.Text := 'Move Window With MemoOnMouseDown';
Button1.SetBounds(150, 220, 100, 40);
// cut form
CutWnd(Handle);
end;
procedure TForm1.Button1Click(Sender: TObject);
begin
// reset form
SetWindowRgn(Handle, 0, True);
end;
procedure TForm1.Memo1MouseDown(Sender: TObject; Button: TMouseButton;
Shift: TShiftState; X, Y: integer);
begin
// move window with mouse over memo
ReleaseCapture;
SendMessage(Handle, WM_SYSCOMMAND, $F012, 0);
end;
end.