home *** CD-ROM | disk | FTP | other *** search
/ Mega Top 1 / os2_top1.zip / os2_top1 / APPS / PROG / PASCAL / SPEED2 / SAMPLES / PMTOOL / PMTOOL.PAS < prev    next >
Pascal/Delphi Source File  |  1994-10-06  |  4KB  |  449 lines

  1. PROGRAM PMTool;
  2.  
  3.  
  4. {***************************************************************************
  5. *                                                                          *
  6. *                Speed-Pascal/2 Sample program "PMTool"                    *
  7. *                                                                          *
  8. *           (C) 1993,94 Rene Nürnberger. All rights reserved.              *
  9. *                                                                          *
  10. *                                                                          *
  11. *  This program can be used as a template for your own MDI                 *
  12. *  Applications. It's equal to PmMDI but provides additionaly a Toolbar    *
  13. *  and a Statusline.                                                       *
  14. *                                                                          *
  15. ****************************************************************************}
  16.  
  17.  
  18. USES Api,PmObject,Crt,PmTypes;    {bind Units used}
  19.  
  20.  
  21. RESOURCE PMTOOL;  {bind external Resources}
  22.  
  23. TYPE
  24.      TMyApplication=OBJECT(TMDIApplication)
  25.                 CONSTRUCTOR Init;
  26.                 DESTRUCTOR Done;
  27.                 FUNCTION HandleEvent(Win:HWND;Msg:ULONG;Para1,Para2:POINTER;
  28.                                      VAR Handled:BOOLEAN):ULONG:VIRTUAL;
  29.                 PROCEDURE AppCreateNotify(AppFrWin,AppWin:HWND):VIRTUAL;
  30.      END;
  31.  
  32. CONST
  33.      CM_NEWCHILD=500;
  34.  
  35. VAR MyApp:TMyApplication;
  36.  
  37.  
  38.  
  39. {define Methods}
  40.  
  41. CONSTRUCTOR TMyApplication.Init;
  42. BEGIN
  43.      Inherited.Init;
  44.      InsertResources(TRUE,FALSE,TRUE); {Application has menu and icon}
  45. END;
  46.  
  47.  
  48. DESTRUCTOR TMyApplication.Done;
  49. BEGIN
  50. END;
  51.  
  52. {Virtual Method HandleEvent. All messages come here first}
  53. FUNCTION TMyApplication.HandleEvent(Win:HWND;Msg:ULONG;Para1,Para2:POINTER;
  54.                                     VAR Handled:BOOLEAN):ULONG;
  55. VAR r:LONGWORD;
  56.     H:BOOLEAN;
  57.     Command:WORD;
  58.     fr:ULONG;
  59.     Frame:HWND;
  60. BEGIN
  61.      H:=TRUE;
  62.      r:=Inherited.HandleEvent(Win,Msg,Para1,Para2,Handled);
  63.      CASE Msg OF
  64.          WM_COMMAND:
  65.          BEGIN
  66.               Command:=WORD(Para1);
  67.               CASE Command OF
  68.                   CM_NEWCHILD:
  69.                   BEGIN
  70.                        fr:=FCF_ICON; {MDI window has an icon}
  71.                        Frame:=CreateMDIChild(1001,'MDI Child',NIL,fr,
  72.                                              CLR_BLACK,CLR_CYAN);
  73.                   END;
  74.               END; {case}
  75.          END;
  76.          ELSE IF not handled THEN H:=FALSE;
  77.      END; {Case}
  78.      Handled:=H;
  79.      HandleEvent:=r;
  80. END;
  81.  
  82. {Virtual Method AppCreateNotify. Called when creating the main window}
  83. PROCEDURE TMyApplication.AppCreateNotify(AppFrWin,AppWin:HWND);
  84. BEGIN
  85.      Inherited.AppCreateNotify(AppFrWin,AppWin);
  86.      WinSetWindowPos(SWP_SPEED,400,500,50,50,HWND_TOP,AppFrWin);
  87.      CreateToolBar(30);
  88.      ToolBarInsertButton(CM_NEWCHILD,2000,10,3,28,24);
  89.      ToolBarInsertButton(CM_TILE,2001,45,3,28,24);
  90.      ToolBarInsertButton(CM_CASCADE,2002,80,3,28,24);
  91.      CreateStatusBar(30);
  92.      StatusBarInsertItem(1,10,3,620,16);
  93.      InsertMenuHelp(1,65535,'',-1);  {Default menu help}
  94.      InsertMenuHelp(1,CM_NEWCHILD,'Create a new MDI child window',-1);
  95.      InsertMenuHelp(1,CM_CLOSE,'Close the active MDI child window',-1);
  96.      InsertMenuHelp(1,CM_CLOSEALL,'Close all MDI child windows',-1);
  97.      InsertMenuHelp(1,CM_TILE,'Arrange MDI child windows by tiling',-1);
  98.      InsertMenuHelp(1,CM_CASCADE,'Arrange MDI child windows by cascading',-1);
  99.      InsertMenuHelp(1,CM_NEXT,'Display next MDI child window',-1);
  100. END;
  101.  
  102.  
  103. BEGIN  {Main}
  104.      MyApp.Init;
  105.      MyApp.Run(1000,'PMTool Sample Application',CLR_DARKGRAY,CLR_WHITE);
  106.      MyApp.Done;
  107. END.
  108.  
  109.  
  110.  
  111.  
  112.  
  113.  
  114.  
  115.  
  116.  
  117.  
  118.  
  119.  
  120.  
  121.  
  122.  
  123.  
  124.  
  125.  
  126.  
  127.  
  128.  
  129.  
  130.  
  131.  
  132.  
  133.  
  134.  
  135.  
  136.  
  137.  
  138.  
  139.  
  140.  
  141.  
  142.  
  143.  
  144.  
  145.  
  146.  
  147.  
  148.  
  149.  
  150.  
  151.  
  152.  
  153.  
  154.  
  155.  
  156.  
  157.  
  158.  
  159.  
  160.  
  161.  
  162.  
  163.  
  164.  
  165.  
  166.  
  167.  
  168.  
  169.  
  170.  
  171.  
  172.  
  173.  
  174.  
  175.  
  176.  
  177.  
  178.  
  179.  
  180.  
  181.  
  182.  
  183.  
  184.  
  185.  
  186.  
  187.  
  188.  
  189.  
  190.  
  191.  
  192.  
  193.  
  194.  
  195.  
  196.  
  197.  
  198.  
  199.  
  200.  
  201.  
  202.  
  203.  
  204.  
  205.  
  206.  
  207.  
  208.  
  209.  
  210.  
  211.  
  212.  
  213.  
  214.  
  215.  
  216.  
  217.  
  218.  
  219.  
  220.  
  221.  
  222.  
  223.  
  224.  
  225.  
  226.  
  227.  
  228.  
  229.  
  230.  
  231.  
  232.  
  233.  
  234.  
  235.  
  236.  
  237.  
  238.  
  239.  
  240.  
  241.  
  242.  
  243.  
  244.  
  245.  
  246.  
  247.  
  248.  
  249.  
  250.  
  251.  
  252.  
  253.  
  254.  
  255.  
  256.  
  257.  
  258.  
  259.  
  260.  
  261.  
  262.  
  263.  
  264.  
  265.  
  266.  
  267.  
  268.  
  269.  
  270.  
  271.  
  272.  
  273.  
  274.  
  275.  
  276.  
  277.  
  278.  
  279.  
  280.  
  281.  
  282.  
  283.  
  284.  
  285.  
  286.  
  287.  
  288.  
  289.  
  290.  
  291.  
  292.  
  293.  
  294.  
  295.  
  296.  
  297.  
  298.  
  299.  
  300.  
  301.  
  302.  
  303.  
  304.  
  305.  
  306.  
  307.  
  308.  
  309.  
  310.  
  311.  
  312.  
  313.  
  314.  
  315.  
  316.  
  317.  
  318.  
  319.  
  320.  
  321.  
  322.  
  323.  
  324.  
  325.  
  326.  
  327.  
  328.  
  329.  
  330.  
  331.  
  332.  
  333.  
  334.  
  335.  
  336.  
  337.  
  338.  
  339.  
  340.  
  341.  
  342.  
  343.  
  344.  
  345.  
  346.  
  347.  
  348.  
  349.  
  350.  
  351.  
  352.  
  353.  
  354.  
  355.  
  356.  
  357.  
  358.  
  359.  
  360.  
  361.  
  362.  
  363.  
  364.  
  365.  
  366.  
  367.  
  368.  
  369.  
  370.  
  371.  
  372.  
  373.  
  374.  
  375.  
  376.  
  377.  
  378.  
  379.  
  380.  
  381.  
  382.  
  383.  
  384.  
  385.  
  386.  
  387.  
  388.  
  389.  
  390.  
  391.  
  392.  
  393.  
  394.  
  395.  
  396.  
  397.  
  398.  
  399.  
  400.  
  401.  
  402.  
  403.  
  404.  
  405.  
  406.  
  407.  
  408.  
  409.  
  410.  
  411.  
  412.  
  413.  
  414.  
  415.  
  416.  
  417.  
  418.  
  419.  
  420.  
  421.  
  422.  
  423.  
  424.  
  425.  
  426.  
  427.  
  428.  
  429.  
  430.  
  431.  
  432.  
  433.  
  434.  
  435.  
  436.  
  437.  
  438.  
  439.  
  440.  
  441.  
  442.