Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Running 2 MFC apps in one Window

Running 2 MFC apps in one Window

Scheduled Pinned Locked Moved C / C++ / MFC
questioncsharpc++com
5 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    erajsri
    wrote on last edited by
    #1

    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.

    M S E 3 Replies Last reply
    0
    • E erajsri

      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.

      M Offline
      M Offline
      Michael Dunn
      wrote on last edited by
      #2

      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?

      S 1 Reply Last reply
      0
      • M Michael Dunn

        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?

        S Offline
        S Offline
        Stephen Hewitt
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        • E erajsri

          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.

          S Offline
          S Offline
          Stephen Hewitt
          wrote on last edited by
          #4

          See here[^]

          Steve

          1 Reply Last reply
          0
          • E erajsri

            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.

            E Offline
            E Offline
            erajsri
            wrote on last edited by
            #5

            Thanx Im looking into your suggestions.

            1 Reply Last reply
            0
            Reply
            • Reply as topic
            Log in to reply
            • Oldest to Newest
            • Newest to Oldest
            • Most Votes


            • Login

            • Don't have an account? Register

            • Login or register to search.
            • First post
              Last post
            0
            • Categories
            • Recent
            • Tags
            • Popular
            • World
            • Users
            • Groups