473,372 Members | 1,277 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,372 software developers and data experts.

CSharp Resize flicker and flashing

If you have "Show window contents while dragging" turned on
(Right-click desktop, Appearance, Effects) then you get horrible
flashing
and flickering on a CSharp form when the form hosts a
TreeView or WebBrowser control and then you resize the form.

Here is what I've tried so far:
1. Turning off CS_VREDRAW and CS_HREDRAW in both the parent form and a
subclass of the control via the "override CreateParams" property
(these values were already off).

2. Setting various styles and handling the OnPaintBackground to do
nothing while also filtering WM_ERASEBKGND during the OnNotifyMessage
event. This was done by the following in the form and control
sub-class constructor:
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);

// Allows for catching the WM_ERASEBKGND message
SetStyle(ControlStyles.EnableNotifyMessage, true);

3. Setting WS_CLIPCHILDREN in the form's CreateParams (was already
set).

4. Using LockWindowUpdate on the Resize event with a timer that clears
it after 300ms of no additional resizes. This fixes the flashing of
the form, but causes desktop icons to refresh which is equally
annoying.

Just for fun I tried Delphi and made a form with both controls and the
resize has no flicker whatsoever so I know a fix is possible.

Thanks in advance for any help.
Nov 15 '05 #1
8 5415
Ian Stiles wrote:

If you have "Show window contents while dragging" turned on
(Right-click desktop, Appearance, Effects) then you get horrible
flashing
and flickering on a CSharp form when the form hosts a
TreeView or WebBrowser control and then you resize the form.

Here is what I've tried so far:
1. Turning off CS_VREDRAW and CS_HREDRAW in both the parent form and a
subclass of the control via the "override CreateParams" property
(these values were already off).

2. Setting various styles and handling the OnPaintBackground to do
nothing while also filtering WM_ERASEBKGND during the OnNotifyMessage
event. This was done by the following in the form and control
sub-class constructor:
SetStyle(ControlStyles.UserPaint, true);
SetStyle(ControlStyles.AllPaintingInWmPaint, true);
SetStyle(ControlStyles.DoubleBuffer, true);

// Allows for catching the WM_ERASEBKGND message
SetStyle(ControlStyles.EnableNotifyMessage, true);

3. Setting WS_CLIPCHILDREN in the form's CreateParams (was already
set).

4. Using LockWindowUpdate on the Resize event with a timer that clears
it after 300ms of no additional resizes. This fixes the flashing of
the form, but causes desktop icons to refresh which is equally
annoying.

Just for fun I tried Delphi and made a form with both controls and the
resize has no flicker whatsoever so I know a fix is possible.

Thanks in advance for any help.


C# is an interpreted language, so it will be slower than native machine code.
I don't know if Delphi is interpreted or not.

Don't erase/paint/do anything in response to WM_ERASEBKGND.

Make sure that you paint *ONLY* within the invalid/paint region in response to
the repaint.
Nov 15 '05 #2
"Julie" <ju***@aol.com> wrote in message news:40***************@aol.com...
C# is an interpreted language, so it will be slower than native machine code. I don't know if Delphi is interpreted or not.


C# is JIT compiled to native code, so a given line of code is interpreted
only the first time it executes. Even then, what's interpreted is highly
optimized pcode. So it is not really accurate to say that C# is
interpreted -- at least not without qualification.

Since the original poster's problem is confined to the TreeView and
WebBrowser controls, the root cause is probably inefficiencies in those
controls. The steps he's already taken are probably beyond the capabilities
of most WinForm developers, and he still hasn't solved it. So my suggestion
is a low-tech one ... live with it, or consider 3rd party replacements for
the offending controls.

After all, as a user I would not be very concerned about such artifacts if
they were confined to when I was dragging the form. I don't really need to
see it then anyway, at least any more than is needed to position it where I
want it.

--Bob
Nov 15 '05 #3
Julie wrote:
[...]
C# is an interpreted language, so it will be slower than native machine code.
I don't know if Delphi is interpreted or not.


Delphi's natively compiled.

Regards
Nov 15 '05 #4
Julie <ju***@aol.com> wrote:
C# is an interpreted language


No it's not. It's JIT-compiled, which is entirely different from being
interpreted.

