Print Page | Close Window

HOWTO: CXTPControlCustom background in ribbon?

Printed From: Codejock Forums
Category: Codejock Products
Forum Name: Command Bars
Forum Description: Topics Related to Codejock Command Bars
URL: http://forum.codejock.com/forum_posts.asp?TID=18098
Printed Date: 04 October 2024 at 9:24pm
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: HOWTO: CXTPControlCustom background in ribbon?
Posted By: mgampi
Subject: HOWTO: CXTPControlCustom background in ribbon?
Date 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 19.0.0, new Projects v 19.1.0
Platform: Windows 10 v 1909 (64bit)
Language: VC++ 2017



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