Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Skin Framework
  New Posts New Posts RSS Feed - Office 2007 theme + animation + draw problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Office 2007 theme + animation + draw problem

 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: Office 2007 theme + animation + draw problem
    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.

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: 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.

Back to Top
Oleg View Drop Down
Admin Group
Admin Group


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: 10 July 2007 at 9:05am

Hi,

Check Samples\CommandBars\CommandBarControls sample - it has slider + Ribbon theme.
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: 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.

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: 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.


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.188 seconds.