'//Code\\ 'This code requires nothing, place it in a module. Option Explicit Public Const WM_USER = &H400 Public Const EM_SETPARAFORMAT = WM_USER + 71 Public Const EM_SETBIDIOPTIONS = WM_USER + 200 Public Const PFM_DIR = &H10000 'Direction mask bit Public Const PFE_RTLPAR = &H1 'RTL paragraph style bit Public Const BOM_DEFPARADIR = &H1 'Default direction mask Public Const BOE_RTLDIR = &H1 'Default RTL para style Type vbParaFormat cbSize As Long dwMask As Long wNumbering As Integer wEffects As Integer dxStrtIndent As Long dxRightIndent As Long dxOffset As Long wAlignment As Integer cTabCount As Integer rgxTabs(31) As Long End Type Public vbPF As vbParaFormat Public Declare Function SendPFMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As vbParaFormat) As Long Type vbBiDiOptions cbSize As Long wMask As Integer wEffects As Integer End Type Public vbBO As vbBiDiOptions Public Declare Function SendBOMessage Lib "user32" Alias "SendMessageA" (ByVal hWnd As Long, ByVal wMsg As Long, ByVal wParam As Long, lParam As vbBiDiOptions) As Long Public Function SetParaDirection(Direction As Integer) As Boolean vbPF.cbSize = LenB(vbPF) 'Size vbPF.dwMask = PFM_DIR 'Attribute to set vbPF.wEffects = Direction 'New direction SetParaDirection = SendPFMessage(Form1.RichTextBox1.hWnd, EM_SETPARAFORMAT, 0, vbPF) End Function '\\Code// '//Code\\ 'This code requires a rich text box control. Buttons named btnLTR and btnRTL are supported but not necassarily needed Option Explicit Private Sub btnLTR_Click() SetParaDirection (Not PFE_RTLPAR) RichTextBox1.SetFocus End Sub Private Sub btnRTL_Click() SetParaDirection (PFE_RTLPAR) RichTextBox1.SetFocus End Sub Private Sub Form_Load() Dim Result As Long SetParaDirection (PFE_RTLPAR) vbBO.cbSize = LenB(vbBO) 'Size vbBO.wMask = BOM_DEFPARADIR 'Attribute to set vbBO.wEffects = BOE_RTLDIR 'Default direction Result = SendBOMessage(RichTextBox1.hWnd, EM_SETBIDIOPTIONS, 0, vbBO) RichTextBox1.RightMargin = 2000 End Sub '\\Code//>Hi Reza
>#Define GWL_EXSTYLE -20 >#Define WS_EX_LAYOUTRTL 0x400000 >#Define WS_EX_NOINHERITLAYOUT 0x100000 >Declare Integer GetWindowLong In user32 INTEGER HWnd, Integer nIndex >Declare Integer SetWindowLong In user32 INTEGER HWnd, Integer nIndex, Integer dwNewLong >OldLong = GetWindowLong(Thisform.HWnd, GWL_EXSTYLE) >SetWindowLong(This.HWnd,GWL_EXSTYLE,Bitor(OldLong,WS_EX_LAYOUTRTL,WS_EX_NOINHERITLAYOUT)) >>