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#
  4. How to change cursor to hand on a specific area of a form or control?

How to change cursor to hand on a specific area of a form or control?

Scheduled Pinned Locked Moved C#
tutorialquestion
7 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.
  • S Offline
    S Offline
    Supra2
    wrote on last edited by
    #1

    Hi I have load an image in the background but i would like to show HAND cursor in some area (e.g button on a background image). I am able to do it for whole form or background image but not for a part of it.

    S H 3 Replies Last reply
    0
    • S Supra2

      Hi I have load an image in the background but i would like to show HAND cursor in some area (e.g button on a background image). I am able to do it for whole form or background image but not for a part of it.

      S Offline
      S Offline
      Sami Jadoon
      wrote on last edited by
      #2

      There is a Cursor property for almost every Windows control. Lets a assume we have a Button control say button1 and we want to change its cursor then we will use the following code: button1.Cursor = Cursors.Hand; Hope it will help.

      Don't believe in love...

      1 Reply Last reply
      0
      • S Supra2

        Hi I have load an image in the background but i would like to show HAND cursor in some area (e.g button on a background image). I am able to do it for whole form or background image but not for a part of it.

        S Offline
        S Offline
        Sami Jadoon
        wrote on last edited by
        #3

        There is a cursor property for almost every Windows control. Lets assume you have a Button say button1 and you want to change its cursor to Hand now you will have to use following code: button1.Cursor = Cursors.Hand; Hope it will help.

        Don't believe in love...

        1 Reply Last reply
        0
        • S Supra2

          Hi I have load an image in the background but i would like to show HAND cursor in some area (e.g button on a background image). I am able to do it for whole form or background image but not for a part of it.

          H Offline
          H Offline
          Henry Minute
          wrote on last edited by
          #4

          You asked this a little while ago. DON'T do this! VERY, VERY rude. You are not giving sufficient information about your problem for anybody to give you an accurate answer.

          Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

          S 1 Reply Last reply
          0
          • H Henry Minute

            You asked this a little while ago. DON'T do this! VERY, VERY rude. You are not giving sufficient information about your problem for anybody to give you an accurate answer.

            Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

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

            thanks for reply my dear friend but little while ago i was asking about trapping mouse event, which i am able to handle now. but what i want now is on mouse over i want to show HAND cursor. As explained i have background image and on that i am having one more small image of a card (e.g Heart one), and i want whenever user take mouse over this card the cursor should get changed to HAND. I know that every control is having a property of cursor but this is an image (HeartOne.jpg) which is drawn over another image (BG.jpg)

            H 1 Reply Last reply
            0
            • S Supra2

              thanks for reply my dear friend but little while ago i was asking about trapping mouse event, which i am able to handle now. but what i want now is on mouse over i want to show HAND cursor. As explained i have background image and on that i am having one more small image of a card (e.g Heart one), and i want whenever user take mouse over this card the cursor should get changed to HAND. I know that every control is having a property of cursor but this is an image (HeartOne.jpg) which is drawn over another image (BG.jpg)

              H Offline
              H Offline
              Henry Minute
              wrote on last edited by
              #6

              If you are drawing the card image, then you know where it is on your form. You know its location and you know its size, therefore you can construct a rectangle from that information. What you need to do is to keep a record of the rectangles for all the cards on your form. I'll leave you to research on how to do that. Then when the mouse cursor moves you will have to go through all those rectangles to see if they hold the mouse position within their boundaries. Look at the MSDN documentation for Rectangle to find a suitable method for that. Your form is a control, therefore it has a Cursor property, you already know about that, so need no help on it. Look away now! RANT coming up! In the first post in this thread you stated that you had asked before but were not getting answers. In your previous post you were asking about detecting when the mouse was over an image. Rewording the question does not make an entirely different post! Stick to the rules. Remember that there are time differences, you are getting responses from all round the world. While you are working, others are asleep. If your problem is so damned urgent then get your credit card out and visit rent-a-coder, otherwise learn patience. I, and others, had responded to your first post, this thread should have been a continuation of that first post. Learn the rules of the forums, and keep to them, otherwise people will just ignore you. Rant over. For what it's worth I think that you are going about this in the wrong way. Ask yourself these questions, "What happens when the user clicks on one of the 'cards'? How do you as the programmer know what 'card' it is? Is it a Heart or Spade, is it a ten or an Ace?" However you should at least complete the part you are doing, before changing your design, because you will learn many useful techniques. Also bear in mind that what you are doing is essentially a 'drawing' program. it's just that you are drawing cards whilst they draw circles, squares etc. So before you ask any more questions about this, Google for 'sketch program c#' or 'drawing program c#' and anything else like that that springs to mind, take a look at that code, it should give you many ideas on how to do your application. Good luck!

              Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

              S 1 Reply Last reply
              0
              • H Henry Minute

                If you are drawing the card image, then you know where it is on your form. You know its location and you know its size, therefore you can construct a rectangle from that information. What you need to do is to keep a record of the rectangles for all the cards on your form. I'll leave you to research on how to do that. Then when the mouse cursor moves you will have to go through all those rectangles to see if they hold the mouse position within their boundaries. Look at the MSDN documentation for Rectangle to find a suitable method for that. Your form is a control, therefore it has a Cursor property, you already know about that, so need no help on it. Look away now! RANT coming up! In the first post in this thread you stated that you had asked before but were not getting answers. In your previous post you were asking about detecting when the mouse was over an image. Rewording the question does not make an entirely different post! Stick to the rules. Remember that there are time differences, you are getting responses from all round the world. While you are working, others are asleep. If your problem is so damned urgent then get your credit card out and visit rent-a-coder, otherwise learn patience. I, and others, had responded to your first post, this thread should have been a continuation of that first post. Learn the rules of the forums, and keep to them, otherwise people will just ignore you. Rant over. For what it's worth I think that you are going about this in the wrong way. Ask yourself these questions, "What happens when the user clicks on one of the 'cards'? How do you as the programmer know what 'card' it is? Is it a Heart or Spade, is it a ten or an Ace?" However you should at least complete the part you are doing, before changing your design, because you will learn many useful techniques. Also bear in mind that what you are doing is essentially a 'drawing' program. it's just that you are drawing cards whilst they draw circles, squares etc. So before you ask any more questions about this, Google for 'sketch program c#' or 'drawing program c#' and anything else like that that springs to mind, take a look at that code, it should give you many ideas on how to do your application. Good luck!

                Henry Minute Do not read medical books! You could die of a misprint. - Mark Twain Girl: (staring) "Why do you need an icy cucumber?" “I want to report a fraud. The government is lying to us all.”

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

                Hi Thanks for your reply and suggestions. I ll certainly see to it. Now I am able to do as per the position of images by using MouseMove function.

                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