Archived

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

wing_majin

editbox control/scrolling in winAPI

Recommended Posts

wing_majin    122
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 this post


Link to post
Share on other sites
Box2020    142
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 line

SendMessage(hEdit,EM_SETSEL,0,-1);
SendMessage(hEdit,EM_GETSEL,(WPARAM)&start,(LPARAM)&finish);

// set the current selection to the end

SendMessage(hEdit,EM_SETSEL,finish,finish);

// insert the text

SendMessage(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 this post


Link to post
Share on other sites
wing_majin    122
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.

Share this post


Link to post
Share on other sites