Hi Mr. Reza
First use the textbox with the following properties
Alignment=1
RightToLeft=.t.
Check the above without using your keyboard layout function. If it is working ok then the problem is in your function.
To use proper keyboard layout function i have replied in your Keyboard layout message earlier. Please read that reply. Hope it will work for you.
With best regards,
Zaheer