{ Test of the unit wPopupWindow0.pp
  --------------------------------------------}
program tEx037;

// 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
 ,wWindow0
 ,wPopupWindow0
 ,wDebug0
 ,Windows;

type
  PMyWindow = ^TMyWindow;
  TMyWindow = object(TWindow)
  //"""""""""""""""""""""""""
  constructor Init(strWinTitlePrm:ShortString);
  procedure WMPaint;
  procedure WMLButtonDown(wXPos,wYPos:word);
//  procedure WMRButtonDown(wXPos,wYPos:word); not used
  function WindowProc(hWindow:HWND; wMsg:UINT; wPar:WPARAM; lPar:LPARAM):LRESULT; virtual;
  end; // TMyWindow = object(TWindow0)

// var nNotUsed : integer; // only to avoid an error message while compliling in DevPascal 1.9

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

procedure TMyWindow.WMPaint;
//==========================
Var
  rRec        : rect;
  dc          : hdc;
  ps          : paintstruct;

begin
dc:=BeginPaint(hWin, @ps);
GetClientRect(hWin, @rRec);
DrawText( dc, 'tEx037.  Test the wPopupWindow0.pp unit',-1,@rRec,
          DT_SINGLELINE or DT_CENTER or DT_VCENTER);
EndPaint(hWin, ps);
end;  // TMyWindow.WMPaint

procedure TMyWindow.WMLButtonDown(wXPos,wYPos:word);
//==================================================
var
  poPopup : PPopupWindow;
begin
wXPos:=wXPos;  wYPos:=wYPos;  // to avoid hints
new(poPopup, Init(@Self));
poPopup^.PopupWindowCreate(20000);

// dispose(poPopup, Done); is done automatically.
end;  // TMyWindow.WMLButtonDown

function TMyWindow.WindowProc(hWindow:HWND; wMsg:UINT; wPar:WPARAM; lPar:LPARAM):LRESULT;
//=======================================================================================
// All window messages are send here.

Begin
WindowProc := 0; // Default return value when processing a message

Case wMsg Of
   WM_paint : WMPaint;
   WM_LButtonDown : WMLButtonDown(LoWord(lPar), HiWord(lPar));
//   WM_RButtonDown : WMRButtonDown(LoWord(lPar), HiWord(lPar)); not used

   else begin // Case wMsg Of
      // Default processing of the messages.
      WindowProc:=inherited WindowProc(hWindow, wMsg, wPar, lPar);
      end; // Case wMsg Of
   End; // Case wMsg Of

End;  // TMyWindow.WindowProc

var
  oApp        : TApplication;
  poMyMainWin : PMyWindow;

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

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

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

