The R Project is an open source statistics package that can run in MS Windows in either MDI (multiple document interface) or SDI (single document interface) mode. MDI is the mode where there is one big window that contains multiple smaller windows; in SDI each window is separate.
The rgl package for R is a 3D graphics package based on OpenGL. Until very recently, it could only display in SDI mode, but recently Daniel Adler and I made the necessary changes to allow it to be hosted as a child window with R running in MDI mode. I found it hard to track down instructions for doing this, so I've decided to write up what we worked out to be necessary. Hopefully these instructions could be used by others who want to host a window in a foreign MDI application. For example, it would be nice if TCL/TK windows could be hosted within the MDI frame in R.
gMDIClientHandle = GetParent(consoleHandle); gMDIFrameHandle = GetParent(gMDIClientHandle);
CreateMDIWindow( classname , title , MDIS_ALLCHILDSTYLES|WS_OVERLAPPEDWINDOW , CW_USEDEFAULT, CW_USEDEFAULT , width, height , gMDIClientHandle , GetModuleHandle(NULL) , (void *)UserData );Sometime after this call, your window procedure will receive a WM_CREATE message for the child, as with any other window. Your new window will not be automatically added to the list of child windows in the Windows menu, you need to do that yourself. However, we've found that doing it in the WM_CREATE handler doesn't work, so we just set a flag here, and when a WM_PAINT message comes through, we make the calls:
SendMessage(gMDIClientHandle, WM_MDIREFRESHMENU, 0, 0); DrawMenuBar(gMDIFrameHandle);Alternatively, you could send the WM_MDISETMENU message to replace the whole menu rather than just updating it.
LPCREATESTRUCT pCreateStruct = (LPCREATESTRUCT)lParam; LPMDICREATESTRUCT pMDICreateStruct = (LPMDICREATESTRUCT)(pCreateStruct->lpCreateParams); void *UserData = (void *)pMDICreateStruct->lParam;
Duncan Murdoch
Last modified 31 July 2006