Solved

CWnd Flicker when resizing a window

Posted on 2003-11-14
5
1,377 Views
Last Modified: 2013-11-20
I have a class derived off of CWnd (CDataTable).

I have the application setup in such a way that when you resize the main window, the CDataTable object will also scale to fit a specified ratio of the screen.

The problem is, when I resize the window, and the CDataTable resizes, the data table produces a flicker effect.

I have tried adding a double-buffer to the CDataTable's WM_PAINT message before painting, but it doesn't affect anything.

I am hoping to figure out either how to stop the flicker, or an easy way to display a flicker free bounding region in place of the entire table when resizing.  Essentially, I need absolutely NO FLICKER;
0
Comment
Question by:r2far
  • 2
  • 2
5 Comments
 
LVL 19

Expert Comment

by:Dexstar
ID: 9751872
r2far:

> I am hoping to figure out either how to stop the flicker, or an easy way to
> display a flicker free bounding region in place of the entire table when
> resizing.  Essentially, I need absolutely NO FLICKER;

Have you tried overriding OnEraseBkGnd() and returning TRUE to block the default erasing process?  That's helped me out a lot in the past.

Hope That Helps,
Dex*
0
 
LVL 19

Expert Comment

by:Dexstar
ID: 9751885
0
 
LVL 4

Author Comment

by:r2far
ID: 9752086
I had already overriden OnEraseBackground() and returned true from it before the base class call.

The link helps but doesn't completly solve my problem.

I can use 'LockWindowUpdate();' to prevent redraw of the object while resizing, but I was hoping to at least have a minimal bounding region to show how the CWnd object is being resized as the user resizes the entire application.

I think what I need is something to inicate when resizing hs stopped.  then I could use that and the OnSize() message to control when I display the full screen, or when I display the bounding region only.

I am getting closer to a solution though
0
 
LVL 4

Author Comment

by:r2far
ID: 9752091
If I can get the application to tell me when sizing starts and when sizing ends, i can actually draw the bounding region using the view.  But I need those start and end points.
0
 
LVL 31

Accepted Solution

by:
Zoppo earned 250 total points
ID: 9753476
Hi r2far,


try calling
      SetClassLong( m_hWnd, GCL_STYLE, GetClassLong( m_hWnd, GCL_STYLE ) & ~( CS_HREDRAW | CS_VREDRAW ));
within a function of the CWnd after window is created (i.e. in an overridden Create)

Lot of windows have by default set the class styles CS_HREDRAW | CS_VREDRAW which indicate the window is
comleteley redrawn when horizontal or vertical resized.

WM_SIZE message is generated while resizing if windows is set to draw windows while move/size ... so WM_SIZE
handler is not a start/end point of re-sizing ...

You can IMO use WM_NCLBUTTONDOWN/WM_NCLBUTTONUP to get start/end point of resize action

hope that helps,

ZOPPO
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This is to be the first in a series of articles demonstrating the development of a complete windows based application using the MFC classes.  I’ll try to keep each article focused on one (or a couple) of the tasks that one may meet.   Introductio…
Introduction: Hints for the grid button.  Nested classes, templated collections.  Squash that darned bug! Continuing from the sixth article about sudoku.   Open the project in visual studio. First we will finish with the SUD_SETVALUE messa…
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

919 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now