"blah, blah"
"blah, blah"
.
.
.
"blah, blah, blah"
For the edit control to type texts I'm using these following styles:
WS_VISIBLE
WS_BORDER
WS_CHILD
WS_VSCROLL
ES_MULTILINE
// create an edit box to type messages
editBoxHandle = CreateWindow(_T("EDIT"),
NULL,
WS_VISIBLE|WS_BORDER|
WS_CHILD|WS_VSCROLL|
ES_MULTILINE,
10,350,
200,50,
mWnd,
0,
hInstance,
0);
For the edit control to print texts I'm using these following styles:
WS_VISIBLE
WS_BORDER
WS_CHILD
WS_VSCROLL
ES_MULTILINE
ES_READONLY
// create a message-output box
msgBoxHandle = CreateWindow(_T("EDIT"),
NULL,
WS_VISIBLE|WS_BORDER|
WS_CHILD|WS_VSCROLL|
ES_MULTILINE|ES_READONLY,
10,10,
295,330,
mWnd,
0,
hInstance,
0);
I try to look into msdn.microsoft.com for edit control references but it doesn't help me. I also look into other posts here in this site but it doesn't help me as well. Here is a snippet of my code that displays a text on the read-only edit control box:
// get length of the text from the edit box
int len = GetWindowTextLength(editBoxHandle);
if(len > 0)
{
char * buffer;
// allocate memory of the buffer from the heap
// and fill it with zeroes. this is similiar to
// the c-style function, calloc()
buffer = (char *)GlobalAlloc(GPTR, len + 1);
// get the text from the edit box
SendMessage(editBoxHandle,WM_GETTEXT,
(WPARAM)len + 1, (LPARAM)buffer);
// set the text to the message box
SendMessage(msgBoxHandle,
WM_SETTEXT,
0,
(LPARAM)buffer);
// deallocate memory of the buffer
GlobalFree((HANDLE)buffer);
buffer = NULL;
}
This code is fine but it overwrites the last text with the new one. Is there a solution to this problem? Also, how can I print messages to the read-only edit control by pressing the ENTER key.
Language: C++
IDE: Visual Studio 2005
API: Winsock 2 and Win32
This post has been edited by yamaki308: 16 February 2009 - 02:57 PM

New Topic/Question
Reply




MultiQuote




|