ROOT used inside MFC MDI app

From: William J Deninger (deninger@uiuc.edu)
Date: Mon Mar 02 1998 - 20:28:11 MET


keywords:
    MS - Microsoft
    MFC - Microsoft Foundation Class
    MDI - Multiple Document Interface

Hello,

I've had success compiling, linking and running ROOT as a MFC MDI application using the Microsoft Visual C++ 5.0 Studio.  What I thought was going to be the major hurdle, the building of a functional project workspace, has turned out to be fairly simple.  I still have one hurdle to overcome, however, which results from the use of multiple threads in the Win95/WinNT port. 

>From previous roottalk correspondences, I remember mentioned that the WinNT/Win95 port actually has two threads (composing two message handling loops): one for the CINT commands, the other for CINT window messages. One of these (I think) is the initial application thread.  The MFC application itself has a message loop (virtual CWndApp::Run()) which can be overloaded in order to change application behavior.  The MFC message loop traditionally is the application thread because it makes no special thread provisions. 

What I'm trying to do in the simplest of terms is get the ROOT canvases attached (as child windows) to the MDI application main frame window, and have the all window messaging handled by the same application thread message loop.  The ROOT CINT command thread would be an additional thread worker thread. 

Adding WS_EX_MDICHILD to the window style  and replacing the NULL window handle with the HWND of the mainframe in TGWin32WindowsObject::CreateWindowsObject was a failed attempt, but I had not combined CWndApp and ROOT message loops.  Does anyone in ROOTLAND have a suggestion for implementing this, or perhaps know of a place I might go for more information?

William J Deninger
deninger@uiuc.edu 

//_____________________________________________________________________________
//
// TGWin32WindowsObject.cpp
void TGWin32WindowsObject::CreateWindowsObject(TGWin32 *lpTGWin32, Int_t x, Int_t y, UInt_t w, UInt_t h){

.
.
fDwStyle     = WS_OVERLAPPEDWINDOW | WS_VISIBLE /*added by deninger*/ | WS_EX_MDICHILD /*end deninger add*/; // window style
  fDwExtStyle  = WS_EX_CONTEXTHELP | WS_EX_OVERLAPPEDWINDOW;
.
.
}

void TGWin32WindowsObject::Win32CreateObject()
{
.
.
  fhwndRootWindow = CreateWindowEx(fDwExtStyle,
                            fWin32Mother->fROOTCLASS,           // extended window style
                            (char *)(fWin32Mother->GetTitle()), // address of window name
                            fDwStyle, // window style
                            x,y,                              // start positio of the window,
                            fSizeFull.cx, fSizeFull.cy,       // size of the window
//                            NULL,                             // handle of parent of owner window
                           MDIMainFrame, // add by deninger 1998,  (HWND handle to main frame)
                            NULL,                             // handle of menu, or child-window identifier
                            fWin32Mother->fHInstance,         // handle of application instance
                            this);                            // address of window-creation data

  ReleaseSemaphore(fhSemaphore, 1, NULL);

// --> temporary        lpWinThr->fhwndRootWindow = CreateTextClass(WinThr);
}

//__________________________________________________________________________________
//
// MyApp.cpp

extern void InitGui();
VoidFuncPtr_t initfuncs[] = { InitGui, 0};
TROOT root("Rint","The gm2 Traceback ROOT Interactive Interface", initfuncs);

#include "TCanvas.h"

extern void *MDIMainFrame;

void MyApp::InitInstance()
{
.
.
    c1 = new TCanvas("c1","place me in the MDI main frame please");
}



This archive was generated by hypermail 2b29 : Tue Jan 04 2000 - 00:34:30 MET