Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Toolkit Pro
  New Posts New Posts RSS Feed - SOLVED MTI tab change flicker
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

SOLVED MTI tab change flicker

 Post Reply Post Reply
Author
Message
Ark42 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 October 2003
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ark42 Quote  Post ReplyReply Direct Link To This Post Topic: SOLVED MTI tab change flicker
    Posted: 30 March 2005 at 8:10pm
I've seen a lot of posts about MTI tabs and various flicker issues when switching tabs. There seemed to be lots of different methods to try to solve this, but they don't make much sense. Hard coding large window size values, ignoring erasing the background, etc. None of that really works for all flicker and doesn't seem to be the best way to solve it anyways.
What I did was simply override ON_WM_MDIACTIVATE() in my CXTPTabClientWnd derived class (and also my CMDIClient CWnd derived class for when I'm not even using MTI!) and place in it:

void MyCXTPTabClientWndDerivedClass::OnMDIActivate(BOOL bActivate, CWnd* pActivateWnd, CWnd* pDeactivateWnd)
{
    SetRedraw(FALSE);
    CWnd::OnMDIActivate(bActivate, pActivateWnd, pDeactivateWnd);
    SetRedraw(TRUE);
    RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW | RDW_ERASE | RDW_ALLCHILDREN);
}

Thus, any redrawing for any reason that happens during the switch process, doesn't take place until the switch completes, and you never see the flicker of a window when changing windows.

Back to Top
Barto View Drop Down
Groupie
Groupie


Joined: 27 February 2005
Location: Germany
Status: Offline
Points: 60
Post Options Post Options   Thanks (0) Thanks(0)   Quote Barto Quote  Post ReplyReply Direct Link To This Post Posted: 31 March 2005 at 4:18am
great solution. this problem has always been bugging me, but i never bothered to look for a solution as I found out that several other applications all have the same problem... thanx
Back to Top
zhou_wz View Drop Down
Groupie
Groupie


Joined: 11 December 2003
Status: Offline
Points: 44
Post Options Post Options   Thanks (0) Thanks(0)   Quote zhou_wz Quote  Post ReplyReply Direct Link To This Post Posted: 31 March 2005 at 4:42am
Cool, But when first pane still flickers if you let it maximum programlly.
Back to Top
Ark42 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 October 2003
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ark42 Quote  Post ReplyReply Direct Link To This Post Posted: 31 March 2005 at 11:54am

It might depend if you are using tab groups or not. Attach(this, TRUE or FALSE);
If you are not using groups, you can use the same SetRedraw trick when creating new windows to eliminate all flicker.  I still do get flicker when I am using groups, because something in causing the redraw to be turned back on someplace in CXTPTabClientWnd then.  I am still investigating that.


Back to Top
Ark42 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 October 2003
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ark42 Quote  Post ReplyReply Direct Link To This Post Posted: 31 March 2005 at 2:09pm

Ok, the only thing causing the flicker then for me was because I was calling SetWindowPos in my OnInitialUpdate, so I just only do that if I am NOT using tab groups, and its fine. I have no flicker anywhere at all, but there is another problem.  I scale my windows to autofit some content in them when they are created, so I need to know their exact size after they are created, but before they are shown.  Using the SetRedraw wrapping this works most of the time, except when using MTI and it is the first window to be displayed, because the tab bar doesn't appear until later on.  I thought calling CXTPTabClientWnd::UpdateContents would help, but that function basically does nothing because of the IsWindowVisible() check at the start there. I just changed it from:
    if (m_hWnd == 0 || !IsWindowVisible())
        return;
to:
    if (m_hWnd == 0)
        return;

and suddenly all my code works great! I know the exact size of the windows, regardless of the tab bar appearing or not, and I get absolutely no flickering anywhere at all.

Oleg - can this change be made into the next release?  I did not see any bad side effect from removing that IsWindowVisible call from UpdateContents() but maybe there is a situation I am not thinking of?

Back to Top
Oleg View Drop Down
Senior Member
Senior Member


Joined: 21 May 2003
Location: United States
Status: Offline
Points: 11234
Post Options Post Options   Thanks (0) Thanks(0)   Quote Oleg Quote  Post ReplyReply Direct Link To This Post Posted: 06 April 2005 at 5:00am

We changed it too.

Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS
Back to Top
Ark42 View Drop Down
Senior Member
Senior Member
Avatar

Joined: 20 October 2003
Status: Offline
Points: 291
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ark42 Quote  Post ReplyReply Direct Link To This Post Posted: 06 April 2005 at 12:25pm

Wow, thanks for all the changes!
BTW guys, documentation is looking very nice in recent versions.
Keep up the good work.

Back to Top
 Post Reply Post Reply
  Share Topic   

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.04
Copyright ©2001-2021 Web Wiz Ltd.

This page was generated in 0.031 seconds.