home *** CD-ROM | disk | FTP | other *** search
/ io Programmo 10 / ioProg_10.iso / soft / optima / samples.z / Form_Test.wxf < prev    next >
Encoding:
Text File  |  1996-09-16  |  23.5 KB  |  881 lines

  1. Save Format v1.3
  2. @begin Form "Form_Test"
  3.  Exported 0;
  4.  
  5.  @begin Object "WModelessDialog"
  6.   WSDlgBorder 1;
  7.   WSDlgFrame 1;
  8.   WSSysMenu 1;
  9.   WSSystemMenu 1;
  10.   WSMinimizeBox 1;
  11.   WSGroup 1;
  12.   WSVisible 1;
  13.   Font "8.MS Sans Serif";
  14.   StatusBar "StatusBarAtBottom";
  15.   Icon "WIcon( WResourceID( ICON_01 ) )";
  16.   FormPositionType "Centered";
  17.   FormAbsTop "111";
  18.   FormAbsLeft "5";
  19.   FDXStructName "Form1FDXStruct";
  20.   Text "Menu Events";
  21.   @begin Event "Create"
  22.    GencodeSrcLine 222;
  23.    FunctionName "Form_Test::Form_Test_Create";
  24.   @end;
  25.   @begin Event "InitMenu"
  26.    GencodeSrcLine 335;
  27.    FunctionName "Form_Test::Form_Test_InitMenu";
  28.   @end;
  29.   @begin Event "InitPopupMenu"
  30.    GencodeSrcLine 342;
  31.    FunctionName "Form_Test::Form_Test_InitPopupMenu";
  32.   @end;
  33.   @begin Event "MenuSelect"
  34.    GencodeSrcLine 349;
  35.    FunctionName "Form_Test::Form_Test_MenuSelect";
  36.   @end;
  37.   @begin UserFunction "Form_Test()"
  38.    Compiler 1;
  39.    GencodeSrcLine 365;
  40.    FunctionName "Form_Test::Form_Test()";
  41.   @end;
  42.   @begin UserFunction "~Form_Test()"
  43.    Compiler 1;
  44.    GencodeSrcLine 369;
  45.    FunctionName "Form_Test::~Form_Test()";
  46.   @end;
  47.   @begin UserFunction "showEvent( WString event, WString object )"
  48.    Private 1;
  49.    GencodeSrcLine 373;
  50.    FunctionName "Form_Test::showEvent( WString event, WString object )";
  51.   @end;
  52.   @begin UserFunction "Prototype for showEvent( WString event, WString object )"
  53.    Private 1;
  54.    GencodeSrcLine 106;
  55.    FunctionName "Form_Test::Prototype for showEvent( WString event, WString object )";
  56.   @end;
  57.   @begin UserFunction "setEvents( WMenuObject * menu, WString hint )"
  58.    Private 1;
  59.    GencodeSrcLine 384;
  60.    FunctionName "Form_Test::setEvents( WMenuObject * menu, WString hint )";
  61.   @end;
  62.   @begin UserFunction "Prototype for setEvents( WMenuObject * menu, WString hint )"
  63.    Private 1;
  64.    GencodeSrcLine 108;
  65.    FunctionName "Form_Test::Prototype for setEvents( WMenuObject * menu, WString hint )";
  66.   @end;
  67.   @begin UserFunction "menu_Select( WObject * source, WMessageEventData * event )"
  68.    Private 1;
  69.    GencodeSrcLine 392;
  70.    FunctionName "Form_Test::menu_Select( WObject * source, WMessageEventData * event )";
  71.   @end;
  72.   @begin UserFunction "Prototype for menu_Select( WObject * source, WMessageEventData * event )"
  73.    Private 1;
  74.    GencodeSrcLine 110;
  75.    FunctionName "Form_Test::Prototype for menu_Select( WObject * source, WMessageEventData * event )";
  76.   @end;
  77.   @begin UserFunction "menu_Close( WObject * source, WMessageEventData * event )"
  78.    Private 1;
  79.    GencodeSrcLine 408;
  80.    FunctionName "Form_Test::menu_Close( WObject * source, WMessageEventData * event )";
  81.   @end;
  82.   @begin UserFunction "Prototype for menu_Close( WObject * source, WMessageEventData * event )"
  83.    Private 1;
  84.    GencodeSrcLine 112;
  85.    FunctionName "Form_Test::Prototype for menu_Close( WObject * source, WMessageEventData * event )";
  86.   @end;
  87.   @begin UserFunction "menu_InitMenu( WObject * source, WMessageEventData * event )"
  88.    Private 1;
  89.    GencodeSrcLine 423;
  90.    FunctionName "Form_Test::menu_InitMenu( WObject * source, WMessageEventData * event )";
  91.   @end;
  92.   @begin UserFunction "Prototype for menu_InitMenu( WObject * source, WMessageEventData * event )"
  93.    Private 1;
  94.    GencodeSrcLine 114;
  95.    FunctionName "Form_Test::Prototype for menu_InitMenu( WObject * source, WMessageEventData * event )";
  96.   @end;
  97.   @begin UserFunction "menu_InitPopupMenu( WObject * source, WMessageEventData * event )"
  98.    Private 1;
  99.    GencodeSrcLine 434;
  100.    FunctionName "Form_Test::menu_InitPopupMenu( WObject * source, WMessageEventData * event )";
  101.   @end;
  102.   @begin UserFunction "Prototype for menu_InitPopupMenu( WObject * source, WMessageEventData * event )"
  103.    Private 1;
  104.    GencodeSrcLine 116;
  105.    FunctionName "Form_Test::Prototype for menu_InitPopupMenu( WObject * source, WMessageEventData * event )";
  106.   @end;
  107.   @begin UserFunction "findMenu( WMessageEventData * event )"
  108.    Private 1;
  109.    GencodeSrcLine 451;
  110.    FunctionName "Form_Test::findMenu( WMessageEventData * event )";
  111.   @end;
  112.   @begin UserFunction "Prototype for findMenu( WMessageEventData * event )"
  113.    Private 1;
  114.    GencodeSrcLine 118;
  115.    FunctionName "Form_Test::Prototype for findMenu( WMessageEventData * event )";
  116.   @end;
  117.   ResID 101;
  118.   DesignName Form_Test;
  119.   TabIndex 0;
  120.   HasPopupMenu popup_Main;
  121.   DesignRect 5,111,251,253;
  122.  @end;
  123.  
  124.  @begin Menu
  125.   ItemCount 0;
  126.   DesignName "menu_Main";
  127.   IsDefault 1;
  128.   ResID 101;
  129.   DesignRect 190,180,19,18;
  130.   @begin Event "InitMenu"
  131.    GencodeSrcLine 464;
  132.    FunctionName "Form_Test::menu_Main_InitMenu";
  133.   @end;
  134.   @begin Popup
  135.    Name "Main";
  136.    Caption "&Main";
  137.    NegotiatePosition None;
  138.    @begin Item
  139.     Name "MainOne";
  140.     Caption "&One";
  141.     ResID 1001;
  142.     NegotiatePosition None;
  143.    @end;
  144.    @begin Item
  145.     Name "MainTwo";
  146.     Caption "&Two";
  147.     ResID 1002;
  148.     NegotiatePosition None;
  149.    @end;
  150.    @begin Popup
  151.     Name "MainCascade";
  152.     Caption "&Cascade";
  153.     NegotiatePosition None;
  154.     @begin Item
  155.      Name "MainCascadeOne";
  156.      Caption "&One";
  157.      ResID 1004;
  158.      NegotiatePosition None;
  159.     @end;
  160.     @begin Item
  161.      Name "MainCascadeTwo";
  162.      Caption "&Two";
  163.      ResID 1005;
  164.      NegotiatePosition None;
  165.     @end;
  166.     @begin Popup
  167.      Name "MainCascadeCascade";
  168.      Caption "&Cascade";
  169.      NegotiatePosition None;
  170.      @begin Item
  171.       Name "MainCascadeCascadeOne";
  172.       Caption "&One";
  173.       ResID 1007;
  174.       NegotiatePosition None;
  175.      @end;
  176.      @begin Item
  177.       Name "MainCascadeCascadeTwo";
  178.       Caption "&Two";
  179.       ResID 1008;
  180.       NegotiatePosition None;
  181.      @end;
  182.     @end;
  183.    @end;
  184.   @end;
  185.  @end;
  186.  
  187.  @begin PopupMenu
  188.   ItemCount 0;
  189.   DesignName "popup_Main";
  190.   IsDefault 1;
  191.   ResID 102;
  192.   DesignRect 215,180,19,18;
  193.   @begin Event "Close"
  194.    GencodeSrcLine 472;
  195.    FunctionName "Form_Test::popup_Main_Close";
  196.   @end;
  197.   @begin Event "InitMenu"
  198.    GencodeSrcLine 484;
  199.    FunctionName "Form_Test::popup_Main_InitMenu";
  200.   @end;
  201.   @begin Event "InitPopupMenu"
  202.    GencodeSrcLine 492;
  203.    FunctionName "Form_Test::popup_Main_InitPopupMenu";
  204.   @end;
  205.   @begin Event "Select"
  206.    GencodeSrcLine 500;
  207.    FunctionName "Form_Test::popup_Main_Select";
  208.   @end;
  209.   @begin Item
  210.    Name "One";
  211.    Caption "One";
  212.    ResID 10000;
  213.    NegotiatePosition None;
  214.   @end;
  215.   @begin Item
  216.    Name "Two";
  217.    Caption "Two";
  218.    ResID 10001;
  219.    NegotiatePosition None;
  220.   @end;
  221.   @begin Popup
  222.    Name "Cascade";
  223.    Caption "Cascade";
  224.    NegotiatePosition None;
  225.    @begin Item
  226.     Name "CascadeOne";
  227.     Caption "One";
  228.     ResID 10003;
  229.     NegotiatePosition None;
  230.    @end;
  231.    @begin Item
  232.     Name "CascadeTwo";
  233.     Caption "Two";
  234.     ResID 10004;
  235.     NegotiatePosition None;
  236.    @end;
  237.    @begin Popup
  238.     Name "CascadeCascade";
  239.     Caption "Cascade";
  240.     NegotiatePosition None;
  241.     @begin Item
  242.      Name "CascadeCascadeOne";
  243.      Caption "One";
  244.      ResID 10006;
  245.      NegotiatePosition None;
  246.     @end;
  247.     @begin Item
  248.      Name "CascadeCascadeTwo";
  249.      Caption "Two";
  250.      ResID 10007;
  251.      NegotiatePosition None;
  252.     @end;
  253.    @end;
  254.   @end;
  255.  @end;
  256.  
  257.  @begin Object "WListBox"
  258.   WLBSNotify 1;
  259.   WLBSHasStrings 1;
  260.   WLBSNoIntegralHeight 1;
  261.   WCCSTop 1;
  262.   WCCSNoDivider 1;
  263.   WSVScroll 1;
  264.   WSBorder 1;
  265.   WSChild 1;
  266.   WSExClientEdge 1;
  267.   WSVisible 1;
  268.   FDXFieldName "lb_1_data";
  269.   FDXFieldType "WInt";
  270.   ResID 103;
  271.   DesignName lb_EventList;
  272.   TabIndex 2;
  273.   DesignRect 15,90,215,85;
  274.   @begin ComponentData "lb_EventList"
  275.   @end;
  276.  @end;
  277.  
  278.  @begin Object "WCommandButton"
  279.   WSChild 1;
  280.   WSMaximizeBox 1;
  281.   WSTabStop 1;
  282.   WSVisible 1;
  283.   Pressed "0";
  284.   FDXFieldName "cb_1_data";
  285.   FDXFieldType "WBool";
  286.   Text "&Clear";
  287.   @begin Event "Click"
  288.    GencodeSrcLine 508;
  289.    FunctionName "Form_Test::cb_Clear_Click";
  290.   @end;
  291.   ResID 104;
  292.   DesignName cb_Clear;
  293.   TabIndex 3;
  294.   DesignRect 15,180,40,16;
  295.  @end;
  296.  
  297.  @begin Object "WLabel"
  298.   WSSNotify 1;
  299.   WSChild 1;
  300.   WSExClientEdge 1;
  301.   WSVisible 1;
  302.   Text "Click here with the right mouse button to activate the form's popup menu.";
  303.   ResID 105;
  304.   DesignName label_1;
  305.   TabIndex 4;
  306.   DesignRect 10,40,110,30;
  307.  @end;
  308.  
  309.  @begin Object "WListBox"
  310.   WLBSNotify 1;
  311.   WLBSHasStrings 1;
  312.   WLBSNoIntegralHeight 1;
  313.   WCCSTop 1;
  314.   WCCSNoDivider 1;
  315.   WSVScroll 1;
  316.   WSBorder 1;
  317.   WSChild 1;
  318.   WSExClientEdge 1;
  319.   WSVisible 1;
  320.   FDXFieldName "lb_1_data";
  321.   FDXFieldType "WInt";
  322.   @begin Event "InitMenu"
  323.    GencodeSrcLine 517;
  324.    FunctionName "Form_Test::lb_Test_InitMenu";
  325.   @end;
  326.   @begin Event "InitPopupMenu"
  327.    GencodeSrcLine 525;
  328.    FunctionName "Form_Test::lb_Test_InitPopupMenu";
  329.   @end;
  330.   ResID 106;
  331.   DesignName lb_Test;
  332.   TabIndex 5;
  333.   HasPopupMenu popup_Main;
  334.   DesignRect 125,40,110,30;
  335.   @begin ComponentData "lb_Test"
  336. @begin-code ListBoxInitialText
  337.  
  338. Click here with the right mouse
  339. button to activate the list box's
  340. popup menu.
  341.  
  342. @end-code;
  343.   @end;
  344.  @end;
  345.  
  346.  @begin Object "WLabel"
  347.   WSSNotify 1;
  348.   WSChild 1;
  349.   WSExClientEdge 1;
  350.   WSVisible 1;
  351.   Text "This sample shows the events generated as you navigate through menus.  See the form's Create event for additional information.";
  352.   ResID 107;
  353.   DesignName label_Comments;
  354.   TabIndex 6;
  355.   DesignRect 10,10,225,25;
  356.  @end;
  357.  
  358.  @begin Object "WGroupBox"
  359.   WCCSTop 1;
  360.   WCCSNoMoveY 1;
  361.   WCCSBottom 1;
  362.   WCCSNoResize 1;
  363.   WSChild 1;
  364.   WSVisible 1;
  365.   Text "Events";
  366.   ResID 108;
  367.   DesignName groupb_1;
  368.   TabIndex 7;
  369.   DesignRect 10,80,225,125;
  370.  @end;
  371.  
  372.  @begin HPPPrefixBlock
  373. @begin-code HPPPrefix
  374.  
  375. // Declarations added here will be included at the top of the .HPP file
  376.  
  377. @end-code;
  378.   GencodeSrcLine 10;
  379.  @end;
  380.  
  381.  @begin CPPPrefixBlock
  382. @begin-code CPPPrefix
  383.  
  384. // Code added here will be included at the top of the .CPP file
  385.  
  386. //  Include definitions for resources.
  387. #include "WRes.h"
  388.  
  389. @end-code;
  390.   GencodeSrcLine 10;
  391.  @end;
  392.  
  393.  @begin ClassContentsBlock
  394. @begin-code ClassContents
  395.  
  396.     public:
  397.         // add your public instance data here
  398.     private:
  399.         // add your private instance data here
  400.         WInt                _count;
  401.         
  402.     protected:
  403.         // add your protected instance data here
  404.  
  405. @end-code;
  406.   GencodeSrcLine 98;
  407.  @end;
  408.  
  409. @begin-code GeneratedClassContents
  410.  
  411.         Form_Test();
  412.         ~Form_Test();
  413.  
  414. @end-code;
  415.  
  416. @begin-code Code "Form_Test::Form_Test()"
  417.  
  418. @@CLASSNAME@::@CLASSNAME@()
  419. {
  420.     
  421. }
  422.  
  423. @end-code;
  424.  
  425. @begin-code Code "Form_Test::~Form_Test()"
  426.  
  427. @@CLASSNAME@::~@CLASSNAME@()
  428. {
  429.     
  430. }
  431.  
  432. @end-code;
  433.  
  434. @begin-code Code "Form_Test::showEvent( WString event, WString object )"
  435.  
  436. void @CLASSNAME@::showEvent( WString event, WString object )
  437. {
  438.     WInt                    index;
  439.     WString                 text;
  440.  
  441.     _count++;
  442.     text.Sprintf( "%2d %s on %s", _count, event.GetText(), object.GetText() );
  443.     index = lb_EventList->Add( text, -1, NULL );
  444.     lb_EventList->SetSelected( index );
  445.  
  446. }
  447.  
  448. @end-code;
  449.  
  450. @begin-code Code "Form_Test::Prototype for showEvent( WString event, WString object )"
  451.  
  452.     private:
  453.         void showEvent( WString event, WString object );
  454.  
  455. @end-code;
  456.  
  457. @begin-code Code "Form_Test::setEvents( WMenuObject * menu, WString hint )"
  458.  
  459. void @CLASSNAME@::setEvents( WMenuObject * menu, WString hint )
  460. {
  461.     menu->SetHintText( hint );
  462.     menu->SetEventHandler( WInitMenuEvent, this, (WEventHandler)menu_InitMenu );
  463.     menu->SetEventHandler( WInitPopupMenuEvent, this, (WEventHandler)menu_InitPopupMenu );
  464.     menu->SetEventHandler( WCloseEvent, this, (WEventHandler)menu_Close );
  465.     menu->SetEventHandler( WSelectEvent, this, (WEventHandler)menu_Select );
  466. }
  467.  
  468. @end-code;
  469.  
  470. @begin-code Code "Form_Test::Prototype for setEvents( WMenuObject * menu, WString hint )"
  471.  
  472.     private:
  473.         void setEvents( WMenuObject * menu, WString hint );
  474.  
  475. @end-code;
  476.  
  477. @begin-code Code "Form_Test::menu_Select( WObject * source, WMessageEventData * event )"
  478.  
  479. WBool @CLASSNAME@::menu_Select( WObject * source, WMessageEventData * event )
  480. {
  481.     WString             hint;
  482.     WMenuObject *       menu;
  483.     WStatusBar *        status;
  484.     WString             text;
  485.     
  486.     menu = (WMenuObject *)source;
  487.     hint = menu->GetHintText();
  488.     text.Sprintf( "the menu %s", hint.GetText() );
  489.     showEvent( "Select", text );
  490.     status = GetStatusBar();
  491.     status->SetText( hint );
  492.  
  493.     return FALSE;
  494. }
  495.  
  496. @end-code;
  497.  
  498. @begin-code Code "Form_Test::Prototype for menu_Select( WObject * source, WMessageEventData * event )"
  499.  
  500.     private:
  501.         WBool menu_Select(  WObject * source,  WMessageEventData * event );
  502.  
  503. @end-code;
  504.  
  505. @begin-code Code "Form_Test::menu_Close( WObject * source, WMessageEventData * event )"
  506.  
  507. WBool @CLASSNAME@::menu_Close( WObject * source, WMessageEventData * event )
  508. {
  509.     WString             hint;
  510.     WMenuObject *       menu;
  511.     WStatusBar *        status;
  512.     
  513.     menu = (WMenuObject *)source;
  514.     hint = menu->GetHintText();
  515.     showEvent( "*** Close", hint );
  516.     status = GetStatusBar();
  517.     status->SetText( "" );
  518.  
  519.     return FALSE;
  520.  
  521. }
  522.  
  523. @end-code;
  524.  
  525. @begin-code Code "Form_Test::Prototype for menu_Close( WObject * source, WMessageEventData * event )"
  526.  
  527.     private:
  528.         WBool menu_Close( WObject * source, WMessageEventData * event );
  529.  
  530. @end-code;
  531.  
  532. @begin-code Code "Form_Test::menu_InitMenu( WObject * source, WMessageEventData * event )"
  533.  
  534. WBool @CLASSNAME@::menu_InitMenu( WObject * source, WMessageEventData * event )
  535. {
  536.     WString             hint;
  537.     WMenuObject *       menu;
  538.     
  539.     menu = (WMenuObject *)source;
  540.     hint = menu->GetHintText();
  541.     showEvent( "*** InitMenu", hint );
  542.     
  543.     return FALSE;
  544. }
  545.  
  546. @end-code;
  547.  
  548. @begin-code Code "Form_Test::Prototype for menu_InitMenu( WObject * source, WMessageEventData * event )"
  549.  
  550.     private:
  551.         WBool menu_InitMenu( WObject * source, WMessageEventData * event );
  552.  
  553. @end-code;
  554.  
  555. @begin-code Code "Form_Test::menu_InitPopupMenu( WObject * source, WMessageEventData * event )"
  556.  
  557. WBool @CLASSNAME@::menu_InitPopupMenu( WObject * source, WMessageEventData * event )
  558. {
  559.     WString             hint = "";
  560.     WString             name;
  561.     WPopupMenu *        popup;
  562.     WString             text;
  563.  
  564.     popup = findMenu( event );
  565.     if( popup ) {
  566.         hint = popup->GetHintText();
  567.     }
  568.     name = ((WWindow *)source)->GetName();
  569.     text.Sprintf( "the menu %s (parent %s)", hint.GetText(), name.GetText() );
  570.     showEvent( "InitPopupMenu", text );
  571.  
  572.     return FALSE;
  573. }
  574.  
  575. @end-code;
  576.  
  577. @begin-code Code "Form_Test::Prototype for menu_InitPopupMenu( WObject * source, WMessageEventData * event )"
  578.  
  579.     private:
  580.         WBool menu_InitPopupMenu( WObject * source, WMessageEventData * event );
  581.  
  582. @end-code;
  583.  
  584. @begin-code Code "Form_Test::findMenu( WMessageEventData * event )"
  585.  
  586. WPopupMenu * @CLASSNAME@::findMenu( 
  587.     WMessageEventData *     event )
  588. {
  589.     WPopupMenu *            popup;
  590.  
  591.     // Look for popup menu on the menu bar
  592.     popup = (WPopupMenu *)menu_Main->Find( (WMenuHandle)event->wParam, WPopupMenu::ClassID() );
  593.     if( popup == NULL ) {
  594.         // Look for popup menu in the form's popup menu
  595.         popup = (WPopupMenu *)popup_Main->Find( (WMenuHandle)event->wParam, WPopupMenu::ClassID() );
  596.     }
  597.     return( popup );
  598. }
  599.  
  600. @end-code;
  601.  
  602. @begin-code Code "Form_Test::Prototype for findMenu( WMessageEventData * event )"
  603.  
  604.     private:
  605.         WPopupMenu * findMenu( WMessageEventData * event );
  606.  
  607. @end-code;
  608.  
  609. @begin-code Code "Form_Test::Form_Test_Create"
  610.  
  611. // Menu Events
  612.  
  613. // The following events are of interest when programming menus:
  614.  
  615. // InitMenu
  616. // --------
  617. // Applies to forms and menu bars (WMenu).  This event is called when a root menu on
  618. // a menu bar or a popup menu on a form is opened.  It is not called when cascaded
  619. // menus within an open menu are opened.
  620.  
  621. // When a menu is opened on a menu bar, the InitMenu event is first called on the menu's
  622. // parent form.  If the InitMenu event routine is not defined on the form, or it returns 
  623. // FALSE, the InitMenu event on the menu bar (WMenu) is called.
  624.  
  625. // You can use this event to set the state of menu items before a menu is displayed.  As the
  626. // specific menu is not identified, you need to set the state of all menu items in all menus.
  627. // (Note: The findMenu function in this sample can be used to determine the specific menu
  628. // that caused the InitMenu event to be called).
  629.  
  630. // The InitMenu event on the form is a convenient place to initialize menus that are used
  631. // both in the form's menu bar and in the form's context menu since this event will
  632. // be called before displaying a root menu in either location.
  633.  
  634. // InitPopupMenu
  635. // -------------
  636. // Applies to a menu (WPopupMenu) and to the parent object of the root popup menu.
  637. // This event is called whenever a popup menu is about to be opened, including cascaded
  638. // menus.
  639.  
  640. // When a popup menu is opened, the InitPopupMenu event is called on the root parent object.
  641. // If this object does not define the InitPopupMenu event, or the event handler returns FALSE,
  642. // the InitPopupMenu event on the menu (WPopupMenu) is called.
  643.  
  644. // You can use this event to set the state of menu items before a menu is displayed.  The 
  645. // specific menu is not identified so when using this event on the root parent object you
  646. // need to set the state of all menu items in all menus.
  647. // (Note: The findMenu function in this sample can be used to determine the specific menu
  648. // that caused the InitMenu event to be called).
  649.  
  650. // Use the WInitPopupMenu to set the state of menu items for individual popup menus, and 
  651. // for menus which are not parented on forms (i.e. where InitMenu cannot be used).
  652.  
  653. // Select
  654. // ------
  655. // Applies to menus (WPopupMenu) and menu items (WMenuItem).  This event is called when the
  656. // item is selected in a menu.
  657.  
  658. // Use the Select event if you want to display a hint about the menu item in the status 
  659. // area of the form.
  660.  
  661. // Close
  662. // -----
  663. // Applies to a form's popup menu (WPopupMenu).  This event is called when the
  664. // popup menu is closed.
  665.  
  666. // ContextMenu
  667. // -----------
  668. // Applies to forms and controls.  This event is called when a user clicks on an object
  669. // with the right mouse button.  You can use this event with the Track method to directly
  670. // control the display of a popup menu.  In this case you could set the state of menu items
  671. // in your ContextMenu event before displaying the menu with the Track method
  672. // rather then in an InitMenu or InitPopupMenu event.
  673.  
  674. // This program does not use the ContextMenu event.  Instead the popup menu for the form
  675. // and test list box are set on the Popup Menu page of their property dialogs.  The Popup
  676. // property of forms and controls can also be set at runtime.  You would do this if
  677. // you wanted to use the same menu in a menu bar and a context menu.
  678.  
  679.  
  680. WBool @CLASSNAME@::Form_Test_Create(
  681.     WObject *               source,
  682.     WCreateEventData *      event )
  683. {
  684.     WStatusBar *            status;
  685.     
  686.     // Reset line count to be displayed for each event.
  687.     _count = 0;
  688.  
  689.     // Set hint text and event handlers for the menu objects that cannot be
  690.     // directly accessed from the form.
  691.  
  692.     // These are the objects on the menu bar
  693.  
  694.     setEvents( menu_Main_Main, "Main" );
  695.     setEvents( menu_Main_MainOne, "MainOne" );
  696.     setEvents( menu_Main_MainTwo, "MainTwo" );
  697.     setEvents( menu_Main_MainCascade, "MainCascade" );
  698.     setEvents( menu_Main_MainCascadeOne, "MainCascadeOne" );
  699.     setEvents( menu_Main_MainCascadeTwo, "MainCascadeTwo" );
  700.     setEvents( menu_Main_MainCascadeCascade, "MainCascadeCascade" );
  701.     setEvents( menu_Main_MainCascadeCascadeOne, "MainCascadeCascadeOne" );
  702.     setEvents( menu_Main_MainCascadeCascadeTwo, "MainCascadeCascadeTwo" );
  703.     
  704.     // These are the objects on the popup menu.
  705.     
  706.     // (The popup menu is set as the form's context menu using the 
  707.     // Popup Menu page of the form's properties).
  708.  
  709.     setEvents( popup_Main_One, "One" );
  710.     setEvents( popup_Main_Two, "Two" );
  711.     setEvents( popup_Main_Cascade, "Cascade" );
  712.     setEvents( popup_Main_CascadeOne, "CascadeOne" );
  713.     setEvents( popup_Main_CascadeTwo, "CascadeTwo" );
  714.     setEvents( popup_Main_CascadeCascade, "CascadeCascade" );
  715.     setEvents( popup_Main_CascadeCascadeOne, "CascadeCascadeOne" );
  716.     setEvents( popup_Main_CascadeCascadeTwo, "CascadeCascadeTwo" );
  717.  
  718.     // Get rid of the resize grip from the status bar
  719.     status = GetStatusBar();
  720.     status->ChangeStyle( WStatusSizeGrip, false, true );
  721.  
  722.     return FALSE;
  723. }
  724.  
  725. @end-code;
  726.  
  727. @begin-code Code "Form_Test::Form_Test_InitMenu"
  728.  
  729. WBool @CLASSNAME@::Form_Test_InitMenu(
  730.     WObject *               source,
  731.     WMessageEventData *     event )
  732. {
  733.     showEvent( "InitMenu", "the form Form_Test" );
  734.     return FALSE;
  735. }
  736.  
  737. @end-code;
  738.  
  739. @begin-code Code "Form_Test::Form_Test_InitPopupMenu"
  740.  
  741. WBool @CLASSNAME@::Form_Test_InitPopupMenu(
  742.     WObject *               source,
  743.     WMessageEventData *     event )
  744. {
  745.     showEvent( "InitPopupMenu", "the form Form_Test" );
  746.     return FALSE;
  747. }
  748.  
  749. @end-code;
  750.  
  751. @begin-code Code "Form_Test::Form_Test_MenuSelect"
  752.  
  753. WBool @CLASSNAME@::Form_Test_MenuSelect(
  754.     WObject *                  source,
  755.     WMessageEventData *        event )
  756. {
  757.     WPopupMenu *    currPopup = GetCurrentPopupMenu();
  758.     WBool            ret = FALSE;
  759.  
  760.     //  This code forces the Close event handler to be called for 
  761.     //  popup menus on the form.
  762.     
  763.     if( event->GetMenuClosed() && currPopup != NULL ) {
  764.         currPopup->CallEventHandler( WCloseEvent, this );
  765.         ret = TRUE;
  766.     }
  767.     return ret;
  768. }
  769.  
  770. @end-code;
  771.  
  772. @begin-code Code "Form_Test::menu_Main_InitMenu"
  773.  
  774. WBool @CLASSNAME@::menu_Main_InitMenu(
  775.     WObject *               source,
  776.     WMessageEventData *     event )
  777. {
  778.     showEvent( "InitMenu", "the menu bar menu_Main" );
  779.     
  780.     return FALSE;
  781. }
  782.  
  783. @end-code;
  784.  
  785. @begin-code Code "Form_Test::popup_Main_Close"
  786.  
  787. WBool @CLASSNAME@::popup_Main_Close(
  788.     WObject *           source,
  789.     WEventData *        event )
  790. {
  791.     WStatusBar *        status;
  792.     
  793.     showEvent( "Close", "the context menu popup_Main" );
  794.     status = GetStatusBar();
  795.     status->SetText( "" );
  796.     
  797.     return FALSE;
  798. }
  799.  
  800. @end-code;
  801.  
  802. @begin-code Code "Form_Test::popup_Main_InitMenu"
  803.  
  804. WBool @CLASSNAME@::popup_Main_InitMenu(
  805.     WObject *               source,
  806.     WMessageEventData *     event )
  807. {
  808.     showEvent( "*** InitMenu", "the context menu popup_Main" );
  809.     
  810.     return FALSE;
  811. }
  812.  
  813. @end-code;
  814.  
  815. @begin-code Code "Form_Test::popup_Main_InitPopupMenu"
  816.  
  817. WBool @CLASSNAME@::popup_Main_InitPopupMenu(
  818.     WObject *               source,
  819.     WMessageEventData *     event )
  820. {
  821.     showEvent( "InitPopupMenu", "the context menu popup_Main" );
  822.    
  823.     return FALSE;
  824. }
  825.  
  826. @end-code;
  827.  
  828. @begin-code Code "Form_Test::popup_Main_Select"
  829.  
  830. WBool @CLASSNAME@::popup_Main_Select(
  831.     WObject *           source,
  832.     WEventData *        event )
  833. {
  834.     showEvent( "*** Select", "popup_Main" );
  835.     
  836.     return FALSE;
  837. }
  838.  
  839. @end-code;
  840.  
  841. @begin-code Code "Form_Test::cb_Clear_Click"
  842.  
  843. WBool @CLASSNAME@::cb_Clear_Click(
  844.     WObject *           source,
  845.     WEventData *        event )
  846. {
  847.     lb_EventList->DeleteAll();
  848.     _count = 0;
  849.     
  850.     return FALSE;
  851. }
  852.  
  853. @end-code;
  854.  
  855. @begin-code Code "Form_Test::lb_Test_InitMenu"
  856.  
  857. WBool @CLASSNAME@::lb_Test_InitMenu(
  858.     WObject *               source,
  859.     WMessageEventData *     event )
  860. {
  861.     showEvent( "*** InitMenu", "on the list box lb_Test" );
  862.     
  863.     return FALSE;
  864. }
  865.  
  866. @end-code;
  867.  
  868. @begin-code Code "Form_Test::lb_Test_InitPopupMenu"
  869.  
  870. WBool @CLASSNAME@::lb_Test_InitPopupMenu(
  871.     WObject *               source,
  872.     WMessageEventData *     event )
  873. {
  874.     showEvent( "InitPopupMenu", "on the list box lb_Test" );
  875.     
  876.     return FALSE;
  877. }
  878.  
  879. @end-code;
  880. @end;
  881.