473,402 Members | 2,064 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,402 software developers and data experts.

Help for Flicker free drawing in c#

I am developing a program in c# where I have to show device connected each other in a dashboard.I am drawing in OnPaint event.when the user move the devices the background is flickering.because each time i am clearing the graphics objects.
I tried using Doublebuffering but still not working.

any body can help me on this.

Thanks
Abdun
Jan 28 '08 #1
6 7468
leoiser
41
did you use the below code

this.SetStyle(ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint |
ControlStyles.DoubleBuffer, true);

If if does not work please let me know.You can email me for immediate reply.Thanks

I am developing a program in c# where I have to show device connected each other in a dashboard.I am drawing in OnPaint event.when the user move the devices the background is flickering.because each time i am clearing the graphics objects.
I tried using Doublebuffering but still not working.

any body can help me on this.

Thanks
Abdun
Jan 29 '08 #2
did you use the below code

this.SetStyle(ControlStyles.AllPaintingInWmPaint |
ControlStyles.UserPaint |
ControlStyles.DoubleBuffer, true);

If if does not work please let me know.You can email me for immediate reply.Thanks
I used that but its not working.
Jan 29 '08 #3
leoiser
41
using System.Runtime.InteropServices;

#region "Avod Flickering the form"

int paintFrozen;

private const int WM_SETREDRAW = 0xB;

[DllImport("User32")]
private static extern bool SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);

private bool FreezePainting
{
get { return paintFrozen > 0; }
set
{
if (value && IsHandleCreated && this.Visible)
{
if (0 == paintFrozen++)
{
SendMessage(Handle, WM_SETREDRAW, 0, 0);
}
}
if (!value)
{
if (paintFrozen == 0)
{
return;
}

if (0 == --paintFrozen)
{
SendMessage(Handle, WM_SETREDRAW, 1, 0);
Invalidate(true);
}
}
}
}
#endregion


Before drawing the image/picture put FreezePainting =true; and after finish FreezePainting=false; it will work...
Jan 29 '08 #4
using System.Runtime.InteropServices;

#region "Avod Flickering the form"

int paintFrozen;

private const int WM_SETREDRAW = 0xB;

[DllImport("User32")]
private static extern bool SendMessage(IntPtr hWnd, int msg, int wParam, int lParam);

private bool FreezePainting
{
get { return paintFrozen > 0; }
set
{
if (value && IsHandleCreated && this.Visible)
{
if (0 == paintFrozen++)
{
SendMessage(Handle, WM_SETREDRAW, 0, 0);
}
}
if (!value)
{
if (paintFrozen == 0)
{
return;
}

if (0 == --paintFrozen)
{
SendMessage(Handle, WM_SETREDRAW, 1, 0);
Invalidate(true);
}
}
}
}
#endregion


Before drawing the image/picture put FreezePainting =true; and after finish FreezePainting=false; it will work...
Thank you for reply.
Actually i am drawingon a Panel not on form.same thing can be applicabe
to Panel or not?
Jan 29 '08 #5
Actually i am drawing on a Panel's OnPaint event.I have created a Graphics object
using Graphics g=Panel.CreateGraphics();

Each time when OnPaint event occurs i clearing the g objects and trying to
redraw the line between devices when they are moved.

where to Put FreezePainting=true inside OnPaintEvent.
I put this in OnPaint event's starting line FreezePainting=true
and OnPaint event's lastline FreezePainting=false;

Its not drawing anything.

Thanks
Jan 29 '08 #6
leoiser
41
before calling the paint() u should call for FreezePainting=true

Actually i am drawing on a Panel's OnPaint event.I have created a Graphics object
using Graphics g=Panel.CreateGraphics();

Each time when OnPaint event occurs i clearing the g objects and trying to
redraw the line between devices when they are moved.

where to Put FreezePainting=true inside OnPaintEvent.
I put this in OnPaint event's starting line FreezePainting=true
and OnPaint event's lastline FreezePainting=false;

Its not drawing anything.

Thanks
Jan 31 '08 #7

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

Similar topics

0
by: Martin Streller | last post by:
Hello, The code below represents a simple ownerdrawn, Listview class in C#. Its purpose is to avoid the flicker of the MS ListView. So I can't fall back to their one. Does anybody know why I...
2
by: mhansemann | last post by:
I'm a C# (but not programming in general) novice, but I couldn't find any answer to this elsewhere. I'm trying to make a text scroll on the form. I thought this was a good example to get started...
20
by: Charles Law | last post by:
This is actually a follow on from yesterday's post about masking mouse clicks in a user control. The solution I have implemented - from Herfried - places a transparent window over the entire...
1
by: Niels Jensen | last post by:
Hi guys, I have the following code which is supposed to draw a grid in a panel consisting of a specified number of squares. I can get it to draw the grid and activate the autoscroll feature,...
0
by: alex sparsky | last post by:
I've written a small control that doesn't do much other than draw some things on the screen with the drawing classes. I am using double buffer as well as doing an internal drawing to buffer on a GDI...
17
by: pigeonrandle | last post by:
Hi, I have seen loads of different ways to do this, but the all seem to yield the same result - text that doesn't flicker when it's moving too slowly! Does anyone know 'the best way' to make text...
4
by: Frank Rizzo | last post by:
Hello, I inherited a large Winforms project that is suffering from excessive flicker when switching between portions of the application. I've noticed that most parts of the application (user...
1
by: =?iso-8859-1?B?S2VyZW0gR/xtcvxrY/w=?= | last post by:
Hi, i am looking for a way to clear and fill a listview and right after a treeview nearly flicker and delay free. The TreeView and Listview contain Images and about 1000 Items. What can someone...
8
by: Rainer Queck | last post by:
Hello NG, I had/have a bad flicker Problem with my Application. On starting some applications, while my app was running, the whole Display started to flicker. Even the desktop Icons! Looking...
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
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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
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
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.