Solved

Why the objects keep refreshing?

Posted on 1998-09-01
5
289 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

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

  Included as part of the C++ Standard Template Library (STL) is a collection of generic containers. Each of these containers serves a different purpose and has different pros and cons. It is often difficult to decide which container to use and …
This article shows you how to optimize memory allocations in C++ using placement new. Applicable especially to usecases dealing with creation of large number of objects. A brief on problem: Lets take example problem for simplicity: - I have a G…
The viewer will learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.
The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

816 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