Click here to Skip to main content
15,891,903 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: Inheriting from std::vector? Pin
Nemanja Trifunovic26-Jan-03 17:27
Nemanja Trifunovic26-Jan-03 17:27 
GeneralChanging screen saver programatically Pin
Mahesh Perumal26-Jan-03 5:18
Mahesh Perumal26-Jan-03 5:18 
GeneralRe: Changing screen saver programatically Pin
Ken Mazaika26-Jan-03 11:56
Ken Mazaika26-Jan-03 11:56 
GeneralGlobal memory (GlobalAlloc, etc...) Pin
Dominik Reichl26-Jan-03 3:40
Dominik Reichl26-Jan-03 3:40 
GeneralRe: Global memory (GlobalAlloc, etc...) Pin
Sigmund26-Jan-03 4:38
Sigmund26-Jan-03 4:38 
GeneralRe: Global memory (GlobalAlloc, etc...) Pin
Dominik Reichl26-Jan-03 6:03
Dominik Reichl26-Jan-03 6:03 
GeneralRe: Global memory (GlobalAlloc, etc...) Pin
Joe Woodbury26-Jan-03 21:37
professionalJoe Woodbury26-Jan-03 21:37 
GeneralProblem splitting dynamically allocated CString Pin
Wim Jans26-Jan-03 2:56
Wim Jans26-Jan-03 2:56 
Hi,

I have a problem splitting up a string.

I have a thread which will send a string to my main thread by posting a message.
I therefore create my string

<br />
CString *s = new CString();<br />
s->Format("%s#@@#%s", _T("Error"), _T("ErrorMessage"));<br />
PostMessage(UWM_SENDSTRING, (WPARAM)i, (LPARAM)s);<br />


The code is successfully received by my function.
However, here is where it goes wrong.

<br />
LRESULT CMyView::OnSendString(WPARAM wparam, LPARAM lparam)<br />
{<br />
  CString *s = (CString*)lparam;<br />
  TRACE0(*s);  // this shows my string<br />
<br />
  int pos = s->Find(_T("#@@#")); // shows the position where it is found, OK<br />
  TRACE0(s->Left(pos)); // gives me crap<br />
  TRACE0(s->Right(s->GetLength()-(pos+4))); // crap to, or Access Violations, etc<br />
  <br />
  delete s;<br />
<br />
<br />


So basically when I show the string, compute a position or show the length of *s everything is fine.
When I just want a part of the string, the first or last, I get a lot of crap or the program just crashes.

When I do all of that splitting in a normal procedure whit normal CString (not dynamically allocated), I get the results thaat I want, namely he part before #@@# and the part after that.

Any ideas how I can let this Left/Right splitting thing work on dynamic CStrings?

tia

Wim
GeneralRe: Problem splitting dynamically allocated CString Pin
Gary R. Wheeler26-Jan-03 5:18
Gary R. Wheeler26-Jan-03 5:18 
GeneralRe: Problem splitting dynamically allocated CString Pin
Ted Ferenc26-Jan-03 9:33
Ted Ferenc26-Jan-03 9:33 
GeneralRe: Problem splitting dynamically allocated CString Pin
Garth J Lancaster26-Jan-03 14:33
professionalGarth J Lancaster26-Jan-03 14:33 
GeneralRe: Problem splitting dynamically allocated CString Pin
Wim Jans26-Jan-03 22:51
Wim Jans26-Jan-03 22:51 
GeneralRe: Problem splitting dynamically allocated CString Pin
Garth J Lancaster27-Jan-03 10:12
professionalGarth J Lancaster27-Jan-03 10:12 
GeneralCreation of child dialogs Pin
annona25-Jan-03 23:31
annona25-Jan-03 23:31 
Generalquestion about CRITICAL_SECTION. Pin
George225-Jan-03 22:17
George225-Jan-03 22:17 
GeneralRe: question about CRITICAL_SECTION. Pin
Renjith Ramachandran26-Jan-03 0:19
Renjith Ramachandran26-Jan-03 0:19 
GeneralRe: question about CRITICAL_SECTION. Pin
George226-Jan-03 1:29
George226-Jan-03 1:29 
GeneralRe: question about CRITICAL_SECTION. Pin
Mike Nordell26-Jan-03 1:56
Mike Nordell26-Jan-03 1:56 
GeneralRe: question about CRITICAL_SECTION. Pin
George226-Jan-03 2:10
George226-Jan-03 2:10 
GeneralRe: question about CRITICAL_SECTION. Pin
peterchen26-Jan-03 6:33
peterchen26-Jan-03 6:33 
GeneralRe: question about CRITICAL_SECTION. Pin
George226-Jan-03 14:18
George226-Jan-03 14:18 
GeneralError: Inaccurate System Timer Pin
Edwin Geng25-Jan-03 21:54
Edwin Geng25-Jan-03 21:54 
GeneralRe: Error: Inaccurate System Timer Pin
Gary R. Wheeler26-Jan-03 5:23
Gary R. Wheeler26-Jan-03 5:23 
Generalfatal error LNK1104: cannot open file "nafxcw.lib" Pin
jimNLX25-Jan-03 21:07
jimNLX25-Jan-03 21:07 
GeneralRe: fatal error LNK1104: cannot open file "nafxcw.lib" Pin
bryce25-Jan-03 23:37
bryce25-Jan-03 23:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.