Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
558 views
in Technique[技术] by (71.8m points)

delphi - How to change the ClientRect of a form?

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.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
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..


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...