Wrox Programmer Forums
Go Back   Wrox Programmer Forums > C# and C > C# 1.0 > C#
|
C# Programming questions specific to the Microsoft C# language. See also the forum Beginning Visual C# to discuss that specific Wrox book and code.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the C# section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old February 24th, 2005, 09:18 AM
Registered User
 
Join Date: Feb 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default how to prevent image flickering?

Hi all,

I have a picturebox (with scrollbars) in my form.
I use the following code:
---------
Graphics g = picBox.CreateGraphics();
g.DrawImage(picBox.Image, new Rectangle(0, 0, picPolicy.ClientSize.Width,
    picPolicy.ClientSize.Height),
    new Rectangle(hScrollBar.Value, vScrollBar.Value,
            picPolicy.ClientSize.Width,
            picPolicy.ClientSize.Height),
            GraphicsUnit.Pixel);
//draws a rectangle to highlight a specified area
g.FillRectangle(brush, rect.Left - hScrollBar.Value, rect.Top - vScrollBar.Value, (rect.Right - rect.Left), (rect.Botom - rect.Top));
picBox.Update();
}
---------
When I'm scrolling the drawn image it flickers too match.
Is there are any way to prevent flickering?

Thanks.

 
Old March 12th, 2005, 01:09 PM
Authorized User
 
Join Date: Mar 2005
Posts: 32
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to aehb
Default

Hello,
there is an idea I used to use it in the animations, but I don't know if it's applicable in your case, you have to work it out.
In the C++ under DOS there were 4 virtual screens for graphics drawing, and while only one screen is visible at a time; you can draw on the other screens and then show them in turn, and that prevents flickering. In a windows application I was trying to make a file manager and was reading the files in the chosen folder to a list box, and I faced a similar problem; when I view the files of a folder like 'windows\system' which has a large number of files, the list box disappears for seconds till the program reads the files and then reappear, I overcame that problem by creating two identical listboxes on the same location and read the files to the hidden list box and then bring it on the top, and that also vanishes the problem, I don't know if you can apply the same idea or not, it's just an idea, good luck and best wishes :)





Similar Threads
Thread Thread Starter Forum Replies Last Post
java script to prevent users to copy image... ethantinder Javascript How-To 3 May 23rd, 2008 12:52 PM
Flickering image transitions in javascript hericles Javascript How-To 3 July 19th, 2007 04:58 PM
How to avoid flickering of controls on CFormview lmadhavi Visual C++ 1 October 4th, 2004 03:00 AM
flickering ducks! Ashleek007 JSP Basics 2 May 11th, 2004 06:36 AM
Refresh a page without the flickering effect pigtail Classic ASP Basics 12 April 5th, 2004 01:34 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.