Loading ...
Sorry, an error occurred while loading the content.

Help with Popup menus in xp's

Expand Messages
  • L. Lee Saunders
    Hello everyone! I am trying to get an XP to pop up a context menu and this is how far I ve gotten. I can get the menu to appear at the exact x & y that I
    Message 1 of 8 , Apr 24 1:29 PM
    • 0 Attachment
      Hello everyone!
       
      I am trying to get an XP to pop up a context menu and this is how far I've gotten.  I can get the menu to appear at the exact x & y that I specify and it goes away after I click on a menu item.
       
      I need to figure out two things:
      1) how do I trap the mouse data I need, ie. did they right or left mouse button and what was the x and y coordinates of the mouse when they clicked.
      2) How do I trap the windows message that tells me what menu item was selected?
       
      This kinda shows how little I am familiar with Windows C/C++ SDK.  All the books show how to do it when you have control of the windows main message loop.  Do I need to do a "SetWindowsHookEx" to get the message?  Would it be of type "WH_SYSMSGFILTER"?
       
      If I can figure this out, I'll post some example xp code that will take advantage of this concept.
       
      The c++ code below is what I've gotten thus far (Thanks Joe!)
      +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
       
      #include <comdef.h>
      #include <windows.h>
      #include <math.h>
       
      extern "C"
      {
       #include <xp.h>
       #include "resource.h"
       #include <stdlib.h>
       #include <time.h>
      }
       
      #define XPID 0xF000
       
      void XPCALL About(void);
      void XPCALL Popup(void);
       
      char CList[]="POPUP\0\0";
      PCMDPROC PList[]={About,Popup};
       
      XP MyXP =
         { 0, CList, PList, 0, 0, 0, XPID, 0, 500, 0, 0, 500 };
       
      extern "C" int APIENTRY
       
      DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
       
      {switch (dwReason)
       {
        case DLL_PROCESS_ATTACH:
        {
         MyXP.ModHdl=hDLL;
         XPRegCmd(&MyXP);
         break;
        }
        case DLL_PROCESS_DETACH:
        {
         XPUnregCmd(&MyXP);
         break;
        }
       }
       return TRUE;
      }
       
      ///////////////////// Popup.cpp About information ///////////////////
       
      FORMST(MyAPkt,"Popup commands:\n\n"
        "\tPopup - Test to create a popup menu\n\0")
       
      void XPCALL About (void)
      {
       FormSt(&MyAPkt,RSC(FD_MsgBox));
      }
       
      /////////////////////// Popup Command ///////////////////////////////
       
      void ShowContextMenu(HINSTANCE hInst, HWND hWnd, POINT point)
      {
       
        HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_POPUP_MENU));
        HMENU hPopup = GetSubMenu(hMenu, 0);
        HWND  hWndPopupOwner = hWnd;
       
        while (GetWindowLong(hWndPopupOwner, GWL_STYLE) & WS_CHILD) {
          hWndPopupOwner = GetParent(hWndPopupOwner);
        } // while
       
        TrackPopupMenuEx(hPopup, TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,
          hWndPopupOwner, 0);
       
        DestroyMenu(hMenu);
      }
       
      void XPCALL Popup(void)

       POINT MyPoint;
       
       MyPoint.x = 100;
       MyPoint.y = 100;
       
          ShowContextMenu(MyXP.ModHdl,MyXP.hMainWin,MyPoint);
       
       CmdEnd();
       return;
      }
       
       
    • Mike Riddle
      You need to get the responding menu item id from a message sent to the windows procedure. You could create a dummy window and call it its parent, and get it
      Message 2 of 8 , Apr 24 6:26 PM
      • 0 Attachment
        You need to get the responding menu item id from a message sent to the windows procedure.
        You could create a dummy window and call it its parent, and get it that way, but I have an
        internal function that catches this. I'll see what I need to do to make it export with the
        toolkit. It would require you to write a simple hook routine, and pass on messages you
        don't use.

        Mike

        L. Lee Saunders wrote:
        Hello everyone!
         
        I am trying to get an XP to pop up a context menu and this is how far I've gotten.  I can get the menu to appear at the exact x & y that I specify and it goes away after I click on a menu item.
         
        I need to figure out two things:
        1) how do I trap the mouse data I need, ie. did they right or left mouse button and what was the x and y coordinates of the mouse when they clicked.
        2) How do I trap the windows message that tells me what menu item was selected?
         
        This kinda shows how little I am familiar with Windows C/C++ SDK.  All the books show how to do it when you have control of the windows main message loop.  Do I need to do a "SetWindowsHookEx" to get the message?  Would it be of type " WH_SYSMSGFILTER"?
         
        If I can figure this out, I'll post some example xp code that will take advantage of this concept.
         
        The c++ code below is what I've gotten thus far (Thanks Joe!)
        +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
         
        #include <comdef.h>
        #include <windows.h>
        #include <math.h>
         
        extern "C"
        {
         #include <xp.h>
         #include "resource.h"
         #include <stdlib.h>
         #include <time.h>
        }
         
        #define XPID 0xF000
         
        void XPCALL About(void);
        void XPCALL Popup(void);
         
        char CList[]="POPUP\0\0";
        PCMDPROC PList[]={About,Popup};
         
        XP MyXP =
           { 0, CList, PList, 0, 0, 0, XPID, 0, 500, 0, 0, 500 };
         
        extern "C" int APIENTRY
         
        DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
         
        {switch (dwReason)
         {
          case DLL_PROCESS_ATTACH:
          {
           MyXP.ModHdl=hDLL;
           XPRegCmd(&MyXP);
           break;
          }
          case DLL_PROCESS_DETACH:
          {
           XPUnregCmd(&MyXP);
           break;
          }
         }
         return TRUE;
        }
         
        ///////////////////// Popup.cpp About information ///////////////////
         
        FORMST(MyAPkt,"Popup commands:\n\n"
          "\tPopup - Test to create a popup menu\n\0")
         
        void XPCALL About (void)
        {
         FormSt(&MyAPkt,RSC(FD_MsgBox));
        }
         
        /////////////////////// Popup Command ///////////////////////////////
         
        void ShowContextMenu(HINSTANCE hInst, HWND hWnd, POINT point)
        {
         
          HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_POPUP_MENU));
          HMENU hPopup = GetSubMenu(hMenu, 0);
          HWND  hWndPopupOwner = hWnd;
         
          while (GetWindowLong(hWndPopupOwner, GWL_STYLE) & WS_CHILD) {
            hWndPopupOwner = GetParent(hWndPopupOwner);
          } // while
         
          TrackPopupMenuEx(hPopup, TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y,
            hWndPopupOwner, 0);
         
          DestroyMenu(hMenu);
        }
         
        void XPCALL Popup(void)

         POINT MyPoint;
         
         MyPoint.x = 100;
         MyPoint.y = 100;
         
            ShowContextMenu(MyXP.ModHdl,MyXP.hMainWin,MyPoint);
         
         CmdEnd();
         return;
        }
         
         

        To Post a message, send it to:   cc2-dev-l@...
        To Unsubscribe, send a blank message to: cc2-dev-l-unsubscribe@...


        Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service .

      • L. Lee Saunders
        ... That would be perfect! Thanks Mike! The ability to use popup menus in XP s would greatly expand the users experience. How about the x & y coordinates when
        Message 3 of 8 , Apr 24 8:39 PM
        • 0 Attachment
          >You need to get the responding menu item id from a message sent to the
          >windows procedure.
          >You could create a dummy window and call it its parent, and get it that
          >way, but I have an
          >internal function that catches this. I'll see what I need to do to make
          >it export with the
          >toolkit. It would require you to write a simple hook routine, and pass
          >on messages you
          >don't use.

          That would be perfect! Thanks Mike! The ability to use popup menus in XP's
          would greatly expand the users experience.

          How about the x & y coordinates when the user right-clicked to correctly
          place the menu?

          Lee

          >
          >>Hello everyone!
          >>
          >>
          >>
          >>I am trying to get an XP to pop up a context menu and this is how far
          >>I've gotten. I can get the menu to appear at the exact x & y that I
          >>specify and it goes away after I click on a menu item.
          >>
          >>
          >>
          >>I need to figure out two things:
          >>
          >>1) how do I trap the mouse data I need, ie. did they right or left
          >>mouse button and what was the x and y coordinates of the mouse when
          >>they clicked.
          >>
          >>2) How do I trap the windows message that tells me what menu item was
          >>selected?
          >>
          >>
          >>
          >>This kinda shows how little I am familiar with Windows C/C++ SDK. All
          >>the books show how to do it when you have control of the windows main
          >>message loop. Do I need to do a "SetWindowsHookEx" to get the
          >>message? Would it be of type " WH_SYSMSGFILTER"?
          >>
          >>
          >>
          >>If I can figure this out, I'll post some example xp code that will
          >>take advantage of this concept.
          >>
          >>
          >>
          >>The c++ code below is what I've gotten thus far (Thanks Joe!)
          >>
          >>+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
          >>
          >>
          >>
          >>#include <comdef.h>
          >>#include <windows.h>
          >>#include <math.h>
          >>
          >>
          >>
          >>extern "C"
          >>{
          >> #include <xp.h>
          >> #include "resource.h"
          >> #include <stdlib.h>
          >> #include <time.h>
          >>}
          >>
          >>
          >>
          >>#define XPID 0xF000
          >>
          >>
          >>
          >>void XPCALL About(void);
          >>void XPCALL Popup(void);
          >>
          >>
          >>
          >>char CList[]="POPUP\0\0";
          >>PCMDPROC PList[]={About,Popup};
          >>
          >>
          >>
          >>XP MyXP =
          >> { 0, CList, PList, 0, 0, 0, XPID, 0, 500, 0, 0, 500 };
          >>
          >>
          >>
          >>extern "C" int APIENTRY
          >>
          >>
          >>
          >>DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
          >>
          >>
          >>
          >>{switch (dwReason)
          >> {
          >> case DLL_PROCESS_ATTACH:
          >> {
          >> MyXP.ModHdl=hDLL;
          >> XPRegCmd(&MyXP);
          >> break;
          >> }
          >> case DLL_PROCESS_DETACH:
          >> {
          >> XPUnregCmd(&MyXP);
          >> break;
          >> }
          >> }
          >> return TRUE;
          >>}
          >>
          >>
          >>
          >>///////////////////// Popup.cpp About information ///////////////////
          >>
          >>
          >>
          >>FORMST(MyAPkt,"Popup commands:\n\n"
          >> "\tPopup - Test to create a popup menu\n\0")
          >>
          >>
          >>
          >>void XPCALL About (void)
          >>{
          >> FormSt(&MyAPkt,RSC(FD_MsgBox));
          >>}
          >>
          >>
          >>
          >>/////////////////////// Popup Command ///////////////////////////////
          >>
          >>
          >>
          >>void ShowContextMenu(HINSTANCE hInst, HWND hWnd, POINT point)
          >>{
          >>
          >>
          >>
          >> HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_POPUP_MENU));
          >> HMENU hPopup = GetSubMenu(hMenu, 0);
          >> HWND hWndPopupOwner = hWnd;
          >>
          >>
          >>
          >> while (GetWindowLong(hWndPopupOwner, GWL_STYLE) & WS_CHILD) {
          >> hWndPopupOwner = GetParent(hWndPopupOwner);
          >> } // while
          >>
          >>
          >>
          >> TrackPopupMenuEx(hPopup, TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x,
          >>point.y,
          >> hWndPopupOwner, 0);
          >>
          >>
          >>
          >> DestroyMenu(hMenu);
          >>}
          >>
          >>
          >>
          >>void XPCALL Popup(void)
          >>{
          >> POINT MyPoint;
          >>
          >>
          >>
          >> MyPoint.x = 100;
          >> MyPoint.y = 100;
          >>
          >>
          >>
          >> ShowContextMenu(MyXP.ModHdl,MyXP.hMainWin,MyPoint);
          >>
          >>
          >>
          >> CmdEnd();
          >> return;
          >>}
          >>
          >>
          >>
          >>
          >>
          >>
          >>To Post a message, send it to: cc2-dev-l@...
          >>To Unsubscribe, send a blank message to: cc2-dev-l-unsubscribe@...
          >>
          >>Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
          >><http://docs.yahoo.com/info/terms/> .
          >
          >


          _________________________________________________________________
          Send and receive Hotmail on your mobile device: http://mobile.msn.com
        • Peter Olsson
          Hi Lee, ... The new v6.11 version of CC2 will include a user command called CMENU which displays a popup menu at the current cursor location. You can design
          Message 4 of 8 , Apr 24 11:58 PM
          • 0 Attachment
            Hi Lee,

            > I am trying to get an XP to pop up a context menu and
            > this is how far I've gotten. I can get the menu to appear
            > at the exact x & y that I specify and it goes away after I
            > click on a menu item.

            The new v6.11 version of CC2 will include a user command called CMENU which
            displays a popup menu at the current cursor location. You can design the
            popup menus much in the same way as regular menus.

            > 1) how do I trap the mouse data I need, ie. did they right
            > or left mouse button and what was the x and y coordinates
            > of the mouse when they clicked.

            Do you need to know which button they used to select from the menu? Unless
            you can get the info from TrackPopupMenuEx I think you will have to use:

            SetWindowsHookEx(WH_MOUSE, MouseHookProc, MyXP.hMainInst, (DWORD)NULL);

            This works well with dialogs and data requests in CC2. I use it there to
            track mouse buttons (simulate drag operations within the dynamic cursor)

            There is also a Windows API command called GetCursorPos which may help.

            > 2) How do I trap the windows message that tells me what
            > menu item was selected?

            If you add the value TPM_RETURNCMD to the fuFlags parameter to
            TrackPopupMenuEx it will nicely return the item selected without having to
            worry about any hooks. It is also a good idea to add TPM_NONOTIFY to avoid
            sending messages to CC2.

            Peter
          • Mike Riddle
            The program doe not get that information returned - only the id of the popup menu item. Mike
            Message 5 of 8 , Apr 25 11:29 AM
            • 0 Attachment
              The program doe not get that information returned - only the id of the popup menu item.
              Mike

              L. Lee Saunders wrote:
              You need to get the responding menu item id from a message sent to the
              windows procedure.
              You could create a dummy window and call it its parent, and get it that
              way, but I have an
              internal function that catches this. I'll see what I need to do to make
              it export with the
              toolkit. It would require you to write a simple hook routine, and pass
              on messages you
              don't use.

              That would be perfect! Thanks Mike! The ability to use popup menus in XP's
              would greatly expand the users experience.

              How about the x & y coordinates when the user right-clicked to correctly
              place the menu?

              Lee

              Hello everyone!



              I am trying to get an XP to pop up a context menu and this is how far
              I've gotten. I can get the menu to appear at the exact x & y that I
              specify and it goes away after I click on a menu item.



              I need to figure out two things:

              1) how do I trap the mouse data I need, ie. did they right or left
              mouse button and what was the x and y coordinates of the mouse when
              they clicked.

              2) How do I trap the windows message that tells me what menu item was
              selected?



              This kinda shows how little I am familiar with Windows C/C++ SDK. All
              the books show how to do it when you have control of the windows main
              message loop. Do I need to do a "SetWindowsHookEx" to get the
              message? Would it be of type " WH_SYSMSGFILTER"?



              If I can figure this out, I'll post some example xp code that will
              take advantage of this concept.



              The c++ code below is w hat I've gotten thus far (Thanks Joe!)

              +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



              #include <comdef.h>
              #include <windows.h>
              #include <math.h>



              extern "C"
              {
              #include <xp.h>
              #include "resource.h"
              #include <stdlib.h>
              #include <time.h>
              }



              #define XPID 0xF000



              void XPCALL About(void);
              void XPCALL Popup(void);



              char CList[]="POPUP\0\0";
              PCMDPROC PList[]={About,Popup};



              XP MyXP =
              { 0, CList, PList, 0, 0, 0, XPID, 0, 500, 0, 0, 500 };



              extern "C" int APIENTRY



              DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)



              {switch (dwReason)
              {
              case DLL_PROCESS_ATTACH:
              {
              MyXP.ModHdl=hDLL;
              XPRegCmd(&MyXP);
              break;
              }
              case DLL_PROCESS_DETACH:
              {
              XPUnregCmd(&MyXP);
              break;
              }
              }
              ret urn TRUE;
              }



              ///////////////////// Popup.cpp About information ///////////////////



              FORMST(MyAPkt,"Popup commands:\n\n"
              "\tPopup - Test to create a popup menu\n\0")



              void XPCALL About (void)
              {
              FormSt(&MyAPkt,RSC(FD_MsgBox));
              }



              /////////////////////// Popup Command ///////////////////////////////



              void ShowContextMenu(HINSTANCE hInst, HWND hWnd, POINT point)
              {



              HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_POPUP_MENU));
              HMENU hPopup = GetSubMenu(hMenu, 0);
              HWND hWndPopupOwner = hWnd;



              while (GetWindowLong(hWndPopupOwner, GWL_STYLE) & WS_CHILD) {
              hWndPopupOwner = GetParent(hWndPopupOwner);
              } // while



              TrackPopupMenuEx(hPopup, TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x,
              point.y,
              hWndPopupOwner, 0);



              DestroyMenu(hMenu);
              }



              void XPCALL Popup(void)
              {
              POINT MyPoin t;



              MyPoint.x = 100;
              MyPoint.y = 100;



              ShowContextMenu(MyXP.ModHdl,MyXP.hMainWin,MyPoint);



              CmdEnd();
              return;
              }






              To Post a message, send it to: cc2-dev-l@...
              To Unsubscribe, send a blank message to: cc2-dev-l-unsubscribe@...

              Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
              <http://docs.yahoo.com/info/terms/> .



              _________________________________________________________________
              Send and receive Hotmail on your mobile device: http://mobile.msn.com


              ------------------------ Yahoo! Groups Sponsor ---------------------~-->
              Buy Stock for $4
              and no minimums.
              FREE Money 2002.
              http://us.click.yahoo.com/orkH0C/n97DAA/ySSFAA/f.ewlB/TM
              ---------------------------------------------------------------------~->

              To Post a message, send it to: cc2-dev-l@...
              To Unsubscribe, send a blank message to: cc2-dev-l-unsubscribe@...

              Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





            • Mike Riddle
              Correction: I understand you are looking for the x,y coordinates of the right-click before you create a popup...I ll work on it. Mike
              Message 6 of 8 , Apr 25 11:31 AM
              • 0 Attachment
                Correction: I understand you are looking for the x,y coordinates of the right-click
                before you create a popup...I'll work on it.
                Mike

                L. Lee Saunders wrote:
                You need to get the responding menu item id from a message sent to the
                windows procedure.
                You could create a dummy window and call it its parent, and get it that
                way, but I have an
                internal function that catches this. I'll see what I need to do to make
                it export with the
                toolkit. It would require you to write a simple hook routine, and pass
                on messages you
                don't use.

                That would be perfect! Thanks Mike! The ability to use popup menus in XP's
                would greatly expand the users experience.

                How about the x & y coordinates when the user right-clicked to correctly
                place the menu?

                Lee

                Hello everyone!



                I am trying to get an XP to pop up a context menu and this is how far
                I've gotten. I can get the menu to appear at the exact x & y that I
                specify and it goes away after I click on a menu item.



                I need to figure out two things:

                1) how do I trap the mouse data I need, ie. did they right or left
                mouse button and what was the x and y coordinates of the mouse when
                they clicked.

                2) How do I trap the windows message that tells me what menu item was
                selected?



                This kinda shows how little I am familiar with Windows C/C++ SDK. All
                the books show how to do it when you have control of the windows main
                message loop. Do I need to do a "SetWindowsHookEx" to get the
                message? Would it be of type " WH_SYSMSGFILTER"?



                If I can figure this out, I'll post some example xp code that will
                take advantage of this concept.



                The c++ code below is w hat I've gotten thus far (Thanks Joe!)

                +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



                #include <comdef.h>
                #include <windows.h>
                #include <math.h>



                extern "C"
                {
                #include <xp.h>
                #include "resource.h"
                #include <stdlib.h>
                #include <time.h>
                }



                #define XPID 0xF000



                void XPCALL About(void);
                void XPCALL Popup(void);



                char CList[]="POPUP\0\0";
                PCMDPROC PList[]={About,Popup};



                XP MyXP =
                { 0, CList, PList, 0, 0, 0, XPID, 0, 500, 0, 0, 500 };



                extern "C" int APIENTRY



                DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)



                {switch (dwReason)
                {
                case DLL_PROCESS_ATTACH:
                {
                MyXP.ModHdl=hDLL;
                XPRegCmd(&MyXP);
                break;
                }
                case DLL_PROCESS_DETACH:
                {
                XPUnregCmd(&MyXP);
                break;
                }
                }
                ret urn TRUE;
                }



                ///////////////////// Popup.cpp About information ///////////////////



                FORMST(MyAPkt,"Popup commands:\n\n"
                "\tPopup - Test to create a popup menu\n\0")



                void XPCALL About (void)
                {
                FormSt(&MyAPkt,RSC(FD_MsgBox));
                }



                /////////////////////// Popup Command ///////////////////////////////



                void ShowContextMenu(HINSTANCE hInst, HWND hWnd, POINT point)
                {



                HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_POPUP_MENU));
                HMENU hPopup = GetSubMenu(hMenu, 0);
                HWND hWndPopupOwner = hWnd;



                while (GetWindowLong(hWndPopupOwner, GWL_STYLE) & WS_CHILD) {
                hWndPopupOwner = GetParent(hWndPopupOwner);
                } // while



                TrackPopupMenuEx(hPopup, TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x,
                point.y,
                hWndPopupOwner, 0);



                DestroyMenu(hMenu);
                }



                void XPCALL Popup(void)
                {
                POINT MyPoin t;



                MyPoint.x = 100;
                MyPoint.y = 100;



                ShowContextMenu(MyXP.ModHdl,MyXP.hMainWin,MyPoint);



                CmdEnd();
                return;
                }






                To Post a message, send it to: cc2-dev-l@...
                To Unsubscribe, send a blank message to: cc2-dev-l-unsubscribe@...

                Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
                <http://docs.yahoo.com/info/terms/> .



                _________________________________________________________________
                Send and receive Hotmail on your mobile device: http://mobile.msn.com


                ------------------------ Yahoo! Groups Sponsor ---------------------~-->
                Buy Stock for $4
                and no minimums.
                FREE Money 2002.
                http://us.click.yahoo.com/orkH0C/n97DAA/ySSFAA/f.ewlB/TM
                ---------------------------------------------------------------------~->

                To Post a message, send it to: cc2-dev-l@...
                To Unsubscribe, send a blank message to: cc2-dev-l-unsubscribe@...

                Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/





              • Peter Olsson
                ... The Windows API function GetCursorPos will do this. Peter
                Message 7 of 8 , Apr 25 11:47 AM
                • 0 Attachment
                  > Correction: I understand you are looking for the x,y coordinates of the
                  > right-click before you create a popup...I'll work on it.

                  The Windows API function GetCursorPos will do this.

                  Peter
                • L. Lee Saunders
                  Hi Mike, I did it! I cannot believe that it was so little amount of code was so hard to come by. It felt like I was having my teeth pulled! :-) The trick was
                  Message 8 of 8 , Apr 25 12:19 PM
                  • 0 Attachment
                    Hi Mike,
                     
                    I did it!  I cannot believe that it was so little amount of code was so hard to come by.  It felt like I was having my teeth pulled! :-)
                     
                    The trick was two fold:
                    The First one was to use the return value of TrackPopupMenuEx and the second was combining GetCursorPos with the exact moment RDATA calls the return proc.
                     
                    This will definitely improve my XP commands!  I think I'll do CMB (combine) first so that the use can continue to click on paths to add them to the path you are building and the right click menu will be to A) Do It, B) Cancel, C) Reverse connection to previous path and D) Reverse connection to new path. (Any help in the menu wording would be greatly appreciated)
                     
                    I've uploaded the popup.dll to the files section of our yahoo group.  The source code is below.
                     
                    Thanks again for everyone's help on this,  I really appreciate it!
                     
                    L. Lee Saunders.
                    =================================================================
                     
                     
                    #include <comdef.h>
                    #include <windows.h>
                    #include <math.h>
                     
                    extern "C"
                    {
                     #include <xp.h>
                     #include "resource.h"
                     #include <stdlib.h>
                     #include <time.h>
                    }
                     
                    #define XPID 0xF000
                     
                    void XPCALL About(void);
                    void XPCALL Popup(void);
                     
                    char CList[]="POPUP\0\0";
                    PCMDPROC PList[]={About,Popup};
                     
                    XP MyXP =
                       { 0, CList, PList, 0, 0, 0, XPID, 0, 500, 0, 0, 500 };
                     
                    extern "C" int APIENTRY
                     
                    DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)
                     
                    {switch (dwReason)
                     {
                      case DLL_PROCESS_ATTACH:
                      {
                       MyXP.ModHdl=hDLL;
                       XPRegCmd(&MyXP);
                       break;
                      }
                      case DLL_PROCESS_DETACH:
                      {
                       XPUnregCmd(&MyXP);
                       break;
                      }
                     }
                     return TRUE;
                    }
                     
                    ///////////////////// Popup.cpp About information ///////////////////
                     
                    FORMST(MyAPkt,"Popup commands:\n\n"
                      "\tPopup - Test to create a popup menu\n\0")
                     
                    void XPCALL About (void)
                    {
                     FormSt(&MyAPkt,RSC(FD_MsgBox));
                    }
                     
                    /////////////////////// Popup Command ///////////////////////////////
                    void XPCALL Popup2 (int Result,int Result2,int Result3);
                     
                    GPOINT2 PointOn;
                     
                    FORMST(lpszPOn,"Right click to get menu\0")
                     
                    RDATA POnReq =
                    {sizeof(RDATA), RD_2DC, NULL, RDF_C, (DWORD*)&PointOn,
                         (DWORD*)&lpszPOn, RDC_XH, Popup2, NULL, NULL, 0, NULL, 0};
                     
                    int ShowContextMenu(HINSTANCE hInst, HWND hWnd, POINT point)
                    {
                     
                     HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_POPUP_MENU));
                     HMENU hPopup = GetSubMenu(hMenu, 0);
                     HWND  hWndPopupOwner = hWnd;
                     
                     while (GetWindowLong(hWndPopupOwner, GWL_STYLE) & WS_CHILD) {
                      hWndPopupOwner = GetParent(hWndPopupOwner);
                     }
                     return TrackPopupMenuEx(hPopup, TPM_LEFTALIGN | TPM_RIGHTBUTTON | TPM_NONOTIFY | TPM_RETURNCMD, point.x, point.y,
                      hWndPopupOwner, 0);
                     
                     DestroyMenu(hMenu);
                    }
                     
                    void XPCALL Popup(void)
                    {
                     ReqData(&POnReq);
                    }
                     
                    void XPCALL Popup2 (int Result,int Result2,int Result3)
                    {
                     POINT pmh;
                     int ReturnValue;
                     
                     if (Result != X_OK)
                     {  
                      if (Result != X_DFLT)
                      {
                       CmdEnd();
                       return;
                      }
                     
                      GetCursorPos(&pmh);
                      ReturnValue = ShowContextMenu(MyXP.ModHdl, MyXP.hMainWin, pmh);
                     
                      if(ReturnValue==40001) //40001 = Continue
                      {
                       //Here I would call my continue code if different then the default
                       //good response
                      }
                     
                      if(ReturnValue==40002) //40002 = Quit
                      {
                       //Here I would call the clean up code before finishing
                       CmdEnd();
                       return;
                      }
                     }
                     
                     ReqData(&POnReq);
                    }
                    ==============================================================
                    ----- Original Message -----
                    Sent: Thursday, April 25, 2002 1:31 PM
                    Subject: Re: [cc2-dev-l] Help with Popup menus in xp's

                    Correction: I understand you are looking for the x,y coordinates of the right-click
                    before you create a popup...I'll work on it.
                    Mike

                    L. Lee Saunders wrote:
                    You need to get the responding menu item id from a message sent to the
                    windows procedure.
                    You could create a dummy window and call it its parent, and get it that
                    way, but I have an
                    internal function that catches this. I'll see what I need to do to make
                    it export with the
                    toolkit. It would require you to write a simple hook routine, and pass
                    on messages you
                    don't use.

                    That would be perfect! Thanks Mike! The ability to use popup menus in XP's
                    would greatly expand the users experience.

                    How about the x & y coordinates when the user right-clicked to correctly
                    place the menu?

                    Lee

                    Hello everyone!



                    I am trying to get an XP to pop up a context menu and this is how far
                    I've gotten. I can get the menu to appear at the exact x & y that I
                    specify and it goes away after I click on a menu item.



                    I need to figure out two things:

                    1) how do I trap the mouse data I need, ie. did they right or left
                    mouse button and what was the x and y coordinates of the mouse when
                    they clicked.

                    2) How do I trap the windows message that tells me what menu item was
                    selected?



                    This kinda shows how little I am familiar with Windows C/C++ SDK. All
                    the books show how to do it when you have control of the windows main
                    message loop. Do I need to do a "SetWindowsHookEx" to get the
                    message? Would it be of type " WH_SYSMSGFILTER"?



                    If I can figure this out, I'll post some example xp code that will
                    take advantage of this concept.



                    The c++ code below is w hat I've gotten thus far (Thanks Joe!)

                    +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++



                    #include <comdef.h>
                    #include <windows.h>
                    #include <math.h>



                    extern "C"
                    {
                    #include <xp.h>
                    #include "resource.h"
                    #include <stdlib.h>
                    #include <time.h>
                    }



                    #define XPID 0xF000



                    void XPCALL About(void);
                    void XPCALL Popup(void);



                    char CList[]="POPUP\0\0";
                    PCMDPROC PList[]={About,Popup};



                    XP MyXP =
                    { 0, CList, PList, 0, 0, 0, XPID, 0, 500, 0, 0, 500 };



                    extern "C" int APIENTRY



                    DllMain (HINSTANCE hDLL, DWORD dwReason, LPVOID lpReserved)



                    {switch (dwReason)
                    {
                    case DLL_PROCESS_ATTACH:
                    {
                    MyXP.ModHdl=hDLL;
                    XPRegCmd(&MyXP);
                    break;
                    }
                    case DLL_PROCESS_DETACH:
                    {
                    XPUnregCmd(&MyXP);
                    break;
                    }
                    }
                    ret urn TRUE;
                    }



                    ///////////////////// Popup.cpp About information ///////////////////



                    FORMST(MyAPkt,"Popup commands:\n\n"
                    "\tPopup - Test to create a popup menu\n\0")



                    void XPCALL About (void)
                    {
                    FormSt(&MyAPkt,RSC(FD_MsgBox));
                    }



                    /////////////////////// Popup Command ///////////////////////////////



                    void ShowContextMenu(HINSTANCE hInst, HWND hWnd, POINT point)
                    {



                    HMENU hMenu = LoadMenu(hInst, MAKEINTRESOURCE(IDR_POPUP_MENU));
                    HMENU hPopup = GetSubMenu(hMenu, 0);
                    HWND hWndPopupOwner = hWnd;



                    while (GetWindowLong(hWndPopupOwner, GWL_STYLE) & WS_CHILD) {
                    hWndPopupOwner = GetParent(hWndPopupOwner);
                    } // while



                    TrackPopupMenuEx(hPopup, TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x,
                    point.y,
                    hWndPopupOwner, 0);



                    DestroyMenu(hMenu);
                    }



                    void XPCALL Popup(void)
                    {
                    POINT MyPoin t;



                    MyPoint.x = 100;
                    MyPoint.y = 100;



                    ShowContextMenu(MyXP.ModHdl,MyXP.hMainWin,MyPoint);



                    CmdEnd();
                    return;
                    }






                    To Post a message, send it to: cc2-dev-l@...
                    To Unsubscribe, send a blank message to: cc2-dev-l-unsubscribe@...

                    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service
                    <http://docs.yahoo.com/info/terms/> .



                    _________________________________________________________________
                    Send and receive Hotmail on your mobile device: http://mobile.msn.com


                    ------------------------ Yahoo! Groups Sponsor ---------------------~-->
                    Buy Stock for $4
                    and no minimums.
                    FREE Money 2002.
                    http://us.click.yahoo.com/orkH0C/n97DAA/ySSFAA/f.ewlB/TM
                    ---------------------------------------------------------------------~->

                    To Post a message, send it to: cc2-dev-l@...
                    To Unsubscribe, send a blank message to: cc2-dev-l-unsubscribe@...

                    Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/







                    To Post a message, send it to:   cc2-dev-l@...
                    To Unsubscribe, send a blank message to: cc2-dev-l-unsubscribe@...


                    Your use of Yahoo! Groups is subject to the Yahoo! Terms of Service.
                  Your message has been successfully submitted and would be delivered to recipients shortly.