Page 168 - DCAP408_WEB_PROGRAMMING
P. 168

Windows Programming




                    Notes                  The ‘Enabled’ and ‘Visible’ checkboxes are ‘checked’ by default, which means that
                                            the menu will be both visible and enabled at the time of creation.

                                           The ‘Shortcut’ option gives us a drop-down list for assigning shortcut keys to our
                                            menus (more on this a little later).
                                       Suppose we want to create a menu for helping the user change the backcolor of the form
                                       to either red or blue or green. For this, we create a menu like this:
                                           Type 1st caption as ‘Red’, 1st name as ‘mnured’. Click on ‘Next’ button.
                                           Type 2nd caption as ‘Blue’, 2nd name as ‘mnublu’. Click on ‘Next’ button.

                                           Type 3rd caption as ‘Green’, 3rd name as ‘mnugre’.
                              :
                                       We should be seeing the menu editor, along with the menus as follows:























                                   :  Click on the ‘OK’ button. The  menu editor  closes, and the form reappears, giving an
                                   4.
                                       appearance as shown below. Observe the menu that appears just below the title bar of the
                                       form:
                              Click











                                   Coding for Menus

                                   The user interface for the menus is ready. Now we will code them to carry out the desired tasks
                               C   when the user clicks on it. Click on a menu in the design window to open the code window. Now
                                   code for the menus click event:
                                   Code    Listing    menu.1
                                   PRIVATE  SUB  mnured_CLICK  (  )
                                   form1.BACKCOLOR    =    VBRED
                                   END  SUB




          162                               LOVELY PROFESSIONAL UNIVERSITY
   163   164   165   166   167   168   169   170   171   172   173