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