{ Test of the unit wRichTextFrame0.pp
  With it, having a simple editor is really simple.
  --------------------------------------------}
program tEx035;

// To tell FreePascal that the application is a Graphical User Interface
// i.e. is running in windows, not in text mode.
{$APPTYPE GUI}

Uses
  Windows
 ,wApplication0
 ,wWindow0
 ,wRichTextFrame0
 ,wDebug0;

type
  PMyWindow = ^TMyWindow;
  TMyWindow = object(TWindow)
  //"""""""""""""""""""""""""
  oRichEditFrame   : TRichTextFrame0;   // RichEditFrame control contained in the window

  constructor Init(strWinTitlePrm:ShortString);

  procedure WinCreate(strWinClass:ShortString); virtual;
  // Set  strWinClass=''  to use the class defined in the application object

  function WMCommand(wPar:WPARAM; lPar:LPARAM):LRESULT; virtual;
  // Handles the menu messages
  end; // TMyWindow = object(TWindow)

constructor TMyWindow.Init(strWinTitlePrm:ShortString);
//=====================================================
begin
inherited Init(strWinTitlePrm);

// To have a Rich Text control, you must create the object, and
// later the corresponding window.
// The third thing to do will be to send it the menu messages.
oRichEditFrame.Init(@Self);

// This line is all what is needed to have a status line.
new(poStatusLine, Init(@Self));
end;  // TMyWindow.Init

procedure TMyWindow.WinCreate(strWinClass:ShortString);
//=====================================================
// Create the window, and insert an edit box and a status line in it.
begin
// here strWinClass=''.
inherited WinCreate(strWinClass);

// Tells the richEdit that there is a status line
oRichEditFrame.poStatusLine:=poStatusLine;

// Size = the part of client area, just to see how it looks like
oRichEditFrame.vXSizeRel:=0.7;  // if you don't specify, it is set automatically
oRichEditFrame.vYSizeRel:=0.7;  // but for clarity, it is better to specify.

// Just to test, center the Rich Edit control in the window
// 0.15 = (1.0.7) / 2
oRichEditFrame.vXPosRel:=0.15;
oRichEditFrame.vYPosRel:=0.15;

// Create the Rich Text Window.
oRichEditFrame.CtrlCreate;
end;  // TMyWindow.WinCreate

function TMyWindow.WMCommand(wPar:WPARAM; lPar:LPARAM):LRESULT;
//=============================================================
// Handles the menu messages
begin
WMCommand := 0; // Default return value when processing a message

if (lPar <> 0) then begin
   // call the parent WMCommand method.
   WMCommand:=inherited WMCommand(wPar, lPar);
   exit;
   end;

// for the menus,  lPar = 0
//=========================

// Let the RichEditFrame control interpret the message.
// It return TRUE, if it did, FALSE if the message was not for him.
// Typically, messages with  wNrMenu > 30000 are for the library, and
// should not be treated here.
if (oRichEditFrame.WMCommand(LoWord(wPar))) then exit;

// if not treated by the RichText control, do the library default treatement.
WMCommand:=inherited WMCommand(wPar, lPar);
end;  // TMyWindow.WMCommand

var
  oApp        : TApplication;
  poMyMainWin : PMyWindow;

Begin // MAIN ******
// Name under which the main window is registered. Spaces are not allowed
oApp.Init('Example035');

// Creation of the main window
new(poMyMainWin, Init('tEx035.  Test the wDialogCreator2.pp unit'));

// Change the color of the background of the main window.
// to have the desktop color, just for beauty.
oApp.WindowClass.hbrBackground :=GetStockObject(GRAY_BRUSH); // COLOR_BACKGROUND+1;

// The App.WindowClass can be modified here, if wanted. (Not usual)
oApp.Run;
oApp.Done;  // The main window object is disposed here.
End.

