473,405 Members | 2,154 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,405 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 5416
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...
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: 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
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
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...
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
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.