Codejock Forums Homepage
Forum Home Forum Home > Codejock Products > Visual C++ MFC > Command Bars
  New Posts New Posts RSS Feed - CustomControl & CXTPControlLabel
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

CustomControl & CXTPControlLabel

 Post Reply Post Reply
Author
Message
jimmy View Drop Down
Senior Member
Senior Member


Joined: 11 November 2003
Location: Austria
Status: Offline
Points: 515
Post Options Post Options   Thanks (0) Thanks(0)   Quote jimmy Quote  Post ReplyReply Direct Link To This Post Topic: CustomControl & CXTPControlLabel
    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

 
Back to Top
znakeeye View Drop Down
Senior Member
Senior Member
Avatar

Joined: 26 July 2006
Status: Offline
Points: 1672
Post Options Post Options   Thanks (0) Thanks(0)   Quote znakeeye Quote  Post ReplyReply Direct Link To This Post 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/
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.359 seconds.