|
-
August 18th, 2007, 03:03 PM
#1
Using Create with a tree control, having problems
I'm sure I'm missing something, but I am learning VC++ on my own here. It seems like every time I try something new, I spend 10 hours tracking down something stupid. Basically this is a button that opens up a property tree control, or dialog, I don't know. Using this here: http://www.codeproject.com/treectrl/proptree.asp
Code:
BOOL CSPec::OnInitDialog()
{
CDialog::OnInitDialog();
DWORD dwStyle;
CRect rc;
// PTS_NOTIFY - CPropTree will send notification messages to the parent window
dwStyle = WS_CHILD|WS_VISIBLE|PTS_NOTIFY;
// Init the control's size to cover the entire client area
GetClientRect(rc);
// Create CPropTree control
Tree.Create(dwStyle, rc, this, IDC_PROPERTYTREE); //Here is the problem
//
// Create some tree items
//
// Create a root item (root items should always be CPropTreeItem object since they
// can not have properties
CPropTreeItem* pRoot;
pRoot = Tree.InsertItem(new CPropTreeItem());
pRoot->SetLabelText(_T("Properties"));
pRoot->SetInfoText(_T("This is a root level item"));
pRoot->Expand(); // have this item expanded by default
// Create a static item
CPropTreeItem* pItem;
pItem = Tree.InsertItem(new CPropTreeItem(), pRoot);
pItem->SetLabelText(_T("Sub Item"));
pItem->SetInfoText(_T("This is a simple subitem"));
// Create a dropdown combolist box
CPropTreeItemCombo* pCombo;
pCombo = (CPropTreeItemCombo*)Tree.InsertItem(new CPropTreeItemCombo(), pRoot);
pCombo->SetLabelText(_T("Combo Item"));
pCombo->SetInfoText(_T("This is a TRUE/FALSE dropdown combo list"));
pCombo->CreateComboBoxBool(); // create the ComboBox control and auto fill with TRUE/FALSE values
pCombo->SetItemValue(TRUE); // set the combo box to default as TRUE
return TRUE; // return TRUE unless you set the focus to a control
}
BOOL CSPec::DestroyWindow()
{
// TODO: Add your specialized code here and/or call the base class
Tree.DeleteAllItems();
Tree.DestroyWindow();
return CDialog::DestroyWindow();
}
I've tried various combinations of using PostNcDestroy, delete Tree vs. DestroyWindow, etc. And all I do is get crashes on the Create line after I close the dialog and open it again. As if it's not really deleting anything or something, and it's trying to access something that doesn't exist. I don't know. This is very frustrating though. :/ Any ideas, or obvious idiocy on my part? Should I just get over it and switch to VB?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|