阅读:2273回复:5
请帮忙,看问题在哪?在我的程序里,需要监听打开和新建文档事件。声明如下变量: Private WithEvents m_pDocEvents As esriArcMapUI.DocumentEvents 响应打开和新建文档事件代码如下: Private Sub m_pDocEvents_NewDocument() MsgBox "m_pDocEvents_NewDocument" End Sub Private Sub m_pDocEvents_OpenDocument() MsgBox "m_pDocEvents_OpenDocument" End Sub 但是在ArcMap打开和新建文档并没有响应以上两个消息!这是为什么,请帮忙看看!! |
|
1楼#
发布于:2004-08-11 15:12
是vba环境里吗,下面这个例子有用 Private Function MxDocument_OpenDocument() As Boolean Dim strPassword As String '设置密码 strPassword = "password" Dim strTextEntered As String Dim intAttempts As Integer Do While intAttempts <> 3 strTextEntered = InputBox("Enter the password:") If strPassword = strTextEntered Then MsgBox "You're in...", vbOKOnly, "Welcome!!!" Exit Function ElseIf strPassword <> strTextEntered Then intAttempts = intAttempts + 1 End If Loop MsgBox "Sorry, not today...", vbOKOnly, "Goodbye!!!" Dim pUID As New UID Dim pExit As ICommandItem ' Use the GUID of the Exit ArcMap command pUID.Value = "{119591DB-0255-11D2-8D20-080009EE4E51}" ' or you can use the ProgID ' pUID.Value = "esriCore.MxFileMenuItem" pUID.SubType = 10 Set pExit = Application.Document.CommandBars.Find(pUID) pExit.Execute End Function
|
|
|
2楼#
发布于:2004-08-11 15:25
不是VBA环境,是动态连接库!
|
|
3楼#
发布于:2004-08-11 16:49
dll必须先定义你用到的对象了
|
|
|
4楼#
发布于:2004-08-12 10:33
给 m_pDocEvents赋值了吗?
|
|
5楼#
发布于:2004-08-12 13:06
是大海兄提到的问题,呵呵,搞定了,谢谢!上面两位大吓!!
|
|