locked
Embed executable in MFC container of tab type. RRS feed

  • Question

  • Hi,

    There is a requirement to make container having 2-3 tabs and each tab corresponds to separate executable. So i need to embed these exe in each corresponding tab so that only one container UI can show other executables UI by clicking on each tab.

    Regards,

    Shashank

    Tuesday, May 19, 2015 5:48 AM

Answers

  • Hi Shashank,

    How do you create the tab control to display the UI of a separate application? I assume you are using CPropertySheet class. According to this helpful article:  Hosting .exe applications into a dialog  , I use this idea to add a dialog which embed application to CPropertySheet object. And It seems works well in my simple sample.

    From this that article, The application you want to embed will start separated and wait 5 seconds embed to your dialog. 

    You could try to create a class derives form CPropertyPage class, add the dialog in above article as a menber of the class.

    ///CMyPP2 is a class derives from CPropertyPage
    
    int CMyPP2::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    	if (CPropertyPage::OnCreate(lpCreateStruct) == -1)
    		return -1;
    
    	// TODO:  Add your specialized creation code here
    	m_hostexe.Create(IDD_DIALOG3, this);
    	m_hostexe.ShowWindow(SW_SHOW);
    
    	return 0;
    }

    Add your tab to Cpropertypage:

    CPropertySheet dlgPropertySheet(L"my property sheet", this);//
    	CMyPP1 Cpage1;//the tab 1
    	CMyPP2 Cpage2;//the tab has a emebed application
    	dlgPropertySheet.AddPage(&Cpage1);
    	dlgPropertySheet.AddPage(&Cpage2);
    	dlgPropertySheet.DoModal();

    See the screenshot of embedding mspaint.exe to the tab :

    Hope this helps some.

    Shu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Shu 2017 Wednesday, May 20, 2015 7:14 AM
    • Marked as answer by Shu 2017 Thursday, May 28, 2015 2:28 AM
    Wednesday, May 20, 2015 7:13 AM
  • If you also want to embed console executables and display the outputs in your tabs, then consider this article: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682499%28v=vs.85%29.aspx.

    • Marked as answer by Shu 2017 Thursday, May 28, 2015 2:28 AM
    Wednesday, May 20, 2015 11:07 AM

All replies

  • Hi Shashank,

    How do you create the tab control to display the UI of a separate application? I assume you are using CPropertySheet class. According to this helpful article:  Hosting .exe applications into a dialog  , I use this idea to add a dialog which embed application to CPropertySheet object. And It seems works well in my simple sample.

    From this that article, The application you want to embed will start separated and wait 5 seconds embed to your dialog. 

    You could try to create a class derives form CPropertyPage class, add the dialog in above article as a menber of the class.

    ///CMyPP2 is a class derives from CPropertyPage
    
    int CMyPP2::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    	if (CPropertyPage::OnCreate(lpCreateStruct) == -1)
    		return -1;
    
    	// TODO:  Add your specialized creation code here
    	m_hostexe.Create(IDD_DIALOG3, this);
    	m_hostexe.ShowWindow(SW_SHOW);
    
    	return 0;
    }

    Add your tab to Cpropertypage:

    CPropertySheet dlgPropertySheet(L"my property sheet", this);//
    	CMyPP1 Cpage1;//the tab 1
    	CMyPP2 Cpage2;//the tab has a emebed application
    	dlgPropertySheet.AddPage(&Cpage1);
    	dlgPropertySheet.AddPage(&Cpage2);
    	dlgPropertySheet.DoModal();

    See the screenshot of embedding mspaint.exe to the tab :

    Hope this helps some.

    Shu


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.


    • Edited by Shu 2017 Wednesday, May 20, 2015 7:14 AM
    • Marked as answer by Shu 2017 Thursday, May 28, 2015 2:28 AM
    Wednesday, May 20, 2015 7:13 AM
  • If you also want to embed console executables and display the outputs in your tabs, then consider this article: https://msdn.microsoft.com/en-us/library/windows/desktop/ms682499%28v=vs.85%29.aspx.

    • Marked as answer by Shu 2017 Thursday, May 28, 2015 2:28 AM
    Wednesday, May 20, 2015 11:07 AM