Access Items of a Subfolder (OLE)

Author Message
kiryph 02/28/2005 08:52 am
Hello,
can anyone help me, how to write c++ code to access items of a subfolder (of a subfolder)?
The example code is written in pascal and doesn`t solve my problem.
I don`t know COM-Programming very well. The truth is, it`s my first program with com objects.
I use the Borland C++Builder 5 Pro. I`ve imported the OE type library.
Now I can place a OE-server object on my form and have access to the exposed objects.
This already works:
I can reach the main folders:
ComboBox1->Text = MainOE1->GetFolder(i)->Caption;

The help system of oe tells me, to get the subfolders, I should use the Object GetItem.
IDispatch* pDisp = MainOE1->GetFolder(FolderNumber)->GetItem(i);
But now I don`t know, what to do further?
I dont really understand the IDispatch-Interface . Do I need knowledge about the IDispatch-Interface?
Maybe somebody can write a small example for me.

Thanks a lot for every hint.
Oleg Chernavin 02/28/2005 08:56 am
I am very sorry, but I cannot help you here myself, because I haven`t worked with OLE Automation in C++. Maybe other users will be able to draft a sample code.

Best regards,
Oleg Chernavin
MP Staff
PierreWoodman 03/02/2005 07:11 pm
Hi, i wrote these 2 methods for parsing a folder incl. subfolders (wrote them in c#) lots of things in it, you don`t need, but i think it can show you the main idea:

private void PopulateProjectManager()
{
// parse master folders
for (int i = 0; i < _OE.FoldersCount; i++)
{
this.RecurseFolder(_OE.GetFolder(i));
}
}

/// <summary>
/// fetch info from each (sub)folder
/// </summary>
/// <param name="IFolder"></param>
private void RecurseFolder(OEFolder IFolder)
{
for (int i = 0; i < IFolder.ItemsCount; i++)
{
if (IFolder.ItemType(i) == OEClassType.OECT_Folder)
{
RecurseFolder((OEFolder)IFolder.GetItem(i));
}
else
{
IOEProject IProject = (IOEProject)IFolder.GetItem(i);
int length = lvwManager.Items.Count;

this.lvwManager.Items.Add(IProject.IID.ToString());
this.lvwManager.Items[length].SubItems.Add(IProject.Caption);
this.lvwManager.Items[length].SubItems.Add(IProject.URL);
this.lvwManager.Items[length].SubItems.Add(IProject.UserName);
this.lvwManager.Items[length].SubItems.Add(IProject.Password);
this.lvwManager.Items[length].SubItems.Add("todo");
this.lvwManager.Items[length].SubItems.Add(IProject.Level.ToString());
this.lvwManager.Items[length].SubItems.Add("todo");
this.lvwManager.Items[length].SubItems.Add("todo");
this.lvwManager.Items[length].SubItems.Add("todo");

// load specific data
LoadDataPerIID(IProject.IID);
}
}
}