GetTextExtentPoint32
(1)
Textmetrics.tmAveCharWidth
(1)
ListView
(1)
Everybody.David
(1)
Windows
(1)
RTL
(1)

Expanding edit control

Asked By David Liebtag
13-Nov-09 02:33 PM
If you select a file name in the Windows shell and press F2 to rename the
file, you are put into an edit field whose width automatically increases as
you type more and more characters.

Does anyone know how they do that?  Is that a built in feature of edit
controls or have they subclassed it an added custom code to resize the
window?

Thanks a lot.

David Liebtag

David,I am not aware of any inbuilt facility of the edit control that will

David Lowndes replied to David Liebtag
14-Nov-09 01:54 PM
David,

I am not aware of any inbuilt facility of the edit control that will do
that. Looking at message with Spy++ it would appear that the control
is just being resized, so I guess it is some custom code.

Dave

David Lowndes wrote:Yeah, I think it is custom. But it is not that hard to do.

Ivo Beltchev replied to David Lowndes
14-Nov-09 02:30 PM
Yeah, I think it is custom. But it is not that hard to do. Basically on
WM_COMMAND/EN_CHANGE measure the text (GetTextExtentPoint32), add some
padding, clamp with some minimal width (let us say
textmetrics.tmAveCharWidth*5). And finally clamp with the right edge of
the parent tree/list control so the control does not go out of the
parent's client area. Of course that is in reverse if you have RTL control.

Ivo

See the ListView source code.

Alain replied to David Liebtag
14-Nov-09 02:53 PM
See the ListView source code.
Thanks everybody.David
David Liebtag replied to David Liebtag
15-Nov-09 09:08 AM
Thanks everybody.

David
Post Question To EggHeadCafe