Play the BCB IDE experience TOOLSAPI

Source: Internet
Author: User
Tags bool ini

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-&GT;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;
}

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.