wxWidgets related...

I'm having a mind block on this one so I thought I'd ask if anyone can tell me what I did wrong.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
DBI::DBI(void) : wxTreeItemData() {
	afr = 0x00;
	afi = 0x00000;
}
DBI::DBI(wxTreeItemData*) : wxTreeItemData() {
	afr = 0x00;
	afi = 0x00000;
}
DBI::~DBI(void) {
	afr = 0x00; afi = 0x0000;
	afn.Clear(); afs.Clear();
}
void hexWin::dbListAdd(void) {
	if (dl < 1) { rdi = dbList->GetRootItem(); }
	DBI cv = new DBI;
	wxString s;
	s.Printf(wxT("New Hack Tree %i"), dl);
	cv.afn = wxT("Notes");
	di = dbList->AppendItem(rdi, s, -1, -1, &cv);
	if (dl < 1) { rdi = dbList->GetItemParent(di); }
	dbList->SelectItem(di); dl++;
}
void hexWin::dbListAddBClick(wxCommandEvent& event) { dbListAdd(); }
void hexWin::dbListSelect(void) { // Fine when adding items but not when I click
	di = dbList->GetSelection();
	DBI* cv = (DBI*)dbList->GetItemData(di);
	dbListNotes->SetValue(cv->afn);
}
void hexWin::dbListSelectC(wxTreeEvent& event) { dbListSelect(); }

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#0 67C0FD3B	wxTextCtrl::DoSetValue() (E:\CBAPP32\hex\wxmsw28u_gcc.dll:??)
#1 67ED7C93	wxTextCtrlBase::SetValue() (E:\CBAPP32\hex\wxmsw28u_gcc.dll:??)
#2 00401B39	hexWin::dbListSelect(this=0x20c5bd8) (Z:\hex\svn\trunk\dbList.cpp:48)
#3 00401B56	hexWin::dbListSelectC(this=0x20c5bd8, event=@0x28ea64) (Z:\hex\svn\trunk\dbList.cpp:50)
#4 67B7BD99	wxEvtHandler::ProcessEventIfMatches() (E:\CBAPP32\hex\wxmsw28u_gcc.dll:??)
#5 67B7BEC8	wxEvtHandler::SearchDynamicEventTable() (E:\CBAPP32\hex\wxmsw28u_gcc.dll:??)
#6 67B7D563	wxEvtHandler::ProcessEvent() (E:\CBAPP32\hex\wxmsw28u_gcc.dll:??)
#7 67C1636E	wxTreeCtrl::MSWOnNotify() (E:\CBAPP32\hex\wxmsw28u_gcc.dll:??)
#8 67BCB851	wxWindow::MSWWindowProc() (E:\CBAPP32\hex\wxmsw28u_gcc.dll:??)
#9 67BC4400	wxWndProc() (E:\CBAPP32\hex\wxmsw28u_gcc.dll:??)
#10 760E62FA	USER32!OffsetRect() (C:\Windows\syswow64\user32.dll:??)
#11 00000000	0x001005e8 in ??() (??:??)
#12 00000000	0x0000004e in ??() (??:??)
#13 760E6D3A	USER32!IsWindow() (C:\Windows\syswow64\user32.dll:??)
#14 67BC43A4	wxAssociateWinWithHandle() (E:\CBAPP32\hex\wxmsw28u_gcc.dll:??)
#15 760E965E	USER32!GetKeyboardLayoutNameW() (C:\Windows\syswow64\user32.dll:??)
#16 00000000	0x00000000 in ??() (??:??) 
I figured out why it was complaining, it was to do with how I created the DBI instance, the fix is below:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
void hexWin::dbListAdd(void) {
	if (dl < 1) { rdi = dbList->GetRootItem(); }
	DBI* cv = new DBI;
	wxString s;
	s.Printf(wxT("New Hack Tree %i"), dl);
	cv->afn = wxT("Notes");
	di = dbList->AppendItem(rdi, s, -1, -1, cv);
	if (dl < 1) { rdi = dbList->GetItemParent(di); }
	dbList->SelectItem(di); dl++;
}
void hexWin::dbListAddBClick(wxCommandEvent& event) { dbListAdd(); }
void hexWin::dbListSelect(void) {
	if (di != pdi) {
		pdi = di;
		DBI* cv = (DBI*)dbList->GetItemData(di);
		dbListNotes->SetValue(cv->afn);
	}
}
void hexWin::dbListSelectC(wxTreeEvent& event) {
	di = event.GetItem();
	dbListSelect();
}
Topic archived. No new replies allowed.