TextBox Padding and Caret Position

For questions and postings not covered by the other forums
Biff
Posts: 3
Joined: Wed Nov 28, 2012 11:19 pm

TextBox Padding and Caret Position

Postby Biff » Thu Nov 29, 2012 4:12 am

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

JohnP
Posts: 73
Joined: Mon Sep 28, 2009 8:41 am
Location: Christchurch

Re: TextBox Padding and Caret Position

Postby JohnP » Thu Nov 29, 2012 10:06 am

Have you tried using TextBox::selStart to position the caret?

Biff
Posts: 3
Joined: Wed Nov 28, 2012 11:19 pm

Re: TextBox Padding and Caret Position

Postby Biff » Thu Nov 29, 2012 12:37 pm

Yes I did, but it did not have the required effect.

User avatar
BeeJay
Posts: 312
Joined: Tue Jun 30, 2009 2:42 pm
Location: Christchurch, NZ

Re: TextBox Padding and Caret Position

Postby BeeJay » Thu Nov 29, 2012 1:59 pm

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.


Return to “General Discussion”

Who is online

Users browsing this forum: Bing [Bot] and 32 guests

cron