'TTabControl: tabs displayed right to left

I am programming in a Hebrew environment and so I want the tabs on the top of a TTabControl to be displayed from right to left. The BiDiMode property doesn't affect the tabs, but rather text contained within the control.

I have tried the following code

SetWindowLong (tc.Handle, GWL_EXSTYLE,
               GetWindowLong(tc.Handle, GWL_EXSTYLE)  or
               WS_EX_LAYOUTRTL or WS_EX_NOINHERITLAYOUT);

which gets the tabs displayed correctly, but prevents the controls held within the ttabcontrol from appearing, and so its use is somewhat limited.

Any ideas? BTW, I'm using Delphi 7.

TIA, No'am



Solution 1:[1]

This isn't my code. Something I found, but it seems to work.

procedure TForm1.FormCreate(Sender: TObject);
const
  LVM_FIRST = $1000;
  LVM_GETHEADER = LVM_FIRST + 31;
var
  header: thandle;
begin
  header:= SendMessage (TabControl1.Handle, LVM_GETHEADER, 0, 0);
  SetWindowLong (header, GWL_EXSTYLE,
                 GetWindowLong (header, GWL_EXSTYLE)  or
                 WS_EX_LAYOUTRTL or WS_EX_NOINHERITLAYOUT);

  SetWindowLong (TabControl1.Handle, GWL_EXSTYLE,
                 GetWindowLong (lv.Handle, GWL_EXSTYLE)  or
                 WS_EX_LAYOUTRTL or WS_EX_NOINHERITLAYOUT);
  lv.invalidate;  
end;

Solution 2:[2]

I tried the code with D2007 and it's working fine on windows7.

But you could use Raize controls, their PageControl and TabControl could be showed from RightToLeft without any code.

Solution 3:[3]

I used the following code and just worked fine

procedure TfrmCustomer.FormCreate(Sender: TObject);
const
  LVM_FIRST = $1000;
  LVM_GETHEADER = LVM_FIRST + 31;
var
  header: thandle;
begin
  header := SendMessage(pgTypes.Handle, LVM_GETHEADER, 0, 0);
  SetWindowLong(header, GWL_EXSTYLE, GetWindowLong(header, GWL_EXSTYLE) or
    WS_EX_LAYOUTRTL or WS_EX_NOINHERITLAYOUT);

  SetWindowLong(pgTypes.Handle, GWL_EXSTYLE, GetWindowLong(pgTypes.Handle,
    GWL_EXSTYLE) or WS_EX_LAYOUTRTL or WS_EX_NOINHERITLAYOUT);
  pgTypes.Invalidate;
end;

pgTypes is name of the TPageControl

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Marvo
Solution 2 Mohammed Nasman
Solution 3 Core