최고의 답변자
Textbox Margin set by EM_SETMARGINS ignored?

질문
-
Hi,
I used EM_SETMARGINS to set 10px margin on the right hand of the textbox.
It works fine when i am typing letters and exceeds the width of the textbox.
When the text is more than what textbox can hold, the text will shift left and the margin space is reserved.
However, once i have text and press "Home" key or left arrow to scroll back, the entire textbox is occupied (including the margin).
It looks like it happens if my textbox is set to be Left-to-Right and if i have margin on right side.
If I set the margin on the left side when the textbox is Left-to-Right, the margin is correct regardless where the current position is.
To make sure nothing is resetting the margin, in the rendering, i get the margin by EM_GETMARGINS and draw 2 lines for both left and right margin.
The line is at the right position regardless where the text is, but if i scroll the text back to the beginning, the right margin is ignored.
Is anything else experiencing this problem?
If so, is there any workaround?
Thanks!- 편집됨 Khronosx 2008년 10월 12일 일요일 오전 2:01
2008년 10월 12일 일요일 오전 1:59
답변
모든 응답
-
Thanks for the reply.
Here is the project.
http://cid-433d41df9bddd7e0.skydrive.live.com/self.aspx/Margin/TextboxMargin.zip
It's C# code, but it uses SendMessage to set the margin.
Here is a picture that might help explaining the problem.
http://cid-433d41df9bddd7e0.skydrive.live.com/self.aspx/Margin/Form.JPG
There are 2 textboxes in the form. Both have 30 px margin on the left side and 20px margin on the right side.
Both textboxes have the exact same text. It works find when user is typing the letters.
However, as soon as the user press arrow keys or Home key to scroll back, the right margin is no longer honored.
The left margin is still working fine.
Red lines are used to show where the margin is.
It looks like, if the TextBox is set to be Left-To-Right, the left margin will always work, but the right margin doesn't.
If the TextBox is set to be Right-To-Left, then the right margin will always work, but the left margin doesn't.
Can you point out what is wrong in the code?
Thanks!2008년 10월 14일 화요일 오전 6:15 -
Hi Khronosx,
I downloaded the project from the LINK above, and copy it to a XP SP2 English edition, exactly, I can reproduce the problem, when the text length is greater than the length of the textbox, scroll back lead to the problem that the text occupied the right margin of the textbox control .
Perhaps you can try to submit a bug via the connect web site below, and you can paste the LINK of this thread to clarify and verify the issue when submit the problem.
http://connect.microsoft.com/visualstudio/
Regards,
Xun
Please remember to mark the replies as answers if they help and unmark them if they provide no help. http://forums.msdn.microsoft.com/en-US/csharpide/thread/8e9ed0d7-11ff-402a-8489-9b5f05eeb706- 편집됨 jack 321 2008년 10월 16일 목요일 오전 4:02 correct grammar
2008년 10월 16일 목요일 오전 4:01 -
The Connect site doesn't handle bugs caused by Windows, only bugs fixable by DevDiv. They'll close your feedback with Closed (external). You'll have to go through Microsoft CSS. However, the odds that they'll make a new version of user32.dll for you are fairly slim. The best you can hope for is a workaround.
Hans Passant.2008년 10월 16일 목요일 오전 9:54