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. MFC: Button press and release?

MFC: Button press and release?

Scheduled Pinned Locked Moved C / C++ / MFC
helpcsharpc++visual-studiotutorial
13 Posts 5 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.
  • R Rostfrei

    Hello! I'm just a basic MFC user. Mostly I do my UIs in resource editor in VS.NET 2003. I know how to handle BN_CLICKED message from button and do something with it (trough message map). But now I have a problem. I should do something on button "press" and something different on button "release". It's the situation when event is dispatched on press and release not just release like it is the case with BN_CLICKED. Is it even possible? Thank you for all the help. Best regards, Rostfrei

    F Offline
    F Offline
    FarPointer
    wrote on last edited by
    #3

    do you mean LButtonDown?? Regards, FarPointer

    R 1 Reply Last reply
    0
    • F FarPointer

      do you mean LButtonDown?? Regards, FarPointer

      R Offline
      R Offline
      Rostfrei
      wrote on last edited by
      #4

      What do you mean by LButtonDown? I just want do something on button down and something else on button up. Rostfrei

      W D 2 Replies Last reply
      0
      • R Rostfrei

        What do you mean by LButtonDown? I just want do something on button down and something else on button up. Rostfrei

        W Offline
        W Offline
        Waldermort
        wrote on last edited by
        #5

        http://msdn.microsoft.com/library/default.asp?url=/library/en-us/winui/winui/windowsuserinterface/userinput/mouseinput/aboutmouseinput.asp[^]

        1 Reply Last reply
        0
        • T toxcct

          WM_LBUTTONDOWN and WM_LBUTTONUP should do

          R Offline
          R Offline
          Rostfrei
          wrote on last edited by
          #6

          Can you please give me more instructions? Like I said I am using resource editor for it. What to type into message map? Rostfrei

          1 Reply Last reply
          0
          • R Rostfrei

            What do you mean by LButtonDown? I just want do something on button down and something else on button up. Rostfrei

            D Offline
            D Offline
            David Crow
            wrote on last edited by
            #7

            Which means you need to supply handlers for the WM_LBUTTONDOWN and WM_LBUTTONUP messages.


            "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

            "There is no death, only a change of worlds." - Native American Proverb

            R 1 Reply Last reply
            0
            • D David Crow

              Which means you need to supply handlers for the WM_LBUTTONDOWN and WM_LBUTTONUP messages.


              "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

              "There is no death, only a change of worlds." - Native American Proverb

              R Offline
              R Offline
              Rostfrei
              wrote on last edited by
              #8

              I managed to supply the handlers. I have the Dialog based application. If I press the mouse anywhere on the dialog I can detect it and can read the coordinates. The problem is when I click on the button. Click is not detected and I guess its intercepted by button. I want to detect the button down and check if mouse down happened in the area where button is. I don't have any method registered with the button. All I want to use it for now is button press/release shadow effect. What can I do? I don't want to draw custom button pictures and place them on the button region. Regards, Rostfrei

              D 1 Reply Last reply
              0
              • R Rostfrei

                I managed to supply the handlers. I have the Dialog based application. If I press the mouse anywhere on the dialog I can detect it and can read the coordinates. The problem is when I click on the button. Click is not detected and I guess its intercepted by button. I want to detect the button down and check if mouse down happened in the area where button is. I don't have any method registered with the button. All I want to use it for now is button press/release shadow effect. What can I do? I don't want to draw custom button pictures and place them on the button region. Regards, Rostfrei

                D Offline
                D Offline
                David Crow
                wrote on last edited by
                #9

                One way is to derive your own class from CButton and put the message handlers in it. If that does not work, perhaps message reflection will.


                "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                "There is no death, only a change of worlds." - Native American Proverb

                R 1 Reply Last reply
                0
                • D David Crow

                  One way is to derive your own class from CButton and put the message handlers in it. If that does not work, perhaps message reflection will.


                  "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                  "There is no death, only a change of worlds." - Native American Proverb

                  R Offline
                  R Offline
                  Rostfrei
                  wrote on last edited by
                  #10

                  I already tried that but it is not possible to declare message map in there class CCustomButton : public CButton { private: DECLARE_MESSAGE_MAP () }; BEGIN_MESSAGE_MAP(CCustomButton, CDialog) END_MESSAGE_MAP() because I get error mainAppDlg.cpp(106): error C2248: 'CDialog::GetThisMessageMap' : cannot access protected member declared in class 'CDialog' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(2864) : see declaration of 'CDialog::GetThisMessageMap' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(2767) : see declaration of 'CDialog' What is message reflection? Regards, Rostfrei

                  D 1 Reply Last reply
                  0
                  • R Rostfrei

                    I already tried that but it is not possible to declare message map in there class CCustomButton : public CButton { private: DECLARE_MESSAGE_MAP () }; BEGIN_MESSAGE_MAP(CCustomButton, CDialog) END_MESSAGE_MAP() because I get error mainAppDlg.cpp(106): error C2248: 'CDialog::GetThisMessageMap' : cannot access protected member declared in class 'CDialog' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(2864) : see declaration of 'CDialog::GetThisMessageMap' c:\Program Files\Microsoft Visual Studio .NET 2003\Vc7\atlmfc\include\afxwin.h(2767) : see declaration of 'CDialog' What is message reflection? Regards, Rostfrei

                    D Offline
                    D Offline
                    David Crow
                    wrote on last edited by
                    #11

                    Rostfrei wrote:

                    I already tried that but it is not possible to declare message map in there

                    Sure it is. MFC would not be worth a whole lot otherwise.

                    Rostfrei wrote:

                    class CCustomButton : public CButton ... BEGIN_MESSAGE_MAP(CCustomButton, CDialog)

                    Notice the discrepancy?


                    "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                    "There is no death, only a change of worlds." - Native American Proverb

                    R 1 Reply Last reply
                    0
                    • D David Crow

                      Rostfrei wrote:

                      I already tried that but it is not possible to declare message map in there

                      Sure it is. MFC would not be worth a whole lot otherwise.

                      Rostfrei wrote:

                      class CCustomButton : public CButton ... BEGIN_MESSAGE_MAP(CCustomButton, CDialog)

                      Notice the discrepancy?


                      "Let us be thankful for the fools. But for them the rest of us could not succeed." - Mark Twain

                      "There is no death, only a change of worlds." - Native American Proverb

                      R Offline
                      R Offline
                      Rostfrei
                      wrote on last edited by
                      #12

                      I'm sorry I just don't get it. What is different? Rostfrei

                      T 1 Reply Last reply
                      0
                      • R Rostfrei

                        I'm sorry I just don't get it. What is different? Rostfrei

                        T Offline
                        T Offline
                        toxcct
                        wrote on last edited by
                        #13

                        a button inherits from CButton, not CDialog X|

                        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