Advertisement
Guest User

Untitled

a guest
Jul 8th, 2016
254
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.54 KB | None | 0 0
  1. program test3;
  2.  
  3. uses App, Objects, Menus, Drivers, Views, Dialogs, MsgBox, StdDlg;
  4.  
  5. type
  6. TMyApp = object(TApplication)
  7. procedure InitMenuBar; virtual;
  8. procedure HandleEvent(var Event: TEvent); virtual;
  9. end;
  10.  
  11. procedure TMyApp.InitMenuBar;
  12. var
  13. R: TRect;
  14. pFileMenu, pHelpMenu : PMenuItem;
  15. begin
  16. GetExtent(R);
  17. R.B.Y := R.A.Y + 1;
  18. pHelpMenu := NewSubMenu('~H~elp', hcNoContext, NewMenu(
  19. NewItem('~A~bout', '', 0, cmHelp, hcNoContext, nil)),
  20. nil);
  21. pFileMenu := NewSubMenu('~F~ile', hcNoContext, NewMenu(
  22. NewItem('~O~pen', 'F2', kbF2, cmOpen, hcNoContext,
  23. NewItem('~C~lose', 'F3', kbF3, cmClose, hcNoContext,
  24. NewLine(
  25. NewItem('E~x~it', 'Alt-X', kbAltX, cmQuit, hcNoContext, nil))))),
  26. pHelpMenu);
  27. MenuBar := new (PMenuBar, Init(R,
  28. NewMenu(pFileMenu)));
  29. end;
  30.  
  31. procedure TMyApp.HandleEvent(var Event: TEvent);
  32. var
  33. FileName: String;
  34. result : integer;
  35. pOpen : PFileDialog;
  36. begin
  37. inherited HandleEvent(Event);
  38. if Event.What = evCommand then
  39. begin
  40. if Event.Command = cmHelp then
  41. begin
  42. MessageBox('About:'+#13#10+'This is my test app'+#13#10+'Alan Ward (C) 2016',
  43. nil, mfInformation or mfOKButton);
  44. end;
  45. if Event.Command = cmOpen then
  46. begin
  47. pOpen := New(PFileDialog, Init('*.txt', 'Open', 'File ~N~ame',
  48. fdOpenButton, hcNoContext));
  49. result := ExecuteDialog (pOpen, @FileName);
  50. end;
  51. end;
  52. end;
  53.  
  54. var MyApp : TMyApp;
  55.  
  56. begin
  57. MyApp.Init;
  58. MyApp.Run;
  59. MyApp.Done;
  60. end.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement