During BREW application development, we often use the current small value in function functions.ProgramSome interface instances, such as ishell and idisplay, usually pass their own struct or object pointer containing the iapplet instance to the function, and then implement our operations.
For example:
The draw () function implements some painting operations, which are usually implemented as follows:
Void draw (ishell * pshell, idisplay * pdisplay)
{
Ishell_getdeviceinfo (pshell ,.....);
Ishell_loadresstring (pshell ,.....);
Idisplay_setcolor (pdisplay ,.....);
Idisplay_drawtext (pdisplay ,.....);
.........
Idisplay_update (pdisplay );
}
Every time we want to pass the pointer of these instances, it is quite troublesome and it seems that the overhead is also higher.
We can use getappinstance () to obtain these interface pointers.
Void draw ()
{
Aeeapplet * pthis = (aeeapplet *) getappinstance (); // obtain the iapplet pointer and forcibly convert it to aeeapplet
// Then we can conveniently use pthis.
Ishell_getdeviceinfo (pthis-> m_pishell ,.....);
Ishell_loadresstring (pthis-> m_pishell ,.....);
Idisplay_setcolor (pthis-> m_pidisplay ,.....);
Idisplay_drawtext (pthis-> m_pidisplay ,.....);
.........
Idisplay_update (pthis-> m_idisplay );
}
In my opinion, it is more convenient for us to compile common functions or to write a Connection Library.
This wayCodeCode can be reused later.
I think so. You are welcome to discuss it.
My email elsec@126.com