case ID_VIEW_ENCODE://按下“编码”按钮 { m_bIsEncodMenuPopup = true; VERIFY( menu.LoadMenu( IDR_ENCODE ) );//IDR_ENCODE是预置的“编码”菜单资源,内含任意一项占位用的菜单 CMyHtmlView = GetActiveMyHtmlView();//检查当前是否存在活动的浏览器视图窗口 if ( pView != NULL ) { LPDISPATCH lpDispatch =pView->GetHtmlDocument();//获得文档指针 if ( lpDispatch != NULL ) { // Get an IDispatch pointer for the IOleCommandTarget interface. IOleCommandTarget * pCmdTarget = NULL; HRESULT hr = lpDispatch->QueryInterface(IID_IOleCommandTarget, (void**)&pCmdTarget); if ( SUCCEEDED( hr ) ) { VARIANT varEncSubMenu; ::VariantInit( &varEncSubMenu ); hr = pCmdTarget->Exec( &::CGID_ShellDocView, CmdID_GetMimeSubMenu, OLECMDEXECOPT_DODEFAULT, NULL, &varEncSubMenu ); if ( SUCCEEDED( hr ) ) { // 添加“编码”菜单 MENUITEMINFO miiEncoding; ::memset( &miiEncoding, 0, sizeof(MENUITEMINFO) ); miiEncoding.cbSize = sizeof(MENUITEMINFO); miiEncoding.fMask = MIIM_SUBMENU; |