0

I have created a dialog box and added activex control in that.I want to get that activex item in one of the class of project whose configuration type is dll.

My complete project consist of multiple project of dll type. Code is breaking when I am creating the dialog in the class. Below is the code:

Class in which I am creating dialog is derived as:

 class ATL_NO_VTABLE LaserStripChart : 
    //public CWinApp,
    public CComObjectRootEx<CComMultiThreadModel>,
    public CComCoClass<LaserStripChart , &CLSID_BNSFLaserStripChart>,
    public ISupportErrorInfo,
    public IConnectionPointContainerImpl<LaserStripChart >,
    public IDispatchImpl<IBNSFLaserStripChart, &IID_IBNSFLaserStripChart,     &LIBID_LASERSTRIPCHARTLib> 

I am trying to get dialog item using following code:

    dummydlg* m_pRGModeDlg1 = new dummydlg();
    m_pRGModeDlg1->Create(5004);
    m_pRGModeDlg1->ShowWindow(SW_SHOW);
    IUnknown* m_iUnknown;   
    CWnd* temp = m_pRGModeDlg1->GetDlgItem(IDC_IPLOTX1);

OnCreate method OnInitDialog should be called but its not getting called, below is the code for dummydlg

.h file:

    class dummydlg : public CDialog
    {
    DECLARE_DYNAMIC(dummydlg)

    public:
    dummydlg(/*CWnd* pParent = NULL*/);// standard constructor
    virtual ~dummydlg();
    virtual BOOL OnInitDialog();
     #ifdef AFX_DESIGN_TIME
     enum { IDD = IDD_DIALOG1 };
     #endif
     protected:
    virtual void DoDataExchange(CDataExchange* pDX);    // DDX/DDV support
    DECLARE_MESSAGE_MAP()
    public:
    afx_msg void OnBnClickedOk();
    };

.cpp file

     #include "resource.h"
     IMPLEMENT_DYNAMIC(dummydlg, CDialog)

    dummydlg::dummydlg()
    : CDialog(IDD_DIALOG1)
    {
    EnableActiveAccessibility();
    }

    dummydlg::~dummydlg()
    {
    }
    void dummydlg::DoDataExchange(CDataExchange* pDX)
    {
    CDialog::DoDataExchange(pDX);
    }

    BEGIN_MESSAGE_MAP(dummydlg, CDialog)
    ON_BN_CLICKED(IDOK, &dummydlg::OnBnClickedOk)
    END_MESSAGE_MAP()
    // dummydlg message handlers
    BOOL dummydlg::OnInitDialog()
    {
     CDialog::OnInitDialog();
     return TRUE;
    }

     void dummydlg::OnBnClickedOk()
     {
      // TODO: Add your control notification handler code here
      CDialog::OnOK();
      }

resource.h

    //{{NO_DEPENDENCIES}}
    // Microsoft Visual C++ generated include file.
    // Used by LaserStripChart.rc

     #define IDS_PROJNAME                    100
     #define IDR_BNSFLASERSTRIPCHART         102
     #define IDC_IPLOTX1                     5003
     #define IDD_DIALOG1                     5004

     // Next default values for new objects
     // 
     #ifdef APSTUDIO_INVOKED
     #ifndef APSTUDIO_READONLY_SYMBOLS
     #define _APS_NEXT_RESOURCE_VALUE        207
     #define _APS_NEXT_COMMAND_VALUE         32768
     #define _APS_NEXT_CONTROL_VALUE         202
     #define _APS_NEXT_SYMED_VALUE           103
     #endif
     #endif

Please help why OnInitDialog is not called OnCreate method.

acraig5075
  • 10,588
  • 3
  • 31
  • 50
  • Is CDialog domodal() is called? – Santosh Dhanawade Nov 08 '16 at 07:53
  • 1
    What does Create return? Check it's result. What else do you have in the dialog? You might need to call InitCommonControlsEx first. Or oleinitialize/coinitialize(ex) in order to instantiate the activex. Or: http://stackoverflow.com/questions/13292166/cdialogcreate-fails-for-dialog-with-activex-control – VuVirt Nov 08 '16 at 09:28
  • You don't seem to check return codes from your method calls. Have you stepped into the call to 'Create'? Have you checked to see you have the correct resource handle to load the dialog resource? – rrirower Nov 08 '16 at 13:54

0 Answers0