Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. captureing right click mouse event........

captureing right click mouse event........

Scheduled Pinned Locked Moved C / C++ / MFC
c++tutorial
9 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    ani_ikram
    wrote on last edited by
    #1

    how to disable user from right clicking in Edit Box.and also cant copy or paste using (ctrl+c) and (ctrl+v) in visual c++ project..

    R S 2 Replies Last reply
    0
    • A ani_ikram

      how to disable user from right clicking in Edit Box.and also cant copy or paste using (ctrl+c) and (ctrl+v) in visual c++ project..

      R Offline
      R Offline
      Rane
      wrote on last edited by
      #2

      Better idea that I would suggest is to disable the edit box. Use the following function to disable the Edit box. EnableWindow(FALSE) Regards, Rane

      1 Reply Last reply
      0
      • A ani_ikram

        how to disable user from right clicking in Edit Box.and also cant copy or paste using (ctrl+c) and (ctrl+v) in visual c++ project..

        S Offline
        S Offline
        SandipG
        wrote on last edited by
        #3

        Yes, derive your own class from CEdit and handle WM_CONTEXTMENU message . For information on WM_CONTEXTMENU[^] I hope it helps..

        Regards, Sandip.

        A 1 Reply Last reply
        0
        • S SandipG

          Yes, derive your own class from CEdit and handle WM_CONTEXTMENU message . For information on WM_CONTEXTMENU[^] I hope it helps..

          Regards, Sandip.

          A Offline
          A Offline
          ani_ikram
          wrote on last edited by
          #4

          can u plz give me a code that using WM_CONTEXTMENU to restrict right cliking in edit box

          S 1 Reply Last reply
          0
          • A ani_ikram

            can u plz give me a code that using WM_CONTEXTMENU to restrict right cliking in edit box

            S Offline
            S Offline
            SandipG
            wrote on last edited by
            #5

            You can try something like this..

            BEGIN_MESSAGE_MAP(CMyEdit, CEdit)
            //{{AFX_MSG_MAP(CMyEdit)
            ON_WM_CONTEXTMENU()
            //}}AFX_MSG_MAP
            ON_MESSAGE(WM_COPY,OnCopy)
            ON_MESSAGE(WM_PASTE,OnPaste)
            END_MESSAGE_MAP()

            /////////////////////////////////////////////////////////////////////////////
            // CMyEdit message handlers

            void CMyEdit::OnContextMenu(CWnd* pWnd, CPoint point)
            {
            // TODO: Add your message handler code here
            }
            void CMyEdit::OnCopy(WPARAM wParam,LPARAM lParam)
            {
            // TODO: Add your message handler code here
            }
            void CMyEdit::OnPaste(WPARAM wParam,LPARAM lParam)
            {
            // TODO: Add your message handler code here
            }

            And declarations..

            protected:
            //{{AFX_MSG(CMyEdit)
            afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
            //}}AFX_MSG

            void OnCopy(WPARAM wParam,LPARAM lParam) ;
            void OnPaste(WPARAM wParam,LPARAM lParam) ;
            

            I hope it helps. I assume you can derive the class from CEdit and add similar handlers to your class. Also don't forget to add the control variable of type CMyEdit for the Edit Box.

            Regards, Sandip.

            A 1 Reply Last reply
            0
            • S SandipG

              You can try something like this..

              BEGIN_MESSAGE_MAP(CMyEdit, CEdit)
              //{{AFX_MSG_MAP(CMyEdit)
              ON_WM_CONTEXTMENU()
              //}}AFX_MSG_MAP
              ON_MESSAGE(WM_COPY,OnCopy)
              ON_MESSAGE(WM_PASTE,OnPaste)
              END_MESSAGE_MAP()

              /////////////////////////////////////////////////////////////////////////////
              // CMyEdit message handlers

              void CMyEdit::OnContextMenu(CWnd* pWnd, CPoint point)
              {
              // TODO: Add your message handler code here
              }
              void CMyEdit::OnCopy(WPARAM wParam,LPARAM lParam)
              {
              // TODO: Add your message handler code here
              }
              void CMyEdit::OnPaste(WPARAM wParam,LPARAM lParam)
              {
              // TODO: Add your message handler code here
              }

              And declarations..

              protected:
              //{{AFX_MSG(CMyEdit)
              afx_msg void OnContextMenu(CWnd* pWnd, CPoint point);
              //}}AFX_MSG

              void OnCopy(WPARAM wParam,LPARAM lParam) ;
              void OnPaste(WPARAM wParam,LPARAM lParam) ;
              

              I hope it helps. I assume you can derive the class from CEdit and add similar handlers to your class. Also don't forget to add the control variable of type CMyEdit for the Edit Box.

              Regards, Sandip.

              A Offline
              A Offline
              ani_ikram
              wrote on last edited by
              #6

              thanks for da reply actually i m very beginner to visual c++ so feel problem while deriving plz can u help me further that how to derive myCEdit from CEdit and override its methods etc.... thanks in advance

              S 1 Reply Last reply
              0
              • A ani_ikram

                thanks for da reply actually i m very beginner to visual c++ so feel problem while deriving plz can u help me further that how to derive myCEdit from CEdit and override its methods etc.... thanks in advance

                S Offline
                S Offline
                SandipG
                wrote on last edited by
                #7

                I will advise you to read some book on MFC. Windows Programming with MFC by Jeff Prosise is good for beginners. Now your problem. 1. Select Insert Menu -> New Class. 2. Type In your class name (CMyEdit)and select Base class as CEdit 3. Then add the handlers and their declarations from my previous posts to the class. 4. Add the member variable of type CMyEdit for Edit box. I hope this makes sense. But I suggest you to read from book as this is something very basic.

                Regards, Sandip.

                A 1 Reply Last reply
                0
                • S SandipG

                  I will advise you to read some book on MFC. Windows Programming with MFC by Jeff Prosise is good for beginners. Now your problem. 1. Select Insert Menu -> New Class. 2. Type In your class name (CMyEdit)and select Base class as CEdit 3. Then add the handlers and their declarations from my previous posts to the class. 4. Add the member variable of type CMyEdit for Edit box. I hope this makes sense. But I suggest you to read from book as this is something very basic.

                  Regards, Sandip.

                  A Offline
                  A Offline
                  ani_ikram
                  wrote on last edited by
                  #8

                  thanks for da help after deriving CMyedit class from Edit and adding handler of WM_CONTEXTMENU, WM_COPY,WM_PASTE now plz tell the code to restrict menu and copy,paste using these methods ,means what would be coding to handle menu in these methods void CMyedit::OnContextMenu(CWnd* pWnd, CPoint point) { // TODO: Add your message handler code here } void CMyedit::OnCopy(WPARAM wParam,LPARAM lParam) { // TODO: Add your message handler code here } void CMyedit::OnPaste(WPARAM wParam,LPARAM lParam) { // TODO: Add your message handler code here }

                  S 1 Reply Last reply
                  0
                  • A ani_ikram

                    thanks for da help after deriving CMyedit class from Edit and adding handler of WM_CONTEXTMENU, WM_COPY,WM_PASTE now plz tell the code to restrict menu and copy,paste using these methods ,means what would be coding to handle menu in these methods void CMyedit::OnContextMenu(CWnd* pWnd, CPoint point) { // TODO: Add your message handler code here } void CMyedit::OnCopy(WPARAM wParam,LPARAM lParam) { // TODO: Add your message handler code here } void CMyedit::OnPaste(WPARAM wParam,LPARAM lParam) { // TODO: Add your message handler code here }

                    S Offline
                    S Offline
                    SandipG
                    wrote on last edited by
                    #9

                    Blank implementation will prevent the Menu as well as copy and paste. You must have not added the member variable of type CMyEdit to your dialog in which you have your Edit Box.. You need to associate your class with the EditBox by adding a member variable and respective call to DDX_Control in the functio DoDataExchange().. No need to edit this manually you can use wizard to add the variable. Only thing wizard will not do is to include header file MyEdit.h which you need to include manually. I hope it is clear.

                    Regards, Sandip.

                    1 Reply Last reply
                    0
                    Reply
                    • Reply as topic
                    Log in to reply
                    • Oldest to Newest
                    • Newest to Oldest
                    • Most Votes


                    • Login

                    • Don't have an account? Register

                    • Login or register to search.
                    • First post
                      Last post
                    0
                    • Categories
                    • Recent
                    • Tags
                    • Popular
                    • World
                    • Users
                    • Groups