Solved

Why the objects keep refreshing?

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Unlike C#, C++ doesn't have native support for sealing classes (so they cannot be sub-classed). At the cost of a virtual base class pointer it is possible to implement a pseudo sealing mechanism The trick is to virtually inherit from a base class…
This article will show you some of the more useful Standard Template Library (STL) algorithms through the use of working examples.  You will learn about how these algorithms fit into the STL architecture, how they work with STL containers, and why t…
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 how to clear a vector as well as how to detect empty vectors in C++.

679 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