The fragment of code below will create a new version of the tool every time it is called.
void create_a_subtool(void)
{
tw_tool("Sub Tool", 256, 128);
/** specify sub tool entries here **/
tw_end_subtool();
}
Sub tools invoked by the user (say by a button press) are usually meant to be unique, and only need to be re-displayed if they have been iconified. They should thus be created with a code fragment like
void create_a_subtool(void)
{
static void *tool_id = NULL;
if(tool_id != 0)
{
tw_show_tool(tool_id);
return;
}
tool_id = tw_tool("Sub Tool", 256, 128);
/** specify sub tool entries here **/
tw_end_subtool();
}
The first time the tool is invoked it will be created in the usual way, subsequent invocations will simply re-display the tool. Similarly dialog boxes should be created with a code fragment that allows them to be re-displayed after dismissal rather than re-created, e.g.
void create_a_dialog()
{
static void *dialog_id = NULL;
if(dialog_id != 0)
{
tw_show(dialog_id);
return;
}
dialog_id = tw_dialog("Dialog Box");
/** specify dialog entries here **/
tw_end_dialog();
}