I’m using this code
procedure DrawPolygonRegion(wnd : HWND; rect : TRect; NumPoints : Integer; DoStarShape : Boolean);
const
RadConvert = PI/180;
Degrees = 360;
MaxLines = 100;
var
x, y,
xCenter,
yCenter,
radius,
pts,
I : Integer;
angle,
rotation: Extended;
arPts : Array[0..MaxLines] of TPoint;
rgn : HRGN;
begin
xCenter := (rect.Right - rect.Left) div 2;
yCenter := (rect.Bottom - rect.Top) div 2;
if DoStarShape then
begin
rotation := Degrees/(2*NumPoints);
pts := 2 * NumPoints;
end
else
begin
rotation := Degrees/NumPoints; //get number of degrees to turn per point
pts := NumPoints
end;
radius := yCenter;
{This loop defines the Cartesian points of the shape. Again,
I've added 90 degrees to the rotation angle so the shapes will
stand up rather than lie on their sides. Thanks again to Terry Smithwick and
David Ullrich for their trig help on CompuServe.}
for I := 0 to pts - 1 do begin
if DoStarShape then
if (I mod 2) = 0 then //which means that
radius := Round(radius/2)
else
radius := yCenter;
angle := ((I * rotation) + 90) * RadConvert;
x := xCenter + Round(cos(angle) * radius);
y := yCenter - Round(sin(angle) * radius);
arPts[I].X := x;
arPts[I].Y := y;
end;
rgn := CreatePolygonRgn(arPts, pts, WINDING);
SetWindowRgn(wnd, rgn, TRUE);
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
DrawPolygonRegion(Handle, BoundsRect, 5, True)
end;
to set the shape of form in this way
Now I need draw a color border in the shape, but I can’t figure out how make this task. the result which I looking for is something like this.

Any ideas how accomplish this task?
If you are going to continue using a region, then call the Win32 API
FrameRgn()function in the Form’sOnPaintevent, eg:However, on Windows 2000 and later, it is better and more efficient on OS resources to not use window regions anymore.
TFormhas hadTransparentandTransparentColorproperties available since Delphi 6, you should use them instead. Set theTransparentproperty toTrue, set theTransparentColorproperty to a unique color that does not appear anywhere else in your Form (clFuchsiais commonly used), draw your desired shape and bordering onto aTBitmapthat is the sameWidthandHeightas the Form and has its background filled with the Form’sTranparentColor, and then you can draw theTBitmaponto the Form’sCanvasin theOnPaintevent (or alternatively put theTBitmaponto a client-alignTImageso you don’t have to draw the Form manually). Whenever Windows composites your Form’s window for display, it will automatically omit the final pixels that use theTransparentColor. The end result is the same – a shaped window – but Windows will be able to manage the transparency, hit testing, overlaying/blending with other windows, etc much more efficiently.