Resizing borderless form from different constraints than far edges?

醉酒当歌 提交于 2019-12-02 00:02:04

Actually it would make sense to define two constants instead of the only EDGEDETECT since you require horizontal and vertical offsets to be different and write it from scratch, but here is a quick patch:

procedure TForm1.WMNCHitTest(var Message: TWMNCHitTest);
const
  EDGEDETECT = 17;  //adjust to suit yourself    // <- increased to suit outer offset
var
  deltaRect: TRect;  //not really used as a rect, just a convenient structure

  OuterRect: TRect;                              // used as a rect
begin
  inherited;
  if BorderStyle = bsNone then begin
    with Message, deltaRect do begin

     ..
      else if (Right<EDGEDETECT) then
        Result := HTRIGHT;
     ..

      OuterRect := BoundsRect;                    // patch
      InflateRect(OuterRect, -10, -3);
      if not PtInRect(OuterRect, SmallPointToPoint(Message.Pos)) then
        Message.Result := HTTRANSPARENT;

    end;
  end;
end;
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!