Click here to Skip to main content
15,890,741 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: search a record Pin
waner michaud7-Aug-09 10:02
waner michaud7-Aug-09 10:02 
AnswerRe: search a record Pin
DJ Matthews24-Jul-09 7:10
DJ Matthews24-Jul-09 7:10 
Questioncalculating sum in a view Pin
Ebube24-Jul-09 3:18
Ebube24-Jul-09 3:18 
AnswerRe: calculating sum in a view Pin
Mike Ellison24-Jul-09 4:04
Mike Ellison24-Jul-09 4:04 
Questionhow to select datagrid row using keyboard ??? Pin
JC.KaNNaN24-Jul-09 3:06
JC.KaNNaN24-Jul-09 3:06 
AnswerRe: how to select datagrid row using keyboard ??? Pin
Muhammad Mazhar24-Jul-09 3:25
Muhammad Mazhar24-Jul-09 3:25 
GeneralRe: how to select datagrid row using keyboard ??? Pin
JC.KaNNaN24-Jul-09 19:01
JC.KaNNaN24-Jul-09 19:01 
Questioncode change for right to left language Pin
MA Awan24-Jul-09 3:04
MA Awan24-Jul-09 3:04 
I am designing an Urdu editor. Urdu language is written from right to left. I have implemented this by using rtb.SelectionAlignment = HorizontalAlignment.Right and using SendKeys.Send("{LEFT}") after every key user presses. I have not used the RightToLeft property of rtb because in that case the cursor remains at right side of rtb and as user presses keys the words move to left. Now I implemented justification using some code from net. I tried it on english editor, it works fine. But when I use it for my Urdu editor the cursor goes to left side of rtb and when I type smthg, words move to right side but cursor remains at left side. The code is here
Enum TextAlign
Left = 1
Right = 2
Center = 3
Justify = 4
End Enum

