当前位置:七道奇文章资讯编程技术VC/C++编程
日期:2011-03-22 13:55:00  来源:本站整理

<b>玩转BCB的IDE 体验ToolsAPI</b>[VC/C++编程]

赞助商链接



  本文“<b>玩转BCB的IDE 体验ToolsAPI</b>[VC/C++编程]”是由七道奇为您精心收集,来源于网络转载,文章版权归文章作者所有,本站不对其观点以及内容做任何评价,请读者自行判断,以下是其具体内容:

大大都BCB程序员大概一辈子都不用关心Toolsapi,但假如象我一样无聊的话,

无妨玩玩和谈论一下:

看看下面的程序,来把IDE变个样:

--->BCB5.0

//---------------------------------------------------------------------------
#include <vcl.h>
#pragma hdrstop
USERES("nodebug.res");
USEPACKAGE("vcl50.bpi");
//---------------------------------------------------------------------------
#include <toolsapi.hpp>
#include <inifiles.hpp>
//---------------------------------------------------------------------------
#pragma package(smart_init)
//---------------------------------------------------------------------------
// Package source.
//---------------------------------------------------------------------------
namespace Nodebug // Here the namespace should be same with this file name.
{
   bool NeedLocalize = true;
   bool NeedWriteToIni = false;
   TIniFile *ini, *chsini;
   AnsiString Section, Ident, Value;
   //===[ Do something on MenuItems. ]======================================
   void __fastcall DoMenuItem(TMenuItem* MenuItem)
   {
     //Display all MenuItems.
     if(MenuItem->Visible==false) MenuItem->Visible = true;
     if ( NeedWriteToIni && !MenuItem->Name.IsEmpty())
     {
       Ident = MenuItem->Name;
       Value = MenuItem->Caption;
       ini->WriteString ( Section, Ident, Value );
     }
   }
   //===[ Do something on MenuItems. ]======================================
   //===[ Enumerate all MenuItem's SubItems. ]==============================
   void __fastcall EnumerateMenuItem(TMenuItem* MenuItem)
   {
     DoMenuItem(MenuItem);
     for ( int i=0; i<MenuItem->Count; i++ )
     {
       EnumerateMenuItem(MenuItem->Items[i]);
     }
   }
   //===[ Enumerate all MenuItem's SubItems. ]==============================
   void __fastcall LocalizeAppMenu()
   {
     _di_INTAServices IDE;
     HRESULT hr = BorlandIDEServices->QueryInterface(__uuidof(INTAServices), (void **) &IDE);
     if (SUCCEEDED(hr))
     {
      //----------[AppBuilder macro start]--------------------------------------
      #ifndef AppBuilder
      #define AppBuilder IDE->MainMenu->Owner
      #endif
      //----------[AppBuilder macro end ]--------------------------------------
       TStringList* SectionList = new TStringList;
       TStringList* IdentList = new TStringList;
       AnsiString Value , Default("NULL");
       try
       {
         chsini->ReadSections(SectionList);
         for (int i = 0; i < SectionList->Count; i++)
         {
           chsini->ReadSection( SectionList->Strings[i], IdentList);
           for (int x = 0; x < IdentList->Count; x++)
           {
             Value = chsini->ReadString( SectionList->Strings[i],
                     IdentList->Strings[x],
                     "NULL");
             if( Default != Value )
             {
               TMenuItem* MI = dynamic_cast<TMenuItem*>
                 (AppBuilder->FindComponent(IdentList->Strings[x]));
               if(MI != NULL) MI->Caption = Value;
             }
           }
         }
       }
       #undef AppBuilder
       __finally
       {
         delete IdentList;
         delete SectionList;
       }
     }
   }
   //===[ BPL's 'Main' function or Entry Function. ]========================
   void __fastcall PACKAGE Register()
   {
     ini = new TIniFile(ChangeFileExt( Application->ExeName, ".INI" ));
     chsini = new TIniFile(ChangeFileExt( Application->ExeName, "CHS.INI" ));
     if( NeedLocalize ) LocalizeAppMenu();
     _di_INTAServices IDE;
     HRESULT hr = BorlandIDEServices->QueryInterface(__uuidof(INTAServices), (void **) &IDE);
     if (SUCCEEDED(hr))
     {
      //----------[AppBuilder macro start]--------------------------------------
      #ifndef AppBuilder
      #define AppBuilder IDE->MainMenu->Owner
      #endif
      //----------[AppBuilder macro end ]--------------------------------------
      for ( int i = 0; i<AppBuilder->ComponentCount; i++ ) // ComponentCount = 409
      {
         if ( AppBuilder->Components[i]->ClassNameIs("TMainMenu") ) // MainMenu1
         {
           //----------[AppMainMenu macro start]--------------------------------------
           #ifndef AppMainMenu
           #define AppMainMenu dynamic_cast<TMainMenu*>( AppBuilder->Components[i])
           #endif
           //----------[AppMainMenu macro end ]--------------------------------------
           for ( int x = 0; x < AppMainMenu->Items->Count; x++ ) //count 11
           {
              if(NeedWriteToIni) Section = AppMainMenu->Items->Items[x]->Name;
              EnumerateMenuItem(AppMainMenu->Items->Items[x]);
           }//for finished.
           #undef AppMainMenu
         }//if finished.
      }//for finished
      #undef AppBuilder
     }
     else ShowMessage("Error:I Can't Access IDE.\nYou'd better unload this module.");
     delete ini;
     delete chsini;
   }
   //===[ BPL's 'Main' function or Entry Function. ]========================
}//namespace finished.
int WINAPI DllEntryPoint(HINSTANCE hinst, unsigned long reason, void*)
{
  return 1;
}


  以上是“<b>玩转BCB的IDE 体验ToolsAPI</b>[VC/C++编程]”的内容,如果你对以上该文章内容感兴趣,你可以看看七道奇为您推荐以下文章:
  • <b>hosts是什么 hosts文件在什么位置 若何改正hosts</b>
  • <b>在 Windows 8 中手动安装语言包</b>
  • <b>五个常见 PHP数据库问题</b>
  • Windows中Alt键的12个高效快速的利用本领介绍
  • <b>MySQL ORDER BY 的实现解析</b>
  • <b>详解MySQL存储历程参数有三种范例(in、out、inout)</b>
  • <b>Win8系统恢复出来经典的开始菜单的办法</b>
  • <b>Win8系统花屏怎么办 Win8系统花屏的办理办法</b>
  • <b>Windows 7系统下无线网卡安装</b>
  • <b>为什么 Linux不需求碎片整理</b>
  • <b>Windows 8中删除账户的几种办法(图)</b>
  • <b>教你如安在win7下配置路由器</b>
  • 本文地址: 与您的QQ/BBS好友分享!
    • 好的评价 如果您觉得此文章好,就请您
        0%(0)
    • 差的评价 如果您觉得此文章差,就请您
        0%(0)

    文章评论评论内容只代表网友观点,与本站立场无关!

       评论摘要(共 0 条,得分 0 分,平均 0 分) 查看完整评论
    Copyright © 2020-2022 www.xiamiku.com. All Rights Reserved .