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 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

Download demo project – 205 Kb


More by Author

Must Read