<DllImport("user32", CharSet:=CharSet.Auto)> _
Private Shared Function SendMessage(ByVal hWnd As HandleRef, _
ByVal msg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
End Function

<DllImport("user32", CharSet:=CharSet.Auto)> _
Private Shared Function SendMessage(ByVal hWnd As HandleRef, _
ByVal msg As Integer, ByVal wParam As Integer, ByRef lp As PARAFORMAT) As Integer
End Function


<StructLayout(LayoutKind.Sequential)> _
Private Structure PARAFORMAT
Public cbSize As Integer
Public dwMask As UInteger
Public wNumbering As Short
Public wReserved As Short
Public dxStartIndent As Integer
Public dxRightIndent As Integer
Public dxOffset As Integer
Public wAlignment As Short
Public cTabCount As Short
<MarshalAs(UnmanagedType.ByValArray, SizeConst:=32)> _
Public rgxTabs() As Integer

' PARAFORMAT2 from here onwards.
Public dySpaceBefore As Int32
Public dySpaceAfter As Int32
Public dyLineSpacing As Int32
Public sStyle As Short
Public bLineSpacingRule As Byte
Public bOutlineLevel As Byte
Public wShadingWeight As Short
Public wShadingStyle As Short
Public wNumberingStart As Short
Public wNumberingStyle As Short
Public wNumberingTab As Short
Public wBorderSpace As Short
Public wBorderWidth As Short
Public wBorders As Short
End Structure

Private updating As Int32 = 0
Private oldEventMask As Int32 = 0

'Constants from the Platform SDK.
Private Const EM_SETEVENTMASK As Integer = 1073
Private Const EM_GETPARAFORMAT As Integer = 1085
Private Const EM_SETPARAFORMAT As Integer = 1095
Private Const EM_SETTYPOGRAPHYOPTIONS As Integer = 1226
Private Const WM_SETREDRAW As Integer = 11
Private Const TO_ADVANCEDTYPOGRAPHY As Integer = 1
Private Const PFM_ALIGNMENT As Integer = 8
Private Const SCF_SELECTION As Integer = 1

Protected Overrides Sub OnHandleCreated(ByVal e As EventArgs)

MyBase.OnHandleCreated(e)

'Enable support for justification.
SendMessage(New HandleRef(Me, Handle), _
EM_SETTYPOGRAPHYOPTIONS, _
TO_ADVANCEDTYPOGRAPHY, _
TO_ADVANCEDTYPOGRAPHY)
End Sub

Public Overloads Property SelectionAlignment() As TextAlign

Get

Dim fmt As PARAFORMAT = New PARAFORMAT()
fmt.cbSize = Marshal.SizeOf(fmt)

' Get the alignment.
SendMessage(New HandleRef(Me, Handle), _
EM_GETPARAFORMAT, _
SCF_SELECTION, fmt)

' Default to Left align.
If ((fmt.dwMask & PFM_ALIGNMENT) = 0) Then
Return TextAlign.Left
End If
If fmt.wAlignment = 1 Then
Return TextAlign.Left
ElseIf fmt.wAlignment = 2 Then
Return TextAlign.Right
ElseIf fmt.wAlignment = 3 Then
Return TextAlign.Center
ElseIf fmt.wAlignment Then
Return TextAlign.Justify
End If
End Get
Set(ByVal value As TextAlign)

Dim fmt As PARAFORMAT = New PARAFORMAT()
fmt.cbSize = Marshal.SizeOf(fmt)
fmt.dwMask = PFM_ALIGNMENT
fmt.wAlignment = CShort(value)

' Set the alignment.
SendMessage(New HandleRef(Me, Handle), _
EM_SETPARAFORMAT, _
SCF_SELECTION, fmt)
End Set
End Property
I tried with this change
If ((fmt.dwMask & PFM_ALIGNMENT) = 0) Then
Return TextAlign.Right
End If
But it doesn’t work. Can anyone plz tell me how to make it work for urdu language?
AnswerRe: code change for right to left language Pin
Muhammad Mazhar24-Jul-09 3:30
Muhammad Mazhar24-Jul-09 3:30 
GeneralRe: code change for right to left language Pin
MA Awan26-Jul-09 6:34
MA Awan26-Jul-09 6:34 
QuestionExcel - save without data connection and macros Pin
DaveyM6924-Jul-09 2:21
professionalDaveyM6924-Jul-09 2:21 
AnswerRe: Excel - save without data connection and macros Pin
EliottA24-Jul-09 2:51
EliottA24-Jul-09 2:51 
GeneralRe: Excel - save without data connection and macros Pin
DaveyM6924-Jul-09 3:01
professionalDaveyM6924-Jul-09 3:01 
GeneralRe: Excel - save without data connection and macros Pin
Mycroft Holmes24-Jul-09 23:27
professionalMycroft Holmes24-Jul-09 23:27 
GeneralRe: Excel - save without data connection and macros Pin
DaveyM6925-Jul-09 8:17
professionalDaveyM6925-Jul-09 8:17 
Questionfiscal printer or fiscal devise Pin
ivo7524-Jul-09 0:44
ivo7524-Jul-09 0:44 
AnswerRe: fiscal printer or fiscal devise Pin
DoctorMick24-Jul-09 1:13
DoctorMick24-Jul-09 1:13 
AnswerRe: fiscal printer or fiscal devise Pin
Mycroft Holmes24-Jul-09 23:31
professionalMycroft Holmes24-Jul-09 23:31 
QuestionDatagridview combobox issue Pin
Josejalapeno24-Jul-09 0:25
Josejalapeno24-Jul-09 0:25 
QuestionWhy does Microsoft do this or am I missing something:Keypress event missing in VB.NET 2008 Pin
Member 442053423-Jul-09 20:51
Member 442053423-Jul-09 20:51 
AnswerRe: Why does Microsoft do this or am I missing something:Keypress event missing in VB.NET 2008 Pin
Tom Deketelaere23-Jul-09 21:17
professionalTom Deketelaere23-Jul-09 21:17 
AnswerRe: Why does Microsoft do this or am I missing something:Keypress event missing in VB.NET 2008 Pin
Johan Hakkesteegt23-Jul-09 21:26
Johan Hakkesteegt23-Jul-09 21:26 
AnswerRe: Why does Microsoft do this or am I missing something:Keypress event missing in VB.NET 2008 PinPopular
Christian Graus23-Jul-09 21:37
protectorChristian Graus23-Jul-09 21:37 
QuestionStructure in listbox Pin
Chandrasekharan P23-Jul-09 19:18
Chandrasekharan P23-Jul-09 19:18 
AnswerRe: Structure in listbox Pin
Christian Graus23-Jul-09 19:35
protectorChristian Graus23-Jul-09 19:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.