What is this
How do I use Led with an AppWizard-generated application? How do I convert
an app which used CRichTextEdit to use Led?
What if I want to build a word-processor? What if I want to build a line-based text editor
(such as you would use for editing program text)?
Basic Idea
One easy way to get started using Led with MSVC & MFC is to use MSVC's AppWizard.
You run AppWizard, and say you want to build an application that uses the CRichTextEdit,
Microsoft's builtin rich text control. Then you revise the output of AppWizard to use
Led instead.
The details
These instructions show you how to build either a simple word processor or a simple
line-based text editor.
Most of the instructions are identical, but where they diverge - they will be specially
marked as {WordProcessor-only} or {LineEditor-only}.
- Build a new project "GARNDLE" as an "MFC AppWizard(exe)" project. Of course
you can use any name you want, but "GARNDLE" will be used throughout this tutorial).
Be sure to put this folder at the top level of some drive letter, and
along side (same drive letter)
as where you installed Led.
You May deviate from this, but if you do, you will need to adjust the include
directories prescribed herein.
- Select default for all choices (MDI, no dbase, no compound doc, etc) until you get
to the end.
Then - if building {WordProcessor-only} - select CRichEditView as the base-class,
and if building {LineEditor-only} - build from CView.
- (OPTIONAL)Build & run, to be sure all is well.
- Select Workspace in IDE, using the "FileView" tab, and say "Add new Project to Workspace".
- when dialog comes up, Add "Led" project, select "Add to current workspace",
and check "dependency of"
and choose "Win32 Static Library".
Then answer next question saying "MFC Support" and not "Precompiled headers".
- Be sure settings for "General/Use MFC as a X" argree between
"Led" and "GARNDLE" projects (in settings dialog).
- Select "Led files" in IDE fileview panel, and say "Add files into project"
Then add all the Led source files (except Led_XXX where XXX is for some
class library other than MFC, e.g. leave out Led_PP*.cpp, and Led_Gtk*.cpp)
- Select Project Settings, and apply settings for "All configurations" and for all projects
("Led and your new project "GARNDLE")
Select C++ panel, and add "qIncludePrefixFile" to the "Processor definitions"
Add "\Led\Headers\,..\" to the "Additional include directories" field (actual paths will depend on
where you put your project relative to where you put the Led sources; above is if you put your project in same
place as other Led shareware demos).
Check the "Enable Run-Time-Type Information (RTTI) checkbox.
- (OPTIONAL)Build & run, to be sure all is well. Nothing should have changed at this
point (except that the build takes longer).
- {LineEditor-only} - Go into GARNDLEDoc.h. Add the #defines:
#define _BASECLASS_ CView
and then search through all the MFC generated headers and sources,
and replace all occurnences of CView with _BASECLASS_
.
- {WordProcessor-only} - Go into GARNDLEDoc.h. Add the #defines:
#define _BASECLASS_ CRichEditView
#define _BASEDOC_ CRichEditDoc
#define _BASECNTRITEM_ CRichEditCntrItem
and then search through all the MFC generated headers and sources,
and replace all occurnences of CRichEditView with _BASECLASS_
,
all occurnences of CRichEditDoc with _BASEDOC_
.
and all occurnences of CRichEditCntrItem with _BASECNTRITEM_
.
Also - add:
#include "GARNDLEDoc.h"
to CntrItem.h.
- (OPTIONAL)Build & run, to be sure all is well. Nothing should have changed at this
point.
- Go into GARNDLEView.h, GARNDLEDoc.h, and ({WordProcessor-only})CntrItem.h. Add the #include
#include "SimpleLed.h"
#if qLedUsesNamespaces
using namespace Led;
#endif
near the top of the file.
- (OPTIONAL)Build & run, to be sure all is well. Nothing should have changed at this
point.
- {WordProcessor-only}--Go into GARNDLEDoc.h. Change the #defines to
#define _BASECLASS_ SimpleLedWordProcessor
#define _BASEDOC_ COleDocument
#define _BASECNTRITEM_ Led_MFC_ControlItem
- {LineEditor-only}--Go into GARNDLEDoc.h. Change the #defines to
#define _BASECLASS_ SimpleLedLineEditor
and delete the methods (from GARNDLEView.h/cpp)
- OnDraw
- PreCreateWindow
- OnPreparePrinting
- OnBeginPrinting
- OnEndPrinting
- {WordProcessor-only}--In CntrItem.h change implementations of
GetDocument() and GetActiveView() to take & of their base calls, since the
Led_MFC_ControlItem returns references to these objects (doc & view) instead
of pointers.
- {WordProcessor-only}--Then go to GARNDLEView.cpp, and comment out the call to
"SetMargins()".
- {WordProcessor-only}--In CntrItem.cpp lose the first 'preo' argument to BASECTRLITEM () call
in CGARNDLECntrItem ::CGARNDLECntrItem
- Build & run. You should now be using the Led text engine.
Now there are lots of additional features you may want to add (like setting fonts on selections,
etc). See the LedIt! or LedLineIt! sources for more details on how todo these things.
Return to Led Page
Return to Tutorials Index
Last Updated 2001-11-07