Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!


CListView Class can't access own members

ragetteragette Member Posts: 1
[size=1]Visual Studio C++ MFC Application

my program compiles but crashes
when a messsage-mapped function (mapped in CMainframe to the CListView derived class)
tries to asses the CMainframe.
the Cmainframe class is accessible from all non message-mapped functions in this CListView derived.

the function runs normally (is called from CMainframe) (can afxmessage, etc ) until it tries to get a handle for the Cmainframe class, or even its OWN CLASS VARIABLES

the CListView derived was added and attached to a pane in a splitter window. (not created in the App Class);

Message Mapped Function (mapped in CMainframe to the CListView derived class)

void CFileListView::OnJpegsNext()
AfxMessageBox("hello"); // works fine

pFrame = (CMainFrame*)GetParentFrame();
if (pFrame == NULL) AfxMessageBox("Nope"); // outputs "Nope"
else AfxMessageBox("Got Handle");

if (GetListCtrl().DeleteAllItems()) AfxMessageBox("delete called");
else AfxMessageBox("DeleteAllItems() returned false"); // outputs "DeleteAllItems() returned false"

Regular Class Function

void CFileListView::OnInitialUpdate()
pFrame = (CMainFrame*)GetParentFrame();
if (pFrame == NULL) AfxMessageBox("Nope");
else AfxMessageBox("Got Handle"); //outputs "Got Handle"

if (GetListCtrl().DeleteAllItems()) AfxMessageBox("delete called"); //outputs "delete called"
else AfxMessageBox("DeleteAllItems() returned false");
Sign In or Register to comment.