Click to See Complete Forum and Search --> : GetParent handle ???


nmg
June 5th, 2003, 12:35 AM
I was created an app that use a CSplitterWnd class to to make 2 pane of CListView class. One of this pane is set as parent of a modeless dialog box that pop up in some particular conditions.

The problem is : inside modeless dialog box I need to know parent window handle for manipulating CListView parent panel accordind to user choices, but my code not work...

Look here:

void CDlgLstAd::OnItemchangedLisact(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_LISTVIEW* pNMListView = (NM_LISTVIEW*)pNMHDR;


if((pNMListView->uNewState & LVIS_SELECTED) == LVIS_SELECTED)
{

// getting associated data :
long lParam = (long)pNMListView->lParam;

// get CListView parent window
CListView* pCtrView = (CListView*)GetParent();

// get CListCtrl associated to CListView
CListCtrl& list = pCtrView->GetListCtrl();


// find item and select it:
LVFINDINFO lvf;
lvf.flags = LVFI_PARAM;
lvf.lParam = lParam;

int idx = list.FindItem(&lvf, -1);
list.SetItemState(idx, LVIS_SELECTED, LVIS_SELECTED);
list.EnsureVisible(idx, FALSE);
}

*pResult = 0;
}

What can I do ?
Thanx.