This is my first post ever in this forum. The problem I came across is about a popup menu in Visual C++.
The application creates a tray icon. Now, I create a menu (baseMenu) with the resource editor of Visual Studio (2008). Then, baseMenu is successfully loaded and I am able to see it when I click to the tray icon. So far so good...
However, I want the application to be able to add new popup menus to baseMenu during runtime. Until now, I can only add new items (basePopupMenus) with AppendMenu(). But, I have a problem populating basePopupMenus with new items before adding them to baseMenu.
Here is the code I use so far:
Code:
baseMenu.LoadMenu(IDR_BASE_MENU);
// Open file to read new items from.
CFile m_fileItems;
if (m_fileItems.Open(_T("items.it"), CFile::modeRead))
{
// Open archive.
CArchive archive(&m_fileItems, CArchive::load);
CString strLoadedBasePopupMenuItem;
// If file is not empty.
if (m_fileItems.GetLength() != 0)
{
do
{
// Load item.
archive >> strLoadedBasePopupMenuItem;
// Try to find substring "+---".
// Item is basePopupMenu.
if (strLoadedBasePopupMenuItem.Find(_T("+---")) == -1)
{
// Create new popup menu.
basePopupMenu.CreatePopupMenu();
baseMenu.GetSubMenu(0)->AppendMenu(MF_ENABLED | MF_POPUP, (UINT)&basePopupMenu.m_hMenu, strLoadedBasePopupMenuItem);
}
else // Item is application.
{
strLoadedBasePopupMenuItem.Remove('-'); // Removing dashes (-)
strLoadedBasePopupMenuItem.Remove('+'); // and plus sign (+).
basePopupMenuItem.CreatePopupMenu();
basePopupMenu.AppendMenu(MF_ENABLED | MF_POPUP, (UINT)&m_NewMenu.m_hMenu, strLoadedBasePopupMenuItem);
}
}
while (archive.IsBufferEmpty()==0);
}
// Close archive and file.
archive.Close();
m_fileItems.Close();
Can anyone, please, tell me what to do?Thanks a lot!
P.S.: Ask me if there is anything I haven't explained enough.

