How to change the ClientRect of a form?
Asked Answered
L

1

-3

Please refer to another question here: Resizing borderless form from different constraints than far edges?

This previous question has been resolved, but I have another similar question. Since I am building a custom shaped form with a different client area, I need to change the ClientRect area of this form. The form has some special drawing of some curved edges and such, but that part's irrelevant. I need to change the ClientRect of the form to represent a new client area where components are allowed to be dropped, and ignore anything put outside of those bounds.

(I have a borderless form, I'm drawing my own border which is a much different size than the standard windows border.)

This solution will kind-of change the way that my previous question works, but that'll be another topic which I'm sure I'll figure out on my own, should be very simple. I just need to be able to properly set this in the first place.

Lex answered 5/12, 2011 at 23:43 Comment(4)
-1. Please use winforms tag only if you develop for .NET (Delphi 8..2007)Vanhouten
What you should be asking is how do I set a non-rectangular clipping region on my form?Sonny
components: torry.net/pages.php?id=94Sonny
I would have looked up 'non-rectangular clipping region' if I knew the topic to begin with, isn't that the point of this place?Lex
C
6
type
  TForm1 = class(TForm)
    ..
  private
    procedure WmNCCalcSize(var Msg: TWMNCCalcSize); message WM_NCCALCSIZE;
    ..

..

procedure TForm1.WmNCCalcSize(var Msg: TWMNCCalcSize);
begin
  inherited;
  if Msg.CalcValidRects then begin
    InflateRect(Msg.CalcSize_Params.rgrc[0], -10, -6);
    Msg.Result := 0;
  end;
end;


Please, carefully read WM_NCCALCSIZE's documentation though, including the remarks section and also NCCALCSIZE_PARAMS, as I'm not sure this is what you want. But this is your message..

Counterpane answered 6/12, 2011 at 1:13 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.