Solved

Screen flicker

Posted on 2002-03-13
8
330 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
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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.

 

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

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

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

Suggested Solutions

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…
C++ Properties One feature missing from standard C++ that you will find in many other Object Oriented Programming languages is something called a Property (http://www.experts-exchange.com/Programming/Languages/CPP/A_3912-Object-Properties-in-C.ht…
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 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.

809 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