Print Page | Close Window

SOLVED MTI tab change flicker

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Toolkit Pro
Forum Description: Topics Related to Codejock Toolkit Pro
URL: http://forum.codejock.com/forum_posts.asp?TID=2054
Printed Date: 07 November 2025 at 4:57pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: SOLVED MTI tab change flicker
Posted By: Ark42
Subject: SOLVED MTI tab change flicker
Date 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.




Replies:
Posted By: Barto
Date 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


Posted By: zhou_wz
Date Posted: 31 March 2005 at 4:42am
Cool, But when first pane still flickers if you let it maximum programlly.


Posted By: Ark42
Date 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.




Posted By: Ark42
Date 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?



Posted By: Oleg
Date Posted: 06 April 2005 at 5:00am

We changed it too.



-------------
Oleg, Support Team
CODEJOCK SOFTWARE SOLUTIONS


Posted By: Ark42
Date 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.




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.04 - http://www.webwizforums.com
Copyright ©2001-2021 Web Wiz Ltd. - https://www.webwiz.net