473,750 Members | 2,265 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Not to draw when my custom control is not visible.

I have created a simple custom control, which displays a string data
on it. It draws the string at its OnPaint(). When the string is
changed I can call Invalidate() to redraw the string. Sort of simple.
But I guess it might not be efficient. The instances of my custom
controls are on a scrollable contrainer, so if it is not in a viewable
area, calling Invalidate() may redraw things even if it's not
necessary. Is Invalidate smart enough not to redraw when it's not
actually visible on the screen? Or, is there any better scheme for
this control? I'd like to hear advices from you.
Jun 27 '08 #1
1 1716
On Tue, 13 May 2008 07:40:38 -0700, Sin Jeong-hun <ty*******@gmai l.com>
wrote:
I have created a simple custom control, which displays a string data
on it. It draws the string at its OnPaint(). When the string is
changed I can call Invalidate() to redraw the string. Sort of simple.
But I guess it might not be efficient.
Unless you run into an actual performance issue, don't worry about it.

The fact is, this is the standard mechanism used by practically every
Windows control. Generally, invalidating a region of a control that's not
visible will indeed have no effect. The OnPaint() won't even be called.
But even if it is called, drawing a control that's not visible is MUCH
faster than drawing one that is. Most of the time, doing this sort of
additional drawing should not cause any sort of noticeable performance
issue.

Just keep doing it the way you're doing it now. In the unlikely event
that you do start to notice some sort of performance issue, then you can
start measuring your code to find out where and what exactly is causing
the performance problem, and _then_ if it turns out that the invalidation
of the control is causing it, you can worry about how to deal with it. I
predict that this chain of conditions will never come to pass. :)

Pete
Jun 27 '08 #2

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

Similar topics

5
12493
by: Brian Keating EI9FXB | last post by:
Hello there, Wonder can anyone point me in the correct direction? I would like to change the standard list view control so that i can have alternated rows in a different color, i.e. white grey white grey And I'd also like to change the color or the first colmn. What is the best approach for same? thanks Brian
3
7222
by: Arnold the Aardvark | last post by:
I am creating a custom draw tree view based on CTreeCtrl. When the control is re-sized the background is blanked completely, resulting in a horrible flicker. I've seen various suggestions involving the use of double buffering. Those are fine but I want to understand what is wrong. When I created the same control in C++Builder the view was totally flicker free, so this must be something the framework does (or doesn't).
2
1445
by: VB Programmer | last post by:
I created a VB.NET user control which I now want to use in my ASP.NET webform. The uc shows up fine in my toolbar, but when I click on it it goes to the bottom of the form, rather than letting me 'draw' it. (Kind of like what happens when you place a Timer control on a form, rather than a Text Box control.) Ideas? Thanks!
1
1121
by: Crirus | last post by:
I know subject is confusing... This is the ideea: I have 3 controls..custom. I have a control that act as a container for them.. does 3 containers fill completly the container one... That container control is the one I use in my form Anyway, I draw some fancy borders on the parent control (the container). Question: Is there any chance to draw on a upper layer that is visible over does controls?
2
3055
by: John | last post by:
I created a number of pictureboxes in a panel, and want to draw lines in those pictureboxes but I cannot. Please see the following code and make corrections. Thanks. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load Panel1.AutoScroll = True Panel1.Width = 200 Panel1.Height = 200
9
6173
by: Duncan Barnes-Ceeney | last post by:
I’m having problems with a custom Combo box. The main problem is that I want to modify the look of the combo which includes the size of the button. To do this I have inherited from the standard combo set it as a UserPaint and provided my own paint. This along with the standard Owner Draw for the list items works fine for the DropDownList version, the problems start with the versions with the edit box which are where the problems are. ...
3
2203
by: Luis Arnauth | last post by:
Hello, I've got a small aplication where i design a small scheme using System.Drawing. I need to use a NumericUpDown control to change some text i've draw. I have all the code under: protected override void OnPaint(PaintEventArgs paintEvent)
9
4027
by: zhaow | last post by:
Hi, All Greetings! I want to develop as appllication that requires a line-drawing function in the blank area between two forms. I have looked up the MSDN, it says that a graphics object need a reference to a control or a form. I guess it means that lines can't be draw on blank area between two forms. Can anybody guarantee this for me? Is there any method can realize this function? I mainly want to draw a line from a button in form1 to...
10
7530
by: Phil | last post by:
I would like to draw some text which will be in front of any other controls, but without obscuring them completely. If I use DrawString in the form's Paint handler the text is always behind, not in front of the other controls. In VB6 I would have simply used a label control and set it to transparent, but this doesn't work in .NET, the background of a label can be set to 'transparent', but this does not show the other controls through,...
0
9000
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...
0
8838
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9577
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9256
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...
1
6804
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
6081
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
4887
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3322
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 we have to send another system
2
2804
muto222
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.