开发者

A single MFC/Win32 control seems to be making my whole desktop repaint

开发者 https://www.devze.com 2022-12-21 12:40 出处:网络
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:

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) anyw开发者_如何学Pythonhere.

Any ideas?


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.

0

精彩评论

暂无评论...
验证码 换一张
取 消