473,473 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Repaint Event

Is there something RePaint event?
I have a couple of controls where I draw using control.CreateGraphics, BUT
when I lost focus or do something inside the contorl (click ,etc) all
graphics are disappears
What the name of the event to handle in order to be able to repaint the
graphics on lost?
Nov 15 '05 #1
7 12975

Hi Tamir,

Thank you for posting in the community! My name is Jeffrey, and I will be
assisting you on this issue.

Based on my understanding, you want to show graphics that was created out
using Control.CreateGraphics well in WinForm.
==============================================
Based on my experience, when your control loses focus or being clicked, the
Paint event will fires. So I think if you invoke your
Control.CreateGraphics code in the control's Paint event, your graphics
will not disappear.

Also, if in some event, your control does not paint well, you can
explicitly call the Control.Invalidate method to force the control to
repaint.

If it still does not work, please paste some sample code, I will work with
you.
==============================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice day!!

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 #2
I tried the both
In onPaint event (on mainForm and every one of controls) is does not seemed
to help. Invocation of Invalidate function CLEARS all graphics drawn
Follow the code of drawing I do

private void drawCant(TSComponents.TSTabButton button)

{

//this.Invalidate();

//this.Refresh();

Graphics gr_Middle = this.pnlMiddle.CreateGraphics();

Graphics gr_Down = this.pnlDown.CreateGraphics();

gr_Middle.Clear(this.pnlMiddle.BackColor);

gr_Down.Clear(this.pnlDown.BackColor);

Pen p = new Pen(button.ForeColorClick,2);

Point[] pts_Middle =

{

new Point(button.Location.X+2,0),

new Point(2,2),

new Point(2,pnlMiddle.Height),

new Point(pnlMiddle.Width-2,pnlMiddle.Height),

new Point(pnlMiddle.Width-2,2),

new Point(button.Location.X+button.Width-2,2),

new Point(button.Location.X+button.Width-2,0)

};

Point[] pts_Down =

{

new Point(button.Location.X+2,0),

new Point(button.Location.X+2,2),

new Point(2,2),

new Point(2,pnlDown.Height-2),

new Point(pnlDown.Width-2,pnlDown.Height-2),

new Point(pnlDown.Width-2,2),

new Point(button.Location.X+button.Width-2,2),

new Point(button.Location.X+button.Width-2,0)

};

Point[] pts_Down_Alone =

{

//new Point(button.Location.X+2,0),

//new Point(button.Location.X+2,2),

new Point(2,0),

new Point(2,pnlDown.Height-2),

new Point(pnlDown.Width-2,pnlDown.Height-2),

new Point(pnlDown.Width-2,0),

//new Point(button.Location.X+button.Width-2,2),

//new Point(button.Location.X+button.Width-2,0)

};
if (pnlMiddle.Visible)

gr_Middle.DrawLines(p,pts_Middle);
if(pnlMiddle.Visible)

gr_Down.DrawLines(p,pts_Down_Alone);

else

gr_Down.DrawLines(p,pts_Down);

gr_Middle.Dispose();

gr_Down.Dispose();

//this.pnlMiddle.Invalidate();

//this.pnlDown.Invalidate();
}

""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:AL**************@cpmsftngxa07.phx.gbl...

Hi Tamir,

Thank you for posting in the community! My name is Jeffrey, and I will be
assisting you on this issue.

Based on my understanding, you want to show graphics that was created out
using Control.CreateGraphics well in WinForm.
==============================================
Based on my experience, when your control loses focus or being clicked, the Paint event will fires. So I think if you invoke your
Control.CreateGraphics code in the control's Paint event, your graphics
will not disappear.

Also, if in some event, your control does not paint well, you can
explicitly call the Control.Invalidate method to force the control to
repaint.

If it still does not work, please paste some sample code, I will work with
you.
==============================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I am standing by to be
of assistance.
Have a nice day!!

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 #3
Hi Tamir,

Thanks for your feedback.

=============================================
I have tried your code, it really does not work.

