Discussion Thread


Message Thread

Developer ComponentFor WindowsUniToolbox

UniToolbox iconThe leading control suite for Unicode development in Visual Basic.

Posted in the UniToolbox Forum.

FAQ: Mirroring Windows Forms and Components


I'm investigating porting an application to provide full right to left support including mirroring the windows forms and components and have come across a strange issue with your UniText control.

To flip a form, I use the following code in the form load method:

Dim OldLong As Long
OldLong = GetWindowLong(Me.hwnd, GWL_EXSTYLE)
SetWindowLong Me.hwnd, GWL_EXSTYLE, (OldLong Or WS_EX_LAYOUTRTL)
InvalidateRect hwnd, 0, False

This uses some Win API calls defined in a .bas file as follows:

Public Declare Function GetWindowLong Lib "user32" Alias "GetWindowLongA"
(ByVal hwnd As Long, ByVal nIndex As Long) As Long Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long Public Declare Function InvalidateRect Lib "user32" (ByVal hwnd As Long, lpRect As Long, ByVal bErase As Long) As Long Public Declare Function FindWindowEx Lib "user32"
Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal
As String, ByVal lpsz2 As String) As Long Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long Public Const WS_EX_LAYOUTRTL = &H400000 Public Const GWL_EXSTYLE = (-20)

To this form I've added one of your UniText controls. When the form is displayed, the UniText appears where I placed it on the form. As soon as I click into the UniText it jumps across the form to where it would be mirrored.

Can you explain this behaviour? I'd like to use the UniText control, but if it's position on any form is unreliable, I can't.


The solution is to place a PictureBox onto the mirrored form and then all controls, including the UniText, on the PictureBox. This fixes the problem as well as another issue where the form repaints badly when you resize it.
by Nico Westerdale on Jul 6 2009 1:32pm Reply

Our Software Stores

IconicoAccurate Design and Development Software

BitsDuJourDiscount Deal Coupons for Windows and Mac Software Apps

Our Software Services

IcoBlogOur Official Blog

© copyright 2004-2021 Iconico, Inc. Code & Design. All Rights Reserved. Terms & Conditions Privacy Policy Terms of Use Login