locked
Textbox Margin set by EM_SETMARGINS ignored? RRS feed

  • Pergunta

  • 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!
    • Editado Khronosx domingo, 12 de outubro de 2008 02:01
    domingo, 12 de outubro de 2008 01:59

Respostas

  • 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.
    • Marcado como Resposta nobugz sábado, 25 de outubro de 2008 21:53
    terça-feira, 14 de outubro de 2008 10:57

Todas as Respostas

  • I cannot repro your problem, it works fine on Windows XP, SP2.  Post a small repro project on a file sharing service.
    Hans Passant.
    domingo, 12 de outubro de 2008 19:32
  • 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!
    terça-feira, 14 de outubro de 2008 06:15
  • 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.
    • Marcado como Resposta nobugz sábado, 25 de outubro de 2008 21:53
    terça-feira, 14 de outubro de 2008 10:57
  • 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!
    terça-feira, 14 de outubro de 2008 17:36
  • 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
    • Editado jack 321 quinta-feira, 16 de outubro de 2008 04:02 correct grammar
    quinta-feira, 16 de outubro de 2008 04: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.
    quinta-feira, 16 de outubro de 2008 09:54
  • 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!
    quinta-feira, 16 de outubro de 2008 18:12
  • I know this is an old post, but I confirm that I'm seeing the same problem with Windows 7, Windows 7 SP1 also.
    domingo, 6 de março de 2011 20:34
  • 2020 and looks like this bug will never be fixed...


    GP Software

    quinta-feira, 9 de abril de 2020 04:51