473,511 Members | 14,393 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

.NET winforms redraw problem

13 New Member
I am using .net 2.0 and working in VS2005.
I've noticed following unpleasant effect in the standard Form class
behaviour: when the Form is hovered by some other window, it is being redrawn very slowly.

Here is the example. I have taken empty form, put there some standard controls:
http://www.ljplus.ru/img4/b/o/boshetunmaj/Redraw2.jpg

My hardware conf is: p4 3200, 2 Gb ram, GeForce 5200.
Mar 12 '08 #1
24 3224
SEngel
13 New Member
I have found that controls redraw at this moment takes up to 80% of CPU time...
Mar 13 '08 #2
Plater
7,872 Recognized Expert Expert
I have never had that occurance unless my computer is super bogged down with a lot of applications.
Might I suggest checking your windows theme/style settings? The P4 might not be able to hand it if you have a LOT of controls on your windows.
Mar 13 '08 #3
SEngel
13 New Member
I have never had that occurance unless my computer is super bogged down with a lot of applications.
Might I suggest checking your windows theme/style settings? The P4 might not be able to hand it if you have a LOT of controls on your windows.
It's strange, but there are only few controls. The most noticable effect is for TextBoxes, ComboBoxes and GroupBoxes.
Which one setting do you mean?
Mar 14 '08 #4
Plater
7,872 Recognized Expert Expert
Hmm, I turn off most of the themeing on my computer so I'm not sure it even has any bearing on it.

Are you doing anything else with the form? Doing anything durring paint/redraw events? Or populating data from a database or anything?
Mar 14 '08 #5
SEngel
13 New Member
Hmm, I turn off most of the themeing on my computer so I'm not sure it even has any bearing on it.

Are you doing anything else with the form? Doing anything durring paint/redraw events? Or populating data from a database or anything?
The form is free from any code.

I have set DoubleBuffered property of groupboxes to true and this helped a little, but the problem still stays.
Mar 15 '08 #6
SEngel
13 New Member
I have found the following effect:
I create multi window app (I run another window in another thread) and catch
events concerning moving and resizing of that other window. On each such event I run DoEvents() in a main thread. This leads to perferct window redraw.

But I can't understand, how to do the same with windows of 3rd side applications.
Can anybode help?
Mar 18 '08 #7
Plater
7,872 Recognized Expert Expert
Ah!
So this window was not running in the GUI thread but in a different thread?
Mar 18 '08 #8
SEngel
13 New Member
Ah!
So this window was not running in the GUI thread but in a different thread?

Yes, I've created BackgroundWorker in the main GUI thread and asked it to do
Run.Application(AnotherWindow);

In this case I've no such awful effect as it was described in the 1st post.
That's because I can catch events from this window.
Mar 18 '08 #9
Plater
7,872 Recognized Expert Expert
I thought you were having trouble with the "main" window. Makes sense that the window in the other thread had trouble with redraws.
Mar 18 '08 #10
SEngel
13 New Member
I thought you were having trouble with the "main" window. Makes sense that the window in the other thread had trouble with redraws.
No, you were right!
again, the situaton is following:

1). I have main window with simple controls. When any window from other app hovers over it, the problem with redraw occurs.
2). I have another window in another thread. There is no problem described in point 1), if I catch it's Move and Resize events in the main window and refresh main window manually by means of DoEvents()
-----------

So, how can I get rid of the problem in point 1) ???
Mar 18 '08 #11
Plater
7,872 Recognized Expert Expert
Did you use Application.Run() to run the main form?
Mar 18 '08 #12
SEngel
13 New Member
Did you use Application.Run() to run the main form?
Yes,

Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(fals e);
Application.Run(new PhotoEngineForm());
Mar 18 '08 #13
Plater
7,872 Recognized Expert Expert
And PhotoEngineForm is the one that has troubles with the screen not getting refreshed?
And this only occurs when that otherr form in that other thread is open correct?
Mar 18 '08 #14
SEngel
13 New Member
And PhotoEngineForm is the one that has troubles with the screen not getting refreshed?
And this only occurs when that otherr form in that other thread is open correct?
PhotoEngineForm is the main form with refresh problems, that is correct.
But troubles occur, when the other application window is moved over PhotoEngineForm.

I have written about other form, let's call it OtherForm, ONLY in order to show, that the problem is theoretically solvable be means of catching onMove and onResize events. (this also means, that my hardware conf can handle it). But I don't know how to catch these events from OTHER applications.
Mar 18 '08 #15
Plater
7,872 Recognized Expert Expert
Well for some reason it seems like your PhotoEngineForm is not getting it's WndProc messages (Windows Messages).
Have you tried overriding that function and dolling out the refresh commands on the correct windows messages?

Either that or I would create a new Form, copy the code into it and set THAT as your main form and see if the results repeat?
Mar 18 '08 #16
SEngel
13 New Member
Well for some reason it seems like your PhotoEngineForm is not getting it's WndProc messages (Windows Messages).
Have you tried overriding that function and dolling out the refresh commands on the correct windows messages?

Either that or I would create a new Form, copy the code into it and set THAT as your main form and see if the results repeat?
Yes, it looks like the form doesn't handles repaint events properly.
Can you advice, which method should I override?

