473,799 Members | 2,950 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

RichTextBox::Ap pendText 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::Outpu tMessage(const std::string& message) {
String* str = message.c_str() ;
Drawing::Font* boldFont = new Drawing::Font(S "Monospac82 1 BT", 9.25F,
System::Drawing ::FontStyle::Bo ld,
System::Drawing ::GraphicsUnit: :Point, (System::Byte)0 );
Drawing::Font* regularFont = m_outputWindow->get_Font();

// Set the default font and color
m_outputWindow->set_SelectionF ont(regularFont );
m_outputWindow->set_SelectionC olor(Drawing::C olor::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(cur Str); // this line triggers
DevPartner ErrorDetection
}

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

// scroll along with our message(s)
m_outputWindow->set_SelectionS tart(m_outputWi ndow->get_Text()-
>get_Length() );
m_outputWindow->Focus();
m_outputWindow->ScrollToCaret( );
}

Nov 2 '07 #1
0 1282

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

Similar topics

3
21177
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 text"; works) Thanks for your attention & solutions
3
4063
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 btnSend_Click(object sender, System.EventArgs e) { for(int i=0;i<3;i++) { Thread thread =new Thread(new ThreadStart(rpt)); thread.Start();
2
15270
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 supposed to behave? Does that mean I have to add the text directly to the Rtf property instead? Because I'm not sure how to add it.... it would need to go before some of the ending tags, right? -Rachel
1
2691
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 attempting to use this class in the aspx page that calls the code, nor is the 'using System.Windows.Forms' referenced in any of the aspx pages. The first client using this software has been experiencing an error that we cannot reproduce in-house. The...
2
17387
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 the control or the scrolltocaret method I decided that it would be worth posting to anyone who might have similar concerns. For the record this works well in an environment where you cannot have focus going to the richtextbox....such as a chat...
0
1492
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 RichtextBox.LoadFile( ) i can display it on the first box. Then, in a for loop i read line by line , extract the information and (the idea is) to put the transformed data in another RichText Box so that the
3
7192
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 just add plain (e.g.. rtf.Text += "new stuff..."; ) but some text, when added, I want to be in a different color or font size. Find() will not work because the text will vary. I have delimiters on it so I could recognize it with a regular ...
1
1714
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 and supposedly it's suppose to work but it doesn't in my case. I tried this code to see if it would recognize the quotations. For testing purpose I wanted to see if it would start the string from the quotation. str =...
4
13491
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 oldest characters it contains start rolling off the top into the bit bucket, does it simply start silently ignoring appends until some characters, are deleted, or does some kind of exception get thrown? I've heard numerous opinions on what the...
0
10475
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10250
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
9068
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7564
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6805
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5463
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5585
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4139
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
2938
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.