Get parent handle ?? - Programmers Heaven

Howdy, Stranger!

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


Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

Get parent handle ??

nmgnmg Posts: 4Member
I created an app that use a CSplitterWnd to make 2 pane of class CListView. One of thst pane is set as parent of a modeless dialog box that pop up in some particular conditions.

Inside this modeless dialog box I need to know parent window handle for manipulating list view parent window associated according user choices.

Here is my code:

void CDlgLstAd::OnItemchangedLisact(NMHDR* pNMHDR, LRESULT* pResult)
// TODO: Add your control notification handler code here
if((pNMListView->uNewState & LVIS_SELECTED) == LVIS_SELECTED)

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

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

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

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

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


*pResult = 0;

But this code not work.The parent window do not respond. What's wrong ?
Thanks in advance.


  • BriballBriball Posts: 265Member
    When you create your modeless dialog, do you pass the list view as the parent? The default is NULL. You have to put:

    CDialog *pDlg = new CDialog;
    pDlg->Create(IDD_DIALOG, this);
    //bla bla bla...

    If it still doesn't work you could just make a public variable in the dialog class called m_pParent which points to the list view. Manually set it when the list view is created.
Sign In or Register to comment.