TextArea set margins in windows

How to set the starting position of the text in a Textarea if its right aligned. I need to start the text a few characters left for readability. Any help?

What you say is unclear. Difficult to know what you want without a graphic representation or a better description. What do you mean by "start the text a few characters left " ? Away from the left side a few characters ? Or towards the left ? If the characters on the line where numbered 0 to 80 from left to right, where would you place the insertion point ?

my textarea is right aligned (Arabic language) and multiline. so i need to start my first character a few spaces from right and all the below lines should also start from the same point. I hope its clear now.

So you want a right margin.

See https://forum.xojo.com/11561-margin-in-a-textarea for a Mac OS X declare that works for Roman script and left margin, but maybe could be adapted.

See Apple Developer documentation for more about the inner workings of the declare.
https://developer.apple.com/library/mac/documentation/Cocoa/Conceptual/CocoaViewsGuide/Introduction/Introduction.html

You do not say if you are using Windows. If that was the case, your question would have been better in ‘Windows’. Unfortunately I do not have any idea about what to do on that platform for such a feature.

I got a pure Xojo solution that will work on either platform :

  • Place a white rectangle with a black border
  • inside it, 1 pixel lower and 1 pixel to the right, place a TextArea with no border and no UseFocusRing
  • Make the TextArea narrower so it makes a margin

When run, the program shows a white box with a margin on the right.

Of course, there will be no way for this to set different margins per paragraph.

I use windows platform. Michel’s idea is good, but only works for the first line.

What do you mean ? You want paragraphs to start with an indent and not set a margin for the whole text ? You know, it is difficult to work like that. For this kind of problem, it woud be much better if you could post an image that shows what you want to obtain.

Can you create an example like this in a word processor and capture the screen ?

Just for reference, here is a VB declare to set the margin in Windows. It should not be too difficult to adapt to Xojo :
http://www.developerfusion.com/code/167/margins-in-a-textbox/

Thanks Michel, that worked perfectly for me. I was looking to set margins inside textarea at the right side.

If you could post the Xojo declare you are now using for others to find, that would be great.

Thanks in advance.

Below is the code i used.

Declare Function SendMessage Lib “user32” Alias “SendMessageA” (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Const EM_SETMARGINS = &HD3
Const EC_LEFTMARGIN = &H1
Const EC_RIGHTMARGIN = &H2

Call SendMessage(TextArea1.Handle, EM_SETMARGINS, EC_LEFTMARGIN + EC_RIGHTMARGIN, 655360)

[quote=114097:@S Abraham]Below is the code i used.

Declare Function SendMessage Lib “user32” Alias “SendMessageA” (ByVal hwnd As Integer, ByVal wMsg As Integer, ByVal wParam As Integer, ByVal lParam As Integer) As Integer
Const EM_SETMARGINS = &HD3
Const EC_LEFTMARGIN = &H1
Const EC_RIGHTMARGIN = &H2

Call SendMessage(TextArea1.Handle, EM_SETMARGINS, EC_LEFTMARGIN + EC_RIGHTMARGIN, 655360)[/quote]

Great. I am sure it can help others with the same need. Thank you.