bool CMenu::InsertItem(UINT itemIndex, bool byPosition, const CMenuItem &item) { #ifndef _UNICODE if (!g_IsNT) { MENUITEMINFOA si; ConvertItemToSysForm(item, si); AString s; if (item.IsString()) { s = GetSystemString(item.StringValue); si.dwTypeData = (LPTSTR)(LPCTSTR)s; } return InsertItem(itemIndex, byPosition, &si); } else #endif { MENUITEMINFOW si; ConvertItemToSysForm(item, si); if (item.IsString()) si.dwTypeData = (LPWSTR)(LPCWSTR)item.StringValue; return InsertItem(itemIndex, byPosition, &si); } }
bool CMenu::GetItem(UINT itemIndex, bool byPosition, CMenuItem &item) { const UINT kMaxSize = 512; #ifndef _UNICODE if (!g_IsNT) { CHAR s[kMaxSize + 1]; MENUITEMINFOA si; ConvertItemToSysForm(item, si); if (item.IsString()) { si.cch = kMaxSize; si.dwTypeData = s; } if (GetItemInfo(itemIndex, byPosition, &si)) { ConvertItemToMyForm(si, item); if (item.IsString()) item.StringValue = GetUnicodeString(s); return true; } } else #endif { wchar_t s[kMaxSize + 1]; MENUITEMINFOW si; ConvertItemToSysForm(item, si); if (item.IsString()) { si.cch = kMaxSize; si.dwTypeData = s; } if (GetItemInfo(itemIndex, byPosition, &si)) { ConvertItemToMyForm(si, item); if (item.IsString()) item.StringValue = s; return true; } } return false; }
bool CMenu::InsertItem(UINT itemIndex, bool byPosition, const CMenuItem &item) { #ifndef _UNICODE if (!g_IsNT) { MENUITEMINFOA si; ConvertItemToSysForm(item, si); AString s; if (item.IsString()) { s = GetSystemString(item.StringValue); si.dwTypeData = (LPTSTR)(LPCTSTR)s; } return InsertItem(itemIndex, byPosition, &si); } else #endif { MENUITEMINFOW si; ConvertItemToSysForm(item, si); if (item.IsString()) si.dwTypeData = (LPWSTR)(LPCWSTR)item.StringValue; #ifdef UNDER_CE UINT flags = (item.fType & MFT_SEPARATOR) ? MF_SEPARATOR : MF_STRING; UINT id = item.wID; if ((item.fMask & MIIM_SUBMENU) != 0) { flags |= MF_POPUP; id = (UINT)item.hSubMenu; } if (!Insert(itemIndex, flags | (byPosition ? MF_BYPOSITION : MF_BYCOMMAND), id, item.StringValue)) return false; return SetItemInfo(itemIndex, byPosition, &si); #else return InsertItem(itemIndex, byPosition, &si); #endif } }