Solved

Screen flicker

Posted on 2002-03-13
8
334 Views
Last Modified: 2008-03-04
I have an application that uses two windows and an edit control that for the most part is single line, but under certain circumstances enlarges itself to 4 lines thus resizing itself and the display window below it.

Display & Main windows have a background of COLOR_APPWORKSPACE.
Edit Windows background is COLOR_WINDOW

In the Display area's paint event I inflate the client area by -4 x and y and then paint that area with FillRect and COLOR_WINDOW

In the routine that resizes these two windows I'm using MoveWindow.

What I'm encountering is severe screen flicker and I was wondering if DeferWindowPos would eliminate this problem, or possible do I have to change something in WNDCLASSEX

I'm calling Windows API not using MFC

Thanks - Peter
0
Comment
Question by:CodeJokey50
[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
  • 4
  • 4
8 Comments
 
LVL 23

Accepted Solution

by:
Roshan Davis earned 100 total points
ID: 6863513

The major flicker may due to the WM_ERASEBACKGROUND. U r filling the background area with a color, Windows also filling before ur color fill with WM_ERASEBACKGROUND. THis can be avoid by assigning a NULL_BRUSH to erase background.
THe code will be something like this
SetClassLong(hWnd, GCL_HBRBACKGROUND, (LONG)GetStockObject(NULL_BRUSH))

and when u creating a child window, u must have to set WS_CLIPCHILDREN for avoiding child area painting when parent draw coming.

GOOD LUCK
0
 

Author Comment

by:CodeJokey50
ID: 6863622
To roshmon:

Your solution: SetClassLong & my implementation of it modified slightly by just returning 0 in the windows procedure for WM_EREASEBKGRND produced the same effect and did if fact get rid of the flicker.

As a matter of fact I did implement SetClassLong also which probably has the same effect as setting that property in WNDCLASSEX.

Only problem is it also got rid of the effect that I'm trying to achieve and when I put the FillRect call back into WM_PAINT for that window, right back to the flicker again.

Thanks regardless, it steers me in a little different direction than I was contempating.
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 6863641
>>I have an application that uses two windows and an edit control that for the most part is single line
What r the other two windows

>>but under certain circumstances enlarges itself to 4 lines thus resizing itself and the display window below it.
Please make clear how


>>In the Display area's paint event I inflate the client area by -4 x and y and then paint that area with
>>FillRect and COLOR_WINDOW

Why r u using FillRect for painting windows, Post WM_PAINT to that window
or painting windows background use, WM_CTLCOLOR

Roshmon
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Author Comment

by:CodeJokey50
ID: 6864165
roshmon:

I've e-mailed you a copy of the application.  A picture is worth a thousand words this way you can see what I mean.
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 6864179
Okay, waiting for your mail....

Roshmon
0
 
LVL 23

Expert Comment

by:Roshan Davis
ID: 6864211
This can be simply avoid by using the SetClassLong function. Apply this function to the window below the edit control.
And also modify that window style to WS_CLIPCHILDREN.

Important: Your computer infected by love virus. Here my Norton appl. found virus on words.exe

Roshmon
0
 

Author Comment

by:CodeJokey50
ID: 6864771
True, but like I said in my post of 3/13/2002 10:00 pm that defeats the visual effect that I'm trying to create so I have to come up with a different solution.

My father complained about the same virus.  I'm getting him to clean it on his computer and send it back to me, then I will compare the two files to see exactly what has been cleaned.  

I really suspicious of virus checking software because of the potenial it has for making McAfee and others millions of dollars. I've read quite a few articles that support this postion also.
0
 

Author Comment

by:CodeJokey50
ID: 6866675
Even though your answer didn't help me out, it is technically correct and it did help me elliminate all the resonable possibilities.

Thanks
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

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

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…
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 difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
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.

734 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