Mini Editor

Top  Previous  Next

 

With WPTools 5 you can create extremely compact editor applications which still do not miss any functionality the end user might expect - such as support for headers and footers, WYSIWYG, scaling, tables etc.

 

When you need a really compact editor we suggest to create objects of the class TWPCustomRtfEdit (defined in unit WPCTRMemo) in code. This way you can also attach two editors to the same TWPRTFDataCollection to create an editor with split screen support.

 

Our demo uses 4 variables defined inside the form interface:

 

TWPMiniEd = class(TForm)

...

public

   WPRichText1, WPRichText2 : TWPCustomRtfEdit;

   RTFData : TWPRTFDataCollection;

   RTFDataProps : TWPRTFProps;

end

 

We also added a splitter, a graphic popup menu and a main menu. At runtime the demo looks like this screen shot:

 

  clip0055

 

The editor objects are created and connected in code inside of the OnCreate event of the form:

 

procedure TWPMiniEd.FormCreate(Sender: TObject);

begin

   RTFData := TWPRTFDataCollection.Create(TWPRTFDataBlock);

   RTFDataProps := TWPRTFProps.Create;

   RTFData.RTFProps := RTFDataProps;

 

   WPRichText1 := TWPCustomRtfEdit.Create(Self);

   WPRichText1.Parent := Self;

   WPRichText1.Align := alClient;

   WPRichText1.TabStop := FALSE;

   WPRichText1.AcceptFiles := TRUE;

   WPRichText1.Memo.SetRTFDataOrProps(RTFData,nil);

 

   WPRichText2 := TWPCustomRtfEdit.Create(Self);

   WPRichText2.Memo.SetRTFDataOrProps(RTFData,nil);

   WPRichText2.Parent := Self;

   WPRichText2.Align := alBottom;

   WPRichText2.Height := 100;

   Splitter1.Top := 0;

 

We now assign the graphic popup menu. This menu is automatically used as contect menu for image objects.

 

   WPRichText1.GraphicPopupMenu := GraphicPopupMenu;

   WPRichText2.GraphicPopupMenu := GraphicPopupMenu;

 

Now we add the text to the body. The HTML format makes it easy to add some formatting.

 

   WPRichText1.AsString := '<div align=left><font face="verdana" size=2>WPTools Demo</font></div>';

 

We also want to show a header text with page numbering. We also use HTML with the WPTools addition tag <pagenr/>.

 

   WPRichText1.HeaderFooter.Get(wpIsHeader,

     wpraOnAllPages).RTFText.AsString :=

      '<div align=right><font face="verdana">www.WPTOOLS.de - Page <pagenr/></font></div><hr>';

 

   WPRichText2.SetZoomMode(-20);

end

 

At last we use the SetZoomMode procedure to select a certain layout and zoom mode. The SetZoomMode makes it easy to modify several properties of the editor all at once. Since it only requires one integer parameter it can be used in menus or actions which are using the 'Tag' property to store the parameter for SetZoomMode.

 

 

Hint: The TWPCustomRtfEdit can also be used in a thread save context, for example to create documents using mailmerge in a thread save context. Please check out the demo "ThreadSave"