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. OnLButtonDown

OnLButtonDown

Scheduled Pinned Locked Moved C / C++ / MFC
7 Posts 4 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
    Aint
    wrote on last edited by
    #1

    Hello. I am trying to get the coordinates of the clicked point inside a picture control on a dialog. For the picture control, I have derived my own class based on CStatic. And I have set the picture control style to Notify. I have created OnLButtonDown method in the Dlg. The problem is when I clicked on the picture, the coordinates are not passed down but when I clicked on other part of the dialog, the coordinates are passed down. Can anyone help me in this? I want to get the coordinates of the picture.

    H W 2 Replies Last reply
    0
    • A Aint

      Hello. I am trying to get the coordinates of the clicked point inside a picture control on a dialog. For the picture control, I have derived my own class based on CStatic. And I have set the picture control style to Notify. I have created OnLButtonDown method in the Dlg. The problem is when I clicked on the picture, the coordinates are not passed down but when I clicked on other part of the dialog, the coordinates are passed down. Can anyone help me in this? I want to get the coordinates of the picture.

      H Offline
      H Offline
      Hamid Taebi
      wrote on last edited by
      #2

      Where do you use of GetCursorPos on your program for get position?


      WhiteSky


      A 1 Reply Last reply
      0
      • H Hamid Taebi

        Where do you use of GetCursorPos on your program for get position?


        WhiteSky


        A Offline
        A Offline
        Aint
        wrote on last edited by
        #3

        When I use GetCursorPos in the dlg in the OnPicture method, i can get the coordinates. But it is the coordinates of the dialog, not the coordinates of the picture. And also i want to get the coordinates when the left button is down and when the left button is up. How do i go abt in doing this?

        P 1 Reply Last reply
        0
        • A Aint

          When I use GetCursorPos in the dlg in the OnPicture method, i can get the coordinates. But it is the coordinates of the dialog, not the coordinates of the picture. And also i want to get the coordinates when the left button is down and when the left button is up. How do i go abt in doing this?

          P Offline
          P Offline
          Parthi_Appu
          wrote on last edited by
          #4

          ReturnRain wrote:

          When I use GetCursorPos in the dlg in the OnPicture method, i can get the coordinates. But it is the coordinates of the dialog, not the coordinates of the picture

          GetCursorPos() will return the x,y points with respect to screen coordinates. Change those to clinet coordinates. say, m_wndMyStatic is your derived static class variable,then

          POINT pt = {0};
          GetCursorPos( &pt );
          m_wndMyStatic.ScreenToClient( &pt );

          ReturnRain wrote:

          And also i want to get the coordinates when the left button is down and when the left button is up. How do i go abt in doing this

          Handle WM_LBUTTONDOWN and WM_LBUTTONUP and do the above. You can get the rect.. Hope this will help

          Do your Duty and Don't expect the Result

          A 1 Reply Last reply
          0
          • A Aint

            Hello. I am trying to get the coordinates of the clicked point inside a picture control on a dialog. For the picture control, I have derived my own class based on CStatic. And I have set the picture control style to Notify. I have created OnLButtonDown method in the Dlg. The problem is when I clicked on the picture, the coordinates are not passed down but when I clicked on other part of the dialog, the coordinates are passed down. Can anyone help me in this? I want to get the coordinates of the picture.

            W Offline
            W Offline
            William Wang
            wrote on last edited by
            #5

            Your picture control is a seperate child window to the dialog, so mouse click message is generated and sent to static window, then the static window send WM_NOTIFY message to the parent dialog window, when ur mouse clicks on static control rather than clicking on dialog window. I recommand u to handle this by overwrite CStatic::OnLButtonDown or handle it by CYourDialog::OnNotify. hope this could help u out.

            life is like a box of chocolate,you never know what you r going to get.

            1 Reply Last reply
            0
            • P Parthi_Appu

              ReturnRain wrote:

              When I use GetCursorPos in the dlg in the OnPicture method, i can get the coordinates. But it is the coordinates of the dialog, not the coordinates of the picture

              GetCursorPos() will return the x,y points with respect to screen coordinates. Change those to clinet coordinates. say, m_wndMyStatic is your derived static class variable,then

              POINT pt = {0};
              GetCursorPos( &pt );
              m_wndMyStatic.ScreenToClient( &pt );

              ReturnRain wrote:

              And also i want to get the coordinates when the left button is down and when the left button is up. How do i go abt in doing this

              Handle WM_LBUTTONDOWN and WM_LBUTTONUP and do the above. You can get the rect.. Hope this will help

              Do your Duty and Don't expect the Result

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

              Thanks! I can get the first part right. But Im confused with the WM_LBUTTONDOWN and WM_LBUTTONUP. Since i want the picture coordinates when the button is down, should i put the codes in OnLButtonDown or OnPicture (picture control)? And just to make sure, OnLButtonDown and OnLButtonUp is in the dlg?

              H 1 Reply Last reply
              0
              • A Aint

                Thanks! I can get the first part right. But Im confused with the WM_LBUTTONDOWN and WM_LBUTTONUP. Since i want the picture coordinates when the button is down, should i put the codes in OnLButtonDown or OnPicture (picture control)? And just to make sure, OnLButtonDown and OnLButtonUp is in the dlg?

                H Offline
                H Offline
                Hamid Taebi
                wrote on last edited by
                #7

                You must get position on the picture class (if you derived a CStatic class)


                WhiteSky


                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