What's new

Issue #2

Doomulation

?????????????????????????
Issue #2... ehh...
Currently, I have menues as resources. In the beginning, I'd like to load these up and then dynamically change the text of each from a string table. That isn't too hard, right?
Well, the problem is that whenever I call SetMenuInfo, I get an error returned ERROR_RESOURCE_DATA_NOT_FOUND. The description is basically that the resource could not be found in the file. Searching the web has yeilded no results, and I have currently NO IDEA what's wrong. Anyone have an idea? I'll include the small function that changes the text.

Code:
void LoadMenuStrings(CMenu& menu)
{
	MENUITEMINFO m_info;
	ZeroMemory(&m_info,sizeof(m_info));
	m_info.fMask = MIIM_ID|MIIM_SUBMENU;
	m_info.cbSize = sizeof(m_info);
	HRESULT hr;

	for (int i = 0; i < (int)menu.GetMenuItemCount(); i++)
	{
		BOOL b = menu.GetMenuItemInfo(i,&m_info,true);
		if (m_info.fType == MFT_SEPARATOR) continue;

		// Data is lost unless stored temporarily locally. Don't ask why; I don't know.
		CString& temp = LoadStringRes(m_info.wID); // Loads the string from the string table and returns it as a CString.
		m_info.dwTypeData = (char*)(const char*)temp;
		
		m_info.cch = (UINT)strlen(m_info.dwTypeData);
		menu.SetMenuItemInfo(i,&m_info,true);
		hr = GetLastError();

		if (m_info.hSubMenu != NULL)
		{
			CMenu SubMenu;
			SubMenu.Attach(m_info.hSubMenu);
			LoadMenuStrings(SubMenu);
		}
	}
}
 

Top