To make the graphics stay permanently, you should hook in the Paint event
and use System's Graphics object to draw your graphic.

If you create and use your own Graphics object, you will draw
asynchronously on the graphics of another control, the control may refresh
its surface at any time, destroying your work in the process.

For more information, please refer to:
http://www.bobpowell.net/pictureboxhowto.htm

You should do like this:
private void button2_Paint(object sender,
System.Windows.Forms.PaintEventArgs e)
{
Graphics g =e.Graphics;
Pen blackPen = new Pen(Color.Red, 3);

float x = 0.0F;
float y = 0.0F;
float width = 10.0F;
float height = 10.0F;
// Draw rectangle to screen.
g.DrawRectangle(blackPen, x, y, width, height);
//g.Dispose(); You can not Dispose the system's Graphics object
}

===============================================
Please apply my suggestion above and let me know if it helps resolve your
problem.

Thank you for your patience and cooperation. If you have any questions or
concerns, please feel free to post it in the group. I will work with you.

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 #4

Hi Tamir,

Does my reply resolve your issue?
If you still have anything unclear, please feel free to tell me. I will
work with you.

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 #5
Thank you for your response,
however It impossible in current project to use paint event in order to
initialize custom draw due the custom draw occured and requested by external
procedure.
Is there other way to do it?

""Jeffrey Tan[MSFT]"" <v-*****@online.microsoft.com> wrote in message
news:x3**************@cpmsftngxa07.phx.gbl...

Hi Tamir,

Does my reply resolve your issue?
If you still have anything unclear, please feel free to tell me. I will
work with you.

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

Hi Tamir,

Thanks for your feedback.

On Windows Form, the system will take charge of the paint of the control.
If you only custom draw your graphics once on the form, then it will be
refreshed immediately and it will disappear.

The only way you are notified is paint event, so I think you must place
your drawing code in this event.

For your issue, I did not see the TRUE obstacle of placing drawing code in
the paint event. Can you show me the KEY difficulty?

Thanks

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 #7

Hi Tamir,

Is your problem resolved?
If you still have anything unclear, please feel free to tell me, I will
work with you.

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 #8

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

Similar topics

11
by: Ike | last post by:
I changing the size of frames dynamically in a page (I am restricted in that I cannot perform a reload of the content of any of the frames). In MSIE, when I resize the frames, thinks repaint...
1
by: Nick | last post by:
I'm creating an MDI application with multiple maximized MDI child forms. When a child form is open, the title/caption is merge with the MDI's title/caption. So, if the MDI title is "Parent" and...
2
by: Joe A | last post by:
I'm using Access 2002 on Windows XP PC, 500 megs ram, Front end/back end app. I have a simple form that draws a thermometer to indicate progress of code that is running. The thermometer form...
2
by: user | last post by:
Hello i have PictureBox p1: p1.Paint += new PaintEventHandler(MyFunction); .... public void MyFunction(Object Sender, PaintEventArgs e) and it works fine but: when i call: p1.Refresh(); ...
0
by: et | last post by:
How do I get the screen to repaint? I have a normal login process where the user clicks on the logon button, and the logon is authenticated. An error is returned if the logon is not validated,...
2
by: Robert | last post by:
Hi! I am experiencing some rendering problems when dynamically changing CSS (width) with both Internet Explorer and Firefox. In some cases it is just in IE and in other cases just Firefox. When...
4
by: MLH | last post by:
Setting form's Picture property to another file from within VBA doesn't repaint the form with new bitmap - for instance... Me.Picture = "c:\pics\MyNewPic.jpg" I tried Me.Repaint afterward,...
0
by: 123456mmmmmm | last post by:
Hi, I have a problem with Repaint my control. At first my control Create correctly. But with every changes like move scroll or anythings else my contrlo will be repaint. How can I avoid repainting...
0
by: milkay | last post by:
<I have code that uses 2 images> the program creates a window and then when u press play, it removes all components in the container. then, i add a NewPanel object. i add mouse listeners and all...
0
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
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,...
1
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...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.