Solved

Screen flicker

Posted on 2002-03-13
8
329 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
  • 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

Netscaler Common Configuration How To guides

If you use NetScaler you will want to see these guides. The NetScaler How To Guides show administrators how to get NetScaler up and configured by providing instructions for common scenarios and some not so common ones.

Question has a verified solution.

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

Templates For Beginners Or How To Encourage The Compiler To Work For You Introduction This tutorial is targeted at the reader who is, perhaps, familiar with the basics of C++ but would prefer a little slower introduction to the more ad…
  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 …
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 how to pass data into a function in C++. This is one step further in using functions. Instead of only printing text onto the console, the function will be able to perform calculations with argumentents given by the user.

823 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