Right To Left Forms support

Tuesday, February 12th, 2008 | Dennis D. Spreen | Delphi Programming

How to enable Right To Left Forms (including icons and form captions) with Delphi:

Override the CreateParams method and insert

Now take a look at your BiDiMode settings – it may have the contrary effect if set to “bdRightToLeft”…

Tags: , , , ,

4 Comments to Right To Left Forms support

Avishai
February 14, 2011

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.

Avishai
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.

Dennis
March 5, 2011

Thanks for that info. You may override the panel’s background redrawing and turn doublebuffing on to avoid flickering.

Avishai
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 Dennis D. Spreen

I'm an avid programmer working on a variety of platforms in a variety of languages with a wide technical interest.

Search

QR Code

Categories