欢迎您来到GIS动力

加入收藏 免费注册 用户登陆 帮助中心
首页 新闻动态 技术专栏 银杏树下 学习考研 软件下载 求职招聘 许愿瓶 节日祝福 用户中心 精彩推荐 资源搜索 地图
专栏导航: AO开发 | SO开发 | ArcGIS桌面 | 超图桌面 | 开发语言 | 数据库 | WebGIS | 银杏文学 | 研究生考题 | FreeMap FreeTalk
   您现在位于: 首页技术专栏ArcGIS应用与开发ArcGIS其它 → 正文
vc下使用MOIMS的IMSUtil类型库
07-11-06 09:41:51 作者: 出处:
一直在使用VC6+MOIMS开发CGI模式的WebGIS系统,但却始终不知道在vc6中如何使用IMSUtil.dll类型库。今天出现了一个很怪异的问题:我写的mapservice单独运行一切正常,静态测试完全通过,但将其拖入IMS Admin中却会失败,连启动时的静态测试代码都过不去,真是诡异至极。分析原因大概是从配置文件appconfig.ini中读取一些参数的时候出的问题,当程序中的GetPrivateProfileString(...)传入appconfig.ini的绝对完整路径时,就不会出现问题,而把路径改为".\\appconfig.ini"相对路径就会完蛋,又不能动态调试,所以十分郁闷,无奈之下考虑使用IMSUtil。过去一直以为vc6下面用不了这个东西,今天上ESRI论坛翻腾了一下,找到了上面那个链接,把问题解决了。不过这个例子是for ArcIMS的,使用MOIMS的时候要稍微改一下:

m_regparams.SetHostURL( " http://<your IP>/scripts/esrimap.dll " );

    就可以了

参考:

Introduction

 

While ESRI provides excellent documentation and tutorials for MapObjects + IMS applications, I find that all of these documents are written with only Visual Basic in mind.   While the fundamental procedures are the same for Visual C++ , there are a number of small development environment-based differences which may be difficult for a C++ programmer to grasp.   Thus, I’ve taken the time to write my own tutorial for developing a MapObjects application for ArcIMS in Visual C++.

 

This tutorial assumes you are familiar with C++ and the Visual C++ environment.   This tutorial has been tested only with MapObjects 2.1 and ArcIMS 4.0.

 

Step 1: Create a new project with MapObjects and WebLink

 

1. Open Visual C++ and Select "New..." from the "File" menu

2. Click the "Projects" tab

3. Select "MFC AppWizard (exe)"

4. Give your project the name "IMSTutorial"

5. Click "OK"

 

 

6. Select "Dialog based" for your application type and click "Finish"

7. Click "OK" when the "New Project Information" window pops up

8. Click the "Project" menu, select "Add To Project", and click "Components and Controls"

9. Browse to the "Registered ActiveX Controls" directory

10. Select "MapObjects 2.1 Map Control" and click "Insert."   Click "OK" when it asks "Insert this component?"

 

 

11. Click "OK" in the "Confirm Classes" window – this adds all the MapObjects header and implementation files to your project.

12. Select "WebLink Control" and click "Insert."   Click "OK" when it asks "Insert this component?"

 

 

13.     Click "OK" in the "Confirm Classes" window – this adds the WebLink header and implementation files to your project.

14.     Click "Close" in the "Components and Controls Gallery" window

15.     The MapObjects and WebLink controls should now be on your Controls toolbar

 

 

 

16.     Click the "TODO: Place dialog controls here" label and delete it.   Add both a MapObjects and a WebLink control to the form by dragging each icon onto it.   Resize the MapObjects control to be a bit bigger.

17.     Next, we’re going to declare each of these components as member variables in the dialog class.   Click the "View" menu, and click "ClassWizard"

18.     Click the "Member Variables" tab.   This shows a list of all the controls on the dialog form.

19.     Double-click "IDC_MAP1"   For the variable name, type "m_map" (without quotes) and click "OK"

 

20.     Double-click "IDC_WEBLINKCTRL1"   For the variable name, type "m_weblink" (without quotes) and click "OK"

21.     Click "OK" in the ClassWizard window

