hi, i created a paint program for my c++ class using a global GraphicsPath
variable. i the, in the onpaint method, draw the line the users draws with
the mouse. simple. the only problem is that when i invalidate the panel im
drawing on in order to see the line, it flickers, even with double buffering.
if i only invalidate a rectangle around teh mouse, if the user mouse the
mouse too fast the line wont be drawn in certain intervals because the paint
event cant fire enough times. how can i either eliminate the flickering or
invalidate a part of the panle enough that it will show the entire line at
draw time. (if i bring anything in front of the panel or minimize the
program, the windows repaint method shows the graphics)
i also tried using a Graphics variable to draw on a surface on a mousedown
event, but then if you minimized the program or brought anything in front of
the graphics, youd lose what you drew. how can i sto this from happeneing?
which ever question is easier to answer, if any, would be helpful. ive been
researching this for weeks but i cant seem to find an answer, thanks
--
-iwdu15 12 2032
iwdu15 wrote: hi, i created a paint program for my c++ class using a global GraphicsPath variable. i the, in the onpaint method, draw the line the users draws with the mouse. simple. the only problem is that when i invalidate the panel im drawing on in order to see the line, it flickers, even with double buffering. if i only invalidate a rectangle around teh mouse, if the user mouse the mouse too fast the line wont be drawn in certain intervals because the paint event cant fire enough times. how can i either eliminate the flickering or invalidate a part of the panle enough that it will show the entire line at draw time. (if i bring anything in front of the panel or minimize the program, the windows repaint method shows the graphics)
i also tried using a Graphics variable to draw on a surface on a mousedown event, but then if you minimized the program or brought anything in front of the graphics, youd lose what you drew. how can i sto this from happeneing?
which ever question is easier to answer, if any, would be helpful. ive been researching this for weeks but i cant seem to find an answer, thanks
iwdu15:
You probably need to do something with the WM_ERASEBKGND message. What I
usually do is return TRUE from the handler and draw everything,
including the backround, in OnPaint().
HTH,
David Wilkinson
how would i do that? and what is "the WM_ERASEBKGND message"...thanks for
your help
--
-iwdu15
iwdu15 wrote: how would i do that? and what is "the WM_ERASEBKGND message"...thanks for your help
iwdu15:
If this is a Win32 or MFC application this is a Windows message like any
other. For MFC you can add message handlers by going to the appropriate
class in ClassView and Selecting Properties->Events.
If this is a .NET application then my suggestion may not be relevant.
You will need to ask someone else to help you.
David Wilkinson
oh, ok, thanks anyway.....does anyone else have any ideas?
--
-iwdu15
Yes. Use a NULL background brush
Brian oh, ok, thanks anyway.....does anyone else have any ideas?
how does that take away the flickering shown on the lines drawn?
Flickering is usually due to erasing the background. But if you erase using
the null background brush, you won't see that flash of white.
Brian
"iwdu15" <iw****@discussions.microsoft.com> wrote in message
news:E9**********************************@microsof t.com... how does that take away the flickering shown on the lines drawn?
WM_ERASEBKGND is a system message. Normally a control responds to it by
painting a gray rectangle. That's what you want to disable. You simply
catch that message and swallow it (override WndProc do not call the base
class' WndProc). But it depends which GUI framework you're using.
I'm not sure if this helps, but this is what I usually put in my
constructors (my owner-draw controls are usually inherited from Panel).
This should take care of the flicker problem, provided you're
implementing your own double buffering:
SetStyle(ControlStyles::Opaque, true);
This turns off the system painting of the control. It means if you don't
paint it on your own, there's going to be a hole in your window, which
gets corrupted as you work. So it's essencial that you do your own
painting by overriding the OnPaint method. Create an off-screen bitmap,
paint your contents on there, then show the off-screen bitmap on the
screen in a single statement. That should be the only painting you're
doing to the screen.
Tom
iwdu15 wrote: how would i do that? and what is "the WM_ERASEBKGND message"...thanks for your help
so then how would i do that using the onpaint method? i have colored lines on
my form and every mousemove i invalidate the panel...if thta helps any
--
-iwdu15
You would register the NULL brush at the time the window is registered. This
is basic windows programming. If this is unclear, see the first few chapters
of Charles Petzold's "Programming Windows" Fifth edition.
Brian
Yes, In MFC:
What you need to do is have your drawing/painting go to a memory device
context (CDC) instead of the screen device context in OnDraw( ). Then paint
to the screen using a bitblt to the screen DC from the mem DC.
You need to:
Create a memory Device Context: new CDC( );
Create a bitmap and make it compatible with the screen DC.
Assign the bitmap to the memory DC.
In OnDraw(), draw to the memDC instead of the screen DC using normal GDI
calls as always.
Then at the end, bitblt the Mem DC to the Screen DC.
Also to handle erase:
Write your own erase that does a FillRect (for example) to the Mem DC.
Override the OnEraseBkgnd( ) and don't call the base class.
It sounds complex and it is a bit, but once you get the idea that your
really just drawing to memory then bitblt'ing to the screen all at once, it's
not so bad.
Plus, no more flicker.
I realize that you are probably referring to .NET so my previous MFC guidance
may not be helpful.
However, I also have addressed flicker in .NET, I'll have to check my code
but it know it required two settings not just one. I think they are:
ControlStyles.DoubleBuffer
ControlStyles.AllPaintingInWmPaint
--
Greg McPherran www.McPherran.com
"Greg" wrote: Yes, In MFC:
What you need to do is have your drawing/painting go to a memory device context (CDC) instead of the screen device context in OnDraw( ). Then paint to the screen using a bitblt to the screen DC from the mem DC.
You need to: Create a memory Device Context: new CDC( ); Create a bitmap and make it compatible with the screen DC. Assign the bitmap to the memory DC. In OnDraw(), draw to the memDC instead of the screen DC using normal GDI calls as always. Then at the end, bitblt the Mem DC to the Screen DC.
Also to handle erase: Write your own erase that does a FillRect (for example) to the Mem DC. Override the OnEraseBkgnd( ) and don't call the base class.
It sounds complex and it is a bit, but once you get the idea that your really just drawing to memory then bitblt'ing to the screen all at once, it's not so bad.
Plus, no more flicker. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Shoaib |
last post by:
I have an IFRAME in HTML page whose source is set to some xml page.XML
page gets displayed properly.
But when i open some other IFRAME on top that IFRAME displaying xml,
there is lot of flickering...
|
by: Joaquin Grech |
last post by:
Hi
I did alot of research on this on the web and msdn and I couldn't find
anything.
I have a listview showing as a grid (table looking, with rows and columns
and no images at all, only text)....
|
by: Jack Smash |
last post by:
Hi,
I'm using a UserControl object for all the graphics handling in my
application. However, if I select an image and move it around, I get
flickering. So in order to get rid of the flickering,...
|
by: John Lee |
last post by:
Hi,
I have a windows application that uses the listview to display about 50
items in detailed view - 4 columns. The first column is static and other
columns will be updated in 100-1000ms - it...
|
by: John Lee |
last post by:
Thanks Jay for your response.
I tried your code and it still flickering a lot. To demonstrate it, you can
grab a listview, create 3 columns - name, value, timestamp, in form_load
event to add 50...
|
by: benben |
last post by:
I created a form and overrided OnPaint, OnClick and OnResize methods. My
OnPaint calls base.OnPaint then repaints the whole screen.
The screen flickers a lot! It didn't happen when the app was...
|
by: Imran |
last post by:
Hi ,
I have an mdi applicaton. When user switch between child forms they are
flickering like crazy! When a Child Form loads, you can see it in it's
original size (the size from Design-time) then...
|
by: n00b |
last post by:
I have some forms with maybe around 30 controls on each and anytime I load
these forms different parts of it start flickering though not all of them at
once and not the same ones everytime. the...
|
by: Mark Thompson |
last post by:
I have a problem with my Visual Basic .NET 2003 application which I
have so far been unable to resolve.
I am trying to get an OpenGL control that I have created working
properly as a control on...
|
by: sj |
last post by:
Flickering Subform!
I am developing a Quotation system in Access 03.
At entry, users enter data thru' a form with subform.
However, the subform keep flicker when I run the system on computer...
|
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...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
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
|
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...
| |