玩轉BCB的IDE,體驗ToolsAPI (轉)

worldblog發表於2007-12-11
玩轉BCB的IDE,體驗ToolsAPI (轉)[@more@]

大多數BCB員也許一輩子都不用關心Tools,但如果象我一樣無聊的話,
不妨玩玩和討論一下:
看看下面的程式,來把變個樣:

---&gtBCB5。0

//---------------------------------------------------------------------------
#include
#pragma hdrstop
USERES("node.res");
USEPACKAGE("vcl50.bpi");
//---------------------------------------------------------------------------
#include
#include
//---------------------------------------------------------------------------
#pragma package(smart_init)
//---------------------------------------------------------------------------
//  Package .
//---------------------------------------------------------------------------

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 enuItem(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; iCount; 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
                                (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; iComponentCount; i++ )  // ComponentCount = 409
          {
                if ( AppBuilder->Components[i]->ClassNameIs("TMainMenu") )  // MainMenu1
                {

                    //----------[AppMainMenu macro start]--------------------------------------
                    #ifndef AppMainMenu
                    #define AppMainMenu dynamic_cast( 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)...
FileNeplicationItem=新建程式
FileNewFotem=新建窗體(&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)
EditAll=全部刪除(&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)
EditSeparator=-

[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記錄
ViewItem=&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=釋出選項(&W)...
ProjectDeployItem=Web釋出(&D)
ProjectSeparator2=-
ProjectOptionsItem=選項(&O)...

[RunMenu]
RunMenu=執行(&R)
RunRunItem=執行(&R)
RunAttachtoProcessItem=附加至程式(&o)...
RunParametersItem=執行引數(&P)...
RunRegisterComItem=註冊(&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)...
RunAdreakItem=新增斷點(&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_MonitorMenu=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= 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)...

問題就是資料庫選單沒有效果。


來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/10752043/viewspace-991358/,如需轉載,請註明出處,否則將追究法律責任。

相關文章