简体   繁体   中英

EDIT control text overflow

This is simple. I created an EDIT control like this:

HWND MYTEXT= CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"", 
                            WS_CHILD|WS_VISIBLE|ES_LEFT|ES_MULTILINE, 
                            20, 120, 150, 20, hWnd, NULL, hInst, NULL);

but when I type text inside of it I can't type more text than the width of the EDIT control. When I reach the end it's like there's no more space and I get a beep. How can I make the text scroll in this situation?

You can give your edit control the WS_HSCROLL and/or WS_VSCROLL window styles . For instance:

HWND myText
    = CreateWindowEx(WS_EX_CLIENTEDGE, L"EDIT", L"", 
                     WS_CHILD | WS_VISIBLE | WS_HSCROLL | ES_LEFT | ES_MULTILINE, 
                     20, 120, 150, 20, hWnd, NULL, hInst, NULL);

Alternately, as Matthew T. Staebler rightfully suggests, use ES_AUTOHSCROLL and/or ES_AUTOVSCROLL (note the ES_ prefix, as these are edit styles, not window styles).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM