473,396 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

RichTextBox::AppendText misbehavior

I've got a form that contains a RichTextBox control and periodically
receives strings to append to it. The function in question is below.
I've been receiving mysterious bug reports of application crashes
('Attempt to Read/Write Protected Memory', 'Object Reference not set
to instance of an object') which I cannot recreate. In the reports,
however, it seems that the crash occurs just after (or possibly
during) a sequence of calls to this function.

For the record, this function is only called by the thread that
created it.

I decided to check out this function using DevPartner's Error
Detection tool, and it occasionally triggers a 'Overrun detected'
error during the call to 'AppendText'. Details of the error simply
point to 'riched20.dll'. What character is being appended (or how
many) does not appear to matter, the fault occurs seemingly randomly.

Putting two and two together, an overflow of some sort could explain
the application crashes, as well as why they aren't consistent or
reproducible.

Questions:
1. Is there anything wrong with the code below? Note that I'm using
VS2005 with /clr:oldSyntax.
2. Does anyone know of any issues along these lines in riched20.dll?
Googling shows a number of issues, but none that seem relevant.

Any suggestions would be greatly appreciated.

Ryan
void myDialog::OutputMessage(const std::string& message) {
String* str = message.c_str();
Drawing::Font* boldFont = new Drawing::Font(S"Monospac821 BT", 9.25F,
System::Drawing::FontStyle::Bold,
System::Drawing::GraphicsUnit::Point, (System::Byte)0);
Drawing::Font* regularFont = m_outputWindow->get_Font();

// Set the default font and color
m_outputWindow->set_SelectionFont(regularFont);
m_outputWindow->set_SelectionColor(Drawing::Color::Black);

// Parse through the characters looking for font formating
for (int ii = 0; ii != str->get_Length(); ++ii) {
__wchar_t currChar = str->get_Chars(ii);

// Parse for font options, setting boldFont or regularFont
appropriately
// ... clipped for brevity

// Append the character
String* curStr = new String(currChar, 1);
m_outputWindow->AppendText(curStr); // this line triggers
DevPartner ErrorDetection
}

m_outputWindow->AppendText(S"\r\n");

// scroll along with our message(s)
m_outputWindow->set_SelectionStart(m_outputWindow->get_Text()-
>get_Length());
m_outputWindow->Focus();
m_outputWindow->ScrollToCaret();
}

Nov 2 '07 #1
0 1247

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: kangoo | last post by:
Hi, I'm trying to remove the last charater in a richTextBox. I though richTextBox.Text.Remove(richTextBox.Text.length-1, 1); would work, but it does nothing (eg richTextBox.Text += "some new...
3
by: zbcong | last post by:
hello i put a richtextbox and a button on the winForm.when the button is clicked,it generate several threads to write to the richtextbox,the code snippet as following: private void...
2
by: Rachel Suddeth | last post by:
It seems that when I programattically add to the Text property (something like RichText1.Text += string1), I lose the formatting that was previously applied to the original Text. Is that how it's...
1
by: Eric | last post by:
Using the 1.1 framework. We are using a newly created instance of a RichTextBox Class in our server code to manipulate RTF that is stored in the database. To clarify, we are not using or...
2
by: JonnyT | last post by:
I searched high and low for an answer on how to auto scroll a richtextbox and now I finally have it. Since it took me a while to get a good efficient way of doing it that didn't require focus to...
0
by: steve | last post by:
Hello, I have been working on this piece of code that's supposed to read from a file - transform - preview and finally save the transformed data. I can read the file and with...
3
by: michael sorens | last post by:
The documentation for the RichTextBox is sketchy at best. I want to do a very simple task but I cannot find information on this. I am using a RichTextBox as an output window. Some text I want to...
1
by: bmerlover | last post by:
I'm having trouble reading quotations inside the richTextBox when a file is opened on to it. I've tried a couple different methods, most of them didn't compile. I came across one that does compile...
4
by: =?Utf-8?B?UmF5IE1pdGNoZWxs?= | last post by:
Hello, I have a multiline RichTextBox that I use for data logging. I'm concerned about how the AppendText method reacts when over time the maximum number of characters have been added. Do the...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.