Page 184 - DCAP408_WEB_PROGRAMMING
P. 184

Windows Programming




                    Notes                        {
                                                        return  RemoveMenu(mnuHandle,  mnuPosition,  MF_REMOVE);
                                                 }
                                                 ///  <summary>
                                                 ///  Appends  a  menu  item  to  the  end  of  the  system  menu  list
                                                 ///  </summary>
                                                 ///  <param  name=”mnuHandle”>Handle  to  the  system  menu  to
                                                       append  to</param>
                                                 ///  <param  name=”MenuID”>A  unique  ID  sent  by  the  calling
                                                       function  to  track  events  for  the  menu</param>
                                                 ///  <param  name=”mnuText”>The  display  text  of  the  menu</
                                                       param>
                                                 ///  <returns>Returns  nonzero  on  success,  0  on  fail.</returns>
                                                 public  long  AppendSysMenu(int  mnuHandle,  int  MenuID,
                                                 string  mnuText)
                                                 {
                                                        return  AppendMenu(mnuHandle,  0,  MenuID,  mnuText);
                                                 }
                                                 ///  <summary>
                                                 ///  Appends  a  separator  bar  at  the  end  of  the  system  menu
                                                 ///  </summary>
                                                 ///  <param  name=”mnuHandle”>Handle  to  the  system  menu</param>
                                                 ///  <returns>Returns  nonzero  on  success,  0  on  fail</returns>
                                                 public  long  AppendSeparator(int  mnuHandle)
                                                 {
                                                        return  AppendMenu(mnuHandle,  MF_SEPARATOR,  0,  null);
                                                 }
                                                 //  THIS  IS  IMPORTANT.  The  WndProc  function  has  to  be
                                                     overridden  so
                                                 //  we  can  capture  the  events  from  a  menu  item  being  selected.
                                                 //  In  the  future,  we  could  add  OwnerDraw  features  here,
                                                     and  process
                                                 //  that  here,  too
                                                 ///  <param  name=”messg”>The  messages  sent  to  WndProc</param>
                                                 protected  override  void  WndProc(ref  Message  messg)
                                                 {
                                                        int  i  =  1;  //  for  EXAMPLE  purposes  only
                                                        //  see  if  this  is  a  menu  message  to  monitor
                                                        if  (messg.Msg  ==  WM_SYSCOMMAND)
                                                        {
                                                               //  decide  how  to  handle  the  command
                                                               switch  (messg.WParam.ToInt32())
                                                               {



          178                               LOVELY PROFESSIONAL UNIVERSITY
   179   180   181   182   183   184   185   186   187   188   189