Thanks JuhaManninen, I really value your input. It makes me rethink some things.
I will try to explain about RightToLeftLayout VS. BiDiMode, but I am not an expert so I may not have the full picture.
BiDiMode implements RightToLeft for Text ONLY. That is it supports R2L languages. But it has no effect beyond that.
RightToLeftLayout only effects TWinControls (that is you can only call it for TWinControls, but anything that is painted on it's canvas is mirrored). RightToLeftLayout changes the origin and direct of the canvas + implements RightToLeft for Text. In Lazarus, for LeftToRight, the origen is at Top-Left (X=0, Y=0) and X increases to the Right. RightToLeftLayout reverses the canvas making (X=0, Y=0) at the Top-Right and increases to the Left. The result is that if TLabel.Left:= 10, it would be 10 from the right. So anything painted on the canvas is painted R2L and requires no code changes. It is also anchored akLeft, which is now the Right side of the Form. ScrollBars are made R2L as well. The TWinControl becomes a true R2L control in all respects. When I use RightToLeftLayout, I leave BiDiMode:= bdLeftToRight. You must call RightToLeftLayout for each TWinControl, but that's a simple loop if the entire Form is R2L.
The right design is to build RightToLeft support into LCL layout engine, as I explained earlier.
I'm only guessing now, but I think it might take a lot of unnecessary code to fix R2L for controls like TPageControl, but RightToLeftLayout does it with only a few lines of code. I'm basing this on what I THINK had to be done to TStringGrid to get it to support R2L. But when I use RightToLeftLayout TStringGrid works almost perfectly. I say almost because the in-place editor stays L2R. I haven't even tried to find out where to fix that yet. Too many other things to look at first.
Now, studying Lazarus code, BiDiMode already has lots of support.
Look for method "SetBiDiMode". It is implemented for many widgetsets, for example for TWin32WSWinControl in Windows:
I have looked at this code. It is using WINAPI calls.
It clearly does the same what your global function does and more.
You wrote that BiDiMode is not for the same purpose as RightToLeftLayout. I am still saying that they are for the same purpose but BiDiMode is poorly implemented.
BiDiMode does less. It does not reverse the canvas. That means that you have to reverse the logic for painting, such as TBarChart (I think that woud require a fair amount of code). Changing the functionality of BiDiMode would break Delphi compatibility and I think there would be some screaming. If you have a multilingual Form then using BiDiMode as it is now might be the best solution. Right now I use TApplication.BiDiMode as a trigger but it could easily be TApplication.RightToLeftLayout. But with the Lazarus code modifications that I have made, TApplication.BiDiMode:= bdRightToLeft results in all Forms in the app. being mirrored with no additional code. Sometimes that doesn't work out too well because as it is now, that means I can't use standard Lazarus Dialog boxes and have to create my own (a lot of additional code. But I have to do it anyway because I have to change the language of the Text and in some cases, the layout).
I have spent countless hours combing through Lazarus code trying to find ways to patch it, but there is a TON of code! I have very good documentation of any changes I have made. And yes, I have made changes and then found others ways to accomplish my goals without modifying Lazarus. Most of my changes should be made to Lazarus directly but they can't be made until the very major problem with Themes is found and fixed. And that problem is way beyond my ability.
Earlier I understood it created a problem by flipping images (?)
Yes, images are a problem that I still have not found a solution for but MS says the solution is there, I just haven't figured out how to do it.
As for .NET, I have successfully ignored it this long and I like it that way. I could say more but I think I'll keep my mouth shut.
I will continue with my experiments and hopefully find more solutions. Reporting to Mantis has been disappointing. At times it seems that there isn't a lot of interest in R2L. And now I can't even get in to Lazarus on my Hebrew login, only my English login (which I reported to Mantis a while back), so testing is limited. I need to ensure that what works in English login also works in Hebrew login.