#### Archived

This topic is now archived and is closed to further replies.

# editbox control/scrolling in winAPI

This topic is 5922 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Kinda n00b-ish at winAPI, but is there anyway to simply append strings to an editbox control like you can with a listbox? I couldn''t find a way to do so since the SetDlgItemText() function overwrites the current value with whatever its sent. So my temporary solution was to pushback every new string to be entered onto an array of strings, then loop through, add each to one large, cumulative string with newlines etc added and send it to the function. (this can''t be the best way to do that....) Now since it just gets a huge string that increases in size, the scrollbar resets to the top each time instead of staying current with the most recently "appended" line of text like I want. Is there a better way, or am I gonna have to try to reset the scroll bar to maximum every time....

##### Share on other sites
Ok - this is a bit strange for a noobie as it requires that you
send messages to the edit control

  DWORD start,finish;char* to_add=" this is added";HWND hEdit= GetDlgItem(m_hWnd,IDC_EDIT1);// first find the end of the lineSendMessage(hEdit,EM_SETSEL,0,-1);SendMessage(hEdit,EM_GETSEL,(WPARAM)&start,(LPARAM)&finish);// set the current selection to the endSendMessage(hEdit,EM_SETSEL,finish,finish);// insert the textSendMessage(hEdit,EM_REPLACESEL,0,(LPARAM)to_add);

Hope this helps, if not then you realy need to look at the windows messages starting with EM_

##### Share on other sites
No its not strange at all ^_^. I''m familiar with message sending basics and EM_ messages etc but looking through those and the explanations offered I became kinda confused. (I was almost there too) But that works great though, thanks a lot.

1. 1
Rutin
25
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 14
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631757
• Total Posts
3002131
×