call main view form subclass
-
Hi, I have a program, SDI, with FormView,
CGreenView
written in vc++6. I have created a subclass ofCListCtrl
namedCMyListCtrl
. Now, when the user right-clicks on the listctrl, a menu pops up with options like 'edit', 'delete' etc. When the user selects 'edit' a dialog pops up and some stuff is done. The coding for the handling the right-click, calling the dialog box is done inCMyListCtrl.
After the dialog box closes, I want to call a function which is written inCGreenView
the main view class. Please can you tell me the right way of doing it?void CMyListCtrl::OnRecordEdit()
{
if (nItem != -1)
{
CAddNew *pDlg = new CAddNew();
pDlg->type = 2;
Dlg->DoModal();
delete pDlg;
// now call the function to update the list
// which is in CGreenView, the main view class
}
}Thanks.
_
Fortitudine Vincimus!_
-
Hi, I have a program, SDI, with FormView,
CGreenView
written in vc++6. I have created a subclass ofCListCtrl
namedCMyListCtrl
. Now, when the user right-clicks on the listctrl, a menu pops up with options like 'edit', 'delete' etc. When the user selects 'edit' a dialog pops up and some stuff is done. The coding for the handling the right-click, calling the dialog box is done inCMyListCtrl.
After the dialog box closes, I want to call a function which is written inCGreenView
the main view class. Please can you tell me the right way of doing it?void CMyListCtrl::OnRecordEdit()
{
if (nItem != -1)
{
CAddNew *pDlg = new CAddNew();
pDlg->type = 2;
Dlg->DoModal();
delete pDlg;
// now call the function to update the list
// which is in CGreenView, the main view class
}
}Thanks.
_
Fortitudine Vincimus!_
I wouldn't try to call the containing view directly from the contained control. Rather you want to catch the EN_CHANGE or similar message that the control will send to its parent when you commit the changes to it. This will probably turn up at the parent as a WM_NOTIFY and you'll need to pull it apart from there and determine that it came from the control you're interested in and due to the cause you're looking for. Have fun :)
Nothing is exactly what it seems but everything with seems can be unpicked.
-
I wouldn't try to call the containing view directly from the contained control. Rather you want to catch the EN_CHANGE or similar message that the control will send to its parent when you commit the changes to it. This will probably turn up at the parent as a WM_NOTIFY and you'll need to pull it apart from there and determine that it came from the control you're interested in and due to the cause you're looking for. Have fun :)
Nothing is exactly what it seems but everything with seems can be unpicked.
Thank you very much for the advice. This what I did. Its working exacly the way I want it to. Hope it is correct.
void CMyListCtrl::OnRecordEdit()
{
if (nItem != -1)
{
CAddNew *pDlg = new CAddNew();
pDlg->type = 2;
pDlg->DoModal();
delete pDlg;// Send Notification to parent of ListView ctrl LV\_DISPINFO lvDispInfo; lvDispInfo.hdr.hwndFrom = m\_hWnd; lvDispInfo.hdr.idFrom = IDC\_FD\_LIST; lvDispInfo.hdr.code = LVN\_ENDLABELEDIT; GetParent()->GetParent()->SendMessage( WM\_NOTIFY, IDC\_FD\_LIST,(LPARAM)&lvDispInfo); } else return;
}
And in the CGreenView class :
void CGreenMView::OnEndlabeleditFdList(NMHDR* pNMHDR, LRESULT* pResult)
{
LV_DISPINFO* pDispInfo = (LV_DISPINFO*)pNMHDR;// stuff to update the listctrl items \*pResult = 0;
}
_
Fortitudine Vincimus!_