乡下人产国偷v产偷v自拍,国产午夜片在线观看,婷婷成人亚洲综合国产麻豆,久久综合给合久久狠狠狠9

  • <output id="e9wm2"></output>
    <s id="e9wm2"><nobr id="e9wm2"><ins id="e9wm2"></ins></nobr></s>

    • 分享

      CSDN技術(shù)中心 在ARX中通過COM在ACAD中添加菜單和工具條

       viki 2008-12-21
       

      代碼如下:

      extern "C" AcRx::AppRetCode
      acrxEntryPoint(AcRx::AppMsgCode msg, void* pkt)
      {
       switch (msg) {
       case AcRx::kInitAppMsg:
        // Comment out the following line if your
        // application should be locked into memory
        acrxDynamicLinker->unlockApplication(pkt);
        acrxDynamicLinker->registerAppMDIAware(pkt);
        InitApplication();
        addMenuThroughMfcCom();
        break;
       case AcRx::kUnloadAppMsg:
        UnloadApplication();
        break;
       }
       return AcRx::kRetOK;
      }

      void addMenuThroughMfcCom()
      {
       TRY
       {
        IAcadApplication IAcad(acedGetAcadWinApp()->GetIDispatch(TRUE));
        IAcadMenuBar IMenuBar(IAcad.GetMenuBar());

        long numberOfMenus;
        numberOfMenus = IMenuBar.GetCount();

        IAcadMenuGroups IMenuGroups(IAcad.GetMenuGroups());

        VARIANT index;
        VariantInit(&index);
        V_VT(&index) = VT_I4;
        V_I4(&index) = 0;
        IAcadMenuGroup IMenuGroup(IMenuGroups.Item(index));
        IAcadPopupMenus IPopUpMenus(IMenuGroup.GetMenus());

        CString cstrMenuName = "靈宇斷面(&L)";

        VariantInit(&index);
        V_VT(&index) = VT_BSTR;
        V_BSTR(&index) = cstrMenuName.AllocSysString();

        IDispatch* pDisp=NULL;

        //see if the menu is already there
        TRY{pDisp = IPopUpMenus.Item(index); pDisp->AddRef();} CATCH(COleDispatchException,e){}END_CATCH;
        VariantClear(&index);

        if (pDisp==NULL) {
         //create it
         IAcadPopupMenu IPopUpMenu(IPopUpMenus.Add(cstrMenuName));
         
         VariantInit(&index);
         V_VT(&index) = VT_I4;
         V_I4(&index) = 0;
         IPopUpMenu.AddMenuItem(index, "橫斷面成圖(&H)", "HDM ");

         VariantInit(&index);
         V_VT(&index) = VT_I4;
         V_I4(&index) = 1;
         IPopUpMenu.AddMenuItem(index, "縱斷面成圖(&Z)", "ZDM ");

         VariantInit(&index);
         V_VT(&index) = VT_I4;
         V_I4(&index) = 2;
         IPopUpMenu.AddSeparator(index);

         VariantInit(&index);
         V_VT(&index) = VT_I4;
         V_I4(&index) = 3;
         IPopUpMenu.AddMenuItem(index, "靈宇斷面幫助(&B)", "DMHELP ");

         pDisp = IPopUpMenu.m_lpDispatch;
         pDisp->AddRef();
        }

        IAcadPopupMenu IPopUpMenu(pDisp);
        if (!IPopUpMenu.GetOnMenuBar())
        {
         VariantInit(&index);
         V_VT(&index) = VT_I4;
         V_I4(&index) = numberOfMenus - 2;;
         IPopUpMenu.InsertInMenuBar(index);
        }
        else
        {
         VariantInit(&index);
         V_VT(&index) = VT_BSTR;
         V_BSTR(&index) = cstrMenuName.AllocSysString();
         IPopUpMenus.RemoveMenuFromMenuBar(index);
         VariantClear(&index);
        }
        pDisp->Release();
       }
       CATCH(COleDispatchException,e)
       {
        e->ReportError();
        e->Delete();
       }
       END_CATCH;
      }

      也可以用相同的方法添加工具條,這樣加入的工具條和CAD本身的完全相同。代碼如下:

      void AddDMToolbar()
      {
       IAcadApplication acad;
       IDispatch *pDisp = acedGetAcadWinApp()->
              GetIDispatch(TRUE); //AddRef is called on the pointer
          acad.AttachDispatch(pDisp); // does not call AddRef()
       IAcadMenuGroups acMenuGroups ( acad.GetMenuGroups() );

       IAcadMenuGroup  acMenu;
       CComVariant vt;
       long cnt = acMenuGroups.GetCount();
       for ( long i = 0; i < cnt; i++ )
       {
        vt = i;
        acMenu = acMenuGroups.Item( vt );

        CString cgrpName = acMenu.GetName();
        if ( cgrpName.CompareNoCase( "Acad" ) == 0 )
        {
         break;
        }
       }

       IAcadToolbars acToolbars (acMenu.GetToolbars());

       CString sToolbarName = "斷面"; 
       IAcadToolbar acToolbar;
       cnt = acToolbars.GetCount();
       for ( i = 0; i < cnt; i++ )
       {
        vt = i;
        acToolbar = acToolbars.Item( vt );
        if( acToolbar.GetName() == sToolbarName )
        {
         return;
        }
       }

       CString appFileName = acedGetAppName(); //取出完整的應(yīng)用程序名稱,含路徑
       char dir[_MAX_DIR], drive[_MAX_DRIVE], path[_MAX_PATH];
       _splitpath(appFileName, drive, dir, NULL, NULL);
       _makepath(path, drive, dir, NULL, NULL);
       
       try
       {
        acToolbar = acToolbars.Add ( sToolbarName );
        acToolbar.SetVisible( true );
        acToolbar.Dock( 0 );

        COleVariant flyOutButton;
        IAcadToolbarItem acToolbarItem;
        CString bmpFile;

        vt = 0;
        acToolbarItem = acToolbar.AddToolbarButton( vt, "橫斷面","繪制橫斷面圖", "hdm ", flyOutButton );
        bmpFile.Format( "%s%s", path, "hdm.bmp" );
        acToolbarItem.SetBitmaps ( bmpFile, bmpFile );

        vt = 1;
        acToolbarItem = acToolbar.AddToolbarButton( vt, "縱斷面","繪制縱斷面圖", "zdm ", flyOutButton );
        bmpFile.Format( "%s%s", path, "zdm.bmp" );
        acToolbarItem.SetBitmaps ( bmpFile, bmpFile );

        vt = 2;
        acToolbarItem = acToolbar.AddToolbarButton( vt, "幫助","顯示軟件幫助信息", "dmhelp ", flyOutButton );
        bmpFile.Format( "%s%s", path, "help.bmp" );
        acToolbarItem.SetBitmaps ( bmpFile, bmpFile );
       }
       catch(...)
       {
        //acutPrintf("\n創(chuàng)建斷面工具條失敗!");
        //acutPrintf("\n請(qǐng)與作者聯(lián)系");
        return;
       }
      }

        本站是提供個(gè)人知識(shí)管理的網(wǎng)絡(luò)存儲(chǔ)空間,所有內(nèi)容均由用戶發(fā)布,不代表本站觀點(diǎn)。請(qǐng)注意甄別內(nèi)容中的聯(lián)系方式、誘導(dǎo)購買等信息,謹(jǐn)防詐騙。如發(fā)現(xiàn)有害或侵權(quán)內(nèi)容,請(qǐng)點(diǎn)擊一鍵舉報(bào)。
        轉(zhuǎn)藏 分享 獻(xiàn)花(0

        0條評(píng)論

        發(fā)表

        請(qǐng)遵守用戶 評(píng)論公約

        類似文章 更多