- //
- // Menu is just a normal string (passed in data parameter)
- //
- m_vMenuData.afStyle |= MIS_TEXT;
- pData = (char*)pItem->GetText().c_str();
+ rItem.afStyle = MIS_SEPARATOR;
+ }
+ else
+ {
+ if (pItem->GetId() == idMenuTitle)
+ {
+ // Item is an unselectable title to be passed via pData
+ rItem.afStyle = MIS_STATIC;
+ }
+ else
+ {
+ //
+ // Menu is just a normal string (passed in data parameter)
+ //
+ rItem.afStyle |= MIS_TEXT;
+ }
+ pData = (char*) pItem->GetItemLabel().wx_str();
+ }
+
+ if (nPos == (size_t)-1)
+ {
+ rItem.iPosition = MIT_END;
+ }
+ else
+ {
+ rItem.iPosition = (SHORT)nPos;
+ }
+
+ APIRET rc;
+
+ rc = (APIRET)::WinSendMsg( GetHmenu()
+ ,MM_INSERTITEM
+ ,(MPARAM)&rItem
+ ,(MPARAM)pData
+ );
+#if wxUSE_OWNER_DRAWN
+ if (pItem->IsOwnerDrawn())
+ {
+ MENUITEM vMenuItem;
+
+ ::WinSendMsg( GetHmenu()
+ ,MM_QUERYITEM
+ ,MPFROM2SHORT( (USHORT)pItem->GetId()
+ ,(USHORT)(FALSE)
+ )
+ ,&vMenuItem
+ );
+ }
+#endif
+
+ if (rc == (APIRET)MIT_MEMERROR || rc == (APIRET)MIT_ERROR)
+ {
+ vError = ::WinGetLastError(vHabmain);
+ sError = wxPMErrorToStr(vError);
+ wxLogError(wxT("Error inserting or appending a menuitem. Error: %s\n"), sError.c_str());
+ wxLogLastError(wxT("Insert or AppendMenu"));
+ return false;
+ }
+
+ //
+ // If we're already attached to the menubar, we must update it
+ //
+ if (IsAttached() && GetMenuBar()->IsAttached())
+ {
+ GetMenuBar()->Refresh();