Solved

Why the objects keep refreshing?

Posted on 1998-09-01
5
292 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

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

Often, when implementing a feature, you won't know how certain events should be handled at the point where they occur and you'd rather defer to the user of your function or class. For example, a XML parser will extract a tag from the source code, wh…
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…
The goal of the video will be to teach the user the concept of local variables and scope. An example of a locally defined variable will be given as well as an explanation of what scope is in C++. The local variable and concept of scope will be relat…
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

623 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