判断IE WEBBROWSER IHTMLDocument2 是否用户正在编辑

BOOL IsActiveElementEdit(CComQIPtr<IHTMLDocument2>& spDocument)
{
 BOOL bEditMode = FALSE;
 if(spDocument)
 {
  /*BSTR p = NULL;
  spDocument->get_designMode(&p);
  CString strDesignMode = p;
  if(strDesignMode.CompareNoCase(_T("On")) == 0)
  {
   bEditMode = TRUE;
  }*/
  /*CComQIPtr<IDisplayServices> spDisplayServices = spDocument;
  if(spDisplayServices)
  {
   CComPtr<IHTMLCaret> spCaret;
   spDisplayServices->GetCaret(&spCaret);
   if(spCaret)
   {
    BOOL bCaretVisible = FALSE;
    spCaret->IsVisible(&bCaretVisible);
    bEditMode = bCaretVisible;
   }
  }*/
  if(!bEditMode)
  {
   CComPtr<IHTMLElement> spElement;
   spDocument->get_activeElement(&spElement);
   if(spElement)
   {
    /*VARIANT_BOOL bTextEdit = FALSE;
    spElement->get_isTextEdit(&bTextEdit);
    bEditMode = bTextEdit;*/
    if(!bEditMode)
    {
     CComQIPtr<IHTMLElement3> spElement3 = spElement;
     if(spElement3)
     {
      VARIANT_BOOL bEditable = FALSE;
      spElement3->get_isContentEditable(&bEditable);
      bEditMode = bEditable;
     }
    }
    /*CComQIPtr<IHTMLElementDefaults> spElementDefaults = spElement;
    if(spElementDefaults)
    {
     BSTR p = NULL;
     spElementDefaults->get_contentEditable(&p);
     CString strEditable = p;
    }*/
    if(!bEditMode)
    {
     CComBSTR bstrTagName;
     spElement->get_tagName(&bstrTagName);
     /*if (lstrcmpiW(L"TEXTAREA", bstrTagName) == 0)
     {
      bEditMode = TRUE;
     }
     else if (lstrcmpiW(L"DIV", bstrTagName) == 0)
     {
     }
     else */if (lstrcmpiW(L"IFRAME", bstrTagName) == 0 || lstrcmpiW(L"FRAME", bstrTagName) == 0)
     {
      /*CComPtr<IDispatch> spDispDocument;
      spElement->get_document(&spDispDocument);
      if(spDispDocument)
      {
       CComQIPtr<IHTMLDocument2> spFrameDocument = spDispDocument;
       if(spFrameDocument)
       {
        bEditMode = IsActiveElementEdit(spFrameDocument);
       }
      }*/
      /*CComQIPtr<IHTMLFrameBase2> spFrameBase(spElement);
      if(spFrameBase)
      {
       CComPtr<IHTMLWindow2> spFrameWindow;
       spFrameBase->get_contentWindow(&spFrameWindow);
       if(spFrameWindow)
       {
        CComQIPtr<IHTMLDocument2> spFrameDocument;
        spFrameWindow->get_document(&spFrameDocument);
        if(!spFrameDocument)
        {
         CComQIPtr<IServiceProvider> spServiceProvider(spFrameWindow);
         if (spServiceProvider)
         {
          CComPtr<IWebBrowser2> spWebBrowser;
          spServiceProvider->QueryService(IID_IWebBrowserApp, IID_IWebBrowser2, (void**)&spWebBrowser);
          if(spWebBrowser)
          {
           CComPtr<IDispatch> spDispDocument;
           spWebBrowser->get_Document(&spDispDocument);

           spFrameDocument = spDispDocument;
          }
         }
        }
        bEditMode = IsActiveElementEdit(spFrameDocument);
       }
      }*/
     }
    }
   }
  }
 }
 return bEditMode;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值