Solved

Why the objects keep refreshing?

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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone 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

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Written by John Humphreys C++ Threading and the POSIX Library This article will cover the basic information that you need to know in order to make use of the POSIX threading library available for C and C++ on UNIX and most Linux systems.   [s…
The goal of the tutorial is to teach the user how to use functions in C++. The video will cover how to define functions, how to call functions and how to create functions prototypes. Microsoft Visual C++ 2010 Express will be used as a text editor an…
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…

752 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