tags:

views:

51

answers:

1

I have a custom control, which owns an edit box and moves it around, etc. The edit-box is typically modified with a wodge of code like this:

edit.MoveWindow( &rc );
edit.SetWindowText( text );
edit.SetLimitText( N );
edit.ShowWindow(SW_SHOW);
edit.SetFocus();
edit.SetSel(0, CB_ERR);

RECT rc is in coordinates local to the custom control, edit is created with the custom control as parent. I'm not even sure this is definitely the problem, but when triggering this code sometimes it is nice and smooth, other times my entire desktop appears to flicker like it's being redrawn. I can't see I'm explicitly calling Invalidate(Rect) anywhere.

Any ideas?

+1  A: 

It's not going to be any of the code that you are showing us. A whole desktop flash is nearly always somewhere in your code that is calling InvalidateRect(NULL,...) so keep digging.

Several of these calls will result in messages being sent to the parent window of the edit, most likely the InvalidateRect is happening while handling that message.

If I was a betting man, I'd bet on the SetFocus() call as the one that's triggering the repaint.

John Knoeller