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. Visual Basic
  4. Mouse Hit Test: How??

Mouse Hit Test: How??

Scheduled Pinned Locked Moved Visual Basic
designtutorialquestion
6 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.
  • B Offline
    B Offline
    bitpusher
    wrote on last edited by
    #1

    Hello, I've a text box in a group box on a form and upon startup, this box is NOT enabled. My UI behavior is supposed to enable the box if the user double clicks on it (I cannot get messages from the box itself while not enabled). After a few hours of trying to find a method, I'm giving up and asking if anyone knows how to do this? I find it hard to believe that there's no "hit test" contained in the Rectangle or Point object types and that I cannot get a rectangle type directly from the text box itself! thanks! JennyP

    B D 3 Replies Last reply
    0
    • B bitpusher

      Hello, I've a text box in a group box on a form and upon startup, this box is NOT enabled. My UI behavior is supposed to enable the box if the user double clicks on it (I cannot get messages from the box itself while not enabled). After a few hours of trying to find a method, I'm giving up and asking if anyone knows how to do this? I find it hard to believe that there's no "hit test" contained in the Rectangle or Point object types and that I cannot get a rectangle type directly from the text box itself! thanks! JennyP

      B Offline
      B Offline
      beowulfagate
      wrote on last edited by
      #2

      By definition, the enabled property "Gets or sets a value indicating whether the control can respond to user interaction"-MSDN. It can't catch any user interaction, including the click, double-click events and the mousemove, mouseup, mousedown events that you may need to hittest. Try setting the read-only property instead. This makes the control able to receive user interaction but will still be uneditable. Good Luck!

      B 1 Reply Last reply
      0
      • B beowulfagate

        By definition, the enabled property "Gets or sets a value indicating whether the control can respond to user interaction"-MSDN. It can't catch any user interaction, including the click, double-click events and the mousemove, mouseup, mousedown events that you may need to hittest. Try setting the read-only property instead. This makes the control able to receive user interaction but will still be uneditable. Good Luck!

        B Offline
        B Offline
        bitpusher
        wrote on last edited by
        #3

        Hello, Thanks for the suggestion. I would rather not allow the user to tab in to the control (and any other UI features) associated with an enabled control. In C++, there's hit test tools for obtaining the mouse position and comparing this to the object's rectangle and I can do most of this in VB, but cannot get the coordinates to match.... but I suspect that there is a simpler (and tried and tested) way. thanks, JennyP

        P 1 Reply Last reply
        0
        • B bitpusher

          Hello, Thanks for the suggestion. I would rather not allow the user to tab in to the control (and any other UI features) associated with an enabled control. In C++, there's hit test tools for obtaining the mouse position and comparing this to the object's rectangle and I can do most of this in VB, but cannot get the coordinates to match.... but I suspect that there is a simpler (and tried and tested) way. thanks, JennyP

          P Offline
          P Offline
          Purple Monk
          wrote on last edited by
          #4

          You could place an image box over the control and when that is double clicked enable the text box, quick and dirty but effective "If i was king cigarettes would be free."

          1 Reply Last reply
          0
          • B bitpusher

            Hello, I've a text box in a group box on a form and upon startup, this box is NOT enabled. My UI behavior is supposed to enable the box if the user double clicks on it (I cannot get messages from the box itself while not enabled). After a few hours of trying to find a method, I'm giving up and asking if anyone knows how to do this? I find it hard to believe that there's no "hit test" contained in the Rectangle or Point object types and that I cannot get a rectangle type directly from the text box itself! thanks! JennyP

            D Offline
            D Offline
            Dennis C Dietrich
            wrote on last edited by
            #5

            Hi Jenny! bitpusher wrote: I've a text box in a group box on a form and upon startup, this box is NOT enabled. My UI behavior is supposed to enable the box if the user double clicks on it (I cannot get messages from the box itself while not enabled). You're talking about a groupbox so I guess you're programming in Visual Basic .NET. I spent some thoughts about your problem and worte a little class which should do exactly what you want. Just give me another day or two to write an article and demo application.

            1 Reply Last reply
            0
            • B bitpusher

              Hello, I've a text box in a group box on a form and upon startup, this box is NOT enabled. My UI behavior is supposed to enable the box if the user double clicks on it (I cannot get messages from the box itself while not enabled). After a few hours of trying to find a method, I'm giving up and asking if anyone knows how to do this? I find it hard to believe that there's no "hit test" contained in the Rectangle or Point object types and that I cannot get a rectangle type directly from the text box itself! thanks! JennyP

              D Offline
              D Offline
              Dennis C Dietrich
              wrote on last edited by
              #6

              Hi there! bitpusher wrote: My UI behavior is supposed to enable the box if the user double clicks on it (I cannot get messages from the box itself while not enabled). After a few hours of trying to find a method, I'm giving up and asking if anyone knows how to do this? Well, I just finished my new article. Maybe this will help (if it doesn't let me know): http://www.codeproject.com/useritems/CtrlActivator.asp[^] Best regards Dennis

              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