CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Threaded View

  1. #1
    Join Date
    May 2015
    Posts
    538

    creating child dialog from the parent handle

    Hello,

    In the legacy code, I have a diaglog opening up.

    But I want to open another window on top of that. So I had written following code on branch for sometime now.

    When I test the child window pops up, but a debug ASSERT is hit.

    Any hints/comments on this is very helpful. I have written a new file for WVCWOptionsDlg

    Code:
    bool CWaveSightImp::Internal::SetupCWOptions(HWND hwndParent)
    {
    	CWnd* pWnd = hwndParent ? CWnd::FromHandle(hwndParent) : NULL;
    
    	WVCWOptionsDlg optionsDlg(&m_reportOptions, pWnd);
    	AFX_MANAGE_STATE(AfxGetStaticModuleState());
    	INT_PTR nRet = optionsDlg.DoModal();
    	if (nRet == IDCANCEL)
    		return false;
    
    	return true;
    }
    Code:
    class WVCWOptionsDlg : public CDialog
    {
    	DECLARE_DYNAMIC(WVCWOptionsDlg)
    
    public:
    	WVCWOptionsDlg(WVCWReportOptions* pOptions, CWnd* pParent = NULL);
    	virtual ~WVCWOptionsDlg();
    
    	enum { IDD = IDD_WV_CW_OPTIONS_DLG };
    
    protected:
    
    	virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    	virtual BOOL OnInitDialog();
    //	virtual void OnOK();
    
    	void SetDefaultOptions();
    	//void ReadFromRegistry();
    	//void WriteToRegistry();
    
    	CButton m_EN_Radio;
    	CButton m_LL_Radio;
    	CButton m_dec_LL_Radio;
    	CButton m_fileCheck;
    	CButton m_binCheck;
    	CButton m_overallCheck;
    	CButton m_clutterCheck;
    
    	CComboBox m_reportCombo;
    
    	WVCWReportOptions* m_pReportOptions;
    public:
    	DECLARE_MESSAGE_MAP()
    	afx_msg void OnOK();
    };

    As attached the call stack, the handle is coming as NULL, but Im able to see the new dialog popping up after the ASSERT !

    Thankyou
    Attached Images Attached Images
    Last edited by pdk5; May 3rd, 2025 at 08:53 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured