Solved

CWnd Flicker when resizing a window

Posted on 2003-11-14
5
1,370 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 30

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

Suggested Solutions

Introduction: Finishing the grid – keyboard support for arrow keys to manoeuvre, entering the numbers.  The PreTranslateMessage function is to be used to intercept and respond to keyboard events. Continuing from the fourth article about sudoku. …
Introduction: Dialogs (1) modal - maintaining the database. Continuing from the ninth article about sudoku.   You might have heard of modal and modeless dialogs.  Here with this Sudoku application will we use one of each type: a modal dialog …
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.
Excel styles will make formatting consistent and let you apply and change formatting faster. In this tutorial, you'll learn how to use Excel's built-in styles, how to modify styles, and how to create your own. You'll also learn how to use your custo…

757 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

18 Experts available now in Live!

Get 1:1 Help Now