Reputation: 847
The question is very simple - how can I change a toolbar's layout to right-to-left (i.e. icons are aligned to the right of the toolbar and their order is reversed - the first one is at the far right, the second one is on the left of it and so on) in Delphi 7?
TToolBar
doesn't publish the BiDiMode
and ParentBiDiMode
properties and even if I publish them in an interceptor class, nothing changes when I set BiDiMode
to bdRightToLeft
(of course with SysLocale.MiddleEast
= True
).
I tried setting WS_EX_LAYOUTRTL
to the toolbar with SetWindowLong
, but the result is really messy -- the toolbar is repainted very badly. Plus the icons themselves are mirrored and I don't want that, I just want them in right-to-left order.
Upvotes: 2
Views: 1284
Reputation: 89
How align last button on right:
Push panel before button, set Caption:='' and BevelOuter:=bvNone and in procedure FormResize():
procedure TForm1.FormResize(Sender: TObject);
begin
panelSep.Width:=0;
panelSep.Width:=ToolBar1.Width - tbLastButton.Left - tbLastButton.Width;
end;
Upvotes: 1
Reputation: 125671
Delphi doesn't expose BiDiMode for TToolbar or TToolButton because the underlying Windows common ToolBar control doesn't support them. See the possible values for configuring ToolBars in the MSDN documentation for ToolBar - none of the possible values for configuring it (including those available when sending TB_SETEXTENDEDSTYLE
include anything related to toolbar LTR/RTL orientation.
You can configure horizontal or vertical orientation using TB_SETEXTENDEDSTYLE
with the TBSTYLE_EX_VERTICAL
flag (which is not recommended, according to the docs), but not LTR/RTR button alignment. You can configure the text directionality using TB_SETDRAWTEXTFLAGS with DT_RTLREADING
, but nothing that changes button alignment from the left side to the right side of the toolbar.
Upvotes: 2