Solved

Screen flicker

Posted on 2002-03-13
8
326 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
Comment Utility

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
Comment Utility
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
Comment Utility
>>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
 

Author Comment

by:CodeJokey50
Comment Utility
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
Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

 
LVL 23

Expert Comment

by:Roshan Davis
Comment Utility
Okay, waiting for your mail....

Roshmon
0
 
LVL 23

Expert Comment

by:Roshan Davis
Comment Utility
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
Comment Utility
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
Comment Utility
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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

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…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
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.
The viewer will learn additional member functions of the vector class. Specifically, the capacity and swap member functions will be introduced.

744 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

13 Experts available now in Live!

Get 1:1 Help Now