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. Capture OnLButtonDown on picture control.

Capture OnLButtonDown on picture control.

Scheduled Pinned Locked Moved C / C++ / MFC
questiongraphicshosting
6 Posts 2 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.
  • L Offline
    L Offline
    llp00na
    wrote on last edited by
    #1

    Dear All; I have a dialog box hosting a picture control which has a bitmap loaded in it. The bitmap is scrollable (I derived a class from CScrollView to do that). How do I capture the OnLButtonDown and OnLButtonUp mouse events that happen within the scrollable image (ie. those which happen within the picture control only) ? Thank you

    llp00na

    N 1 Reply Last reply
    0
    • L llp00na

      Dear All; I have a dialog box hosting a picture control which has a bitmap loaded in it. The bitmap is scrollable (I derived a class from CScrollView to do that). How do I capture the OnLButtonDown and OnLButtonUp mouse events that happen within the scrollable image (ie. those which happen within the picture control only) ? Thank you

      llp00na

      N Offline
      N Offline
      Naveen
      wrote on last edited by
      #2

      Derive a class from CStatic and make a control variable for the picture object of tis class. Now you can handle the OnLButtonDown and OnLButtonUp inside this class. Another way is to overide the PreTranslateMessage() of the main dialog. Inside it check the message is WM_LBUTTONDOWN or WM_LBUTTONUP and the hWnd is the handle of the picture control.

      nave

      L 1 Reply Last reply
      0
      • N Naveen

        Derive a class from CStatic and make a control variable for the picture object of tis class. Now you can handle the OnLButtonDown and OnLButtonUp inside this class. Another way is to overide the PreTranslateMessage() of the main dialog. Inside it check the message is WM_LBUTTONDOWN or WM_LBUTTONUP and the hWnd is the handle of the picture control.

        nave

        L Offline
        L Offline
        llp00na
        wrote on last edited by
        #3

        Thank you for your answer. I will try our your first suggestion, it sounds feasible. Another inquiry if you dont mind, the picture control is scrollable (ie. if the loaded image is bigger than the size of the picture control, scroll bars are provided to allow the user to view all parts of the image) and i will need to retrieve the (x,y) of user clicks within the image. do you think i will have problems getting the coordinates in this case considering the top left corner of the image control as the reference point?

        llp00na

        N 1 Reply Last reply
        0
        • L llp00na

          Thank you for your answer. I will try our your first suggestion, it sounds feasible. Another inquiry if you dont mind, the picture control is scrollable (ie. if the loaded image is bigger than the size of the picture control, scroll bars are provided to allow the user to view all parts of the image) and i will need to retrieve the (x,y) of user clicks within the image. do you think i will have problems getting the coordinates in this case considering the top left corner of the image control as the reference point?

          llp00na

          N Offline
          N Offline
          Naveen
          wrote on last edited by
          #4

          llp00na wrote:

          do you think i will have problems

          offcourse no. The point you recieve in the WM_LBUTTONDOWN will be a point relative to the top left postion of the image control itself

          nave

          L 2 Replies Last reply
          0
          • N Naveen

            llp00na wrote:

            do you think i will have problems

            offcourse no. The point you recieve in the WM_LBUTTONDOWN will be a point relative to the top left postion of the image control itself

            nave

            L Offline
            L Offline
            llp00na
            wrote on last edited by
            #5

            But the control image is attached to a scrollable window -a class derived from CScrollView-

            llp00na

            1 Reply Last reply
            0
            • N Naveen

              llp00na wrote:

              do you think i will have problems

              offcourse no. The point you recieve in the WM_LBUTTONDOWN will be a point relative to the top left postion of the image control itself

              nave

              L Offline
              L Offline
              llp00na
              wrote on last edited by
              #6

              I think I have got it. I have added the mouse event handlers to the derived class from CScrollView :). Thank you very much for your help.

              llp00na

              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