22.     Test your project by pressing the F5 key.   The dialog window should pop up, and the weblink control should be invisible.

 

 

23.     Save your project

 

Step 2: Configuring MapObjects

 

  1. Add MapHelper.   In the MFC Common samples directory (default is C:\Program Files\ESRI\MapObjects2\Samples\MFC\Common) are three files that we need:
    • MapObjects2.h
    • MapHelper.h
    • MapHelper.cpp

Using Windows Explorer, copy these files from this directory and paste them into your Visual C++ project’s directory.

  1. Add these three files to your project by clicking the "Project" menu, select "Add To Project", and click "Files…"   Select those three files listed above and click "OK"
  2. Open up your "stdafx.h" file from this project and add the following two lines after the existing #include directives:

 

#include "MapObjects2.h"

#include "MapHelper.h"

 

  1. Next, we’re going to add map data to the MapObjects Map Control.   Find the body to the OnInitDialog() member function in the CIMSTutorialDlg class and find the following line:

 

// TODO: Add extra initialization here

 

            Immediately below this line, add the following line of code:

 

                        AddLayer(m_map, "C:\\Program Files\\ESRI\\MapObjects2\\Samples\\Data\\World\\country.shp", moGreen);

 

     The exact path to this data varies by installation.   (two backslashes are used because the backslash is an escape character)         

 

  1. Test the application by pressing F5.   You should see the country boundaries in the MapObjects control

 

 

Step 3: Configuring WebLink

 

  1. Go back to the form editor (Click the ResourceView tab in the left pane, expand "IMS Tutorial Resources", expand "Dialog," double-click IDD_IMSTUTORIAL_DIALOG)
  2. Right-click the WebLink control and select "Properties."   Then click the "Control" tab.
  3. For LocalIP, enter the IP address of your computer.   Do not enter the localhost address (127.0.0.1) as it will not work correctly if you do so.
  4. For WebPort, enter 5062
  5. In the body to the OnInitDialog() member function in the CIMSTutorialDlg class, add the following line after the AddLayer() code that we added in the previous step:

 

if(!m_weblink.Start())

{

     MessageBox("Could not start WebLink control");

}

 

     This code opens the port you specified and begins listening for connections.   If an error occurs, a dialog box will pop up.

 

  1. Create a new virtual function OnFinalRelease() in the CIMSTutorialDlg class.   In the ClassView pane, right-click CIMSTutorialDlg and select "Add Virtual Function"

 

 

  1. Double-click "OnFinalRelease" and click "Edit Existing"
  2. In the OnFinalRelease() function, find the following line

 

// TODO: Add your specialized code here and/or call the base class

 

            Immediately below it, add the following line of code:

 

                        m_weblink.Stop();

 

            This code closes the port before the application quits.

9.       Finally, when the WebLink port is open and a request comes in, the application must handle it.   Open up the ClassWizard and select the "Message Maps" tab.

10.   Select the "CIMSTutorialDlg" class, the "IDC_WEBLINKCTRL1" object, and the "Request" message.   Then click "Add Function."   Accept the default function name by clicking "OK"   Then click "Edit Code"

11.     Find the following line in your new function:

 

// TODO: Add your control notification handler code here

           

            Immediately below it, add the following code:

 

CMoStrings args(arguments);

CMoStrings vals(values);

args.m_bAutoRelease = false;

vals.m_bAutoRelease = false;

9 7 3 1 2 4 8 :

(本文已被浏览 次)
发布人:admin
推荐给好友:发送给好友
上篇新闻:
下篇新闻:
相关评论
发表我的评论
  • 尊重网上道德,遵守《全国人大常委会关于维护互联网安全的决定》及中华人民共和国其他各项有关法律法;
  • 本站有权保留或删除您发表的任何评论内容;
  •   相关文章  
    无相关新闻

    关于我们友情链接 ┋ 与我在线 ┋ 管理 ┋ TOP
     
    网站当前版本:GisPower CMS V3.0
    『GIS 动力』- http://www.gispower.org/
    联系我们:webmaster#gispower.org
    Copyright (c) 2003-2007 GisPOwer.Org. All Rights Reserved.
     

                   滇ICP备05006901号