Running 2 MFC apps in one Window
-
I want to know how I would be able to run 2 or more MFC apps within one single MFC Window. The purpose of doing this is to enable the user to run one or more MDI applications in one single Window. The user should be able to select or attach other MFC applications ( all of which are MDI Window applications ) at initialisation. Once he selects the front ends, the parent application should find the executable files of the selected apps and then launch the child windows of those apps, within its own primary Window. My question is, how would this be possible ? I have heard that .net allows you to host MFC apps within its own, but I do not intend to work on .net solutions. Ive heard OLE is a suitable workaround for this too, but is there any easier approach ? thanx in advance, looking forward to a prompt reply.
-
I want to know how I would be able to run 2 or more MFC apps within one single MFC Window. The purpose of doing this is to enable the user to run one or more MDI applications in one single Window. The user should be able to select or attach other MFC applications ( all of which are MDI Window applications ) at initialisation. Once he selects the front ends, the parent application should find the executable files of the selected apps and then launch the child windows of those apps, within its own primary Window. My question is, how would this be possible ? I have heard that .net allows you to host MFC apps within its own, but I do not intend to work on .net solutions. Ive heard OLE is a suitable workaround for this too, but is there any easier approach ? thanx in advance, looking forward to a prompt reply.
You can't do this with regular Win32 apps because you can't have windows from different processes in the same stack. You could try making the main frame an ActiveX control container, then write the other apps as AX controls.
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?
-
You can't do this with regular Win32 apps because you can't have windows from different processes in the same stack. You could try making the main frame an ActiveX control container, then write the other apps as AX controls.
--Mike-- Visual C++ MVP :cool: LINKS~! Ericahist | PimpFish | CP SearchBar v3.0 | C++ Forum FAQ Ford, what's this fish doing in my ear?
You can do it. Run the following twice. The first instance creates a main window and the second a child within the first. If you use Spy you'll see that both windows belong to different processes. OLE relies on this feature of Win32 to implement in-place editing with out-of-process servers. Some messages should not be sent across processes (such as WM_NOTIFY) so obviously the window would have to be written to take this into account. In real world applications using edit controls as I’ve done is probably not sensible if parent notification is required, but using them simplifies the example code. =========================================== // RunTwice.cpp : Defines the entry point for the application. // #include "stdafx.h" #pragma data_seg(".shared") HWND s_hMainWindow = NULL; #pragma data_seg() #pragma comment(linker, "/SECTION:.shared,RWS") WNDPROC g_pSuper; LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam) { switch (uMsg) { case WM_NCDESTROY: PostQuitMessage(0); break; } return CallWindowProc(g_pSuper, hwnd, uMsg, wParam, lParam); } int APIENTRY WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) { if (s_hMainWindow==NULL) { s_hMainWindow = CreateWindow( "EDIT", "Main", WS_VISIBLE | WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | ES_MULTILINE, 0, 0, 500, 500, NULL, NULL, hInstance, NULL ); LONG res = SetWindowLong(s_hMainWindow, GWL_WNDPROC, reinterpret_cast(&WindowProc)); g_pSuper = reinterpret_cast(res); } else { HWND hChild = CreateWindow( "EDIT", "Child", WS_VISIBLE | WS_CHILD | WS_BORDER | ES_MULTILINE, 100, 100, 300, 300, s_hMainWindow, NULL, hInstance, NULL ); LONG res = SetWindowLong(hChild, GWL_WNDPROC, reinterpret_cast(&WindowProc)); g_pSuper = reinterpret_cast(res); } MSG m; while (GetMessage(&m, NULL, 0, 0)) { TranslateMessage(&m); DispatchMessage(&m); } return 0; } Steve
-
I want to know how I would be able to run 2 or more MFC apps within one single MFC Window. The purpose of doing this is to enable the user to run one or more MDI applications in one single Window. The user should be able to select or attach other MFC applications ( all of which are MDI Window applications ) at initialisation. Once he selects the front ends, the parent application should find the executable files of the selected apps and then launch the child windows of those apps, within its own primary Window. My question is, how would this be possible ? I have heard that .net allows you to host MFC apps within its own, but I do not intend to work on .net solutions. Ive heard OLE is a suitable workaround for this too, but is there any easier approach ? thanx in advance, looking forward to a prompt reply.
-
I want to know how I would be able to run 2 or more MFC apps within one single MFC Window. The purpose of doing this is to enable the user to run one or more MDI applications in one single Window. The user should be able to select or attach other MFC applications ( all of which are MDI Window applications ) at initialisation. Once he selects the front ends, the parent application should find the executable files of the selected apps and then launch the child windows of those apps, within its own primary Window. My question is, how would this be possible ? I have heard that .net allows you to host MFC apps within its own, but I do not intend to work on .net solutions. Ive heard OLE is a suitable workaround for this too, but is there any easier approach ? thanx in advance, looking forward to a prompt reply.