473,854 Members | 1,502 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Paint onClick

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
Nov 15 '05 #1
5 7063
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
"Tamir Khason" <ta**********@t con-NOSPAM.co.il> wrote in message
news:ui******** ******@tk2msftn gp13.phx.gbl...
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

Nov 15 '05 #2
Just invalidate the control in the onclick and paint from the paint event.

See the most asked GDI+ FAQ question for reasons why it shouldn't be done
any other way.

--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Tamir Khason" <ta**********@t con-NOSPAM.co.il> wrote in message
news:ui******** ********@tk2msf tngp13.phx.gbl. ..
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

Nov 15 '05 #3
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.butto n.Left, tab.button.Top) , //tab.button - is the
button clicked
new Point(tab.butto n.Left+tab.butt on.Width, tab.button.Top) ,
new Point(tab.butto n.Left+tab.butt on.Width, tab.button.Top +
tab.button.Heig ht),
new Point(pnlMainba r.Width,tab.but ton.Top + tab.button.Heig ht),
//pnlMain - some panel on the screen
new Point(pnlMainba r.Width, pnlWorkArea.Top + pnlWorkArea.Hei ght),
//pnlMainbar - see pnlMain
new Point(pnlWorkAr ea.Left, pnlWorkArea.Top + pnlWorkArea.Hei ght), //
pnlWorkArea - see pnlMain
new Point(tab.butto n.Left, tab.button.Top)

};
g.DrawLines(new Pen(tab.tabColo r,3),pts);
How can I force it to draw ON THE SCREEN, but not ON THE CONTROL
"Bob Powell [MVP]" <bob@_spamkille r_bobpowell.net > wrote in message
news:uM******** *****@TK2MSFTNG P11.phx.gbl...
Just invalidate the control in the onclick and paint from the paint event.

See the most asked GDI+ FAQ question for reasons why it shouldn't be done
any other way.

--
Bob Powell [MVP]
C#, System.Drawing

The November edition of Well Formed is now available.
Learn how to create Shell Extensions in managed code.
http://www.bobpowell.net/currentissue.htm

Answer those GDI+ questions with the GDI+ FAQ
http://www.bobpowell.net/gdiplus_faq.htm

Read my Blog at http://bobpowelldotnet.blogspot.com

"Tamir Khason" <ta**********@t con-NOSPAM.co.il> wrote in message
news:ui******** ********@tk2msf tngp13.phx.gbl. ..
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


Nov 15 '05 #4
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 whateveryouwant updated.Invalid ate() and put your code
in that event

--
Using M2, Opera's revolutionary e-mail client: http://www.opera.com/m2/
Nov 15 '05 #5

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.

Nov 15 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
2183
by: Tamir Khason | last post by:
Why when I lost focus (go to back) on form all GDI+ paints disappears..... BUG or I do something wrong???? TNX
0
1931
by: vooose | last post by:
Consider a UserControl to which you do userControl.Paint += new PaintEventHandler(paint_method) If you don't like that way, and prefer to override onPaint( ) then the problem stated below still exists (I tried both ways). Imagine you have a Console.WriteLine( ) in the paint method so you know when its getting called. Also there is no place in the code that userControl.Paint is -+ so the event is *never* removed.
5
1475
by: ruca | last post by:
Hi, Can anyone give me examples of how can I hightlight cells of my datagrid? I know that I must use ItemBound event and probably JavaScript. The thing is that I have a anual calendar, constructed in a DataGrid. Then what I want is select a range of two dates in that same calendar to do any action.
3
1989
by: Mike Cooper | last post by:
I have been staring at the above error for over a week now! I have a an inherited data class looking like thus: Public Class DataGridBoolColumnInherit Inherits System.Windows.Forms.DataGridBoolColumn Protected Overloads Overrides Sub Paint(ByVal g As Graphics, ByVal bounds As Rectangle, ByVal As CurrencyManager, ByVal rowNum As Integer, ByVal backBrush As Brush, ByVal foreBrush As Brush, ByVal alignToRight As Boolean)
6
3171
by: jcrouse | last post by:
I am rotating some text is some label controls. In the one place I use it it works fine. In the other place I use it I can't figure out the syntax. I don't really understand the event. Where it works fine, it seems to fire when the form changes visibility. Here is the code. Private Sub lblP1JoyUp_Paint(ByVal sender As Object, ByVal e As System.Windows.Forms.PaintEventArgs) Handles lblP1JoyUp.Paint If lblP1JoyUp.Visible = True Then Dim...
7
1833
by: hamil | last post by:
The following code will display a tif file on a form. When another form is moved over the tif image, the tif image is erased where the form was moved. A paint event occurs when this happens. My question is..how would I save the tif images as soon as it is initially painted, and then restore the image in a paint event. It seems to me that there should be some sort of a SaveImage method and a RestoreImage method that would be fast. Note:...
7
2362
by: Rotsey | last post by:
Hi, I have a interface that I use for a form so I can pass the form to another object. How do I add the Paint event to the interface and subsequently handle the paint event in my other object.? I am not sure of the syntax required to do this?
5
2095
by: =?Utf-8?B?SmVzcGVyLCBEZW5tYXJr?= | last post by:
Hi, On a usercontrol I've put a set of radiobuttons within a groupbox. These radiobuttons have visual style enables, i.e. they turn orange when hovering over them and green when pushed. Normally I put my updation of data shown in the controls on the usercontrol in the Paint event handler of the usercontrol. When it comes to the radiobuttons, a paint event for the usercontrol is fired whenever hovering over the radiobuttons, making...
3
9060
by: ShadowLocke | last post by:
This is a weird one. I have a page that has two Panels on it with BorderStyle set to double. In design mode everything looks as it should. When I start the page up or move it to a production server, the borders on the Panel do not show up unless you first minimize the browser and bring it back up or move a window over it/force the window to repaint. I thought maybe it was just my comp but i see it on any IE6 computer. Firefox and Safari paint...
0
9901
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
1
10758
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10371
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9513
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7915
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7082
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5942
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
2
4159
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3187
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.