plashenkov / TBX

Themeable toolbars, menus and controls for Delphi
MIT License
46 stars 18 forks source link

Multimonitor-Problem with TBXMDI when MainForm on secondary monitor #1

Open plashenkov opened 10 years ago

plashenkov commented 10 years ago

Issue imported from Google Code: https://code.google.com/p/tbxlib/issues/detail?id=3

Reported by bernd.ott [at] quantendrehung.de, Jan 30, 2013

You need at least two monitors. put the primary monitor on left side. the secondary monitor hast to be on right side and in a higher position in windows.

see screenshot

use an mdi application. put tbxmdi on form. put mainform on secondary monitor in maximized mode. put mdichild in max. mode. click mdi close button.

you get an exception: Exception class: ERangeError Exception address: 0064F929

Stack list, generated 30.01.2013 15:38:01 [0064F924] TBXMDI.TTBXMDIButtonsItem.ItemClick + $4C [004033BE] System.ErrorAt + $16 [0064F924] TBXMDI.TTBXMDIButtonsItem.ItemClick + $4C [005B1CC8] TB2Item.TTBCustomItem.Click + $A8 [005B1BA7] TB2Item.TTBCustomItem.ClickWndProc + $BB [004303AC] Classes.StdWndProc + $14 [0049093C] Forms.TApplication.ProcessMessage + $FC [00490976] Forms.TApplication.HandleMessage + $A [00490C6B] Forms.TApplication.Run + $B3

mdiproblem


sorry, component is ttbxmdihandler


file tbxmdi fails at: SendMessage(ChildForm.Handle, WM_SYSCOMMAND, Cmd, GetMessagePos);

GetMessagePos delivers a negative position.

http://msdn.microsoft.com/en-us/library/windows/desktop/ms646360(v=vs.85).aspx

maybe that parameter can be 0 or -1. but that has to be testet


My suggest patch:

Index: TBXMDI.pas
===================================================================
--- TBXMDI.pas  (revision 19)
+++ TBXMDI.pas  (working copy)
@@ -286,7 +286,7 @@
   begin
     Form := Application.MainForm.ActiveMDIChild;
     if Assigned(Form) then
-      SendMessage(Form.Handle, WM_SYSCOMMAND, TTBXCustomItem(Sender).Tag, GetMessagePos);
+      SendMessage(Form.Handle, WM_SYSCOMMAND, TTBXCustomItem(Sender).Tag, -1);
   end;
 end;

@@ -606,7 +606,7 @@
         Cmd := SC_CLOSE
       else
         Cmd := SC_MINIMIZE;
-      SendMessage(ChildForm.Handle, WM_SYSCOMMAND, Cmd, GetMessagePos);
+      SendMessage(ChildForm.Handle, WM_SYSCOMMAND, Cmd, -1);
     end;
   end;
 end;