Click here to Skip to main content
16,004,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I want draw a line or circle,ellipse when i click different buttons.
Thank your help!
Posted
Comments
walterhevedeich 2-May-11 21:35pm    
Your question is unclear. Do you mean the shapes will be drawn when you click buttons? or the buttons will determine what shape you will draw? Rephrase your question to make it clear.
blackcat02 3-May-11 11:34am    
the buttons will determine what shape i will draw:)

You need to handle the event Paint or override the method OnPaint of some control (could be a form) where you paint. You handler of OnPaint will be called with event arguments parameter which provides the instance of Graphics you use for drawing.

That will create some static rendering. How to change it on some event like button click?

Make your rendering depending on some data, which can be a member(s) of you form, for example. Your click event can modify the data, so next time your control is rendered it will show some different picture. For example, no line before click, a line after click. But changing data itself does not mean re-drawing, right? How to trigger the update. You need to case the Windows message WM_PAINT to be dispatched to a control. Do trigger it, you call Control.Invalidate right after you changed the data. For performance gain, you can call Invalidate with a parameter (Region or Rectangle) to invalidate only a part of the scene. The same technique is used for animation of the rendered picture. Double buffering of the control is recommended to avoid flicker.


—SA
 
Share this answer
 
Comments
blackcat02 6-May-11 9:51am    
can u post that code?i'm newbie:)
Sergey Alexandrovich Kryukov 6-May-11 11:30am    
What code? I explained everything. VB? No I don't have it installed.
It just works as I explained, there are millions of samples. You know the idea and key works -- should be enough.
--SA
In your application, handel the OnButtonClick Event in that using Graphic object draw the space in required position on from.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900