The application of the tool and Tangrammini component of Software Framework VI: MDI Application one

Source: Internet
Author: User
Tags valid

In the previous article I introduced the application of the Tangrammini component in the SDI program, from which I plan to write two to three articles on the use of Tangrammini components in MDI applications, in fact the application in MDI is consistent with the application creation steps in SDI. After using the Tangrammini component in an MDI application, it makes the application's framework design faster, simpler, easier to modify, and gives the MDI application a strong personalization color.

For installation of the Tangrammini component, please download the component installation package and install it in http://www.tangrammini.com.

Since the use of the Tangrammini component in an MDI application is basically consistent with the use in SDI, the following instructions have been used to introduce the original version of the Tangrammini component document in SDI, with just a few modifications.

First we want to generate an ordinary MDI 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 to enter MDI (Note: The MDI here is the project name, you can also name whatever), and then click the OK button, select the multiple documents 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 MDI 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_itangramm INIB2C,
(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", 0,3,&bsucceed);
}
where CoInitialize (NULL) is initialized, and then the CoCreateInstance () function is invoked to create the TANGRAMMINIB2C component and save it in the M_PMINIB2C member variable, after the TANGRAMMINIB2C component is created, Starting with the TANGRAMMINIB2C component to help create the Tangramminictrl control, let me first explain the next tangramminib2c TargetHandle and Tangramminictrl two properties, Where TargetHandle represents the parent window of the Tangramminictrl control to create, which is set to m_hwnd, which means that the Tangramminictrl control is created on the main frame window and becomes a child window of the main frame window. The TANGRAMMINIB2C Tangramminictrl attribute is represented as a reference to the created Tangramminictrl control, where we use Get_tangramminictrl (&m_pminictrl) Gets a reference to the created Tangramminictrl control and returns it to the member variable M_pminictrl.

After we get a reference to the Tangramminictrl control, we like to use the Tangramminictrl control in the dialog box, first call the LoadFile () method to load the frame file, and then call Setmdiclient (...) Method installs the framework and the client area. The Setmdiclient method represents the location where the Tangramminictrl control fills the current view and translates the current MDI client area to the name page1_s0001_ S0000 (You can also use other valid blank view names) in the Tangram blank view area.

BOOL SetMDIClient(BSTR strObjName, LONG nMDIHandle, LONG nMDIStyle);

Because the Tangrammini component was originally designed to be designed for MDI applications, the Setmdiclient method exists with three parameters, the first parameter being the name of the Tangram blank view, like any other method ; The second is the MDI client Area window handle, and if 0 indicates that the MDI client area is automatically matched, in this case we can also set this parameter to M_hwndmdiclient, and if it is not an MDI application, it is necessary to specify a valid window handle; The third parameter is the MDI client area style. Where Nmdistyle valid values are 0, 1, 2, 34 values, representing four styles.

After a few simple steps above, the final effect is shown below. Here I use the test.xtml framework file directly from the SDI case.

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.