Right To Left Forms support
How to enable Right To Left Forms (including icons and form captions) with Delphi:
Override the CreateParams method and insert
procedure TForm1.CreateParams(var Params: TCreateParams);
begin
inherited;
Params.ExStyle := Params.ExStyle or WS_EX_LEFT or WS_EX_RTLREADING or
WS_EX_LEFTSCROLLBAR or WS_EX_LAYOUTRTL or WS_EX_NOINHERITLAYOUT;
end;
Now take a look at your BiDiMode settings – it may have the contrary effect if set to “bdRightToLeft”…
4 Comments to Right To Left Forms support
Thank you for posting this. I thought I was the only one bothered by this. However, in Delphi 6, at first this appears to work fine, but things have a way of disappearing. For example, as soon as a TStringGrid gets focus, it becomes invisible. I’ve tried Repaint and Refresh on both the component and the Form with no luck.
March 5, 2011
Just to let you know and to thank you, I found that your method works if you first put a client aligned TPanel on the Form and make it the parent of all components. The Form becomes much slower and does a lot of visible redraws, but it works. If you put edit components directly on the TForm, they become unstable. I hope this information may help others in writing RightToLeft apps. Thank you again for sharing.
March 5, 2011
Thanks for that info. You may override the panel’s background redrawing and turn doublebuffing on to avoid flickering.
December 1, 2011
This seems to work for both Delphi6 and Lazarus. I hope it can be useful to others:
unit Unit1;
interface
uses
Windows, SysUtils, Classes, Graphics, Controls, Forms, StdCtrls, Grids;
type
TForm1 = class(TForm)
Button1: TButton;
Label1: TLabel;
StringGrid1: TStringGrid;
Memo1: TMemo;
Edit1: TEdit;
private
{ Private declarations }
procedure CreateParams(var Params : TCreateParams); override;
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
const
LangHeb = $40D;
var
Cover: TCustomControl;
procedure TForm1.CreateParams(var Params : TCreateParams);
begin
inherited CreateParams(Params);
Params.ExStyle:= WS_EX_LAYOUTRTL or WS_EX_NOINHERITLAYOUT;
Cover:= TCustomControl.Create(Self);
while Form1.ControlCount>0 do begin
Form1.Controls[0].Parent:= Cover;
end;
with Cover do begin
Parent:= Form1;
Align:= alClient;
BiDiMode:= bdRightToLeft;
end;
end;
initialization
with Application do begin
NonBiDiKeyboard:= IntToHex(GetUserDefaultLangId,8);
BiDiKeyboard:= IntToHex(LangHeb,8);
SysLocale.MiddleEast:= True;
end;
end.
Leave a comment
About
Recent Posts
- VerySimpleXML – a lightweight Delphi XML reader and writer
- Solving circular unit references with class helpers
- How to change the language of the Cisco SPA504G
- Eclipse on Mac OS X – Workspace error on NFS mounts
- Lua 5.1 for Delphi 2010
- WordPress Plugin – QR Code Tag v1.0
- Favourite Android applications
- Hint: Blank Typo3 installation screen
- How to create an ESXi v4 Whitebox ISO with Windows Tools
- Ext: tt_news – no translation for name of months
Search
Categories
Tags
Archives
Delphi Feeds
- MSBuild and Delphi compiler hints – binary patch
- Temporärer Beitrag, der zur Designerkennung verwendet wurde (1d773c88-5a47-40d8-a9d8-60a2f29e72ed – 3bfe001a-32de-4114-a6b4-4005b770f6d7)
- An Interface Implementation Pattern for Consideration
- Functional programming style in Delphi
- FireMonkey 3D Text Editor
- Delphi Mapping REST Clients
- Lua4Delphi – Broken the Interface
- XE2 VCL Styles "EQ"
- Upcoming webinars for Delphi developers
- Wireless Android Control
I'm an avid programmer working on a variety of platforms in a variety of languages with a wide technical interest.


February 14, 2011