     -         hook    . .  -   !    -

       ,    .
         CFileDialog,       .   WM_INITDIALOG ,    :

CListCtrl* m_pwndFileList = (CListCtrl*)GetDlgItem(/*   */);

, -   FindWindowEx,         .      . .  ,         SetWindowLong (  ),          .        (GetWindowLong),   CallWindowProc  .  GetDlgCtrlID    ID  ,       .. ,        . ! (   OWL) -  ,  WM_INITDIALOG,   HoopProc,      (. ),    ,   ,     -        ;D

-----------------------------------------------
,  ,         ,  , ..         ,   ?

in_folder -    
lpszTitle -  
hWnd -   ( )

void GetOpenFolder(CString &in_folder, LPCTSTR lpszTitle, HWND hWnd)
{
    BROWSEINFO      bif;
    LPITEMIDLIST    pidl;
    LPMALLOC        pMalloc = NULL;
 
    ZeroMemory(&bif, sizeof(bif));
 
    bif.hwndOwner = hWnd;
    bif.pszDisplayName = NULL;
    bif.lpszTitle = lpszTitle;
    bif.ulFlags = BIF_EDITBOX;
    pidl = SHBrowseForFolder(&bif);
 
    if (pidl != NULL)
    {
        SHGetPathFromIDList(pidl, in_folder.GetBuffer(1024));
        in_folder.ReleaseBuffer();
 
        if (SHGetMalloc(&pMalloc) == NOERROR)
        {
            pMalloc->Free((void *)pidl);
            pMalloc->Release();
        }
    }else
    {
        in_folder = "";
    }
}

----------------------------------------
This is because the ListView control isn't a direct child of the File Open dialog. Using Spy++ reveals that it's a child of another window, of class SHELLDLL_DefView with a child ID of 0x461. The SHELLDLL_DefView in turn is a child window of the File Open dialog. Ok, so we write this code to access the ListView... 

    CWnd *pWnd = GetParent()->GetDlgItem(0x461)->GetDlgItem(IDOK);
and it crashes. Yet the line looks like it's correct. But if you break it down into the individual steps involved: 

    CWnd *pShellWnd = GetParent()->GetDlgItem(0x461);

    CWnd *pListViewWnd = pShellWnd->GetDlgItem(IDOK);


---------------------------------------------


Explorer-Style Control Identifiers 
The Windows Software Development Kit (SDK) provides the default dialog box template for the old-style dialog boxes, but does not include the default template for the Explorer-style dialog boxes. This is because the Explorer-style dialog boxes allow you to add your own controls but do not support modifying the template for the standard controls. However, in some cases, you may need to know the control identifiers used in the default templates. For example, the CDM_HIDECONTROL and CDM_SETCONTROLTEXT messages require a control identifier. 

The following table shows the identifiers of the standard controls in the Explorer-style Open and Save As dialog boxes. The identifiers are constants defined in Dlgs.h and Winuser.h. 

Control identifier Control description 
chx1 The read-only check box  
cmb1 Drop-down combo box that displays the list of file type filters 
stc2 Label for the cmb1 combo box 
cmb2 Drop-down combo box that displays the current drive or folder, and that allows the user to select a drive or folder to open 
stc4 Label for the cmb2 combo box 
cmb13 Drop-down combo box that displays the name of the current file, allows the user to type the name of a file to open, and select a file that has been opened or saved recently. This is for earlier Explorer-compatible applications without hook or dialog template. Compare with edt1. 
edt1 Edit control that displays the name of the current file, or allows the user to type the name of the file to open. Compare with cmb13. 
stc3 Label for the cmb13 combo box and the edt1 edit control 
lst1 List box that displays the contents of the current drive or folder 
stc1 Label for the lst1 list box 
IDOK The OK command button (push button)  
IDCANCEL The Cancel command button (push button)  
pshHelp The Help command button (push button)  
