Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

How To Call The RTF Editor

How do I pass my application's richtext for editing to the lmdrichpack pop-up dialog like a simplified wordpad/write.exe? In other words, my application needs to do what happens when in the IDE I place a TLMDRichEdit control on the form and double-click it, which opens a ShellForm.LMDRichEdit1 - TLMDRichEdit dialog with menus File | Edit | View | Insert | Format, a toolbar, the LMDRichEdit1 control, and OK/Cancel buttons. I found the form in source/: LMDRTFRichDialogForm.dfm and LMDRTFRichDialogForm.pas used by LMDRTFRichDialog.pas.

Comments

  • 8 Comments sorted by Votes Date Added
  • Just place TLMDRichEdit control on a form along with standard toolbar component. Use standard TActionList component to link toolbar buttons to actions. LMD RichPack provides a set of built-in rich edit related actions, which you can add to action list via its context menu:

    Right click|New standard action|LMDRichEdit|...

    Look also at the package demos.
  • I followed those instructions. Which action under LMDRichEdit do I pick? None of their names suggest opening an RTF editor. I selected LMDRichEditBaseEditAction1. It runs but pushing the button does nothing. I am a new Delphi developer so I may be missing even the obvious to you. I don’t want to develop an editor but use LMD’s pre-built modal editor dialog exactly as the IDE does when double-clicking a TLMDRichEdit to edit RTF content. I just want to pass RTF text to the dialog and get it back. Before I purchased the richpack my conversation with sales indicated this would be possible and straightforward as even that dialog's source is available.
  • Here is an example but appears to re-implement the editor form from scratch: demos\delphi\lmdrtf\RichEdit_Execute\
  • // This is a minimal example that sets and gets RTFText.

    unit Unit1;

    interface

    uses
      Winapi.Windows, Winapi.Messages, System.SysUtils, System.Classes,
      Vcl.Graphics, Vcl.Controls, Vcl.Forms, Vcl.Dialogs, pLMDRTFRichEditor;

    type
      TForm1 = class(TForm)
        procedure FormClick(Sender: TObject);
      public
        constructor Create(AOwner: TComponent); override;
      end;

    var
      Form1: TForm1;
      GlobalRTF: string = '{\rtf1\ansi\deff0{\fonttbl{\f0\fswiss Arial;}}\f0\fs20 Hello, \b world\b0!}';

    implementation

    {$R *.dfm}

    { TForm1 }

    constructor TForm1.Create(AOwner: TComponent);
    begin
      inherited;
      Self.OnClick := FormClick;
    end;

    procedure TForm1.FormClick(Sender: TObject);
    var
      Editor: TfrmLMDRichEditorForm;
    begin
      Editor := TfrmLMDRichEditorForm.Create(nil);
      try
        Editor.LMDRichEdit.RTFText := GlobalRTF;
        if Editor.ExecuteEx('Edit RTF', Editor.LMDRichEdit) then
          GlobalRTF := Editor.LMDRichEdit.RTFText;
      finally
        Editor.Free;
      end;
    end;

    end.
  • Yes, you need to implement required dialog from the scratch. The package provides RTF editor control and standard actions for them, but you have to design dialog's form yourself and show it with ShowModal in your application. It's a standard way in Delphi.
  • Alternatively you can copy-paste the code from demo's LMDRTFRichEditor.pas unit, or event simpler - use this unit as a whole in your project.
  • Why not use TfrmLMDRichEditorForm from the src folder? The short example I provided before seems to work but when I integrate it into a large application it appears to hang but really just opens unrefreshed. It gets painted when another windows is moved over it. Where is documentation on how to use it?
  • TfrmLMDRichEditorForm - is functionality of our desing-time package. It's not supposed to be used in customer's applications. You can use it, of course, at your own risk, or you can copy it to your project and tweak the code as needed.
Sign In or Register to comment.