| View previous topic :: View next topic |
| Author |
Message |
kitterz Grandmaster Cheater Supreme
Reputation: 0
Joined: 24 Dec 2007 Posts: 1268
|
Posted: Thu Jun 12, 2008 7:54 am Post subject: C++ EM_GETLINE problem |
|
|
| Code: |
int numoflines;
string temp;
TCHAR teststring[128];
numoflines = SendMessage(ScriptWin, EM_GETLINECOUNT, 0, 0);
temp = SendMessage(ScriptWin, EM_GETLINE, 1, (LPARAM)&teststring);
SendMessage(OutputWin, WM_SETTEXT, 0, (LPARAM)(LPCTSTR)teststring); |
Ya...I, trying to put the string into the buffer....and then display it in another window....but sometimes i get random characters after what i put in the first edit box.
Example:
I put "Hello my name is Bob" in the first box.
Then, after this code executes, in the second box it says something like
"Hello my name is BobX*"
|
|
| Back to top |
|
 |
Renkokuken GO Moderator
Reputation: 4
Joined: 22 Oct 2006 Posts: 3249
|
Posted: Thu Jun 12, 2008 8:04 am Post subject: |
|
|
| Be sure to null-terminate the string.
|
|
| Back to top |
|
 |
kitterz Grandmaster Cheater Supreme
Reputation: 0
Joined: 24 Dec 2007 Posts: 1268
|
Posted: Thu Jun 12, 2008 8:07 am Post subject: |
|
|
| Renkokuken wrote: | | Be sure to null-terminate the string. |
Pardon me? What does that mean?
|
|
| Back to top |
|
 |
Renkokuken GO Moderator
Reputation: 4
Joined: 22 Oct 2006 Posts: 3249
|
|
| Back to top |
|
 |
kitterz Grandmaster Cheater Supreme
Reputation: 0
Joined: 24 Dec 2007 Posts: 1268
|
Posted: Thu Jun 12, 2008 8:28 am Post subject: |
|
|
| I get it....but I don't know how to use it so it works with TCHAR
|
|
| Back to top |
|
 |
Renkokuken GO Moderator
Reputation: 4
Joined: 22 Oct 2006 Posts: 3249
|
Posted: Thu Jun 12, 2008 8:29 am Post subject: |
|
|
| kitterz wrote: | | I get it....but I don't know how to use it so it works with TCHAR | TCHAR is just a definition of either char or wchar_t, depending on the character set of the solution.
Last edited by Renkokuken on Thu Jun 12, 2008 8:34 am; edited 1 time in total |
|
| Back to top |
|
 |
kitterz Grandmaster Cheater Supreme
Reputation: 0
Joined: 24 Dec 2007 Posts: 1268
|
Posted: Thu Jun 12, 2008 8:32 am Post subject: |
|
|
| hmmm im using amulti-byte char set
|
|
| Back to top |
|
 |
Renkokuken GO Moderator
Reputation: 4
Joined: 22 Oct 2006 Posts: 3249
|
Posted: Thu Jun 12, 2008 8:34 am Post subject: |
|
|
| kitterz wrote: | | hmmm im using amulti-byte char set | TCHAR is just char then.
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Thu Jun 12, 2008 8:37 am Post subject: |
|
|
The return value of the message EM_GETLINE is the number of TCHAR's copied to the buffer.
| Code: | TCHAR tszString[256];
int nLines = SendMessage(ScriptWin, EM_GETLINECOUNT, 0, 0);
int nLength = SendMessage(ScriptWin, EM_GETLINE, 1, (LPARAM)tszString);
tszString[nLength+1] = '\0';
SendMessage(OutputWin, WM_SETTEXT, 0, (LPARAM)tszString); |
Also, don't forget the wParam in EM_GETLINE is a zero-based index of the lines. so 1 is the second line.
_________________
|
|
| Back to top |
|
 |
Renkokuken GO Moderator
Reputation: 4
Joined: 22 Oct 2006 Posts: 3249
|
Posted: Thu Jun 12, 2008 8:38 am Post subject: |
|
|
| Hhaha, I was trying to have him solve it on his own, but that works out fine either way.
|
|
| Back to top |
|
 |
kitterz Grandmaster Cheater Supreme
Reputation: 0
Joined: 24 Dec 2007 Posts: 1268
|
Posted: Thu Jun 12, 2008 8:41 am Post subject: |
|
|
Thanks you're the best!
@ Renkokuken i did solve it on my own b4 lurc came in but thx lurc annyways!
|
|
| Back to top |
|
 |
Renkokuken GO Moderator
Reputation: 4
Joined: 22 Oct 2006 Posts: 3249
|
Posted: Thu Jun 12, 2008 8:45 am Post subject: |
|
|
| Glad to hear it's working, and good luck with the rest of the project.
|
|
| Back to top |
|
 |
|