程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 編程語言 >> C語言 >> C++ >> 關於C++ >> 玩轉BCB的IDE 體驗ToolsAPI

玩轉BCB的IDE 體驗ToolsAPI

編輯:關於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;
}

//---------------------------------------------------------------------------

我不是要弄個創天版BCB!!

這裡是我寫的中文化文件。

放在\bin下面,叫成BCBCHS.ini

[FileMenu]

FileMenu=文件(&F)

FileNewItem=新建(&N)...

FileNewApplicationItem=新建程序

FileNewFormItem=新建窗體(&F)

FileNewUnitItem=新建單元(&U)

FileNewFrameItem=新建框架(&m)

FileOpenSeparater=-

FileOpenItem=打開(&O)...

FileOpenProjectItem=打開工程(&j)...

FileClosedFilesItem=再次打開(&R)

FileSaveSeparater=-

FileSaveItem=保存(&S)

FileSaveAsItem=另存為(&A)...

FileSaveProjectAs=工程另存為(&e)...

FileSaveAllItem=全部保存(&v)

FileCloseItem=關閉(&C)

FileCloseAllItem=全部關閉(&l)

FileMenuSeparator=-

FileUseUnitItem=包含單元頭文件(&I)...

FilePrintItem=打印(&P)...

FileExitItem=退出(&x)

[EditMenu]

EditMenu=編輯(&E)

EditUndoItem=撤消(&U)

EditRedoItem=恢復(&R)

EditCutItem=剪切(&t)

EditCopyItem=復制(&C)

EditPasteItem=粘貼(&P)

EditDeleteItem=刪除(&D)

EditSelectAll=全部刪除(&l)

EditAlignGridItem=按網格對齊(&G)

EditFrontItem=控件提前(&F)

EditBackItem=控件置後(&B)

EditAlignItem=控件對齊(&A)...

