18. CFileDialog is always a child of the Explorer dialog window: When you use the Explorer-style CFileDialog (which in Windows 95 you are doing by default), MFC 4.0 assumes the Explorer model of customization. This implies that custom improvements to the File dialog are included on a separate template that is added around the standard Explorer dialog. In MFC 4.0, the actual CFileDialog window is a child dialog of the main File Common Dialog, even if you are not providing a template to customize the dialog. Therefore, if you have a need to alter the standard Explorer interface by moving or hiding controls, prefix all GetDlgItem() calls to Explorer controls with GetParent(). For example, this expression: GetParent()->GetDlgItem(IDOK) will return a pointer to the Open/Save button on the Explorer dialog. However, this is not recommended because code that relies on the details of the standard Explorer dialog controls will break if the Explorer layout is changed in the future. This default can be changed by removing the OFN_EXPLORER style. For more information, see the following Microsoft Knowledge Base article: Q131225 PRB: CFileDialog::DoModal() Does Not Display FileOpen Dialog
我就是看了这一段。就是不明白为什么这种情况需要用。那个“Therefore”我不太明白!!
通过调用api ::GetDlgItem(hWnd,idChild) 返回子窗口的句柄然后再由FromHandlePermanent,取得子窗口的mfc对象知道这些了应该知道什么情况下用GetParent,什么情况下不用吧