locked
Textbox Margin set by EM_SETMARGINS ignored? RRS feed

  • Question

  • 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!
    • Edited by Khronosx Sunday, October 12, 2008 2:01 AM
    Sunday, October 12, 2008 1:59 AM

Answers

  • No repro on XP but repro on Vista x64.  This looks like a Vista bug to me, I don't see a viable workaround.  You'll have to contact Microsoft CSS.
    Hans Passant.
    • Marked as answer by nobugz Saturday, October 25, 2008 9:53 PM
    Tuesday, October 14, 2008 10:57 AM

All replies

  • I cannot repro your problem, it works fine on Windows XP, SP2.  Post a small repro project on a file sharing service.
    Hans Passant.
    Sunday, October 12, 2008 7:32 PM
  • 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!
    Tuesday, October 14, 2008 6:15 AM
  • No repro on XP but repro on Vista x64.  This looks like a Vista bug to me, I don't see a viable workaround.  You'll have to contact Microsoft CSS.
    Hans Passant.
    • Marked as answer by nobugz Saturday, October 25, 2008 9:53 PM
    Tuesday, October 14, 2008 10:57 AM
  • Interesting... I am using XP SP3 and it's reproing for me..

    I will see if i can get SP2 machine to try out.

    Thanks!
    Tuesday, October 14, 2008 5:36 PM
  • 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
    • Edited by jack 321 Thursday, October 16, 2008 4:02 AM correct grammar
    Thursday, October 16, 2008 4:01 AM
  • 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.
    Thursday, October 16, 2008 9:54 AM
  • Thanks Xun and Hans,

    I just wanted to know whether the problem was due to my code or if it's a bug from system.

    I have already start making workaround, so hopefully that will work better.

    Thanks!
    Thursday, October 16, 2008 6:12 PM
  • I know this is an old post, but I confirm that I'm seeing the same problem with Windows 7, Windows 7 SP1 also.
    Sunday, March 6, 2011 8:34 PM
  • 2020 and looks like this bug will never be fixed...


    GP Software

    Thursday, April 9, 2020 4:51 AM