Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7823427
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:14:35+00:00 2026-06-02T08:14:35+00:00

I’m using this code procedure DrawPolygonRegion(wnd : HWND; rect : TRect; NumPoints : Integer;

  • 0

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

enter image description here

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.

enter image description here

Any ideas how accomplish this task?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:14:37+00:00Added an answer on June 2, 2026 at 8:14 am

    If you are going to continue using a region, then call the Win32 API FrameRgn() function in the Form’s OnPaint event, eg:

    type
      TForm1 = class(TForm)
        procedure FormPaint(Sender: TObject);
      private
        Rgn: HRGN;
      protected
        procedure CreateWindowHandle(const Params: TCreateParams); override;
      end;
    
    function CreateMyPolygonRegion(rect : TRect; NumPoints : Integer; DoStarShape : Boolean): HRGN; 
    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; 
    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; 
    
      Result := CreatePolygonRgn(arPts, pts, WINDING); 
    end; 
    
    procedure TForm1.CreateWindowHandle(const Params: TCreateParams);
    begin
      inherited;
      Rgn := CreateMyPolygonRegion(BoundsRect, 5, True);
      SetWindowRgn(Handle, Rgn, TRUE);
    end;
    
    procedure TForm1.FormPaint(Sender: TObject); 
    begin 
      Canvas.FillRect(ClientRect);
      Canvas.Brush.Color := clRed;
      FrameRgn(Canvas.Handle, Rgn, Canvas.Brush.Handle, 2, 2);
    end; 
    

    However, on Windows 2000 and later, it is better and more efficient on OS resources to not use window regions anymore. TForm has had Transparent and TransparentColor properties available since Delphi 6, you should use them instead. Set the Transparent property to True, set the TransparentColor property to a unique color that does not appear anywhere else in your Form (clFuchsia is commonly used), draw your desired shape and bordering onto a TBitmap that is the same Width and Height as the Form and has its background filled with the Form’s TranparentColor, and then you can draw the TBitmap onto the Form’s Canvas in the OnPaint event (or alternatively put the TBitmap onto a client-align TImage so 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 the TransparentColor. 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.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
I am reading a book about Javascript and jQuery and using one of the
this is what i have right now Drawing an RSS feed into the php,

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.