Add How to create a non-rectangular control


How to create a non-rectangular control

By : Pooia Lalbakhsh
MS in computer engineering

You can create any controls with any shapes....HOW? I'LL tell you...

First of all you should specify the shape ( better to say specify the region)

To do this you can use one of the region functions, some of them are
ordered bellow.

CreateEllipticRgn
CreateEllipticRgnIndirect
CreatePolygonRgn
CreatePolyPolygonRgn
CreateRectRgn
CreateRectRgnIndirect
CreateRoundRectRgn
....
....

after using one of these functions you have a particular region.

the next step is assigning this region to the control you are working on.
This step is done using "setwindowrgn" function within the Formcreate Event.

This code makes a non-rectangular form for you, you can test it
to see the result:

procedure TForm1.FormCreate(Sender: TObject);
var points : array [1..5] of TPoint;
region : hrgn;
begin
points [1].x:= 10;
points [1].Y:= 10;
points [2].x:= 100;
points [2].y:= 50;
points [3].x:= 50;
points [3].y:= 80;
points [4].x:= 10;
points [4].y:= 200;
points [5].x:= 10;
points [5].Y:= 10;
region := createpolygonrgn(points, 5, 1);
setwindowrgn(form1.handle, region, true);
end;


Related Discussions
Latest News
Submit News Form Past News
Latest Forum Entries