Appending multiple RichEdit Fields together | CodeGuru

Appending multiple RichEdit Fields together

Environment: VC6, NT4 SP4 The is the search front-end to an access database for a travel agency. We came into the RichEdit class pretty naive as to how it worked. After much screaming, yelling, and E-Mailing. We finally got the thing to do what we wanted. The data entry app allows you to enter all […]

Written By
CodeGuru Staff
CodeGuru Staff
Jul 26, 1999
2 minute read
CodeGuru content and product recommendations are editorially independent. We may make money when you click on links to our partners. Learn More

Environment: VC6, NT4 SP4

The is the search front-end to an access database for a travel
agency. We came into the RichEdit class pretty naive as to how it worked.
After much screaming, yelling, and E-Mailing. We finally got the thing to do
what we wanted.

The data entry app allows you to enter all types of information in
RichEdit format. The search app (posted below) then allows you the search the
database with alot of different criteria, then fill multiple fields on the results form.
The tough part was a big rich edit control where we appended together 23 fields
containing rtf text streams. We had endless problems getting this to work correctly
as we kept losing the formatting after 5 iterations of appending. Gavin pointed out
what we were doing wrong.

Dan, the solution is very easy.

You have associated via DDX (classwizard binding) a CString named m_main to
your RichEditCtrl. This is a *HUGE* no-no since RichEditCtrl controls are
NON BINDABLE. Even binding it to a control variable (your ctr_main) is
sometimes risky. Here is what I did:

1) Went into ClassWizard and deleted the member variable CString m_main.
2) Added CString m_main as a plain member variable (non-bound)

Thing works perfectly!

Gah!! Live and learn! :(I’m not posting any code here because there is alot. Anyone who’s interested in filtering databases
using ODBC might want to download the code. The project files are the Search portion
of the app, anyone who want the data entry portion can email me! If you want the Access database that
goes with this, drop me a note. Please
have mercy on how some of this code was written, the project had to be finished in a
hurry, and we were new to the scene so it isn’t the best code.

One project I would love to do and post here on CodeGuru is to
create a master RichEdit class that would handle all the things necessary for RichEdit in
a more comprehensible fashion. There has been at least one attempt for this by Jeremy Iverson, and I’d like to build on it
a little more for those richedit developers out there. So If anyone knows an easier
or more efficient (shouldn’t be hard) way of doing sections of our code, please comment,
and we will use these in the master RichEdit class. Hope someone finds this useful!!

-Daniel Canham

Thanks to: Gavin Stark – who showed us a stupid mistake we were
making

Download demo project – 205 Kb

History

CodeGuru Logo

CodeGuru covers topics related to Microsoft-related software development, mobile development, database management, and web application programming. In addition to tutorials and how-tos that teach programmers how to code in Microsoft-related languages and frameworks like C# and .Net, we also publish articles on software development tools, the latest in developer news, and advice for project managers. Cloud services such as Microsoft Azure and database options including SQL Server and MSSQL are also frequently covered.

Property of TechnologyAdvice. © 2026 TechnologyAdvice. All Rights Reserved

Advertiser Disclosure: Some of the products that appear on this site are from companies from which TechnologyAdvice receives compensation. This compensation may impact how and where products appear on this site including, for example, the order in which they appear. TechnologyAdvice does not include all companies or all types of products available in the marketplace.