In the previous four, I introduced the use of the Tangrammini component in the dialog box program, and I will briefly introduce the use of the Tangrammini component in the SDI (Single Document Interface) program. Using Tangrammini components to build frameworks in SDI programs makes application framework design faster and simpler. Nonsense I don't say much, directly into the subject.
Note that to install the Tangrammini component, download the component installation package in http://www.tangrammini.com and install it, and if you want to run the source code, you must also install the Tangrammini component before you can compile and run it.
First of all, we want Mr. to become an ordinary SDI program. Start the Microsoft Visual C + + 6.0 development environment, go to File->new in the main menu, select Projects page in the New dialog box, and then select MFC AppWizard (EXE), in Project Name in SDI (Please note: SDI here is the project name, you can also name whatever), click the OK button, select the single document type on the first page of the wizard, and click Finish to complete the creation of a single document program. You can also not finish directly, you can do some other changes first, and then complete.
Because it is not a dialog box, this time we can not directly drag into the interface Tangramminictrl control, only the dynamic creation of Tangramminictrl control, where we have two ways to create Tangramminictrl, one way of course is to create directly by hand Another approach is to use the TANGRAMMINIB2C component to create, because TANGRAMMINIB2C has the ability to assist in creating Tangramminictrl, and of course to create Tangramminictrl controls with the TANGRAMMINIB2C component, We must first create the TANGRAMMINIB2C component. Here I decided to use the second option, which is to use the TANGRAMMINIB2C component to create the Tangramminictrl control, because the method is easier and less coded. After the Tangrammini component is installed, there are examples of these two creation methods in the case, and you can view them yourself.
In order to encode convenient, we directly from the installation package case source to find Tangrammini_i.c and tangrammini_i.h two files copied to the previously created SDI project source. After we get this done, we're ready to start coding:
1, open stdafx.h file, add include header file statement:
#include "TangramMini_i.c"
#include "TangramMini_i.h"
To compile without problems, I am here to remind you that it is best to include the. c file first, and then the. h file.
2. COM support is required because the ActiveX component needs to be created, and CoInitialize (NULL) statements must be invoked before the TANGRAMMINIB2C component is created.
3, in the CMainFrame class to add Member variable M_PMINIB2C and M_pminictrl respectively, the type is itangramminib2c* and itangramminictrl* type respectively.
4, modify the OnCreate () function of the CMainFrame class, add the following example code in the tail of the function (also the most important code in this article):CoInitialize(NULL);
HRESULT hr = CoCreateInstance(CLSID_TangramMiniB2C,
NULL,
CLSCTX_INPROC_SERVER,
IID_ITangramMiniB2C,
(LPVOID*)&m_pMiniB2C);
if (SUCCEEDED(hr) && (m_pMiniB2C != NULL))
{
m_pMiniB2C->put_TargetHandle((LONG)m_hWnd);
m_pMiniB2C->get_TangramMiniCtrl(&m_pMiniCtrl);
VARIANT_BOOL bSucceed;
m_pMiniCtrl->LoadFile(L"test.xtml",&bSucceed);
m_pMiniCtrl->SetMDIClient(
L"Page1_S0001_S0000",
(LONG)theApp.m_pClientView->m_hWnd,
0,&bSucceed);
}