SilverpointDev / sptbxlib

SpTBXLib is an expansion package for TB2K Delphi components that adds multiple features including support for styles and custom skins.
https://www.silverpointdevelopment.com
Other
69 stars 33 forks source link

Incorrect alignment - MDI Application, TSpTBXDock with multi Toolbars #119

Open sergSVK opened 2 months ago

sergSVK commented 2 months ago

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

SilverpointDev commented 2 months ago

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;
sergSVK commented 2 months ago

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;
SilverpointDev commented 2 months ago

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

You have to add it