Paint onClick

  • Thread starter Thread starter Tamir Khason
  • Start date Start date
T

Tamir Khason

How I can paint something onClick event?
I need PaintEventArgs event in order to paint and raise Graphics, but
onClick I have only EventArgs Event...

Thanx
 
Add the paint event as well as the onlcick event then use a boolean and set
it to true as you perform the click .. then check for the boolean true in
paint method and do the necessary drawings..

Nirosh
 
Did it, but now I have other problem ...
I call drawlines by clicking on some image(button) ,but it paints INSIDE the
control was called from by paint event , instead of doing it on whole
screen, here is the code:

Graphics g = e.Graphics;
Point[] pts =
{
new Point(tab.button.Left, tab.button.Top), //tab.button - is the
button clicked
new Point(tab.button.Left+tab.button.Width, tab.button.Top),
new Point(tab.button.Left+tab.button.Width, tab.button.Top +
tab.button.Height),
new Point(pnlMainbar.Width,tab.button.Top + tab.button.Height),
//pnlMain - some panel on the screen
new Point(pnlMainbar.Width, pnlWorkArea.Top + pnlWorkArea.Height),
//pnlMainbar - see pnlMain
new Point(pnlWorkArea.Left, pnlWorkArea.Top + pnlWorkArea.Height), //
pnlWorkArea - see pnlMain
new Point(tab.button.Left, tab.button.Top)

};
g.DrawLines(new Pen(tab.tabColor,3),pts);


How can I force it to draw ON THE SCREEN, but not ON THE CONTROL
 
Well, you can obtain a graphics object from whatever control you want with
CreateGraphics, but in doing so you should beware the danger mentioned by
Bob.

But most likely you are updating the wrong OnPaint event.
In button_click call whateveryouwantupdated.Invalidate() and put your code
in that event
 
Hi Tamir,

In Click event, you can invoke Invalidate method of the control that you
want to draw.
If you want to draw on the full screen' DC, I think you should use P/invoke
some win32 APIs such as GetWindowDC, and get the full screen's DC.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top