0

We have a text box which is in fact an instance of the standard native Windows edit control used to enter text. The control was created using CreateWindowsEx without the ES_AUTOHSCROLL flag specified. It implies that word wrapping for entered text is used automatically.

Our goal is to fix the control's width and increase the height of the control automatically as the number of text lines is increased to show all them. An example: by default, the text box is empty. The user starts typing, and as soon as the end of the first line is reached, the text box automatically increases its height by one text line so the last word is put into the beginning of the second line due to word wrap.

How to gain this? Our development environment is VB6, but any WinAPI-based code is also welcome.

TecMan
  • 2,743
  • 2
  • 30
  • 64
  • 2
    Broadly speaking: The parent window receives EN_CHANGE notifications when the text changes in the control - every time you get one, calculate the size of the text and adjust the control accordingly. I'd offer more detail but I'm having trouble with the fact that you're using VB6 :) – Jonathan Potter Nov 13 '13 at 09:01
  • @JonathanPotter, no problem to share your ideas or code. Despite the fact that the project's source code is VB6, we can implement any WinAPI solution in it - or almost any :) – TecMan Nov 13 '13 at 11:32
  • @JonathanPotter, I guess it's clear how to calculate the size of the rectangle for the text with DrawText, but the clue to solution is how to determine the whole edit control size taking into account its internal padding, etc. And does the edit control uses the same text rendering engine as DrawText so we can use it in this scenario? – TecMan Nov 13 '13 at 11:36
  • The `DT_EDITCONTROL` flag suggests that it can. – Jonathan Potter Nov 13 '13 at 12:39

0 Answers0