Page 1 of 1

TextBox Padding and Caret Position

Posted: Thu Nov 29, 2012 4:12 am
by Biff
Hello

I have a subclassed TextBox control with which I need to add padding to the left margin.

The only success I have had so far is by sending an EM_SETMARGINS message to the text box. However, this only seems to work when I place the method call in the parent form's load event and the parent form's windowState is set to Normal. If I place the method call in say the windowCreated event of the control it seems to have no effect. This is despite a subsequent EM_GETMARGINS reponse indicating that the padding is set. As soon as the form is resized or if the default windowState is Maximized the caret position is reset and subsequent EM_SETMARGINS messages seem to have no effect (again despite EM_GETMARGINS responses indicating the padding is set).

I have also attempted to manipulate the caret using SetCaretPos but this seems to have no effect wherever I make the call, again despite subsequent calls to GetCaretPos indicating that the caret position was successfully updated.

If anyone could possible shed any light on this (rather frustrating and irritating!) behaviour and if there are any means of achieving what I would like I would be most grateful.

Thanks

Re: TextBox Padding and Caret Position

Posted: Thu Nov 29, 2012 10:06 am
by JohnP
Have you tried using TextBox::selStart to position the caret?

Re: TextBox Padding and Caret Position

Posted: Thu Nov 29, 2012 12:37 pm
by Biff
Yes I did, but it did not have the required effect.

Re: TextBox Padding and Caret Position

Posted: Thu Nov 29, 2012 1:59 pm
by BeeJay
If you're trying to have a little bit more "white-space" on the left of the TextBox, to make the text more comfortable to read, and you're using skins in your application, then you can "simulate" a larger left border by adding additional pixels in the appropriate colour to the left-border skin element for the TextBox skin. If your requirements are more than just some additional "white-space" on the left of the TextBox you made need to open an NFS against Jade requesting the ability to control the left/right margins.

Regarding setting the carat to a position part way through your TextBox's text, that should be achievable using the TextBox::selStart property as already suggested by John.

Hope that helps.

Cheers,
BeeJay.