I'll upload source code soon... But this effect doesn't take place on every PC. It looks like .NET forms on PCs with newer video adapter and CPU work perfectly...
Mar 18 '08 #17
Plater
7,872 Recognized Expert Expert
What happens if you don't do this:
Application.EnableVisualStyles();

It should no longer attempt to match the "theme" of your computer settings (I think).
See if that makes a difference?
Mar 18 '08 #18
SEngel
13 New Member
What happens if you don't do this:
Application.EnableVisualStyles();

It should no longer attempt to match the "theme" of your computer settings (I think).
See if that makes a difference?
I have commented this line, but It doesn't help :(

Here is the example of simple application with the screen from my computer (that is not PhotoEngineForm, but as you can see, there are troubles here too):
http://rapidshare.com/files/100541360/WindowsApplication1.rar.html
Mar 18 '08 #19
vijayB
40 New Member
Try to rebuild the solution and create it's executable. The problem might be the loading/unloading of VS2K5 environment

I am using .net 2.0 and working in VS2005.
I've noticed following unpleasant effect in the standard Form class
behaviour: when the Form is hovered by some other window, it is being redrawn very slowly.

Here is the example. I have taken empty form, put there some standard controls:
http://www.ljplus.ru/img4/b/o/boshetunmaj/Redraw2.jpg

My hardware conf is: p4 3200, 2 Gb ram, GeForce 5200.
Mar 19 '08 #20
Plater
7,872 Recognized Expert Expert
I did not see anything different about that application then any other.
It was "funny" while I was dragging the window (my system is under heavy load) but as soon as I stopped moving it was fine.
I tested and Visual Studio and all my other windows exhibited the "funny" behavior while I was moving the window. I think it was certainly related to my system being under load.
Mar 19 '08 #21
SEngel
13 New Member
I did not see anything different about that application then any other.
It was "funny" while I was dragging the window (my system is under heavy load) but as soon as I stopped moving it was fine.
I tested and Visual Studio and all my other windows exhibited the "funny" behavior while I was moving the window. I think it was certainly related to my system being under load.
What hardware conf do you have?
Mar 20 '08 #22
Plater
7,872 Recognized Expert Expert
Pentium D 2.8Ghz with 1 gig ram.
Nothing great.
I also had THREE visual studios open as well as a bunch of IEs Firefox(who is a pig and takes up like 100megs virtual memory) and MS SQL Server Management, along with a few other things.
Mar 20 '08 #23
SEngel
13 New Member
Pentium D 2.8Ghz with 1 gig ram.
Nothing great.
I also had THREE visual studios open as well as a bunch of IEs Firefox(who is a pig and takes up like 100megs virtual memory) and MS SQL Server Management, along with a few other things.
and what video adapter do you have?
Mar 23 '08 #24
Plater
7,872 Recognized Expert Expert
It appears to be generic:
"Intel(R) 82945G Express Chipset Family" is all it says.
Mar 24 '08 #25

Sign in to post your reply or Sign up for a free account.

Similar topics

0
1283
by: PHH | last post by:
Help me, please, When I redraw a ListviewItem in Listview (redraw items with icon and text columms). I used SetStyle(ControlStyle.UserPaint, true) function. And I redraw finish and run...
0
1891
by: WHITETIGER | last post by:
Help me, please, When I redraw a ListviewItem in Listview (redraw items with icon and text columms). I used SetStyle(ControlStyle.UserPaint, true) function. And I redraw finish and run...
2
3480
by: ch424 | last post by:
Hi, Does anybody know the fastest way to trigger a DrawingArea redaw in pygtk? At the moment, I'm using a bit of a hack: def redraw(self): self.area.hide() self.area.show() Is there a...
1
3339
by: kiplring | last post by:
I wrote a program which draw a dancer at cornor of desktop. ( I Accessed through hDC) But It has a problem. I remains all trait at the desktop until I invoke any Redraw( Refresh) action - click,...
1
3666
by: Fabrício de Novaes Kucinskis | last post by:
Hi all, I have to problems concerning datagrids, tabcontrols and scrollbars: 1) I created a form with a TabControl. This TabControl has two TabPages: the first with a datagrid to browse...
5
4062
by: Segfahlt | last post by:
I need a little help here please. I have 2 win forms user controls in 2 different projects that I'm hosting in 2 different virtual directories. The controls have been test and operate okay in...
0
2579
by: Dean Earley | last post by:
Hi all. I have just added translucency to one of my applications using the layered windows API, but I have come across a redraw problem. Unfortunately, I cant reproduce this in a standalone...
2
13053
by: diogoko | last post by:
I have some code like: try { someButton.disabled = true; cpuIntensiveCode(); } finally { someButton.disabled = false; } The problem is that someButton is never disabled, because the browser
8
1185
by: Spockman | last post by:
Hi Guys! I stuck in this problem quiet awhile. I have a MainForm in my application. It contains a second one as a member. If both a visible I have a problem to redraw the second one. eg: MainForm...
23
4463
by: raylopez99 | last post by:
Here I am learning WinForms and two months into it I learn there's a WPF API that is coming out. Is this WPF out yet, and is it a threat to WinForms, in the sense that all the library routines I...
0
7251
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
7430
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...
1
7089
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
7517
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
5673
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
5072
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
1581
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
790
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
451
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...

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.