翻译稿

发布时间 : 星期五 文章翻译稿更新完毕开始阅读

Getting Started with MapObjects Version 2.x in Visual C++

}

41

case ID_ALIGN_LEFTTOP: alignment = DT_LEFT|DT_TOP; break; case ID_ALIGN_CENTER: alignment = DT_VCENTER|DT_CENTER; break; case ID_ALIGN_RIGHTBOTTOM: alignment = DT_RIGHT|DT_BOTTOM; break; }

CEasyMapView* pView = (CEasyMapView*)m_pOrigView; ASSERT_VALID(pView);

pView->SetAlignment(alignment); Invalidate();

2. Change the CPreviewView reference in CEasyMapView::OnFilePrintPreview to CMapPreviewView:

if (!DoPrintPreview(IDD_PREVIEW, this, RUNTIME_CLASS(CMapPreviewView), pState))

Test your changes

1. 2. 3. 4.

Build and run the application.

Use the File-Print Preview menu to display a preview of the printer page. Use the alignment buttons to align your map on the page. Print

Getting Started with MapObjects Version 2.x in Visual C++ 42

APPENDIX A

Adding MapObjects to your Visual C++ project using the #import directive

The #import directive is used to incorporate information from a type library. The content of the type library is converted into C++ classes, mostly describing the COM interfaces.

As a developer of MapObjects you only have access to the type library information contained in the MO20.OCX. When you Insert a Component into your Visual C++ project, Visual Studio automatically generates wrapper classes and their associated .cpp and .h files for each MapObjects class. These

wrapper classes need to be added to your project (for the MapObjects classes that are directly referenced by your project). Also, ESRI supply a header file \MapObjects for constants such as colour constants and coordinate system constants (eg moRed, moPCS_BritishNationalGrid)

If you intend to use MapObjects without using the graphical user interface (i.e. you do not intend to use the actual Map control object that is dragged onto your Form) then ERSI recommend that you use the #import directive. This automates the creation of the necessary files required by the compiler and also includes all enummerations directly . It also means that you do not need to include the C++ wrapper files in your project. . There are a number of parameters that must be passed so that the correct import of the MO20.OCX takes place. The #import directive will also generate Smart Pointers for the MapObjects classes.

#import \ no_namespace named_guids raw_native_types \\

rename(\

The rename of EOF and Font is required to avoid clashes with other system definitions, however other parameters can be changed to suit your requirements.

An example of using one of the Smart Pointers.

IMoPointPtr pPoint(\ // CLSID_ + class name without \pPoint->Set(1,2,0,0);

联系合同范文客服:xxxxx#qq.com(#替换为@)