Question

Is there any way to programmatically scroll a single-line edit control in Windows?

For example, if the text in an edit control is too large to display at once, then the default behavior when the edit control gets the focus is to select all text and show the end of the text. I'd like to instead show the beginning of the text (while still leaving all text selected).

Was it helpful?

Solution

Although there's (apparently) no API for scrolling to the beginning and selecting all text, it seems to work to simulate the keystrokes that would do the same:

#ifndef CTRL               
#define CTRL(x) (x&037)    
#endif

SendMessage(edit_handle, WM_KEYDOWN, VK_HOME, 0);
SendMessage(edit_handle, WM_CHAR, CTRL('A'), 0);

OTHER TIPS

You can either call SetScrollPos or send the WM_VSCROLL/WM_HSCROLL message directly to the window. You can find the full list of scroll functions here.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top