Print Page | Close Window

Office 2007 theme + animation + draw problem

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Skin Framework
Forum Description: Topics Related to Codejock Skin Framework
URL: http://forum.codejock.com/forum_posts.asp?TID=7568
Printed Date: 27 November 2024 at 5:34am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: Office 2007 theme + animation + draw problem
Posted By: Ark42
Subject: Office 2007 theme + animation + draw problem
Date Posted: 09 July 2007 at 11:11pm

I have two buttons, a play and stop button, where only one is enabled at a time. If I use Office 2007 theme + enable animation and click the play button, the effects blink rapidly as they fade away because the play button disables itself on click and the stop button is then enabled.




Replies:
Posted By: Ark42
Date Posted: 10 July 2007 at 1:43am

I've found the problem here, it was in my custom slider control for the command bars causing extra invalidates.

void CXTPSliderCtrlToolbar::OnPaint(void)
{
    const MSG *msg = GetCurrentMessage();
    if( msg->wParam ) {
        CDC *pDC = CDC::FromHandle((HDC)msg->wParam);
        CRect rect;
        GetClientRect(&rect);

        CTransMemDC memDC(pDC, rect, SLIDER_COLORKEY);

        DefWindowProc(WM_PAINT, (WPARAM)memDC.m_hDC, 0);

        if( GetFocus() == this ) {
            CXTPPaintManager *pPaintMgr = static_cast<CXTPMDIFrameWnd *>(AfxGetMainWnd())->GetCommandBars()->GetPaintManager();
            memDC.Draw3dRect(&rect, pPaintMgr->GetXtremeColor(COLOR_BTNSHADOW), pPaintMgr->GetXtremeColor(COLOR_BTNHIGHLIGHT));
        } else if( (GetStyle() & WS_DISABLED) && m_bkColorKey != 0 ) {
            for( int y = rect.top; y < rect.bottom; y++ ) {
                for( int x = rect.left; x < rect.right; x++ ) {
                    if( (x & 1) == (y & 1) ) {
                        memDC.SetPixel(x, y, m_bkColorKey);
                    }
                }
            }
        }
    } else {
        CPaintDC dc(this);
//        GetParent()->RedrawWindow(NULL, NULL, RDW_INVALIDATE | RDW_UPDATENOW);
        if( pControl ) pControl->RedrawParent(FALSE);
    }
}


Instead of calling RedrawWindow, I had to capture the CXTPControlCustom pointer and call it's RedrawParent().

Now there is still another problem -- Office 2007 theme does NOT call WM_CTLCOLORSTATIC when drawing the slider bars, so the background is a solid blue color and not what SLIDER_COLORKEY needs for my transparent DC to work.

How can I make my custom slider control use transparent background with Office 2007 theme? It worked great with Office 2003 theme before.



Posted By: Oleg
Date Posted: 10 July 2007 at 9:05am

Hi,

Check Samples\CommandBars\CommandBarControls sample - it has slider + Ribbon theme.


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


Posted By: Ark42
Date Posted: 10 July 2007 at 11:16am
Unfortunately, no, your CXTPControlSlider() will not work - I need access to SetTickFreq() as well as removing TBS_BOTH and increasing the height to 30px. Also, CXTPControlSlider() looks to be drawn in XP style even using Office 2007 Ribbon skin:


The class I've been using since 9.81 and before works fine still, and is even drawn in the correct Office 2007 style:


If I manually set my key color to RGB(191, 219, 255) to match that background color, it is drawn correctly too:


However, that would NOT draw correctly on other systems or themes with the hard-coded key color. I really need it to somehow obey WM_CTLCOLORSTATIC like it still does if I use Office 2003 theme.



Posted By: Ark42
Date Posted: 10 July 2007 at 1:40pm
Ok, I've found a solution so I can keep using my custom control. Instead of hooking WM_CTLCOLORSTATIC from CXTPControlCustom-derived class with XTPHookManager, I moved the same code to ON_WM_CTLCOLOR_REFLECT in the CSliderCtrl-derived class and it works for Office 2007 while still working the same for Office 2003 theme.





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