4/30/2024 0 Comments Loading circle png![]() I'll give you an example of the code below. Take an image like this (right click to save) and get it rotating in a picture box on a form. I suggest you break it down into three stages. Hi rafter, it wouldn't surprise me if you are suffering from information overload. The short answer is that you will always use the (overridden) OnPaint method when drawing within your own control. You will raise the Paint method by calling the base OnPaint method that you overrode. By overriding the OnPaint event you are ensuring that your drawing in that method is performed before (or after) the event handlers. While handling the Paint event within the control *can* work, if the consumer also handles the paint event, it can lead to unpredictable behavior (multiple consumers of an event) since the order in which the methods are called that handle the event is not strictly defined. If you are performing painting/drawing within the control, you will ordinarily override the OnPaint event - this will leave the Paint method to be handled exclusively by the consumer of the control (e.g. In the latter case, *your* method will be called when the control needs painting. So, you can either handle the Paint event, by effectively adding an event handler, or you can override the OnPaint event. Whats the difference between overriden OnPaint Method and paint event handler?The OnPaint method is called when a control needs painting. So if when i start by drawing a line on the form, will all my drawing code go in a class or directly in my form code? You may not like the fact I'm not doing the work for you, but you'll learn a lot by trying the above.so, does the code that i right for drawing two circles go into a class that is attached to the project? You may not like the fact I'm not doing the work for you, but you'll learn a lot by trying the above."You may not like the fact I'm not doing the work for you", dont worry about it. To do this, make some integer variables and use them as your x and y locations for the line, then on timer tick add 10 to the variables and redraw. Make sure you know how to use a timer to move that line and draw it somewhere else. Once you've done it, play around with changing it's colour, location etc until you're confident. Do some googling, learn how to paint a line on a form. Using the tick event of a timer, you can keep painting the next line on the next two points. You then, draw a line from a point on the smaller circle to a point on the larger circle. The idea is to draw two imaginary circles, one smaller than the other and placed in the middle of the larger. ![]() I don't personally like gifting answers, I feel that you don't learn anything that way. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |