|
Can you provide a code snippet on how you are calling the function?
Have you tried using just a CString object to see what happens?
|
|
|
|
|
Sure. All of the code is contained within and email parsing program. The plain text body requires formating that is handled through this function (as you can see from the trace code, I traced the error as far back as I could):
<br />
BOOL FormatBodyText(CStringEx &strBodyText, CAttributes *Attrib)<br />
{<br />
FSTRACE("Starting FormatBodyText...\n");<br />
<br />
WordWrap(strBodyText, Attrib->m_intWrapSize);<br />
FSTRACE("did word wrapping...\n");<br />
<br />
ParseForLinks(strBodyText, Attrib->m_strHrefReplace, Attrib->m_strMailtoReplace);<br />
FSTRACE("did parseForLinks...\n");<br />
<br />
if(Attrib->m_bDoHopLinks)<br />
ParseForHopLinks(strBodyText, Attrib);<br />
<br />
return true;<br />
}<br />
The function is called like this:
<br />
FormatBodyText(MsgQry->m_strBodyText, Attrib);<br />
MsgQry is a pointer to a class containing the various parts of the email message.
Attrib is a pointer to a class containing the program's attributes.
Thanks again
|
|
|
|
|
Have you narrowed it down to a CString object formatted in a particular way? I tried it with a few "dummy" strings and it did not crash. I'm not sure if it did what it was supposed to (logic), but it did not crash.
|
|
|
|
|
It only crashes on one particular string (email body text). There is nothing unusual about the body text at all. The code works perfectly on every other string I throw at it. I'm assuming that the string itself or the code is not the problem because the Mid() stopped the error and the error doesn't occur while stepping through the code.
Are there any known allocation issues with CStrings? What kind of memory movement does a Mid perform that would stop this from happening.
Another note of interest is that in order for the Mid to stop the error, it has to pull a substring from within the string. Performing a Mid(0,str.GetLength()) still causes the error. Performing a Mid(5,20) stops the error. *shrug*
|
|
|
|
|
Here is another strange point. After making the statement above about "performing a Mid(5,20)", I tried that exact number (I was just using those numbers as an example. I had up till this point, used the vars I had available in the loop). That didn't work! In order to make the error stop, I have to pull at least 48 chars in the mid:
<br />
strTemp = String.Mid(106, 48);<br />
It doesn't matter where in the string I start. Mid(1,48), Mid(1000,48). Just as long as I pull at least 48 chars from the string. Anything less, creates the error.
*big shrug*
|
|
|
|
|
Just a curiosity...
Does:
String.Replace("\n", "\r\n");
not work for some reason?
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
I'm not simply replacing \n with \r\n. I'm wrapping a string at specified positions. If linewrap is set at 80, then I move to that pos in the line then look for the next space (don't want to wrap in the middle of a word), and insert a \r\n.
|
|
|
|
|
ahhh. i c
- Nitron
"Those that say a task is impossible shouldn't interrupt the ones who are doing it." - Chinese Proverb
|
|
|
|
|
levay wrote:
If linewrap is set at 80, then I move to that pos in the line then look for the next space...
Shouldn't you be looking for the previous space? If position 80 is in the middle of a 10-letter word, you'd actually be breaking at position 85.
|
|
|
|
|
Agreed. Relative wrapping was good enough for what I was trying to accomplish at that time. I'll probably go back later and make it more accurate (ie: <= linewrap), but at this time it wasn't a priority.
|
|
|
|
|
I don't know what your CStringEx extension class is or how it is defined but by the symptoms, I'd guess you have stack corruption. The fact that the bug goes away when you allocate more memory leads me to believe that something is trashing the stack if that allocation doesn't take place.
I tried to reproduce this problem using CString but couldn't (in debug and retail). Have you tried to use CString instead of CStringEx? What you could also do is debug the retail executable in the dissasembler and keep watching the stack to see if the return pointer is kept intact.
|
|
|
|
|
Your hunch was right. Not sure where the corruption is happening yet, but I was able to preempt it by doing the following:
<br />
MsgQry->m_strBodyText.GetBuffer(dwSize + 1);<br />
MsgQry->m_strBodyText.ReleaseBuffer(dwSize + 1);<br />
I have never used GetBuffer/ReleaseBuffer for pre-allocating CString memory before. Anything I should be aware of? Any performance hits by allocating in this way? Is there a better way to allocate than this?
Thanks
|
|
|
|
|
Other than the fact you are starting with intLineSize set equal to intWrapSize, instead of 0, I do not not see the problem. I am looking at you your code and I feal like the is something wrong. I do not know what it is (at 4:28 AM), but it is there.
Trust in the code Luke. Yea right!
|
|
|
|
|
Hi,
does anybody know how to implement a multiline list view? I need list items which are 2 or 3 lines high. \n, \r\n and \r\r\n don't work.
Regards,
Happosai
------------------------------------
http://www.happosai.tk
|
|
|
|
|
Try this article http://www.codeproject.com/listctrl/lvcustomdraw.asp the last pic in the article has a multi line list.. I haven't gone through the code but it may be a place to start..
Rob
Whoever said nothing's impossible never tried slamming a revolving door!
|
|
|
|
|
Hi,
sure, it's a place to start, but not for a beginner like me "I achieved this by doing all the painting on my own." That's too hart for me but thanks anyway.
Regards
Happosai
------------------------------------
http://www.happosai.tk
|
|
|
|
|
Is there a way that you can open solitare through a C++ command and if there is what is it?
Thanks
Matt
Matt Millican
http://www.internetmill.com
|
|
|
|
|
InternetMill wrote:
Is there a way that you can open solitare through a C++ command and if there is what is it?
Try the ShellExecute function.
-Nick Parker
|
|
|
|
|
Not with C++ (it knows nothing about launching applications). With the Windows SDK, you can use WinExec (not recommended), ShellExecute, or CreateProcess.
|
|
|
|
|
Hi, working on an instalation project and would like to know if there is any safe way to install a .inf file with some C++ code, for win 95, 98, NT4, 2k and XP.
The problem is that I have a USB device and would like to install the driver for it witout the need for the device to be inserted into the computer.
regards ME
|
|
|
|
|
Yes.
I am not sure why you need to install an .ini file(assume .inf was a mistake). But you need to not only copy the driver to the %windir%\system32\drivers directory you need to modify the registry (so it knows it exist).
Note: None of the above can be done on WinNT/Win2000/WinXp unless an Adiminstrator is doing the install.
Trust in the code Luke. Yea right!
|
|
|
|
|
I want to add new records with my program to my database
but I don't know how to do this .
please help me.
|
|
|
|
|
Are you wanting to know how to use CRecordset::AddNew()?
|
|
|
|
|
yes I want to know how can I use this method in a dialog base application . please give me an example
|
|
|
|
|
Have you checked out MSDN, or Googled for examples?
|
|
|
|