CSDN博客

img cker

玩转BCB的IDE,体验ToolsAPI

发表于2001/10/28 1:37:00  1509人阅读

分类: BCB/DELPHI

大多数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)...

问题就是数据库菜单没有效果。

0 0

相关博文

我的热门文章

img
取 消
img