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 7520983
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 30, 20262026-05-30T02:09:37+00:00 2026-05-30T02:09:37+00:00

I tried to do with SetWindowRgn , and I couldn’t. Can do that (the

  • 0

I tried to do with SetWindowRgn, and I couldn’t.

Can do that (the top 2 corners are rounded, the window has a shadow) like on this picture?

enter image description here

  • 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-05-30T02:09:38+00:00Added an answer on May 30, 2026 at 2:09 am

    Here is a code sample of how to set the window region with shadow:
    (Notes: The Form BorderStyle assumed to be bsNone, not re-sizable)

    type
    TForm1 = class(TForm)
      procedure FormCreate(Sender: TObject);
    private
      procedure CreateFlatRoundRgn;
    protected
      procedure CreateParams(var Params: TCreateParams); override;
    public
    end;
    
    var
      Form1: TForm1;
    
    implementation
    
    {$R *.DFM}
    
    procedure ExcludeRectRgn(var Rgn: HRGN; LeftRect, TopRect, RightRect, BottomRect: Integer);
    var
      RgnEx: HRGN;
    begin
      RgnEx := CreateRectRgn(LeftRect, TopRect, RightRect, BottomRect);
      CombineRgn(Rgn, Rgn, RgnEx, RGN_OR);
      DeleteObject(RgnEx);
    end;
    
    procedure TForm1.CreateFlatRoundRgn;
    const
      CORNER_SIZE = 6;
    var
      Rgn: HRGN;
    begin
      with BoundsRect do
      begin
        Rgn := CreateRoundRectRgn(0, 0, Right - Left + 1, Bottom - Top + 1, CORNER_SIZE, CORNER_SIZE);
        // exclude left-bottom corner
        ExcludeRectRgn(Rgn, 0, Bottom - Top - CORNER_SIZE div 2, CORNER_SIZE div 2, Bottom - Top + 1);
        // exclude right-bottom corner
        ExcludeRectRgn(Rgn, Right - Left - CORNER_SIZE div 2, Bottom - Top - CORNER_SIZE div 2, Right - Left , Bottom - Top);
      end;
      // the operating system owns the region, delete the Rgn only SetWindowRgn fails
      if SetWindowRgn(Handle, Rgn, True) = 0 then
        DeleteObject(Rgn);
    end;
    
    procedure TForm1.FormCreate(Sender: TObject);
    begin
      BorderStyle := bsNone;
      CreateFlatRoundRgn;
    end;
    
    procedure TForm1.CreateParams(var Params: TCreateParams);
    const
      CS_DROPSHADOW = $00020000;
    begin
      inherited CreateParams(Params);
      with Params do
      begin
        Style := WS_POPUP;
        WindowClass.Style := WindowClass.Style or CS_DROPSHADOW;
      end;
    end;
    

    Another way to draw a custom shadow would be to set Window WS_EX_LAYERED and use UpdateLayeredWindow

    Here is a very good example of how it’s done (sources are in C++ but very easy to understand)

    For more complicated shapes you can use a PNG image on the form and Alpha Blend it.


    EDIT:

    Resizing a WS_POPUP Window is a world of pain…
    You have a few options:

    • Write a WM_NCHITEST handler
    • Use WM_Syscommand $F008 to resize (above link) or $F012 to move the Window.
    • Using WS_EX_STATICEDGE and WS_SIZEBOX styles.

    NOTE that you need to re-create the Window region when you re-size it (e.g OnResize event).

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

Sidebar

Related Questions

Tried something like this: HttpApplication app = s as HttpApplication; //s is sender of
Tried to reuse Sum but got this error: cannot resolve method Sum how can
tried this many times but I just can't figure out how to define custom
I'm writing a program that uses SetWindowRgn to make transparent holes in a window
Tried to create this Extension method. Works except that the helper is rendering text,
Tried to do some searching on this, but couldn't find exactly what I needed.
Tried this: Remove-Item C:\foo\.svn but this is the error that I encountered Remove-Item :
I tried to set NSDateFormatter for year, like this: NSDateFormatter *dateFormatter = [[NSDateFormatter alloc]
Tried running a java method that runs this oracle SQL query String query =
I tried solving my problem using this link update - I figured out that

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.