![]() |
Access Violation with CXTPControlComboBox |
Post Reply ![]() |
Author | |
Anna2004 ![]() Newbie ![]() ![]() Joined: 08 November 2007 Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() Posted: 22 November 2007 at 5:14am |
Hi,
I am using CXTControlComboBox in my toolbar.
First, I declare it as CXTControlComboBox m_skins in MainFrame.h.
And in MainFrame.cpp, I add the strings to this combobox in the following way:
int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
{ if (lpCreateControl->nID == ID_MY_TOOL_SKIN) { m_skins.SetWidth(60); m_skins.SetDropDownListStyle(TRUE); m_skins.AddString(_T("Skin1")); m_skins.AddString(_T("Skin2")); lpCreateControl->pControl = &m_skins;
return TRUE; } return FALSE; } I got Access Violation when I exit the application, when it came to destructor of CMainFrame.
Then I looked through the examples and find out that I should use a pointer, like this:
in MainFrame.h
CXTControlComboBox* m_skins;
in MainFrame.cpp
int CMainFrame::OnCreateControl(LPCREATECONTROLSTRUCT lpCreateControl)
{ if (lpCreateControl->nID == ID_MY_TOOL_SKIN) { m_skins = (CXTPControlComboBox*)CXTPControlComboBox::CreateObject(); m_skins->AddString(_T("Skin1")); m_skins->AddString(_T("Skin2")); m_skins->SetDropDownWidth(150); lpCreateControl->pControl = m_skins; return TRUE; } return FALSE; } Could someone explain for me why?
Thanks for your help
|
|
![]() |
|
jimmy ![]() Senior Member ![]() Joined: 11 November 2003 Location: Austria Status: Offline Points: 516 |
![]() ![]() ![]() ![]() ![]() |
All Controls are destroy by CommandBars Manager.
If you use a member variable, the CommandBars Manager will destroy the control and also the member variable will be destroyed. (double destroy of a object). Jimmy |
|
![]() |
|
Anna2004 ![]() Newbie ![]() ![]() Joined: 08 November 2007 Status: Offline Points: 8 |
![]() ![]() ![]() ![]() ![]() |
I see. Thanks.
But the code (member variable not using pointer) worked fine with VS2003 and XtremeToolkid Pro 9.8. Why is that?
|
|
![]() |
Post Reply ![]() |
|
Tweet
|
Forum Jump | Forum Permissions ![]() You cannot post new topics in this forum You cannot reply to topics in this forum You cannot delete your posts in this forum You cannot edit your posts in this forum You cannot create polls in this forum You cannot vote in polls in this forum |