ljndhr 2016-12-25 17:22 采纳率: 0%
浏览 1174

VC的MFC调用C#编写的ACTIVEX控件失败,求教是怎么回事?

在DIALOG类中加入了LoadActiveX方法
void CViewcharDlg::LoadActiveX(LPCTSTR strActiveXName, REFIID riidOfActiveX, int x, int y, int nWidth, int nHeight)
{
//Initialize ATL control containment code.
BOOL(WINAPI *m_AtlAxWinInit)();
m_AtlAxWinInit = (BOOL(WINAPI *)(void))::GetProcAddress
(_hWebLib, "AtlAxWinInit");
m_AtlAxWinInit();

// Get the dimensions of the main window's client 
// area, and enumerate the child windows. Pass the 
// dimensions to the child windows during enumeration. 
RECT rcClient;
_hSelf = this->m_hWnd;
//GetClientRect(_hSelf, &rcClient);

_hAtl = ::CreateWindowEx(
    WS_EX_CLIENTEDGE, \
    TEXT("AtlAxWin"), \
    strActiveXName, \
    WS_CHILD | WS_VISIBLE | WS_EX_RTLREADING,\
    x, y, nWidth, nHeight,\
    this->m_hWnd, \
    NULL, \
    NULL, \
    NULL);

if (!_hAtl)
{
    ::MessageBox(NULL, TEXT("Can not load AtlAxWin!"),
        TEXT(""), MB_OK | MB_ICONSTOP);
    throw int(106901);
}

HRESULT(WINAPI *m_AtlAxGetControl) (HWND h, IUnknown** pp);
m_AtlAxGetControl = (HRESULT(WINAPI *)
    (HWND, IUnknown**))::GetProcAddress(_hWebLib, "AtlAxGetControl");

m_AtlAxGetControl(_hAtl, &_pUnk);

_pUnk->QueryInterface(__uuidof(Demo::IObjectSafetyPtr),
    (LPVOID *)&_pDotNetCOMPtr);

if (_pDotNetCOMPtr != NULL)
{
    //_pDotNetCOMPtr->SetInterfaceSafetyOptions((long)_hSelf);
}
else
{
    // Get the dimensions of the main window's client 
    // area, and enumerate the child windows. Pass the 
    // dimensions to the child windows during enumeration. 
    //RECT rcClient;
//  GetClientRect(_hSelf, &rcClient);

    ::DestroyWindow(_hAtl);
    _hAtl = ::CreateWindowEx(
        WS_EX_CLIENTEDGE, \
        TEXT("AtlAxWin"), \
        TEXT("MSHTML:""Please register ActiveX control before using this plugin."""),
        WS_CHILD | WS_VISIBLE | WS_CLIPCHILDREN |
        WS_EX_RTLREADING, \
        0, 0, nWidth, nHeight, \
        this->m_hWnd, \
        NULL, \
        NULL, \
        NULL);
}

}
然后在在要使用ActiveX的Dialog的OnInitDialog()中加入下面的代码。
LoadActiveX(TEXT("Demo.IObjectSafety"), __uuidof(Demo::IObjectSafety), 0, 0, 750, 500);

但是程序运行后VC控件窗口中出现了ACTIVEX控件窗口但是里面显示 已取消到网页的导航,确保 Web 地址 http://demo.iobjectsafety 正确。

请各位大神看下这是怎么回事?

  • 写回答

1条回答 默认 最新

  • zqbnqsdsmd 2016-12-31 02:43
    关注
    评论

报告相同问题?

悬赏问题

  • ¥20 腾讯企业邮箱邮件可以恢复么
  • ¥15 有人知道怎么将自己的迁移策略布到edgecloudsim上使用吗?
  • ¥15 错误 LNK2001 无法解析的外部符号
  • ¥50 安装pyaudiokits失败
  • ¥15 计组这些题应该咋做呀
  • ¥60 更换迈创SOL6M4AE卡的时候,驱动要重新装才能使用,怎么解决?
  • ¥15 让node服务器有自动加载文件的功能
  • ¥15 jmeter脚本回放有的是对的有的是错的
  • ¥15 r语言蛋白组学相关问题
  • ¥15 Python时间序列如何拟合疏系数模型