| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1187 人关注过本帖
标题:方法添加 错误
只看楼主 加入收藏
zzkkoo8
Rank: 1
等 级:新手上路
帖 子:11
专家分:3
注 册:2009-8-6
结帖率:66.67%
收藏
 问题点数:0 回复次数:5 
方法添加 错误
我在DevStudio Add-in Wizard  创建了 一个工程  在ICommands  接口添加了 一个方法   


我用的VC++


// quite.odl : type library source for quite.dll

// This file will be processed by the Make Type Library (mktyplib) tool to
// produce the type library (quite.tlb).

[    uuid(4C66AFD1-53B2-44AD-A178-D808B3A7770E), version(1.0),
    helpstring ("QUITE Developer Studio Add-in") ]
library Quite
{
    importlib("stdole32.tlb");
    importlib("devshl.dll");
    importlib("ide\devdbg.pkg");
    

    //  Dual interface for CCommands
    //
    //  All commands that your add-in adds to DevStudio
    //   must appear in this interface.  You may use the
    //   ClassView to add methods to this interface, which
    //   will cause stub implementations of those methods to
    //   appear in your CCommands class.
    
    [    uuid(713F3DEE-713A-4CE7-9B44-822829A28986),
        oleautomation,
        dual
    ]

    interface ICommands : IDispatch
    {
        // methods
        [id(1)]
        HRESULT QuiteCommandMethod();
        [id(2), helpstring("method QuitVCIDE")] HRESULT QuitVCIDE();
    };

    //  Class information for CCommands

    [ uuid(840B0262-7AED-4E38-9B66-97BD1C05E464) ]
    coclass Commands
    {
        [default] interface ICommands;
    };

    [ hidden, uuid(73F268AA-6EA0-472F-9625-392C1A10518C) ]
    coclass ApplicationEvents
    {
        [default] interface IApplicationEvents;
    }

    [ hidden, uuid(74635E9A-9073-4036-A9DD-70C04613A874) ]
    coclass DebuggerEvents
    {
        [default] interface IDebuggerEvents;
    }

    //{{AFX_APPEND_ODL}}
    //}}AFX_APPEND_ODL}}
};
这是本来   方法里的代码

下面是我加的   


但是总有一处错误  


STDMETHODIMP CCommands::QuitVCIDE()
{
       AFX_MANAGE_STATE(AfxGetStaticNoduleState())
   VERIFY_OK(m_pApplication->EnableModeless(VARIANT_FAlSE));
   if(MessageBox(NULL,"确实要退出VC开发环境么?","提示",MB_YESNO)==IDyes)
                        m_pApplication->Quit();
   VERIFY_OK(m_pApplication->EnableModeless(VARIANT_TRUE));
   return S_OK;
}
搜索更多相关主题的帖子: tool 工程 version library produce 
2009-08-20 10:05
zzkkoo8
Rank: 1
等 级:新手上路
帖 子:11
专家分:3
注 册:2009-8-6
收藏
得分:0 
--------------------Configuration: quite - Win32 Debug--------------------
Creating Type Library...
Processing D:\study\VC6\MyProjects\quite\quite.odl
quite.odl
Processing D:\study\VC6\VC98\INCLUDE\oaidl.idl
oaidl.idl
Processing D:\study\VC6\VC98\INCLUDE\objidl.idl
objidl.idl
Processing D:\study\VC6\VC98\INCLUDE\unknwn.idl
unknwn.idl
Processing D:\study\VC6\VC98\INCLUDE\wtypes.idl
wtypes.idl
D:\study\VC6\MyProjects\quite\quite.odl(59) : error MIDL2025 : syntax error : expecting an interface name or DispatchInterfaceName or CoclassName or ModuleName or a COM object name or LibraryName or a type specification near "STDMETHODIMP"
D:\study\VC6\MyProjects\quite\quite.odl(59) : error MIDL2026 : cannot recover from earlier syntax errors; aborting compilation  
执行 midl.exe 时出错.
 
quite.dll - 1 error(s), 0 warning(s)
2009-08-20 10:07
zzkkoo8
Rank: 1
等 级:新手上路
帖 子:11
专家分:3
注 册:2009-8-6
收藏
得分:0 
NoduleState  ModuleState


这个已经修正了  


但是还是错误
执行 midl.exe 时出错.  
 
quite.dll - 1 error(s), 0 warning(s)
2009-08-20 10:40
zzkkoo8
Rank: 1
等 级:新手上路
帖 子:11
专家分:3
注 册:2009-8-6
收藏
得分:0 
执行 midl.exe 时出错.执行 midl.exe 时出错.执行 midl.exe 时出错.执行 midl.exe 时出错.执行 midl.exe 时出错.



抓狂
2009-08-20 10:50
qsx691226
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2017-10-21
收藏
得分:0 
STDMETHODIMP CCommands::QuitVCIDE()
{
       AFX_MANAGE_STATE(AfxGetStaticNoduleState())
   VERIFY_OK(m_pApplication->EnableModeless(VARIANT_FAlSE));
   if(MessageBox(NULL,"确实要退出VC开发环境么?","提示",MB_YESNO)==IDyes)
                        m_pApplication->Quit();
   VERIFY_OK(m_pApplication->EnableModeless(VARIANT_TRUE));
   return S_OK;
}
这段代码加到
library Quite
{
STDMETHODIMP CCommands::QuitVCIDE()
{
       AFX_MANAGE_STATE(AfxGetStaticNoduleState())
   VERIFY_OK(m_pApplication->EnableModeless(VARIANT_FAlSE));
   if(MessageBox(NULL,"确实要退出VC开发环境么?","提示",MB_YESNO)==IDyes)
                        m_pApplication->Quit();
   VERIFY_OK(m_pApplication->EnableModeless(VARIANT_TRUE));
   return S_OK;
}
}
即可
2017-10-21 11:26
qsx691226
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2017-10-21
收藏
得分:0 
添加方法“add method”后,在quit.odl(就是类视图的ICommands,双击打开),添加一个[id2....]
interface ICommands : IDispatch
    {
        // methods
        [id(1)]
        HRESULT QuitCommandMethod();
        [id(2), helpstring("method QuitVCIDE")] HRESULT QuitVCIDE();
    };
以下这段代码是添加到类视图的CDSAddin的OnConnection(双击打开)文件中,添加到尾部即可
STDMETHODIMP CCommands::QuitVCIDE()
{
       AFX_MANAGE_STATE(AfxGetStaticNoduleState())
   VERIFY_OK(m_pApplication->EnableModeless(VARIANT_FAlSE));
   if(MessageBox(NULL,"确实要退出VC开发环境么?","提示",MB_YESNO)==IDyes)
                        m_pApplication->Quit();
   VERIFY_OK(m_pApplication->EnableModeless(VARIANT_TRUE));
   return S_OK;
}
2017-10-22 16:42
快速回复:方法添加 错误
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.039595 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved