Solved

Screen flicker

Posted on 2002-03-13
8
327 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
 

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
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

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

Suggested Solutions

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
Introduction This article is a continuation of the C/C++ Visual Studio Express debugger series. Part 1 provided a quick start guide in using the debugger. Part 2 focused on additional topics in breakpoints. As your assignments become a little more …
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 learn how to user default arguments when defining functions. This method of defining functions will be contrasted with the non-default-argument of defining functions.

914 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