{ Example of a text window, with a toolbar.
  uses  wWindowText0.pp  and  tToolBar0.pp
  Short Example.
  --------------------------------------------}
program tEx053;

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

Uses
  wApplication0
 ,wWindowText0 // To write text in an independent window
 ,wToolBar0
// ,wMenus0
// ,wWindowBase0
 ,wDialogCreatorLOW2
 ,wErrors0
// ,wGlobals2
 ,wDebug0;
// ,Windows;

type
  PMyWindow = ^TMyWindow;
  TMyWindow = object(TWindowText)
  //"""""""""""""""""""""""""""""
  poToolBar : PToolBar;
  // Remember the toolbar, to destroy it when a new one is wanted.

  constructor Init(strWinTitlePrm:ShortString);
  destructor Done; virtual;

  procedure MenuCreate; virtual;
  // Creates the menu

  procedure WinCreate(strWinClass:ShortString); virtual;
  // When creating the window, we ask to show the dialog box, not the window

//  function WMCommand(wPar:WPARAM; lPar:LPARAM):LRESULT; virtual;
  // Handles the menu messages

//  function WindowProc(hWindow:HWND; wMsg:UINT; wPar:WPARAM; lPar:LPARAM):LRESULT; virtual;
  end; // TMyWindow = object(TWindow)

// var glnNotUsed : integer; // To avoid an error in the DevPascal 1.9 environment
var
  oApp        : TApplication;
  poMyMainWin : PMyWindow;

//******************************************************************
// TMyWindow = object(TWindow)
//******************************************************************

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

poToolBar:=NIL;

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

destructor TMyWindow.Done;
//========================
begin
// if (poToolBar <> NIL) then dispose(poToolBar, Done); done by the parent
inherited Done;
end;  // TMyWindow.Done

procedure TMyWindow.MenuCreate;
//=============================
// Create the menu, override the default method of  TWindowText
begin
new(poMenu, Init(@Self));
hMenuWin:=poMenu^.MenuMsgCreate(10000);
end;  // TMyWindow.MenuCreate

procedure TMyWindow.WinCreate(strWinClass:ShortString);
//=====================================================
Begin
inherited WinCreate(strWinClass);

poToolBar:=PToolBar(ToolBarCreateMSG(11199, @self));

// The size of the RichEditFrame must be shorten
oRichEditFrame.nYSizePix:=oRichEditFrame.nYSizePix - poToolBar^.nYSizePix;
oRichEditFrame.nYPosPix := poToolBar^.nYSizePix;

// Repaint the RichEditFrame
oRichEditFrame.NotifyParentResize(TRUE);
end;  // TMyWindow.WinCreate

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

// Creation of the main window
new(poMyMainWin, Init('tEx053.  A text window with a toolbar'));

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