Consider a very large loop. In an interpreted language, the interpreter
looks at the bytecodes (or whatever) of the language for each iteration
of the loop, and performs whatever operations those bytecodes describe.
This is very slow.

A JIT-compiler, however, takes the method and compiles it into native
code. The whole loop then runs in native code, and nothing needs to
examine the bytecode within the loop. This is usually about the same
speed as "statically compiled" languages.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #5

"C# Learner" <cs****@learner.here> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
Julie wrote:
[...]
C# is an interpreted language, so it will be slower than native machine code. I don't know if Delphi is interpreted or not.


Delphi's natively compiled.


C# is JIT-compiled. That is, it is compiled into native code too, but this
normally happens as needed during loading and execution. Once compiled,
it's as native as anything else. That is the .NET path toward inter-CPU
portability.
Nov 15 '05 #6
Michael A. Covington wrote:
Delphi's natively compiled.


C# is JIT-compiled. That is, it is compiled into native code too, but this
normally happens as needed during loading and execution. Once compiled,
it's as native as anything else. That is the .NET path toward inter-CPU
portability.


Yeah, I guess "natively-compiled" is rather ambiguous. Instead, I
should have said "fully compiled prior to program execution".

Thanks
Nov 15 '05 #7
"Jon Skeet [C# MVP]" wrote:

Julie <ju***@aol.com> wrote:
C# is an interpreted language


No it's not. It's JIT-compiled, which is entirely different from being
interpreted.

Consider a very large loop. In an interpreted language, the interpreter
looks at the bytecodes (or whatever) of the language for each iteration
of the loop, and performs whatever operations those bytecodes describe.
This is very slow.

A JIT-compiler, however, takes the method and compiles it into native
code. The whole loop then runs in native code, and nothing needs to
examine the bytecode within the loop. This is usually about the same
speed as "statically compiled" languages.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too


Yeah, I got the terminology wrong.

Regardless it is curently slower than native. Last I heard is that it averages
about 80% as fast as native code.
Nov 15 '05 #8
Julie <ju***@aol.com> wrote:
Yeah, I got the terminology wrong.

Regardless it is curently slower than native. Last I heard is that it
averages about 80% as fast as native code.


It entirely depends on what you're doing. For many things it'll be very
very close to native code - to the extent that whether or not it beats
a native compiler will depend on the compiler. As I say though, it
depends on what you're doing.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 15 '05 #9

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

Similar topics

2
by: Abhishek | last post by:
My objective is quite simple. I want to display a JPG image and then on it overlay a polygon. This polygon can be moved by a user. The even is trapped on the mouse down event of the control. I can...
0
by: Byron | last post by:
HI- I have a problem while resizing a Window to make a transparent overlay. Using a control looks terrible due to flicker, but you can use a borderless form with the transparency setting that...
0
by: Lauren Quantrell | last post by:
I never noticed this before but looking at a continuous bound form, when I resize it it seems to also requery the recordsource. Is that possible or am I imagining it? I notice the rows flashing as...
5
by: Ian Stiles | last post by:
I have tried everything under the sun to get rid of horrible flashing and flickering that occurs on a CSharp form when the form hosts a TreeView or WebBrowser control and then you resize the form....
1
by: **Developer** | last post by:
I'm geting a lot of flashing while resizing a form containing one of my usercontrols that is docked fill. This doesn't alway happen, depends on what is visible on the control. Is there some...
5
by: Jim Hubbard | last post by:
Has anyone seen a fix for the flickering effect you get when resizing a Webbrowser control? It's really irritating and doesn't make for a professional-looking application.
8
by: nirdeshonline | last post by:
Hi, I have added a simple listbox in windows form under c# 2.0. It contains a collection of approx 10 strings as list items. Now when i resize the form whole listbox flickers. Please tell me...
11
by: Newbie Coder | last post by:
Hi All VB.NET 2003 Can anyone tell me how to stop a user control being able to be resized during both design time & run time, please? I am looking for something like the LOCKED property,...
3
by: JT | last post by:
have a VB6 project that on the form I have set the BorderStile to 2 - sizable and created a function to resize the form and its controls min or max. Although, I am trying to find a way to...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.