-
edit controls
well i have been reading msdn and some previous posts on the topic here...
from what i have read you cannot continuously add text to an edit control? is this correct? from what i have gathered i would have to keep adding my text into a large buffer and sending it to the edit control every time i wanted to modify the contents of the edit control... is this correct or is there a way to add text to currently present text in my edit control?
-
One solution is to link a CString object to the edit box. Call UpdateData(FALSE) after you append characters to the CString object.
Kuphryn
-
Use editbox message. there are lots of them;
SendMessage(hedit, EM_SETSEL, (WPARAM) begpos,(LPARAM)endpos)
you can use this to manupulate any part of the text in editbox.
there are a whole range of them in MSDN you can use.
-
hmmm ill look into those... anyone perchance know how to add carriage returns in edit controls? adding "\n" to a string does not seem to have any effect :p
-
You need to use a '\r' as well.
-
heh having a little trouble :(
http://support.microsoft.com/default...;en-us;Q109550
my edit controls are set ES_READONLY by the way
Code:
hwndDisplayBox = CreateWindow("EDIT",
NULL,
WS_CHILD | WS_VISIBLE | WS_VSCROLL |
ES_LEFT | ES_MULTILINE | ES_AUTOVSCROLL | WS_BORDER | ES_READONLY,
0, 0, 0, 0,
hwnd,
(HMENU) ID_DISPLAYBOX,
(HINSTANCE) GetWindowLong(hwnd, GWL_HINSTANCE),
NULL);
//lower down in another function :p
CHAR szBuffer []= "Connecting to server";
HWND hEdit = GetDlgItem (hwndDisplayBox, ID_DISPLAYBOX);
int ndx = GetWindowTextLength (hEdit);
SendMessage (hEdit, EM_SETSEL, (WPARAM)ndx, (LPARAM)ndx);
SendMessage (hEdit, EM_REPLACESEL, 0, (LPARAM) ((LPSTR) szBuffer));
unfortunatly im not getting any text showing up from the above...
i removed the setfocus as it seemed redundant according to msdn since im not allowing the user to input anything...
well im puzzled :confused:
-
Is GetDlgItem() returning the handle or NULL? It looks like you are creating your editbox handle over the dialogbox handle, or you are using the editbox handle where you should be using the dialogbox handle in the call, without seeing more of course, it's hard to be sure.
-
>>HWND hEdit = GetDlgItem (hwndDisplayBox, ID_DISPLAYBOX);
Adrian has it.
'using the editbox handle (hwndDisplayBox) where you should be using the dialogbox handle (hwnd) in the call'
This should be using the HWND of the parent (from the CreateWindow() HWNDPARENT param) not the edit control.
In fact you do not need to call this function if you already have the edits HWND (hwndDisplayBox and you have made it a global)
-
>>> (hwndDisplayBox and you have made it a global)
Or static.
-
HWND hEdit = GetDlgItem (hwndDisplayBox, ID_DISPLAYBOX);
SendMessage (hEdit, EM_SETSEL, (WPARAM)ndx, (LPARAM)ndx);
and check this two;
your index for (WPARAM) should be the beg position.
you are actually doing nothing with this .because
endpos = beg pos = 0;
it should be as follows:
SendMessage (hEdit, EM_SETSEL, (WPARAM) 0, (LPARAM)ndx);
i think:rolleyes:
-
how about this:
SendMessage(TextBoxHwnd, EM_SETSEL, -1, -1);
SendMessage(TextBoxHwnd, EM_REPLACESEL, FALSE, (LPARAM) "text");
maybe?
-
Please don't bump old threads, (post to treads after they have been inactive for more than a week or so. They simply clutter the bard, and if the original poster hasn't asked any followups, he's either happy or left.