Solved

Why the objects keep refreshing?

Posted on 1998-09-01
5
284 Views
Last Modified: 2010-04-02
I worked along a program with the MFC library, and I added some code for Bitmap and font display in the OnDraw function. Then the program is compiled and run, but when I
resize the program. The objects inside the view just keeps
flashing/Refreshing. ls there any way that I can get around it?
Thanks
Jacky
0
Comment
Question by:whluk
5 Comments
 
LVL 1

Expert Comment

by:Andy_Keys
ID: 1171825
Look at the WM_sizing and see if this is any use
0
 
LVL 2

Expert Comment

by:duneram
ID: 1171826
alternatively display a bigger screen initially.  SetWindowPos api will let you control the size of a window.  Coupled with GetSystemMetrics(SM_CXSCREEN) AND SM_CYSCREEN you can make a window take the full screen.
0
 
LVL 6

Expert Comment

by:snoegler
ID: 1171827
Perhaps the flashing occurs because you don't process the OnEraseBkgnd() message.
If your OnPaint() function draws the entire update region (i.e. with the background),
then you may ignore the OnEraseBkgnd() message:

BOOL CMyWnd::OnEraseBkgnd()
{
  return TRUE; // Do not call the base class implementation
}
0
 
LVL 8

Accepted Solution

by:
Answers2000 earned 50 total points
ID: 1171828
The Window style for your window will include CS_HREDRAW and CS_VREDRAW which forces a redraw of the _entire_ client area if your Windows is resized (which isn't what you want) - All frames & views do this by default in MFC

The solution is to override PreCreateWindow and create your own window class for which doesn't have these styles set, something like:

BOOL CMyView::PreCreateWindow(CREATESTRUCT& cs) {

    cs.lpszClass = AfxRegisterWndClass(
      cs.style & ~(CS_HREDRAW | CS_VREDRAW)
      ) ;

    return CView::PreCreateWindow(cs)
}



0
 
LVL 8

Expert Comment

by:Answers2000
ID: 1171829
Oops I made a mistake

cs.style & ~(CS_HREDRAW | CS_VREDRAW)

should be

0
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Introduction This article is the first in a series of articles about the C/C++ Visual Studio Express debugger.  It provides a quick start guide in using the debugger. Part 2 focuses on additional topics in breakpoints.  Lastly, Part 3 focuses on th…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

762 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