Send informations to a splitter windows (List View))
-
I have a SDI application. My view is split into 2 parts. One of these windows is a List View. The user has the possibility of adding an item in the list view from a dialog. My problem is that I don't know how to get the information of the list view to call the function which to add items. I tried the code below but it doesn't seem to work. CMainFrame *pMainFrame=(CMainFrame*)AfxGetMainWnd(); CDocument * pDoc = ((CView *)pMainFrame->m_wndSplitter.GetPane(0,0))->GetDocument(); CBOFListView* prt = (CBOFListView*)pDoc->GetRuntimeClass(); prt->AddItemToList(Item); //AddItemToList is the function used to add items Thanks Regards!!
-
I have a SDI application. My view is split into 2 parts. One of these windows is a List View. The user has the possibility of adding an item in the list view from a dialog. My problem is that I don't know how to get the information of the list view to call the function which to add items. I tried the code below but it doesn't seem to work. CMainFrame *pMainFrame=(CMainFrame*)AfxGetMainWnd(); CDocument * pDoc = ((CView *)pMainFrame->m_wndSplitter.GetPane(0,0))->GetDocument(); CBOFListView* prt = (CBOFListView*)pDoc->GetRuntimeClass(); prt->AddItemToList(Item); //AddItemToList is the function used to add items Thanks Regards!!
Try moving the creation of the dialog into a handler in the list view class. Then all you can just pass a pointer to the view to the dialog in the dialog's ctor.
CYourDialog wndYourDialog ( this /* the view */ );
Where your dialog's ctor looks something like this;
CYourDialog::CYourDialog ( CYourView * pView ) : m_pTheView ( pView ) {}
Then just add the items to the view from the dialog throught the pointer to the view. Ben Burnett --------- On the topic of code with no error handling -- It's not poor coding, it's "optimistic" ;)