I cannot thank you guys enough for all your help. I finally got the functionality I have been missing for so long. With a bit of tweaking of some code that you provided, I ended up with this script that works like a charm ( for me ). This is such a valuable macro!
Thanks again!
-B
#include "slick.sh"
/**
*
* @param hTree
* @param caption
*
* @return boolean
*/
boolean findAndSelectCaption(int hTree, _str caption)
{
int state,bm1,bm2,flags;
int index = hTree._TreeSearch(TREE_ROOT_INDEX,caption,'TS');
boolean found = false;
if (index > 0)
{
hTree._TreeSetAllFlags(0,TREENODE_SELECTED);
hTree._TreeGetInfo(index,state,bm1,bm2,flags);
hTree._TreeSetInfo(index,state,bm1,bm2,flags|TREENODE_SELECTED);
hTree._TreeSetCurIndex(index);
found = true;
}
return found;
}
/**
*
* @param filename
* @param ext
*
* @return _str
*/
_str buildCaption(_str filename, _str ext)
{
_str newfile = strip_filename(filename,'E');
newfile = newfile :+ '.' :+ ext;
_str caption = strip_filename(newfile,'P');
caption = caption :+ "\t" :+ newfile;
return caption;
}
_command void showInProject(_str filename = p_buf_name) name_info(',')
{
int hTree = _find_object('_tbprojects_form._proj_tooltab_tree');
_str caption = strip_filename(filename,'P');
caption = caption :+ "\t" :+ filename;
if(hTree > 0)
{
boolean found = findAndSelectCaption(hTree, caption);
if(!found)
{
_str project_found = _WorkspaceFindProjectWithFile(filename, _workspace_filename, true, true);
if (project_found == '')
{
message('No project containing the file ' :+ filename);
return;
}
activate_projects();
_str project_caption = buildCaption(project_found,'vpj');
int index = hTree._TreeSearch(TREE_ROOT_INDEX, project_caption, 'T');
if(index == -1)
{
project_caption = buildCaption(project_found,'vcproj');
index = hTree._TreeSearch(TREE_ROOT_INDEX, project_caption, 'T');
}
if(index == -1)
{
project_caption = buildCaption(project_found,'csproj');
index = hTree._TreeSearch(TREE_ROOT_INDEX, project_caption, 'T');
}
if(index != -1)
{
if (hTree._projecttbIsProjectNode(index)
&& hTree._TreeGetFirstChildIndex(index) < 0)
{
hTree.toolbarBuildFilterList(hTree._projecttbTreeGetCurProjectName(index),index);
// Rebuilding the filter list for the project just expanded
// will re-set the current index. Refocus the project node
hTree._TreeSetCurIndex(index);
}
}
else
{
message('No project containing the file ' :+ filename);
return;
}
found = findAndSelectCaption(hTree, caption);
if(!found)
{
message('File not found : ' :+ filename);
}
}
}
else
{
message("Could not find the project tree.");
}
}