sptbxlib
sptbxlib copied to clipboard
Menu dropdowns right aligned on touchscreen pcs.
Currently applications made with the SpTBX will show menus as right aligned to their parent button on touchscreen pcs. This is due to the GetSystemMetrics(SM_MENUDROPALIGNMENT) call in TB2Items.pas. Touchscreen PCs return a non-zero value for this to indicate right alignment (supposedly this default is because most using a touch screen are right handed.) On the surface this would appear to be the correct thing to do, but no other applications seem to adhere to this which makes SpTBX (or TB2 really) applications stand out. It seems this metric should only be used for popup menus and not drop down ones (or at least that appears to be the convention.) This is specifically an issue in TB2Items.pas and not in SpTBX code. This change would have to be part of the TBX patch.
Do you know exactly what needs to be changed?
[Update: For some reason the insert code option isn't formatting correctly for me (I must be doing it wrong.) Basically remove the "if GetSystemMetrics(SM_MENUDROPALIGNMENT) = 0 then " condition and replace it with "X := ParentItemRect.Left" This is at line 1844 in my version of TB2Item.pas.]
In TB2Item.pas change the following:
if GetSystemMetrics(SM_MENUDROPALIGNMENT) = 0 then X := ParentItemRect.Left else X := ParentItemRect.Right - W;
to:
X := ParentItemRect.Left;
Thanks for your work on sptbx!
By the way there are Windows options controlling this behavior. See https://www.tenforums.com/tutorials/68038-set-menus-open-aligned-left-right-windows-10-a.html
I think it is best left as is and let the users change the Windows option. This option affects other applications as well.