Incorrect additional information in WM_SIZING for a window with a very small height

  • I create a window without a title.
  • I change it manually (or programmatically) so that its height is 30 pixels or less.
  • When I then take the lower bound to change it vertically, it behaves as if I had dragged the upper bound. Indeed, when debugging a program, the WM_SIZING parameter contains WMSZ_TOP instead of WMSZ_BOTTOM.

My program is written in Delphi, basically the problem reproduces with the main form with the following FormCreate:

procedure TForm2.FormCreate(Sender: TObject);

  var oldStyle : LongInt;
  var newStyle : LongInt;

begin
  //  Adapt windows style.

  oldStyle := WINDOWS.GetWindowLong (
                          handle,
                          GWL_STYLE);

  newStyle := oldStyle              and
              (not WS_CAPTION)      and
              (not WS_MAXIMIZEBOX);

  WINDOWS.SetWindowLong(
              handle,
              GWL_STYLE,
              newStyle);

  //  SetWindowPos with SWP_FRAMECHANGED needs to be called at that point
  //  in order for the style change to be taken immediately into account.

  WINDOWS.SetWindowPos(
              handle,
              0,
              0,
              0,
              0,
              0,
              SWP_NOZORDER     or
              SWP_NOMOVE       or
              SWP_NOSIZE       or
              SWP_FRAMECHANGED or
              SWP_NOACTIVATE);
end;
+4
source share
2 answers

. , HTTOP, HTBOTTOM. :

procedure TForm1.WMNCHitTest(var Message: TWMNCHitTest);
begin
  inherited;
  if (Message.Result = HTTOP) and
      (Message.Pos.Y > Top + Height - GetSystemMetrics(SM_CYSIZEFRAME)) then
    Message.Result := HTBOTTOM;
end;
+7

, . , delphi ( , API WINDOWS).

:

procedure TForm2.WMNcHitTest(
                     var msg : TWMNCHitTest);
begin
  inherited;

  case msg.result of

      HTTOP:
        begin
          if msg.pos.y > top + height div 2 then
              msg.result := HTBOTTOM;
        end;

      HTTOPRIGHT:
        begin
          if msg.pos.y > top + height div 2 then
              msg.result := HTBOTTOMRIGHT;
        end;

      HTTOPLEFT:
        begin
          if msg.pos.y > top + height div 2 then
              msg.result := HTBOTTOMLEFT;
        end;

  end;
end;
+5

All Articles