// JP opened flex table

Click to See Complete Forum and Search --> : BUG: CListCtrl: repaint missing


Udo Liess
June 9th, 1998, 05:58 AM
Some days ago I posted a note about a problem with CListCtrl. But no reactions. Now I found out a little bit more about it.


Here is the BUG:


(I use WinNT 4.0, VC5)

Create a MFC application as dialog based (MainDialog).


Create a dialog resource (ChildDialog).

Set dialog style to CHILD.

Place a list control on this dialog.


In MainDialog::OnInit() call ChildDialog::Create().

--> ChildDialog is a child of MainDialog


Thats all!


Now run the application.

Use ALT+TAB to switch to another application that hides our MFC application. Then switch back to our application the same way. All OK? Yes, no problem.

BUT: Click on the list control (--> set the (unvisible) focus to the list control).

Now switch to another application and back again... You will see: THERE IS NO REPAINT OF LIST CONTROL!!!


I found out what happend (but dont know why it happens):

For "debugging" in ChildDialog::OnPaint() I called Beep(1000,1000),

in CListCtrlOwn::OnPaint() I called Beep(2000,1000).

And then I hear and see: If the list control has the focus, Windows first calls CListCtrlOwn::OnPaint() and then ChildDialog::OnPaint(). But that is NOT the right way, isn't it?


Udo

Udo Liess
September 8th, 1998, 10:07 AM
I received a mail from Laurent (see below). Thank you. Here my answer:


I have no experience with WS_CLIPCHILDREN but I worked out an other solution. It is a little bit dirty, because it only repaints the contents of the CListCtrl not the border:


In my program I have got CDialog::CDlgSequenceControl and this dialog has got CListCtrl::m_ListFigure. Now I include the paint methode of dialog and call the Invalidate(TRUE)-function vor my CListCtrl.


void CDlgSequenceControl::OnPaint()

{

CPaintDC dc(this); // device context for painting




m_ListFigure.Invalidate(TRUE); // THIS IS A BUG WORKAROUND!!! of microsoft bug: wrong repaint order


// Do not call CDialog::OnPaint() for painting messages

}


Maybe this will help you a little bit. I my case it is enough for the first time (sometimes the border just vanishes). I have no hope to get more if I use MFC...


Udo


----------

From: Laurent Martin

Sent: Dienstag, 8. September 1998 14:29

To: liess@ardenne-at.de

Subject: CListCtrl: repaint missing


Hello Udo,


I have just read jour bug report in Codeguru, and I have a similar problem:

I created an MDI app with formviews, in which each view contains an

embedded property sheet.

The property sheet has one property page containing a CListCtrl, which

doesn't repaint well when it has the focus!

But this problem appears only when my property page (dialog) has the

WS_CLIPCHILDREN style. Does this help you?

Anyway, this does not help me in another case (which worries me now): the

formview contains an activex control, itself containing a property sheet

which in turn contains a CListCtrl... REPAINT PROBLEM again when the

CListCtrl has the focus! Looking through Spy++, I saw that the activex

control, which is an ancestor of the property sheet, has the

WS_WLIPCHILDREN style. But if I disable this style, things get even worse:

all of my property page controls have repaint problems!

SOS


Please tell me if you have any clues.

Thank you Udo!


Laurent

Laurent Martin
September 9th, 1998, 01:47 PM
Hello again Udo,


Thank you for your quick reply.

On my side, I've worked out an acceptable solution: instead of issuing an

Invalidate in the OnPaint, put this line:


myCListCtrl.RedrawWindow(NULL,NULL,RDW_FRAME | RDW_INVALIDATE | RDW_ERASE | RDW_UPDATENOW);


I hope this will do it for you too.

See you.

Laurent

//JP added flex table