| 1115 | } |
| 1116 | |
| 1117 | BOOL SMenuEx::InsertMenu(UINT uPos, UINT uFlag, int nId, LPCTSTR lpNewItem) |
| 1118 | { |
| 1119 | SMenuExRoot *pMenuRoot = sobj_cast<SMenuExRoot>(GetRoot()->GetWindow(GSW_FIRSTCHILD)); |
| 1120 | SASSERT(pMenuRoot); |
| 1121 | SWindow * pItemRef = FindItem(uPos,uFlag); |
| 1122 | |
| 1123 | if (uFlag & MF_BYCOMMAND && !pItemRef) |
| 1124 | return FALSE; |
| 1125 | |
| 1126 | SMenuExItem *pMenuItem = (SMenuExItem*)pMenuRoot->CreateMenuItem((uFlag & MF_SEPARATOR) ? SMenuExSep::GetClassName() : SMenuExItem::GetClassName()); |
| 1127 | |
| 1128 | if (pItemRef) |
| 1129 | { |
| 1130 | SWindow *pRefPrev = pItemRef->GetWindow(GSW_PREVSIBLING); |
| 1131 | if (pRefPrev) |
| 1132 | { |
| 1133 | pRefPrev->GetParent()->InsertChild(pMenuItem, pRefPrev); |
| 1134 | } |
| 1135 | else |
| 1136 | { |
| 1137 | pItemRef->GetParent()->InsertChild(pMenuItem, ICWND_FIRST); |
| 1138 | } |
| 1139 | } |
| 1140 | else |
| 1141 | { |
| 1142 | pMenuRoot->InsertChild(pMenuItem); |
| 1143 | } |
| 1144 | if (!(uFlag & MF_SEPARATOR)) |
| 1145 | { |
| 1146 | pMenuItem->SetWindowText(lpNewItem); |
| 1147 | if (uFlag & MF_POPUP) |
| 1148 | { |
| 1149 | pMenuItem->m_pSubMenu = new SMenuEx(pMenuItem); |
| 1150 | pMenuItem->m_pSubMenu->IniNullMenu(pMenuRoot); |
| 1151 | } |
| 1152 | |
| 1153 | pMenuItem->SetAttribute(L"ID", SStringW().Format(L"%d",nId)); |
| 1154 | if (uFlag & MF_CHECKED) |
| 1155 | { |
| 1156 | pMenuItem->SetAttribute(L"check", L"1"); |
| 1157 | } |
| 1158 | } |
| 1159 | |
| 1160 | return TRUE; |
| 1161 | } |
| 1162 | |
| 1163 | BOOL SMenuEx::IniNullMenu(SMenuExRoot *ParentRoot) |
| 1164 | { |
nothing calls this directly
no test coverage detected