Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - HOWTO: CXTPControlCustom background in ribbon?
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

HOWTO: CXTPControlCustom background in ribbon?

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

Joined: 14 July 2003
Status: Offline
Points: 1201
Post Options Post Options   Thanks (0) Thanks(0)   Quote mgampi Quote  Post ReplyReply Direct Link To This Post Topic: HOWTO: CXTPControlCustom background in ribbon?
    Posted: 22 March 2011 at 5:52am
Hi;

I created a custom control derived from CWnd that contains a CEdit (masked) and a CXTPButton. This control ist used in dialogs and views and now I want to use this control as a CXTPControlCustom in my apps ribbon bar.
So far so good, but I can't find out how to handle the background drawing when contained in riboon (see screenshot).
For skinned dialogs the  background drawing is ok, but in ribbons not!

Here's my OnPaint() function of the CWnd derived custom control:

void CXRTimeStampCtrl::OnPaint()
{
    CPaintDC dc(this); // device context for painting
   
    CRect rect;
   
    DWORD dwStyle=GetStyle();

    GetClientRect(&rect);
       
    if (BackColor_!=0xFFFFFFFF)
        dc.FillSolidRect(rect, BackColor_);
    else {
        HBRUSH hBrush=reinterpret_cast<HBRUSH>(GetParent()->SendMessage(WM_CTLCOLORSTATIC, reinterpret_cast<WPARAM>(dc.m_hDC), reinterpret_cast<LPARAM>(m_hWnd)));
        dc.FillSolidRect(rect, dc.GetBkColor());
    }
    if (dwStyle & TSCS_SHOWCAPTION)
    {
        CFont* pOldFont=dc.SelectObject(&_fontCaption);
        CString strText;
        GetWindowText(strText);
        dc.DrawText(strText, rect, DT_LEFT|DT_END_ELLIPSIS|DT_SINGLELINE|DT_VCENTER);
        if (pOldFont)
            dc.SelectObject(pOldFont);
    }
}


And here's the result in ribbon (left) and dialog (right):



Any help is very welcome!
Martin

Product: Xtreme Toolkit v 22.1.0, new Projects v 24.0.0
Platform: Windows 10 v 22H2 (64bit)
Language: VC++ 2022
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.266 seconds.