sptbxlib icon indicating copy to clipboard operation
sptbxlib copied to clipboard

Incorrect alignment - MDI Application, TSpTBXDock with multi Toolbars

Open sergSVK opened this issue 1 year ago • 3 comments

I discovered an unpleasant alignment of elements when switching between child windows. The bug is reproduced in the following sequence.

  1. Open >1 child window
  2. We reduce the width of any window until the rows of toolbars increase (by default, 1 non-fixed row)
  3. Maximizing the child window
  4. From the "Window" menu we switch between windows. When the window is resized at the top we see a bug. The child window area is visible in red (I made the child window color red). The height of the area is equal to the height of the toolbar.

I'm using Delphi 10.4 Sydney. I don't know if this bug can be reproduced on other versions. A test example is attached. The executable file is also attached.

Test.zip

sergSVK avatar Apr 24 '24 14:04 sergSVK

Try this, open TB2Dock.pas and add this:


TTBDock = class(TCustomControl)
  private
  ...
  procedure CMSysCommand(var Message: TWMKeyDown); message CM_SYSCOMMAND;
  ...

procedure TTBDock.CMSysCommand(var Message: TWMKeyDown);
begin
  inherited;

  // Robert: fix alignment bug when maximizing/restoring form.
  // To reproduce:
  // Place a dock with 2 toolbars on 1 row, add some toolbar items
  // Set ShrinkMode to tbsmNone on the 2 toolbars
  // Place a Button on the form with Align set to alClient
  // Run the app
  // Reduce the width of the form so there are 2 rows of toolbars
  // Maximize, the dock is resized but the Button is not aligned correctly
  // Restore, the dock is resized but the Button is not aligned correctly
  if (Message.CharCode = SC_MAXIMIZE) or (Message.CharCode = SC_RESTORE) then
    if Assigned(Parent) then
      Parent.Realign;
end;

SilverpointDev avatar May 06 '24 12:05 SilverpointDev

Hello, Robert. There is a problem. The CM_SYSCOMMAND message does not exist. Method WMSysCommand already exists with a different parameter.

procedure WMSysCommand(var Message: TWMSysCommand); message WM_SYSCOMMAND;
procedure TTBDock.WMSysCommand(var Message: TWMSysCommand);
begin
  { Relay WM_SYSCOMMAND messages to floating toolbars which were formerly
    docked. That way, items on floating menu bars can be accessed with Alt. }
  if Message.CmdType and $FFF0 = SC_KEYMENU then
    RelayMsgToFloatingBars({$IFNDEF CLR} TMessage(Message) {$ELSE} Message.OriginalMessage {$ENDIF});
end;

sergSVK avatar May 06 '24 19:05 sergSVK

Hello, Robert. There is a problem. The CM_SYSCOMMAND message does not exist.

You have to add it

SilverpointDev avatar May 07 '24 16:05 SilverpointDev