Create a MapX control in Visual C ++

Source: Internet
Author: User

First, select the new command in the File menu to bring up the new dialog box. Select mfcappwizard (exe) and enter mapxsample as the project name in projectname. Click OK to go to the first step of the Application Wizard. Use the Application Wizard to create a multi-document (or single-document) interface application.
Before creating the MapX control, you must add the MapX. h and MapX. cpp files to the project. Select Add to project> files from the project menu, open the insertfiles into project dialog box, and select MapX. cpp and MapX. h to add the files to the project.
Note: Do not select the add to project> components and controls command in the project menu. If you select this command to add the MapX control, a new. cpp attachment will be created, but this text does not include all MapX objects.
After the MapX. h and MapX. cpp files are added to the project, add the header file of the MapX object to the mapxsarnpleview that contains the control. As listed below:
# Include "MapX. H"
Class cmapxsampleview: Public cview
{
Protected;
Cmretrial m_ctrlmapx;
}
Create a resource ID for Mapx to represent the control. The procedure is as follows:
(1) Select the resourcesymbols command from the View menu to open the resourcesymbols dialog box.
(2) In the resourcesymbols dialog box, click the new command button to bring up the newsymbol dialog box.
(3) In the newsymbol dialog box, enter idc_map as the name.
Create a handler for the wm_size and wm_create messages in the Class Wizard:
1. Go to "View"> "Class Wizard"
2. Select your view class from the "Class Name" combo box.
3. In the message box, click "wm_create", and then click "add function ".
4. Select "wm_size" in the message box and click "add function ".
5. Click Edit code ".
Create this control when creating a view. In cmapxsampview: oncreate:
Int cmapxsampleview: oncreate (maid)
{
If (cview: oncreate (lpcreatestruct) =-1)
Retrun-1;

// Use the default size to create a map. In the resize message ing function, adjust the map size to fill the whole zone. //
If (! M_ctrlmapx.create (null, ws_visible, crect (100,100,), this, idc_map ))
Return-1;
Return 0;
}

Void cmapxsampleview: onsize (uint ntype, int CX, int CY)
{
Cview: onsize (ntype, CX, CY );
If (CX! = 0 & Cy! = 0)
M_ctrlmapx.movewindow (0, 0, CX, Cy, true );
}

Void cmapxsampleview: onsize (uint ntype, int CX, int CY)
{
Cview: onsize (ntype, CX, CY );

// Adjust the map size to fill the entire customer Zone
If (CX! = 0 & Cy! = 0)
M_ctrlmapx.movewindow (0, 0, CX, Cy, true );
}

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.