EditSizeItem=控件大小(&S...

EditScaleItem=控件比例(&e)...

EditTabOrderItem=Tab次序(&O)...

EditCreationOrderItem= 控件創建次序(&n)...

EditFlipChildrenItem=鏡像子控件(&h)

EditFlipChildrenAllItem=全部(&A)

EditFlipChildrenSelectedItem=選定的(&S)

EditLockControlsItem=鎖定控件(&k)

CORBAEditSeparator=-

[SearchMenu]

SearchMenu=搜索(&S)

SearchFindItem=查找(&F)...

SearchFileFindItem=多文件查找(&d)...

SearchReplaceItem=替換(&R)...

SearchAgainItem=重新搜索(&S)

SearchIncrementalItem=增量搜索(&I)

SearchGoToItem=跳轉至指定行號(&G)...

SearchGotoAddressItem=跳轉至指定地址(&e)

[ViewsMenu]

ViewsMenu=查看(&V)

ViewPrjMgrItem=工程管理器(&P)

TransMgrMenu=翻譯管理器(&M)

ViewObjInspItem=對象查看器(&O)

ViewToDoListItem=To-Do列表(&L)

ViewAlignItem=對齊面板(&A)

CodeExplorer=類浏覽器(&x)

ViewCompListItem=組件列表(&C)

ViewWindowListItem=窗口列表(&W)...

ViewDebugItem=調試窗口(&D)

ViewBreakpointsItem=斷點(&B)

ViewCallStackItem=堆棧調用(&S)

ViewWatchesItem=&Watches

ViewLocalVariablesItem=局部變量(&L)

ViewThreadsItem=線程(&T)

ViewModulesItem=模塊(&M)

ViewEventLogItem=事件記錄(&E)

ViewCodeGuardLogItem=CodeGuard記錄

ViewCPUItem=&CPU

ViewFPUItem=&FPU

AltViewCallStackItem=AltViewCallStackItem

AltViewCPUItem=AltViewCPUItem

ViewDesktopsMenu=桌面(&k)

SaveDesktop1=保存桌面(&S)...

DeleteDesktop=刪除(&t)...

SetDebugDesktop1=設置調試桌面(&D)

ViewToggleFormItem=切換窗體/單元(&g)

ViewUnitItem=單元(&U)...

ViewFormItem=窗體(&F)...

ViewTypeLibraryItem=類型庫(&T)

ViewNewEditorItem=新建編輯窗口(&E)

ViewToolbarsItem=工具欄(&r)

ViewSwapSourceFormItem=按文字查看(&V)

ViewNextWindowItem=下一個窗口(隱藏項)

[ProjectMenu]

ProjectMenu=工程(&P)

ProjectAddItem=添加到工程(&A)...

ProjectRemoveItem=從工程移除(&R)...

ProjectImportTypeLibraryItem=引入類型庫(&L)...

ProjectAddRepositoryItem=添加到倉庫(&t)...

ViewPrjSourceItem=查看源文件(&V)

InternationalMenu=語言(&g)

AddLangMenu=添加(&A)...

RemoveLangMenu=移除(&R)...

SetActiveLangMenu=設置激活項(&S)... (<無>)

UpdateResDLLMenu=升級資源(&U)DLLs

ProjectViewMakefileItem=編輯編譯選項源文件(&p)

ProjectExportMakefileItem=輸出Makefile...

N2=-

ProjectAddNewProjectItem=添加新工程(&N)...

ProjectAddExistingProjectItem=添加已有工程(&x)...

ProjectCompileSeparator=-

ProjectCompileUnitItem=編譯單元(&C)

ProjectCompileItem=&Make

ProjectBuildItem=&Build

ProjectInformationItem=&工程信息

N1=-

ProjectCompileAllItem=Make全部工程(&k)

ProjectBuildAllItem=Build全部工程(&u)

ProjectSeparator=-

ProjectDepOptItem=Web發布選項(&W)...

ProjectDeployItem=Web發布(&D)

ProjectSeparator2=-

ProjectOptionsItem=選項(&O)...

[RunMenu]

RunMenu=運行(&R)

RunRunItem=運行(&R)

RunAttachtoProcessItem=附加至進程(&o)...

RunParametersItem=運行參數(&P)...

RunRegisterComItem=注冊ActiveX服務器(&A)

RunUnregisterComItem=注銷Activex服務器(&X)

RunParametersSeparator=-

RunStepOverItem=單步Step Over(&S)

RunTraceIntoItem=單步Trace Into(&T)

RunTraceToSourceItem=跟蹤至下一行源碼(&N)

RunGotoCursorItem=運行至光標處(&C)

RunUntilReturnItem=運行至調用返回(&U)

RunShowCSIPItem=顯示執行點(&h)

RunPauseItem=程序暫停(&g)

RunResetItem=程序重置(&e)

RunInspectSeparator=-

RunInspectItem=巡查(&I)...

RunEvalModItem=求值/修改(&v)...

RunAddWatchItem=添加Watch(&W)...

RunAddBreakItem=添加斷點(&B)

RunAddSourceBreakpointItem=源碼斷點(&S)...

RunAddAddressBreakpointItem=地址斷點(&A)...

RunAddDataBreakpointItem=數據斷點(&D)...

RunAddModuleLoadBreakpointItem=模塊加載斷點(&M)...

[ComponentMenu]

ComponentMenu=組件(&C)

ComponentNewItem=新建組件(&N)...

ComponentAddtoPackage=安裝組件(&I)...

ComponentImportAXCItem=引入Activex控件(&X)...

ComponentInstallCompositeItem=創建組件模板(&T)...

ComponentInstallPackagesItem=安裝程序包(&P)...

ComponentPaletteItem=設置面板(&C)...

[DatabaseMenu]

DatabaseMenu=數據庫(&D)

Borland_DbExplorerMenu=浏覽(&E)

Borland_SQLMonitorMenu=SQL監視器(&S)

Borland_FormWizardMenu=窗體向導(&F)...

[ToolsMenu]

ToolsMenu=工具(&T)

ToolsOptionsItem=環境選項(&O)...

ToolsEditorOptionsItem=編輯器選項(&E)...

ToolsDebuggerOptionsItem=調試器選項(&D)...

ITEOptionsMenu=翻譯工具選項(&n)...

ToolsGalleryItem=倉庫(&R)...

RepositoryMenu=翻譯倉庫(&a)...

CORBAToolsSeparator1=-

CORBAToolsSeparator2=-

ToolsToolsItem=設置自定義工具(&T)...

[HelpMenu]

HelpMenu=幫助(&H)

HelpContentsItem=C++Builder幫助

HelpCBuilderToolsItem=C++Builder工具(&T)

HelpWinSDKItem=Windows SDK(&W)

HelpInprisePage=Borland主頁(&B)

HelpCommunityPage=Borland論壇主頁

HelpCBuilderPage=C++Builder主頁(&P)

HelpDevSupportPage=C++Builder開發人員支持(&S)

DirectItem=C++Builder直通車(&r)...

HelpProgGuideSeparater=-

HelpCustomizeItem=自定義(&t)...

HelpAboutSeparator=-

HelpAboutItem=關於(&A)...

問題就是數據庫菜單沒有效果

  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved