Print Page | Close Window

CustomControl & CXTPControlLabel

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=16716
Printed Date: 01 May 2025 at 5:20am
Software Version: Web Wiz Forums 12.04 - http://www.webwizforums.com


Topic: CustomControl & CXTPControlLabel
Posted By: jimmy
Subject: CustomControl & CXTPControlLabel
Date Posted: 18 May 2010 at 7:23am
Hello,

i've a  Control based on CXTPControlCustom

On Painting of my control, i use  the CXTPControlLabel class
to draw a label into my control

class CXTPControlLabelHelper : public CXTPControlLabel
{
public:
    virtual void SetParent(CXTPCommandBar* pParent)
    {
        __super::SetParent(pParent);
    }
    void SetType(XTPControlType type)
    {
        m_controlType = type;
        m_bSelected = TRUE;
    }
    virtual int GetSelected() const
    {
        return m_bSelected;
    }
};

void MyControl::OnPaint()
{
....
    CXTPControlLabelHelper label;
    label.SetCaption(strText);
    label.SetParent(m_pControl->GetParent());
    if (m_pControl->IsFocused())
        label.SetType(xtpControlCustom);
    else
    {
        // Codejock bei ThemeRibbon hotfix
        if (!m_pControl->GetPaintManager()->m_bOffsetPopupLabelText)
            rcText.left += nGripperWidth;
    }

    label.SetRect(rcText);
    m_pControl->GetPaintManager()->DrawControlPopupParent(&dc, &label, TRUE);
}

m_pControl is a pointer to my CXTPControlCustom object.

In Debug it work correct.
But in release it crash in CXTPControlLabel destructor.

Here is the callstack
     mfc71.dll!CCmdTarget::ExternalQueryInterface(const void * iid=0x774b1a80, void * * ppvObj=0x0012ebb0)  Zeile 332    C++
     ToolkitPro1400vc71.dll!CXTPAccessible::XAccessible::QueryInterface()  + 0x1e    C++
     ole32.dll!_CoDisconnectObject@8()  + 0x4a   
     mfc71.dll!CCmdTarget::ExternalDisconnect()  Zeile 396    C++
     mfc71.dll!CCmdTarget::~CCmdTarget()  Zeile 51    C++
     ToolkitPro1400vc71.dll!CXTPControl::~CXTPControl()  + 0x104    C++
     Lasal2.exe!CMarkupFilterCtrl::OnPaint()  Zeile 270 + 0x12    C++

i use VS.NET 2003 & CJ V14.0.0beta

  Jimmy

 



Replies:
Posted By: znakeeye
Date Posted: 19 May 2010 at 11:39am
I guess your control receives WM_PAINT, and is then deleted from elsewhere - destroying your markup context. In debug-mode the memory stays intact, but in release mode it is probably zeroed out or altered by some other memory allocation.
 
Make sure your custom control HWND is destroyed before the destructor is called:
 
CMainFrame::OnDestroy()
{
     m_customWindowCtrl.DestroyWindow();
}
 
 


-------------
PokerMemento - http://www.pokermemento.com/



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