473,398 Members | 2,812 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

Graphics 102 : regional refresh of form/control

I now have graphics being drawn in the Paint event of my form (yeah, and
it's very cool). Problem was that it only updated any changes to these
graphics when Paint was called.

So, I then made it so the Refresh() method of the form was called for each
graphic object. In this case it drew just fine, but Paint was being called
so often I lost control of the form (e.g., trying to close the form using
the close 'x' in upper right corner resulted in an hour-glass icon and no
action). I then made it so it only called refresh once every so often. Now
all is good...

BUT - I'd like to be able to refresh only a portion (rectangular region) of
the form for speed. I notice all the .NET Control's can do this. I also
don't think the Control's Refresh() has an overloaded version that
establishes the rectangle of refresh.

Is there a 'region refresh' for controls (or possibly just for containers or
forms), and what is it if it does exist?

Thanks in advance! : )

[==P==]
Nov 17 '05 #1
2 1870
Ok, I may have a partial answer to my own question. There is a Control
method called Invalidate() that let's me invalidate any rectangular region
of the Control. So this is what I was looking for.

BUT - does this mean that Refresh() only refreshes invalidated areas? Does
drawing a graphic (ala the Graphics class, for example the use of
DrawLine()) automatically invalidate the graphic object's region? If so, I
don't need to do anything more than what I'm already doing! : )

[==P==]

"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I now have graphics being drawn in the Paint event of my form (yeah, and
it's very cool). Problem was that it only updated any changes to these
graphics when Paint was called.

So, I then made it so the Refresh() method of the form was called for each
graphic object. In this case it drew just fine, but Paint was being called
so often I lost control of the form (e.g., trying to close the form using
the close 'x' in upper right corner resulted in an hour-glass icon and no
action). I then made it so it only called refresh once every so often.
Now all is good...

BUT - I'd like to be able to refresh only a portion (rectangular region)
of the form for speed. I notice all the .NET Control's can do this. I also
don't think the Control's Refresh() has an overloaded version that
establishes the rectangle of refresh.

Is there a 'region refresh' for controls (or possibly just for containers
or forms), and what is it if it does exist?

Thanks in advance! : )

[==P==]

Nov 17 '05 #2
Peter Oliphant wrote:
Ok, I may have a partial answer to my own question. There is a Control
method called Invalidate() that let's me invalidate any rectangular region
of the Control. So this is what I was looking for.

BUT - does this mean that Refresh() only refreshes invalidated areas? Does
drawing a graphic (ala the Graphics class, for example the use of
DrawLine()) automatically invalidate the graphic object's region? If so, I
don't need to do anything more than what I'm already doing! : )

[==P==]

"Peter Oliphant" <po*******@RoundTripInc.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
I now have graphics being drawn in the Paint event of my form (yeah, and
it's very cool). Problem was that it only updated any changes to these
graphics when Paint was called.

So, I then made it so the Refresh() method of the form was called for each
graphic object. In this case it drew just fine, but Paint was being called
so often I lost control of the form (e.g., trying to close the form using
the close 'x' in upper right corner resulted in an hour-glass icon and no
action). I then made it so it only called refresh once every so often.
Now all is good...

BUT - I'd like to be able to refresh only a portion (rectangular region)
of the form for speed. I notice all the .NET Control's can do this. I also
don't think the Control's Refresh() has an overloaded version that
establishes the rectangle of refresh.

Is there a 'region refresh' for controls (or possibly just for containers
or forms), and what is it if it does exist?

Thanks in advance! : )

[==P==]


Peter,

InvalidateRect and Update seem to be the winning combo for me. I'm not
sure what the offical answer is though.

--
Rob Schieber
Nov 17 '05 #3

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

Similar topics

8
by: ComputerSmith | last post by:
Hi all. I have programmed VB6 apps before, ones that use dropdown listboxes, text boxes, etc... normal stuff. I was asked by a friend to write a "simple" app that I am unsure how to proceed...
12
by: Sanjay | last post by:
hi, We are currently porting our project from VB6 to VB .NET. Earlier we used to make scale transformations on objects like pictureBox , forms etc.Now Such transformations are made on the...
5
by: Vin | last post by:
Hi, I am using the following code to draw whatever the user draws using x,y. // draws lines directly on a winform. CreateGraphics().DrawLine(APen, x, y, OldX, OldY); Now how do I save the...
7
by: Peter Row | last post by:
Hi, I've started work on my own control some parts of which use standard controls, others I need to draw on my controls surface to get the display output I require, however.... I seem to be...
6
by: Paul_Madden | last post by:
I have a System.Windows.Forms.Form onto which I add a Panel (MyPanel) directly derived from System.Windows.Forms.Panel. Here are the important code fragments ... public class MyPanel : Panel...
4
by: Sugan | last post by:
Hi all, I've created a Custom button control and i'm drawing the graphics for the button when the paint event is fired. I used Invalidate method to redraw the graphics in events like mousemove,...
2
by: JR | last post by:
Hi, How can I add some graphics to a picturebox, panel or form that already have some graphics on it. Everytime i use the invalidate or refresh function of that control it starts on a blank...
7
by: Delme Greening | last post by:
I have an empty project with a button on a form. What code do I need to put behind the button to draw a rectangle on my form when it is clicked?
11
by: Peter Webb | last post by:
I previously asked about two problems I had with some graphics - the first was that when I drew animation to a picturebox it wouldn't display when the Form loaded. It was suggested to me by...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
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...
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,...
0
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...

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.