ROOT used inside MFC MDI app

William J Deninger (deninger@uiuc.edu)
Mon, 2 Mar 1998 13:28:11 -0600


This is a multi-part message in MIME format.

------=_NextPart_000_0009_01BD45DF.0C0687A0
Content-Type: text/plain;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

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.=20

>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.=20

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.=20

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=20

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

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

void TGWin32WindowsObject::Win32CreateObject()
{
.
.
fhwndRootWindow =3D 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 =3D =
CreateTextClass(WinThr);
}

//_______________________________________________________________________=
___________
//
// MyApp.cpp

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

#include "TCanvas.h"

extern void *MDIMainFrame;

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

------=_NextPart_000_0009_01BD45DF.0C0687A0
Content-Type: text/html;
charset="iso-8859-1"
Content-Transfer-Encoding: quoted-printable

<!DOCTYPE HTML PUBLIC "-//W3C//DTD W3 HTML//EN">

keywords:
    MS - = Microsoft
    MFC -=20 Microsoft Foundation Class
    MDI - Multiple Document=20 Interface
 
Hello,
 
I've had success compiling, linking = and running=20 ROOT as a MFC MDI application using the Microsoft Visual C++ 5.0 = Studio. =20 What I thought was going to be the major hurdle, the building of a = functional=20 project workspace, has turned out to be fairly simple.  = I still have one hurdle to overcome, however, = which results=20 from the use of multiple threads in the Win95/WinNT port.
 
From previous roottalk correspondences, I remember = mentioned=20 that the WinNT/Win95 port actually has two threads (composing two = message=20 handling loops): one for the CINT commands, the other for CINT window = messages.=20 One of these (I think) is the initial application thread.  The MFC=20 application itself has a message loop (virtual CWndApp::Run()) which can = be=20 overloaded in order to change application behavior.  The MFC = message loop=20 traditionally is the application thread because it makes no special = thread=20 provisions. 
 
What I'm trying to do in the simplest of terms is = get the ROOT=20 canvases attached (as child windows) to the MDI application main frame = window,=20 and have the all window messaging handled by the same application thread = message=20 loop.  The ROOT CINT command thread would be an additional thread = worker=20 thread.
 
Adding WS_EX_MDICHILD to the window = style =20 and replacing the NULL window handle with the HWND of the mainframe in=20 TGWin32WindowsObject::CreateWindowsObject was a failed attempt, but I = had not=20 combined CWndApp and ROOT message loops.  Does anyone in ROOTLAND have a suggestion for implementing = this, or=20 perhaps know of a place I might go for more information?
 
William J Deninger
deninger@uiuc.edu
 
//__________________________________________________= ___________________________
//
// TGWin32WindowsObject.cpp
void = TGWin32WindowsObject::CreateWindowsObject(TGWin32=20 *lpTGWin32, Int_t x, Int_t y, UInt_t w, UInt_t h){
 
.
.
fDwStyle     =3D = WS_OVERLAPPEDWINDOW |=20 WS_VISIBLE /*added by deninger*/ | WS_EX_MDICHILD /*end deninger add*/; = //=20 window style
  fDwExtStyle  =3D WS_EX_CONTEXTHELP |=20 WS_EX_OVERLAPPEDWINDOW;
.
.
}
 
void=20 TGWin32WindowsObject::Win32CreateObject()
{
.
.
  fhwndRootWindow =3D=20 CreateWindowEx(fDwExtStyle,
       =             &= nbsp;       =20 fWin32Mother->fROOTCLASS,       &nb= sp;  =20 // extended window=20 style
          &nbs= p;            = ;    =20 (char *)(fWin32Mother->GetTitle()), // address of window=20 name
           = ;            =     =20 fDwStyle, // window=20 style
          &nbs= p;            = ;    =20 x,y,           &nb= sp;           &nbs= p;     =20 // start positio of the=20 window,
          &n= bsp;           &nb= sp;    =20 fSizeFull.cx, fSizeFull.cy,       // size = of the=20 window
//          &= nbsp;           &n= bsp;    =20 NULL,           &n= bsp;           &nb= sp;    =20 // handle of parent of owner=20 window
          &nb= sp;           &nbs= p;   =20 MDIMainFrame, // add by deninger 1998,  (HWND handle to main=20 frame)
          &nb= sp;           &nbs= p;    =20 NULL,           &n= bsp;           &nb= sp;    =20 // handle of menu, or child-window=20 identifier
          = ;            =      =20 fWin32Mother->fHInstance,       &nb= sp; //=20 handle of application=20 instance
          &= nbsp;           &n= bsp;    =20 this);           &= nbsp;           &n= bsp;   =20 // address of window-creation data
 
  ReleaseSemaphore(fhSemaphore, 1, = NULL);
 
// --> = temporary       =20 lpWinThr->fhwndRootWindow =3D = CreateTextClass(WinThr);
}
 
//_____________________________________________= _____________________________________
//
// MyApp.cpp
 
extern void = InitGui();
VoidFuncPtr_t=20 initfuncs[] =3D { InitGui, 0};
TROOT root("Rint","The = gm2=20 Traceback ROOT Interactive Interface", initfuncs);
 
#include = "TCanvas.h"
 
extern void = *MDIMainFrame;
 
void MyApp::InitInstance()
{
.
.
   =20 c1 =3D new = TCanvas("c1","place me in the=20 MDI main frame please");
}
 
------=_NextPart_000_0009_01BD45DF.0C0687A0--