这篇教程C++ GetHmenu函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中GetHmenu函数的典型用法代码示例。如果您正苦于以下问题:C++ GetHmenu函数的具体用法?C++ GetHmenu怎么用?C++ GetHmenu使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了GetHmenu函数的26个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: wxCHECK_MSGbool wxMenuBar::Append(wxMenu *menu, const wxString& title){ WXHMENU submenu = menu ? menu->GetHMenu() : 0; wxCHECK_MSG( submenu, false, wxT("can't append invalid menu to menubar") ); if ( !wxMenuBarBase::Append(menu, title) ) return false; menu->wxMenuBase::SetTitle(title); if (GetHmenu()) { if ( !::AppendMenu(GetHmenu(), MF_POPUP | MF_STRING, (UINT_PTR)submenu, title.t_str()) ) { wxLogLastError(wxT("AppendMenu")); }#if wxUSE_ACCEL if ( menu->HasAccels() ) { // need to rebuild accelerator table RebuildAccelTable(); }#endif // wxUSE_ACCEL if (IsAttached()) Refresh(); } return true;}
开发者ID:CodeSmithyIDE,项目名称:wxWidgets,代码行数:32,
示例2: wxLogLastErrorwxMenu *wxMenuBar::Remove(size_t pos){ wxMenu *menu = wxMenuBarBase::Remove(pos); if ( !menu ) return NULL; if (GetHmenu()) { if ( !::RemoveMenu(GetHmenu(), (UINT)MSWPositionForWxMenu(menu,pos), MF_BYPOSITION) ) { wxLogLastError(wxT("RemoveMenu")); }#if wxUSE_ACCEL if ( menu->HasAccels() ) { // need to rebuild accell table RebuildAccelTable(); }#endif // wxUSE_ACCEL if (IsAttached()) Refresh(); } return menu;}
开发者ID:CodeSmithyIDE,项目名称:wxWidgets,代码行数:27,
示例3: GetMenuCountbool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title){ // Find out which MSW item before which we'll be inserting before // wxMenuBarBase::Insert is called and GetMenu(pos) is the new menu. // If IsAttached() is false this won't be used anyway bool isAttached = (GetHmenu() != 0); if ( !wxMenuBarBase::Insert(pos, menu, title) ) return false; menu->wxMenuBase::SetTitle(title); if ( isAttached ) { // We have a problem with the index if there is an extra "Window" menu // in this menu bar, which is added by wxMDIParentFrame to it directly // using Windows API (so that it remains invisible to the user code), // but which does affect the indices of the items we insert after it. // So we check if any of the menus before the insertion position is a // foreign one and adjust the insertion index accordingly. int mswExtra = 0; // Skip all this if the total number of menus matches (notice that the // internal menu count has already been incremented by wxMenuBarBase:: // Insert() call above, hence -1). int mswCount = ::GetMenuItemCount(GetHmenu()); if ( mswCount != -1 && static_cast<unsigned>(mswCount) != GetMenuCount() - 1 ) { wxMenuList::compatibility_iterator node = m_menus.GetFirst(); for ( size_t n = 0; n < pos; n++ ) { if ( ::GetSubMenu(GetHmenu(), n) != GetHmenuOf(node->GetData()) ) mswExtra++; else node = node->GetNext(); } } if ( !::InsertMenu(GetHmenu(), pos + mswExtra, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)GetHmenuOf(menu), title.t_str()) ) { wxLogLastError(wxT("InsertMenu")); }#if wxUSE_ACCEL if ( menu->HasAccels() ) { // need to rebuild accell table RebuildAccelTable(); }#endif // wxUSE_ACCEL if (IsAttached()) Refresh(); } return true;}
开发者ID:CodeSmithyIDE,项目名称:wxWidgets,代码行数:60,
示例4: wxCHECK_MSGbool wxMenuBar::Append(wxMenu *menu, const wxString& title){ WXHMENU submenu = menu ? menu->GetHMenu() : 0; wxCHECK_MSG( submenu, false, wxT("can't append invalid menu to menubar") ); if ( !wxMenuBarBase::Append(menu, title) ) return false; menu->wxMenuBase::SetTitle(title);#if defined(WINCE_WITHOUT_COMMANDBAR) if (IsAttached())#else if (GetHmenu())#endif {#if defined(WINCE_WITHOUT_COMMANDBAR) if (!GetToolBar()) return false; TBBUTTON tbButton; memset(&tbButton, 0, sizeof(TBBUTTON)); tbButton.iBitmap = I_IMAGENONE; tbButton.fsState = TBSTATE_ENABLED; tbButton.fsStyle = TBSTYLE_DROPDOWN | TBSTYLE_NO_DROPDOWN_ARROW | TBSTYLE_AUTOSIZE; size_t pos = GetMenuCount(); HMENU hPopupMenu = (HMENU) menu->GetHMenu() ; tbButton.dwData = (DWORD)hPopupMenu; wxString label = wxStripMenuCodes(title); tbButton.iString = (int) label.wx_str(); tbButton.idCommand = NewControlId(); if (!::SendMessage((HWND) GetToolBar()->GetHWND(), TB_INSERTBUTTON, pos, (LPARAM)&tbButton)) { wxLogLastError(wxT("TB_INSERTBUTTON")); return false; }#else if ( !::AppendMenu(GetHmenu(), MF_POPUP | MF_STRING, (UINT_PTR)submenu, title.wx_str()) ) { wxLogLastError(wxT("AppendMenu")); }#endif#if wxUSE_ACCEL if ( menu->HasAccels() ) { // need to rebuild accelerator table RebuildAccelTable(); }#endif // wxUSE_ACCEL if (IsAttached()) Refresh(); } return true;}
开发者ID:Zombiebest,项目名称:Dolphin,代码行数:59,
示例5: GetHmenuvoid wxMenu::SetTitle(const wxString& label){ bool hasNoTitle = m_title.empty(); m_title = label; HMENU hMenu = GetHmenu(); if ( hasNoTitle ) { if ( !label.empty() ) { if ( !::InsertMenu(hMenu, 0u, MF_BYPOSITION | MF_STRING, (UINT_PTR)idMenuTitle, m_title.t_str()) || !::InsertMenu(hMenu, 1u, MF_BYPOSITION, (unsigned)-1, NULL) ) { wxLogLastError(wxT("InsertMenu")); } } } else { if ( label.empty() ) { // remove the title and the separator after it if ( !RemoveMenu(hMenu, 0, MF_BYPOSITION) || !RemoveMenu(hMenu, 0, MF_BYPOSITION) ) { wxLogLastError(wxT("RemoveMenu")); } } else { // modify the title if ( !ModifyMenu(hMenu, 0u, MF_BYPOSITION | MF_STRING, (UINT_PTR)idMenuTitle, m_title.t_str()) ) { wxLogLastError(wxT("ModifyMenu")); } } } // put the title string in bold face if ( !m_title.empty() ) { SetDefaultMenuItem(GetHmenu(), (UINT)idMenuTitle); }}
开发者ID:CodeSmithyIDE,项目名称:wxWidgets,代码行数:48,
示例6: WXUNUSEDbool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id_){ const int id = (signed short)id_; // ignore commands from the menu title if ( id != idMenuTitle ) { // Default value for uncheckable items. int checked = -1; // update the check item when it's clicked wxMenuItem * const item = FindItem(id); if ( item && item->IsCheckable() ) { item->Toggle(); // Get the status of the menu item: note that it has been just changed // by Toggle() above so here we already get the new state of the item. // // Also notice that we must pass unsigned id_ and not sign-extended id // to ::GetMenuState() as this is what it expects. UINT menuState = ::GetMenuState(GetHmenu(), id_, MF_BYCOMMAND); checked = (menuState & MF_CHECKED) != 0; } SendEvent(id, checked); } return true;}
开发者ID:Zombiebest,项目名称:Dolphin,代码行数:30,
示例7: GetMenuItemswxMenuItem* wxMenu::DoRemove( wxMenuItem* pItem){ // // We need to find the items position in the child list // size_t nPos; wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst(); for (nPos = 0; node; nPos++) { if (node->GetData() == pItem) break; node = node->GetNext(); } // // DoRemove() (unlike Remove) can only be called for existing item! // wxCHECK_MSG(node, NULL, wxT("bug in wxMenu::Remove logic"));#if wxUSE_ACCEL // // Remove the corresponding accel from the accel table // int n = FindAccel(pItem->GetId()); if (n != wxNOT_FOUND) { delete m_vAccels[n]; m_vAccels.RemoveAt(n); }#endif // wxUSE_ACCEL // // Remove the item from the menu // ::WinSendMsg( GetHmenu() ,MM_REMOVEITEM ,MPFROM2SHORT(pItem->GetId(), TRUE) ,(MPARAM)0 ); if (IsAttached() && GetMenuBar()->IsAttached()) { // // Otherwise, the chane won't be visible // GetMenuBar()->Refresh(); } // // And from internal data structures // return wxMenuBase::DoRemove(pItem);} // end of wxMenu::DoRemove
开发者ID:chromylei,项目名称:third_party,代码行数:56,
示例8: definedwxMenu *wxMenuBar::Replace(size_t pos, wxMenu *menu, const wxString& title){ wxMenu *menuOld = wxMenuBarBase::Replace(pos, menu, title); if ( !menuOld ) return NULL; menu->wxMenuBase::SetTitle(title);#if defined(WINCE_WITHOUT_COMMANDBAR) if (IsAttached())#else if (GetHmenu())#endif { int mswpos = MSWPositionForWxMenu(menuOld,pos); // can't use ModifyMenu() because it deletes the submenu it replaces if ( !::RemoveMenu(GetHmenu(), (UINT)mswpos, MF_BYPOSITION) ) { wxLogLastError(wxT("RemoveMenu")); } if ( !::InsertMenu(GetHmenu(), (UINT)mswpos, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)GetHmenuOf(menu), title.wx_str()) ) { wxLogLastError(wxT("InsertMenu")); }#if wxUSE_ACCEL if ( menuOld->HasAccels() || menu->HasAccels() ) { // need to rebuild accell table RebuildAccelTable(); }#endif // wxUSE_ACCEL if (IsAttached()) Refresh(); } return menuOld;}
开发者ID:Zombiebest,项目名称:Dolphin,代码行数:43,
示例9: definedwxMenu *wxMenuBar::Remove(size_t pos){ wxMenu *menu = wxMenuBarBase::Remove(pos); if ( !menu ) return NULL;#if defined(WINCE_WITHOUT_COMMANDBAR) if (IsAttached())#else if (GetHmenu())#endif {#if defined(WINCE_WITHOUT_COMMANDBAR) if (GetToolBar()) { if (!::SendMessage((HWND) GetToolBar()->GetHWND(), TB_DELETEBUTTON, (UINT) pos, (LPARAM) 0)) { wxLogLastError(wxT("TB_DELETEBUTTON")); } }#else if ( !::RemoveMenu(GetHmenu(), (UINT)MSWPositionForWxMenu(menu,pos), MF_BYPOSITION) ) { wxLogLastError(wxT("RemoveMenu")); }#endif#if wxUSE_ACCEL if ( menu->HasAccels() ) { // need to rebuild accell table RebuildAccelTable(); }#endif // wxUSE_ACCEL if (IsAttached()) Refresh(); } m_titles.RemoveAt(pos); return menu;}
开发者ID:DumaGit,项目名称:winsparkle,代码行数:43,
示例10: SHORT1FROMMRwxMenu* wxMenuBar::Remove( size_t nPos){ wxMenu* pMenu = wxMenuBarBase::Remove(nPos); SHORT nId; if (!pMenu) return NULL; nId = SHORT1FROMMR(::WinSendMsg( (HWND)GetHmenu() ,MM_ITEMIDFROMPOSITION ,MPFROMSHORT(nPos) ,(MPARAM)0) ); if (nId == MIT_ERROR) { wxLogLastError(wxT("LogLastError")); return NULL; } if (IsAttached()) { ::WinSendMsg( (HWND)GetHmenu() ,MM_REMOVEITEM ,MPFROM2SHORT(nId, TRUE) ,(MPARAM)0 );#if wxUSE_ACCEL if (pMenu->HasAccels()) { // // Need to rebuild accell table // RebuildAccelTable(); }#endif // wxUSE_ACCEL Refresh(); } m_titles.RemoveAt(nPos); return pMenu;} // end of wxMenuBar::Remove
开发者ID:vdm113,项目名称:wxWidgets-ICC-patch,代码行数:42,
示例11: GetMenuItemswxMenuItem *wxMenu::DoRemove(wxMenuItem *item){ // we need to find the item's position in the child list size_t pos; wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst(); for ( pos = 0; node; pos++ ) { if ( node->GetData() == item ) break; node = node->GetNext(); }#if wxUSE_ACCEL // remove the corresponding accel from the accel table int n = FindAccel(item->GetId()); if ( n != wxNOT_FOUND ) { delete m_accels[n]; m_accels.RemoveAt(n);#if wxUSE_OWNER_DRAWN ResetMaxAccelWidth();#endif } //else: this item doesn't have an accel, nothing to do#endif // wxUSE_ACCEL // Update indices of radio groups. if ( m_radioData ) { bool inExistingGroup = m_radioData->UpdateOnRemoveItem(pos); wxASSERT_MSG( !inExistingGroup || item->GetKind() == wxITEM_RADIO, wxT("Removing non radio button from radio group?") ); } // remove the item from the menu if ( !::RemoveMenu(GetHmenu(), (UINT)pos, MF_BYPOSITION) ) { wxLogLastError(wxT("RemoveMenu")); } if ( IsAttached() && GetMenuBar()->IsAttached() ) { // otherwise, the change won't be visible GetMenuBar()->Refresh(); } // and from internal data structures return wxMenuBase::DoRemove(item);}
开发者ID:xiyuera,项目名称:wxWidgets,代码行数:53,
示例12: GetHmenuvoid wxMenu::SetTitle( const wxString& rLabel ){ bool bHasNoTitle = m_title.empty(); HWND hMenu = GetHmenu(); m_title = rLabel; if (bHasNoTitle) { if (!rLabel.empty()) { if (!::WinSetWindowText(hMenu, rLabel.c_str())) { wxLogLastError(wxT("SetMenuTitle")); } } } else { if (rLabel.empty() ) { ::WinSendMsg( GetHmenu() ,MM_REMOVEITEM ,MPFROM2SHORT(hMenu, TRUE) ,(MPARAM)0 ); } else { // // Modify the title // if (!::WinSetWindowText(hMenu, rLabel.c_str())) { wxLogLastError(wxT("SetMenuTitle")); } } }} // end of wxMenu::SetTitle
开发者ID:vdm113,项目名称:wxWidgets-ICC-patch,代码行数:38,
示例13: GetMenuItemswxMenuItem *wxMenu::DoRemove(wxMenuItem *item){ // we need to find the item's position in the child list size_t pos; wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst(); for ( pos = 0; node; pos++ ) { if ( node->GetData() == item ) break; node = node->GetNext(); } // DoRemove() (unlike Remove) can only be called for an existing item! wxCHECK_MSG( node, NULL, wxT("bug in wxMenu::Remove logic") );#if wxUSE_ACCEL // remove the corresponding accel from the accel table int n = FindAccel(item->GetId()); if ( n != wxNOT_FOUND ) { delete m_accels[n]; m_accels.RemoveAt(n);#if wxUSE_OWNER_DRAWN ResetMaxAccelWidth();#endif } //else: this item doesn't have an accel, nothing to do#endif // wxUSE_ACCEL // remove the item from the menu if ( !::RemoveMenu(GetHmenu(), (UINT)pos, MF_BYPOSITION) ) { wxLogLastError(wxT("RemoveMenu")); } if ( IsAttached() && GetMenuBar()->IsAttached() ) { // otherwise, the change won't be visible GetMenuBar()->Refresh(); } // and from internal data structures return wxMenuBase::DoRemove(item);}
开发者ID:Zombiebest,项目名称:Dolphin,代码行数:47,
示例14: wxLogLastError// The wxWindow destructor will take care of deleting the submenus.wxMenu::~wxMenu(){ // we should free Windows resources only if Windows doesn't do it for us // which happens if we're attached to a menubar or a submenu of another // menu if ( !IsAttached() && !GetParent() ) { if ( !::DestroyMenu(GetHmenu()) ) { wxLogLastError(wxT("DestroyMenu")); } }#if wxUSE_ACCEL // delete accels WX_CLEAR_ARRAY(m_accels);#endif // wxUSE_ACCEL}
开发者ID:HackLinux,项目名称:chandler-1,代码行数:19,
示例15: WXUNUSEDbool wxMenu::OS2Command( WXUINT WXUNUSED(uParam), WXWORD vId ){ // // Ignore commands from the menu title // if (vId != (WXWORD)idMenuTitle) { SendEvent( vId ,(int)::WinSendMsg( GetHmenu() ,MM_QUERYITEMATTR ,MPFROMSHORT(vId) ,(MPARAM)MIA_CHECKED ) ); } return true;} // end of wxMenu::OS2Command
开发者ID:vdm113,项目名称:wxWidgets-ICC-patch,代码行数:19,
示例16: GetMenuItemswxMenuItem *wxMenu::DoRemove(wxMenuItem *item){ // we need to find the item's position in the child list size_t pos; wxMenuItemList::compatibility_iterator node = GetMenuItems().GetFirst(); for ( pos = 0; node; pos++ ) { if ( node->GetData() == item ) break; node = node->GetNext(); }#if wxUSE_ACCEL RemoveAccel(item);#endif // wxUSE_ACCEL // Update indices of radio groups. if ( m_radioData ) { if ( m_radioData->UpdateOnRemoveItem(pos) ) { wxASSERT_MSG( item->IsRadio(), wxT("Removing non radio button from radio group?") ); } //else: item being removed is not in a radio group } // remove the item from the menu if ( !::RemoveMenu(GetHmenu(), (UINT)pos, MF_BYPOSITION) ) { wxLogLastError(wxT("RemoveMenu")); } if ( IsAttached() && GetMenuBar()->IsAttached() ) { // otherwise, the change won't be visible GetMenuBar()->Refresh(); } // and from internal data structures return wxMenuBase::DoRemove(item);}
开发者ID:CodeSmithyIDE,项目名称:wxWidgets,代码行数:43,
示例17: wxCHECK_RETvoid wxMenuBar::SetMenuLabel(size_t pos, const wxString& label){ wxCHECK_RET( pos < GetMenuCount(), wxT("invalid menu index") ); m_menus[pos]->wxMenuBase::SetTitle(label); if ( !IsAttached() ) { return; } //else: have to modify the existing menu int mswpos = MSWPositionForWxMenu(GetMenu(pos),pos); UINT_PTR id; UINT flagsOld = ::GetMenuState((HMENU)m_hMenu, mswpos, MF_BYPOSITION); if ( flagsOld == 0xFFFFFFFF ) { wxLogLastError(wxT("GetMenuState")); return; } if ( flagsOld & MF_POPUP ) { // HIBYTE contains the number of items in the submenu in this case flagsOld &= 0xff; id = (UINT_PTR)::GetSubMenu((HMENU)m_hMenu, mswpos); } else { id = pos; } if ( ::ModifyMenu(GetHmenu(), mswpos, MF_BYPOSITION | MF_STRING | flagsOld, id, label.t_str()) == (int)0xFFFFFFFF ) { wxLogLastError(wxT("ModifyMenu")); } Refresh();}
开发者ID:CodeSmithyIDE,项目名称:wxWidgets,代码行数:42,
示例18: WXUNUSEDbool wxMenu::MSWCommand(WXUINT WXUNUSED(param), WXWORD id_){ const int id = (signed short)id_; // ignore commands from the menu title if ( id != idMenuTitle ) { // update the check item when it's clicked wxMenuItem * const item = FindItem(id); if ( item && item->IsCheckable() ) item->Toggle(); // get the status of the menu item: note that it has been just changed // by Toggle() above so here we already get the new state of the item UINT menuState = ::GetMenuState(GetHmenu(), id, MF_BYCOMMAND); SendEvent(id, menuState & MF_CHECKED); } return true;}
开发者ID:beanhome,项目名称:dev,代码行数:20,
示例19: wxLogLastError//// The wxWindow destructor will take care of deleting the submenus.//wxMenu::~wxMenu(){ // // We should free PM resources only if PM doesn't do it for us // which happens if we're attached to a menubar or a submenu of another // menu if (!IsAttached() && !GetParent()) { if (!::WinDestroyWindow((HWND)GetHmenu()) ) { wxLogLastError(wxT("WinDestroyWindow")); } }#if wxUSE_ACCEL // // Delete accels // WX_CLEAR_ARRAY(m_vAccels);#endif // wxUSE_ACCEL} // end of wxMenu::~wxMenu
开发者ID:vdm113,项目名称:wxWidgets-ICC-patch,代码行数:24,
示例20: wxCHECK_RETvoid wxMenuBar::SetMenuLabel( size_t nPos, const wxString& rLabel){ SHORT nId; MENUITEM vItem; wxCHECK_RET(nPos < GetMenuCount(), wxT("invalid menu index")); m_titles[nPos] = rLabel; if (!IsAttached()) { return; } nId = SHORT1FROMMR(::WinSendMsg((HWND)m_hMenu, MM_ITEMIDFROMPOSITION, MPFROMSHORT(nPos), (MPARAM)0)); if (nId == MIT_ERROR) { wxLogLastError(wxT("LogLastError")); return; } if(!::WinSendMsg( (HWND)m_hMenu ,MM_QUERYITEM ,MPFROM2SHORT(nId, TRUE) ,MPARAM(&vItem) )) { wxLogLastError(wxT("QueryItem")); } nId = vItem.id; if (::WinSendMsg(GetHmenu(), MM_SETITEMTEXT, MPFROMSHORT(nId), (MPARAM)rLabel.wx_str())); { wxLogLastError(wxT("ModifyMenu")); } Refresh();} // end of wxMenuBar::SetMenuLabel
开发者ID:vdm113,项目名称:wxWidgets-ICC-patch,代码行数:38,
示例21: UpdateAccel// append a new item or submenu to the menubool wxMenu::DoInsertOrAppend(wxMenuItem *pItem, size_t pos){#if wxUSE_ACCEL UpdateAccel(pItem);#endif // wxUSE_ACCEL UINT flags = 0; // if "Break" has just been called, insert a menu break before this item // (and don't forget to reset the flag) if ( m_doBreak ) { flags |= MF_MENUBREAK; m_doBreak = false; } if ( pItem->IsSeparator() ) { flags |= MF_SEPARATOR; } // id is the numeric id for normal menu items and HMENU for submenus as // required by ::AppendMenu() API UINT id; wxMenu *submenu = pItem->GetSubMenu(); if ( submenu != NULL ) { wxASSERT_MSG( submenu->GetHMenu(), wxT("invalid submenu") ); submenu->SetParent(this); id = (UINT)submenu->GetHMenu(); flags |= MF_POPUP; } else { id = pItem->GetId(); } // prepare to insert the item in the menu wxString itemText = pItem->GetText(); LPCTSTR pData = NULL; if ( pos == (size_t)-1 ) { // append at the end (note that the item is already appended to // internal data structures) pos = GetMenuItemCount() - 1; } // adjust position to account for the title, if any if ( !m_title.empty() ) pos += 2; // for the title itself and its separator BOOL ok = false; // check if we have something more than a simple text item#if wxUSE_OWNER_DRAWN if ( pItem->IsOwnerDrawn() ) { // is the item owner-drawn just because of the bitmap? if ( pItem->GetBitmap().Ok() && !pItem->GetTextColour().Ok() && !pItem->GetBackgroundColour().Ok() && !pItem->GetFont().Ok() ) { // try to use InsertMenuItem() as it's guaranteed to look correctly // while our owner-drawning code is not // first compile-time check#ifdef MIIM_BITMAP WinStruct<MENUITEMINFO> mii; // now run-time one: MIIM_BITMAP only works under WinME/2000+ if ( wxGetWinVersion() >= wxWinVersion_98 ) { mii.fMask = MIIM_ID | MIIM_STRING | MIIM_DATA | MIIM_BITMAP; mii.wID = id; mii.cch = itemText.length(); mii.dwTypeData = wx_const_cast(wxChar *, itemText.c_str()); // we can't pass HBITMAP directly as hbmpItem for 2 reasons: // 1. we can't draw it with transparency then (this is not // very important now but would be with themed menu bg) // 2. worse, Windows inverses the bitmap for the selected // item and this looks downright ugly // // so instead draw it ourselves in MSWOnDrawItem() mii.dwItemData = wx_reinterpret_cast(ULONG_PTR, pItem); mii.hbmpItem = HBMMENU_CALLBACK; ok = ::InsertMenuItem(GetHmenu(), pos, TRUE /* by pos */, &mii); if ( !ok ) { wxLogLastError(wxT("InsertMenuItem()")); } else // InsertMenuItem() ok { // we need to remove the extra indent which is reserved for // the checkboxes by default as it looks ugly unless check // boxes are used together with bitmaps and this is not the // case in wx API//.........这里部分代码省略.........
开发者ID:HackLinux,项目名称:chandler-1,代码行数:101,
示例22: GetHmenuvoid wxMenu::SetTitle(const wxString& label){ bool hasNoTitle = m_title.empty(); m_title = label; HMENU hMenu = GetHmenu(); if ( hasNoTitle ) { if ( !label.empty() ) { if ( !::InsertMenu(hMenu, 0u, MF_BYPOSITION | MF_STRING, (UINT_PTR)idMenuTitle, m_title.wx_str()) || !::InsertMenu(hMenu, 1u, MF_BYPOSITION, (unsigned)-1, NULL) ) { wxLogLastError(wxT("InsertMenu")); } } } else { if ( label.empty() ) { // remove the title and the separator after it if ( !RemoveMenu(hMenu, 0, MF_BYPOSITION) || !RemoveMenu(hMenu, 0, MF_BYPOSITION) ) { wxLogLastError(wxT("RemoveMenu")); } } else { // modify the title#ifdef __WXWINCE__ WinStruct<MENUITEMINFO> info; info.fMask = MIIM_TYPE; info.fType = MFT_STRING; info.cch = m_title.length(); info.dwTypeData = const_cast<wxChar *>(m_title.wx_str()); if ( !SetMenuItemInfo(hMenu, 0, TRUE, & info) ) { wxLogLastError(wxT("SetMenuItemInfo")); }#else if ( !ModifyMenu(hMenu, 0u, MF_BYPOSITION | MF_STRING, (UINT_PTR)idMenuTitle, m_title.wx_str()) ) { wxLogLastError(wxT("ModifyMenu")); }#endif } }#ifdef __WIN32__ // put the title string in bold face if ( !m_title.empty() ) { SetDefaultMenuItem(GetHmenu(), (UINT)idMenuTitle); }#endif // Win32}
开发者ID:Zombiebest,项目名称:Dolphin,代码行数:62,
示例23: UpdateAccel//.........这里部分代码省略......... (bmpChecked.IsOk() && IsGreaterThanStdSize(bmpChecked)) ) { mustUseOwnerDrawn = true; } } // use InsertMenuItem() if possible as it's guaranteed to look // correct while our owner-drawn code is not if ( !mustUseOwnerDrawn ) { WinStruct<MENUITEMINFO> mii; mii.fMask = MIIM_STRING | MIIM_DATA; // don't set hbmpItem for the checkable items as it would // be used for both checked and unchecked state if ( pItem->IsCheckable() ) { mii.fMask |= MIIM_CHECKMARKS; mii.hbmpChecked = GetHBitmapForMenu(pItem, true); mii.hbmpUnchecked = GetHBitmapForMenu(pItem, false); } else if ( pItem->GetBitmap().IsOk() ) { mii.fMask |= MIIM_BITMAP; mii.hbmpItem = GetHBitmapForMenu(pItem); } mii.cch = itemText.length(); mii.dwTypeData = const_cast<wxChar *>(itemText.wx_str()); if ( flags & MF_POPUP ) { mii.fMask |= MIIM_SUBMENU; mii.hSubMenu = GetHmenuOf(pItem->GetSubMenu()); } else { mii.fMask |= MIIM_ID; mii.wID = id; } mii.dwItemData = reinterpret_cast<ULONG_PTR>(pItem); ok = ::InsertMenuItem(GetHmenu(), pos, TRUE /* by pos */, &mii); if ( !ok ) { wxLogLastError(wxT("InsertMenuItem()")); } else // InsertMenuItem() ok { // we need to remove the extra indent which is reserved for // the checkboxes by default as it looks ugly unless check // boxes are used together with bitmaps and this is not the // case in wx API WinStruct<MENUINFO> mi; // don't call SetMenuInfo() directly, this would prevent // the app from starting up under Windows 95/NT 4 typedef BOOL (WINAPI *SetMenuInfo_t)(HMENU, MENUINFO *); wxDynamicLibrary dllUser(wxT("user32")); wxDYNLIB_FUNCTION(SetMenuInfo_t, SetMenuInfo, dllUser); if ( pfnSetMenuInfo ) { mi.fMask = MIM_STYLE; mi.dwStyle = MNS_CHECKORBMP;
开发者ID:Zombiebest,项目名称:Dolphin,代码行数:67,
示例24: definedbool wxMenuBar::Insert(size_t pos, wxMenu *menu, const wxString& title){ // Find out which MSW item before which we'll be inserting before // wxMenuBarBase::Insert is called and GetMenu(pos) is the new menu. // If IsAttached() is false this won't be used anyway bool isAttached =#if defined(WINCE_WITHOUT_COMMANDBAR) IsAttached();#else (GetHmenu() != 0);#endif if ( !wxMenuBarBase::Insert(pos, menu, title) ) return false; menu->wxMenuBase::SetTitle(title); if ( isAttached ) {#if defined(WINCE_WITHOUT_COMMANDBAR) if (!GetToolBar()) return false; TBBUTTON tbButton; memset(&tbButton, 0, sizeof(TBBUTTON)); tbButton.iBitmap = I_IMAGENONE; tbButton.fsState = TBSTATE_ENABLED; tbButton.fsStyle = TBSTYLE_DROPDOWN | TBSTYLE_NO_DROPDOWN_ARROW | TBSTYLE_AUTOSIZE; HMENU hPopupMenu = (HMENU) menu->GetHMenu() ; tbButton.dwData = (DWORD)hPopupMenu; wxString label = wxStripMenuCodes(title); tbButton.iString = (int) wxMSW_CONV_LPCTSTR(label); tbButton.idCommand = NewControlId(); if (!::SendMessage((HWND) GetToolBar()->GetHWND(), TB_INSERTBUTTON, pos, (LPARAM)&tbButton)) { wxLogLastError(wxT("TB_INSERTBUTTON")); return false; }#else // We have a problem with the index if there is an extra "Window" menu // in this menu bar, which is added by wxMDIParentFrame to it directly // using Windows API (so that it remains invisible to the user code), // but which does affect the indices of the items we insert after it. // So we check if any of the menus before the insertion position is a // foreign one and adjust the insertion index accordingly. int mswExtra = 0; // Skip all this if the total number of menus matches (notice that the // internal menu count has already been incremented by wxMenuBarBase:: // Insert() call above, hence -1). int mswCount = ::GetMenuItemCount(GetHmenu()); if ( mswCount != -1 && static_cast<unsigned>(mswCount) != GetMenuCount() - 1 ) { wxMenuList::compatibility_iterator node = m_menus.GetFirst(); for ( size_t n = 0; n < pos; n++ ) { if ( ::GetSubMenu(GetHmenu(), n) != GetHmenuOf(node->GetData()) ) mswExtra++; else node = node->GetNext(); } } if ( !::InsertMenu(GetHmenu(), pos + mswExtra, MF_BYPOSITION | MF_POPUP | MF_STRING, (UINT_PTR)GetHmenuOf(menu), title.t_str()) ) { wxLogLastError(wxT("InsertMenu")); }#endif#if wxUSE_ACCEL if ( menu->HasAccels() ) { // need to rebuild accell table RebuildAccelTable(); }#endif // wxUSE_ACCEL if (IsAttached()) Refresh(); } return true;}
开发者ID:xiyuera,项目名称:wxWidgets,代码行数:86,
示例25: UpdateAccel//// Append a new item or submenu to the menu//bool wxMenu::DoInsertOrAppend( wxMenuItem* pItem, size_t nPos ){ wxMenu* pSubmenu = pItem->GetSubMenu(); MENUITEM& rItem = (pSubmenu != NULL)?pSubmenu->m_vMenuData: pItem->m_vMenuData; ERRORID vError; wxString sError;#if wxUSE_ACCEL UpdateAccel(pItem);#endif // wxUSE_ACCEL // // If "Break" has just been called, insert a menu break before this item // (and don't forget to reset the flag) // if (m_bDoBreak) { rItem.afStyle |= MIS_BREAK; m_bDoBreak = false; } // // Id is the numeric id for normal menu items and HMENU for submenus as // required by ::MM_INSERTITEM message API // if (pSubmenu != NULL) { wxASSERT_MSG(pSubmenu->GetHMenu(), wxT("invalid submenu")); pSubmenu->SetParent(this); rItem.iPosition = 0; // submenus have a 0 position rItem.id = (USHORT)pSubmenu->GetHMenu(); rItem.afStyle |= MIS_SUBMENU | MIS_TEXT; } else { rItem.id = (USHORT)pItem->GetId(); } char *pData = NULL;#if wxUSE_OWNER_DRAWN if (pItem->IsOwnerDrawn()) { // // Want to get {Measure|Draw}Item messages? // item draws itself, passing pointer to data doesn't work in OS/2 // Will eventually need to set the image handle somewhere into vItem.hItem // rItem.afStyle |= MIS_OWNERDRAW; pData = NULL; rItem.hItem = (HBITMAP)pItem->GetBitmap().GetHBITMAP(); pItem->m_vMenuData.afStyle = rItem.afStyle; pItem->m_vMenuData.hItem = rItem.hItem; } else#endif if (pItem->IsSeparator()) { 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 );//.........这里部分代码省略.........
开发者ID:vdm113,项目名称:wxWidgets-ICC-patch,代码行数:101,
示例26: UpdateAccel//.........这里部分代码省略......... // check if we have something more than a simple text item bool makeItemOwnerDrawn = false;#endif // wxUSE_OWNER_DRAWN if (#if wxUSE_OWNER_DRAWN !pItem->IsOwnerDrawn() &&#endif !pItem->IsSeparator() ) { WinStruct<MENUITEMINFO> mii; mii.fMask = MIIM_STRING | MIIM_DATA; // don't set hbmpItem for the checkable items as it would // be used for both checked and unchecked state if ( pItem->IsCheckable() ) { mii.fMask |= MIIM_CHECKMARKS; mii.hbmpChecked = pItem->GetHBitmapForMenu(wxMenuItem::Checked); mii.hbmpUnchecked = pItem->GetHBitmapForMenu(wxMenuItem::Unchecked); } else if ( pItem->GetBitmap().IsOk() ) { mii.fMask |= MIIM_BITMAP; mii.hbmpItem = pItem->GetHBitmapForMenu(wxMenuItem::Normal); } mii.cch = itemText.length(); mii.dwTypeData = wxMSW_CONV_LPTSTR(itemText); if ( flags & MF_POPUP ) { mii.fMask |= MIIM_SUBMENU; mii.hSubMenu = GetHmenuOf(pItem->GetSubMenu()); } else { mii.fMask |= MIIM_ID; mii.wID = id; } if ( flags & MF_GRAYED ) { mii.fMask |= MIIM_STATE; mii.fState = MFS_GRAYED; } if ( flags & MF_CHECKED ) { mii.fMask |= MIIM_STATE; mii.fState = MFS_CHECKED; } mii.dwItemData = reinterpret_cast<ULONG_PTR>(pItem); ok = ::InsertMenuItem(GetHmenu(), pos, TRUE /* by pos */, &mii); if ( !ok ) { wxLogLastError(wxT("InsertMenuItem()"));#if wxUSE_OWNER_DRAWN // In case of failure switch new item to the owner-drawn mode. makeItemOwnerDrawn = true;#endif } else // InsertMenuItem() ok {
开发者ID:CodeSmithyIDE,项目名称:wxWidgets,代码行数:67,
注:本文中的GetHmenu函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ GetHobList函数代码示例 C++ GetHitUnit函数代码示例 |