home *** CD-ROM | disk | FTP | other *** search
/ Power-Programmierung / CD1.mdf / pascal / tpw / docdemos / ewndtest.pas < prev    next >
Pascal/Delphi Source File  |  1991-05-20  |  2KB  |  64 lines

  1. {************************************************}
  2. {                                                }
  3. {   Turbo Pascal for Windows                     }
  4. {   Demo program                                 }
  5. {   Copyright (c) 1991 by Borland International  }
  6. {                                                }
  7. {************************************************}
  8.  
  9. program EWndTest;
  10.  
  11. {$R EWNDTEST.RES}
  12.  
  13. uses WObjects, WinTypes, WinProcs, Strings, StdWnds;
  14.          
  15. const
  16.   cm_SendText = 399;
  17.  
  18. type
  19.   TTestApplication = object(TApplication)
  20.     procedure InitMainWindow; virtual;
  21.   end;
  22.  
  23.   PTestWindow = ^TTestWindow;
  24.   TTestWindow = object(TEditWindow)
  25.     constructor Init(AParent: PWindowsObject; ATitle: PChar);
  26.     procedure HandleSend(var Msg: TMessage);
  27.       virtual cm_First + cm_SendText;
  28.   end;
  29.  
  30. { --------TTestWindow methods------------------ }
  31. constructor TTestWindow.Init(AParent: PWindowsObject; ATitle: PChar);
  32. begin
  33.   TEditWindow.Init(AParent, ATitle);
  34.   Attr.Menu := LoadMenu(HInstance, MakeIntResource(102));
  35. end;
  36.  
  37. procedure TTestWindow.HandleSend(var Msg: TMessage);
  38. var
  39.   Lines: Integer;
  40.   Text: array[0..20] of Char;
  41. begin
  42.   Lines := Editor^.GetNumLines;
  43.   Str(Lines, Text);
  44.   StrCat(Text, ' lines sent');
  45.   MessageBox(HWindow, @Text, 'Message Sent', mb_Ok);
  46. end;
  47.  
  48. { -----------TTestApplication Methods------------ }
  49. procedure TTestApplication.InitMainWindow;
  50. begin
  51.   MainWindow := New(PTestWindow, Init(nil, 'Edit Window Tester'));
  52.   HAccTable := LoadAccelerators(HInstance, MakeIntResource(100));
  53. end;
  54.  
  55. var
  56.   TestApp : TTestApplication;
  57.  
  58. begin
  59.   TestApp.Init('EWndTest');
  60.   TestApp.Run;
  61.   TestApp.Done;
  62. end.
  63.  
  64.