Most BCB programmers may not care about TOOLSAPI for a lifetime, but if bored like me,
You may wish to play and discuss:
Look at the following program to change the IDE to a sample:
--->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 is 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; + +)
{
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 (Application->exename, Changefileext). 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;
}