TextBox Padding and Caret Position
Posted: 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
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