Resizing borderless form from different constraints than far edges?

前端 未结 1 1065
时光说笑
时光说笑 2021-01-23 03:12

I have a custom form which does not have any type of border. I\'m drawing some custom borders of my own instead, which do not extend up to the far edges of the form. Instead, wh

相关标签:
1条回答
  • 2021-01-23 04:02

    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;
    
    0 讨论(0)
提交回复
热议问题