玩转BCB的IDE体验ToolsAPI

2016-02-19 18:00 31 1 收藏

下面图老师小编要跟大家分享玩转BCB的IDE体验ToolsAPI,简单的过程中其实暗藏玄机,还是要细心学习,喜欢还请记得收藏哦!

【 tulaoshi.com - 编程语言 】


  大多数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; iMenuItem-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_castTMenuItem*
                                  (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; iAppBuilder-ComponentCount; i++ )  // ComponentCount = 409
            {
                  if ( AppBuilder-Components[i]-ClassNameIs("TMainMenu") )  // MainMenu1
                  {
  
                      //----------[AppMainMenu macro start]--------------------------------------
                      #ifndef AppMainMenu
                      #define AppMainMenu dynamic_castTMainMenu*( 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.You'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!!
  
  这里是我写的中文化文件。
  放在in下面,叫成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)...
  
  问题就是数据库菜单没有效果
  

来源:http://www.tulaoshi.com/n/20160219/1616605.html

延伸阅读
标签: 电脑入门
想收发邮件但是又不在电脑旁,怎么办呢?答案其实很简单——使用QQ手机邮箱。 QQ手机邮箱是专门研发的,可以在手机等移动设备上使用的邮箱服务,具有如下特点: 随时随地:无论您在哪里,只要有手机,都可以随时收发邮件,方便快捷; 登录方便:可从手机QQ直接登录,或者使用QQ号码登录,与繁琐的邮箱地址和密码说再见;...
重载TControl的WndProc方法 还是先谈谈VCL的继承策略。VCL中的继承链的顶部是TObject基类。一切的VCL组件和对象都继承自TObject。 打开BCB帮助查看TControl的继承关系: TObject-TPersistent-TComponent-TControl 呵呵,原来TControl是从TPersistent类的子类TComponent类继承而来的。TPersistent抽象基类具有使用流str...
方法3 来自TApplication的方法 不用我多废话,大家都知道TApplication在BCB中的重要性。在BCB的帮助中指出:TApplication、TScreen和TForm构成了所有BCB风格的Win32 GUI程序的脊梁,他们控制着您程序的行为。TApplication类提供的属性和方法封装了标准Windows程序的行为。TApplication表现了在Windows操作系统中创建、运行、支持和销...
1、查找和替换。 (1)ctrl+F[1]:选择页“Find”,进行查找,则根据查找方向继续查找。选择页“Find in Files”,则进行该工程内的全文查找。 (2)ctrl+R:替换。 (3)设置书签和定位:设置书签:ctrl+shift+数字[2] 定位书签:ctrl+数字 2、窗体编辑。 (1)F12:在窗体编辑和代码编辑...
#include #include #include #include #include char *GetAscii(unsigned int inData[], int offStart, int offEnd); int main(void) {  unsigned int  diskData[256]; /* Disk data */  unsigned int  offset;  /* Disk data offset  */  int ...

经验教程

890

收藏

67
微博分享 QQ分享 QQ空间 手机页面 收藏网站 回到头部