CMenu * PortPopup::PortMenu(bool isInput) { CMenu *deviceMenu = new CMenu; CMenu *midiMenu = MidiMenu(isInput); CMenu *audio1Menu = AudioMenu(isInput, 1); CMenu *audio2Menu = AudioMenu(isInput, 2); CMenu *audio4Menu = AudioMenu(isInput, 4); CMenu *joyMenu = JoyMenu(isInput); deviceMenu->CreatePopupMenu(); if (isInput) { // audioPSMenu->AppendMenu(MF_STRING, WM_MDS_AUDIO_DEVICE_PAIR, "pair mono audio dev"); // joyMenu->AppendMenu(MF_STRING, WM_MDS_JOYSTICK_DEVICE, "joystick dev"); deviceMenu->AppendMenu(MF_POPUP, (UINT) midiMenu->m_hMenu, "midi input"); deviceMenu->AppendMenu(MF_POPUP, (UINT) audio1Menu->m_hMenu, "audio 1ch input"); deviceMenu->AppendMenu(MF_POPUP, (UINT) audio2Menu->m_hMenu, "audio 2ch input"); deviceMenu->AppendMenu(MF_POPUP, (UINT) joyMenu->m_hMenu, "joy input"); } else { // channelStreamMenu->AppendMenu(MF_STRING, WM_MDS_CHANNEL_STREAM, "stream to channel X"); // channelAudioMenu->AppendMenu(MF_STRING, WM_MDS_CHANNEL_AUDIO, "audio to channe X"); // parallelMenu->AppendMenu(MF_STRING, WM_MDS_MIDI_DEVICE, "parallel dev"); CMenu *channelAudioMenu = ChannelMenu(isInput); CMenu *channelStreamMenu = ChannelMenu(isInput); // channelStreamMenu->AppendMenu(MF_STRING, 2, "stream to channel X"); // joyMenu->AppendMenu(MF_POPUP, (UINT)channelStreamMenu->m_hMenu, "test"); deviceMenu->AppendMenu(MF_POPUP, (UINT) midiMenu->m_hMenu, "midi output"); deviceMenu->AppendMenu(MF_POPUP, (UINT) audio1Menu->m_hMenu, "audio 1ch output"); deviceMenu->AppendMenu(MF_POPUP, (UINT) audio2Menu->m_hMenu, "audio 2ch output"); deviceMenu->AppendMenu(MF_POPUP, (UINT) joyMenu->m_hMenu, "joy output"); deviceMenu->AppendMenu(MF_POPUP, (UINT) channelStreamMenu->m_hMenu, "channel stream output"); deviceMenu->AppendMenu(MF_POPUP, (UINT) channelAudioMenu->m_hMenu, "channel audio output"); } MENUINFO menuInfo; menuInfo.fMask = MIM_APPLYTOSUBMENUS|MIM_STYLE; menuInfo.dwStyle = MNS_MODELESS |MNS_AUTODISMISS // MNS_NOTIFYBYPOS ; deviceMenu->SetMenuInfo(&menuInfo); return deviceMenu; // Remove and destroy old menu //SetMenu(NULL); //CMenu* old_menu = CMenu::FromHandle(m_hMenuDefault); //old_menu->DestroyMenu(); // Add new menu. //SetMenu(&m_NewMenu); // Assign default menu //m_hMenuDefault = m_NewMenu.m_hMenu; }
void CManagePSWDPols::OnPolicyRightClick(NMHDR * /*pNotifyStruct*/, LRESULT *pLResult) { *pLResult = 0; // Perform default processing on return POSITION pos = m_PolicyNames.GetFirstSelectedItemPosition(); if (pos == NULL) return; int nItem = m_PolicyNames.GetNextSelectedItem(pos); // Ignore is default policy (first entry) if (nItem == 0) return; const StringX sxPolicyName = m_PolicyNames.GetItemText(nItem, 0); // Ignore if no entries using this policy if (m_MapPSWDPLC[sxPolicyName].usecount == 0) return; PWScore *pcore = (PWScore *)GetMainDlg()->GetCore(); m_ventries.clear(); // Ignore if can't find any even if there should be! if (!pcore->GetEntriesUsingNamedPasswordPolicy(sxPolicyName, m_ventries)) return; CPoint msg_pt = ::GetMessagePos(); CMenu menu; int ipopup = IDR_POPLISTENTRIES; if (menu.LoadMenu(ipopup)) { MENUINFO minfo = { 0 }; minfo.cbSize = sizeof(MENUINFO); minfo.fMask = MIM_MENUDATA; minfo.dwMenuData = ipopup; BOOL brc = menu.SetMenuInfo(&minfo); ASSERT(brc != 0); CMenu *pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, msg_pt.x, msg_pt.y, this); } }
void COptionsShortcuts::OnHeaderRClick(NMHDR *, LRESULT *pLResult) { if (m_iColWidth == m_iDefColWidth) return; const DWORD dwTrackPopupFlags = TPM_LEFTALIGN | TPM_RIGHTBUTTON; CMenu menu; CPoint ptMousePos; GetCursorPos(&ptMousePos); if (menu.LoadMenu(IDR_POPRESETCOLUMNWIDTH)) { MENUINFO minfo; SecureZeroMemory(&minfo, sizeof(minfo)); minfo.cbSize = sizeof(minfo); minfo.fMask = MIM_MENUDATA; minfo.dwMenuData = IDR_POPRESETCOLUMNWIDTH; menu.SetMenuInfo(&minfo); CMenu* pPopup = menu.GetSubMenu(0); pPopup->TrackPopupMenu(dwTrackPopupFlags, ptMousePos.x, ptMousePos.y, this); } *pLResult = TRUE; }
//右击IM列表` void CIMWnd::OnNMRclickIMList(NMHDR * pNMHDR, LRESULT * pResult) { try { CBcfFile fMsg(CBcfFile::GetAppPath()+"ClientMessage.bcf"); CPoint point; GetCursorPos(&point); m_IMList->ScreenToClient(&point); HTREEITEM hti=m_IMList->HitTest(point); if(!hti) return; int dwUserid=m_IMList->GetItemData(hti); if(dwUserid<1000) return; dwUserid-=1000; CString sname=m_IMList->GetItemText(hti); CMenu menu; menu.CreatePopupMenu(); MENUINFO mi; menu.GetMenuInfo(&mi); mi.cbSize=sizeof(MENUINFO); mi.fMask=MIM_BACKGROUND; mi.hbrBack = CreateSolidBrush(RGB(0xD1,0xF1,0xFF)); menu.SetMenuInfo(&mi); if((m_IMList->GetParentItem(hti)==m_IMList->htiFamilier) ||(m_IMList->GetParentItem(hti)==m_IMList->htiUnfamilier)) { menu.AppendMenu(MF_STRING,10,fMsg.GetKeyVal("IMDlg","Chat","聊天")); } menu.AppendMenu(MF_STRING,11,fMsg.GetKeyVal("IMDlg","Delete","删除")); if(m_IMList->GetParentItem(hti)!=m_IMList->htiFamilier) { menu.AppendMenu(MF_STRING,21,fMsg.GetKeyVal("IMDlg","ToFriend","加入好友")); } if(m_IMList->GetParentItem(hti)!=m_IMList->htiBlack) { menu.AppendMenu(MF_STRING,22,fMsg.GetKeyVal("IMDlg","ToBadGuyList","加入黑名单")); } CPoint p; ::GetCursorPos(&p); int ret=menu.TrackPopupMenu(TPM_LEFTALIGN|TPM_LEFTBUTTON|TPM_RETURNCMD,p.x,p.y,this); switch(ret) { case 10: { #ifndef MAINROOM_USE_SHORTMSG int nImg; m_IMList->GetItemImage(hti,nImg,nImg); CIMSession *imSession=m_IMList->openIMSession(dwUserid,sname);// if(imSession) { if(nImg==3 || nImg==5) imSession->setUserOnline(true); if(nImg==4 || nImg==6) imSession->setUserOnline(false); imSession->ShowWindow(SW_SHOW); } #else m_IMList->openShortMsg(dwUserid,sname.GetBuffer(sname.GetLength())); #endif } break; case 11: { //if(AFCMessageBox(fMsg.GetKeyVal("IMDlg","R_U_SureDelFriend","您确定要删除该好友吗?"), // fMsg.GetKeyVal("IMDlg","Tip","提示"),AFC_YESNO)==IDOK) if(DUIMessageBox(m_hWnd,MB_YESNO|MB_ICONINFORMATION,fMsg.GetKeyVal("IMDlg","Tip","提示"),true,fMsg.GetKeyVal("IMDlg","R_U_SureDelFriend","您确定要删除该好友吗?"))==IDOK) m_IMList->SetUserGroup(dwUserid,NULL,0); } break; case 21: m_IMList->SetUser(dwUserid,"",true); break; case 22: { //if(AFCMessageBox(fMsg.GetKeyVal("IMDlg","MoveFriendToBadList","您确定要将该好友放到黑名单吗?"), // fMsg.GetKeyVal("IMDlg","Tip","提示"),AFC_YESNO)==IDOK) if(DUIMessageBox(m_hWnd,MB_YESNO|MB_ICONINFORMATION,fMsg.GetKeyVal("IMDlg","Tip","提示"),true,fMsg.GetKeyVal("IMDlg","MoveFriendToBadList","您确定要将该好友放到黑名单吗?"))==IDYES) { m_IMList->SetUserGroup(dwUserid,NULL,3); CString szMsg; szMsg.Format(fMsg.GetKeyVal("IMDlg","MoveOneToBadList","玩家[%s]已经加入到你的黑名单中"), sname); AFCTimerMsgBox(5, szMsg); } } break; } DeleteObject(mi.hbrBack); } catch (...) { TCHAR smsg[1000]={0}; wsprintf(smsg,"IM_TRY_CATCH : [%s]",__FUNCTION__); } *pResult = 0; }
void CCompareResultsDlg::OnItemRightClick(NMHDR *pNMHDR, LRESULT *pLResult) { *pLResult = 0; // Perform default processing on return NMLISTVIEW *pNMLV = (NMLISTVIEW *)pNMHDR; m_LCResults.SetRow(pNMLV->iItem); CPoint msg_pt = ::GetMessagePos(); CMenu menu; int ipopup; bool bTargetRO(true), bSourceRO(true); if (m_LCResults.GetSelectedCount() != 1) { // Special processing - only allow "Copy All" items to original or // "Synchronise All" items to original // Do not allow "Synchronise All" is any selected entry does not // have a corresponding entry in the original DB // No point if original is R-O - is checked in OnItemChanging() m_LCResults.SetColumn(COMPARE); ipopup = IDR_POPCOPYALLTOORIGINAL; bTargetRO = m_bOriginalDBReadOnly; bSourceRO = m_bComparisonDBReadOnly; bool bNoSyncAll(false); POSITION pos = m_LCResults.GetFirstSelectedItemPosition(); while (pos) { const int irow = m_LCResults.GetNextSelectedItem(pos); DWORD_PTR dwItemData = m_LCResults.GetItemData(irow); st_CompareData *pst_data = GetCompareData(dwItemData); ASSERT(pst_data != NULL); if (pst_data->uuid0 == pws_os::CUUID::NullUUID() || pst_data->indatabase != BOTH) { bNoSyncAll = true; break; } } if (menu.LoadMenu(ipopup)) { MENUINFO minfo ={0}; minfo.cbSize = sizeof(MENUINFO); minfo.fMask = MIM_MENUDATA; minfo.dwMenuData = ipopup; BOOL brc = menu.SetMenuInfo(&minfo); ASSERT(brc != 0); CMenu *pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); if (bNoSyncAll) pPopup->RemoveMenu(ID_MENUITEM_SYNCHRONIZEALL, MF_BYCOMMAND); pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, msg_pt.x, msg_pt.y, this); } return; } switch (pNMLV->iSubItem) { case 0: // Column is the current database // Therefore: Source = Current DB, Target = Comparison DB m_LCResults.SetColumn(CURRENT); ipopup = IDR_POPEDITVIEWORIGINAL; bTargetRO = m_bComparisonDBReadOnly; bSourceRO = m_bOriginalDBReadOnly; break; case 1: // Column is the comparison database // Therefore: Source = Comparison DB, Target = Current DB m_LCResults.SetColumn(COMPARE); ipopup = IDR_POPCOPYTOORIGINAL; bTargetRO = m_bOriginalDBReadOnly; bSourceRO = m_bComparisonDBReadOnly; break; default: return; } DWORD_PTR dwItemData = m_LCResults.GetItemData(m_LCResults.GetRow()); st_CompareData *pst_data = GetCompareData(dwItemData); ASSERT(pst_data != NULL); // Get where this entry is: // IDENTICAL means CURRENT + COMPARE but identical // BOTH means CURRENT + COMPARE but with differences int indatabase = pst_data->indatabase; // If entry isn't in this database that the user click or the entry is only // in the other column - do nothing if (m_LCResults.GetColumn() != indatabase && (indatabase != BOTH && indatabase != IDENTICAL)) return; if (menu.LoadMenu(ipopup)) { MENUINFO minfo ={0}; minfo.cbSize = sizeof(MENUINFO); minfo.fMask = MIM_MENUDATA; minfo.dwMenuData = ipopup; BOOL brc = menu.SetMenuInfo(&minfo); ASSERT(brc != 0); CMenu *pPopup = menu.GetSubMenu(0); ASSERT(pPopup != NULL); // Disable copy/sychnronize if target is read-only or entry is protected // Delete synchronize if not in both databases (and not already identical) if (m_LCResults.GetColumn() == COMPARE) { // User clicked on Comparison DB if (bTargetRO) { // Can't modify RO DB pPopup->RemoveMenu(ID_MENUITEM_COPY_TO_ORIGINAL, MF_BYCOMMAND); pPopup->RemoveMenu(ID_MENUITEM_SYNCHRONIZE, MF_BYCOMMAND); } else { // If it is in the current DB (i.e. BOTH as we know it is in the compare // column as the user has clicked on it) and is protected - don't allow copy if (indatabase == BOTH && pst_data->bIsProtected0) pPopup->RemoveMenu(ID_MENUITEM_COPY_TO_ORIGINAL, MF_BYCOMMAND); } } // Can't synchonize pr compare if not in both databases! if (indatabase != BOTH) { pPopup->RemoveMenu(ID_MENUITEM_SYNCHRONIZE, MF_BYCOMMAND); pPopup->RemoveMenu(ID_MENUITEM_COMPARE_ENTRIES, MF_BYCOMMAND); } // Change Edit to View if source read-only OR entry is protected OR if Comparison DB if (bSourceRO || pst_data->bIsProtected0) { const CString cs_View_Entry(MAKEINTRESOURCE(IDS_VIEWENTRY2)); pPopup->ModifyMenu(ID_MENUITEM_COMPVIEWEDIT, MF_BYCOMMAND, ID_MENUITEM_COMPVIEWEDIT, cs_View_Entry); } pPopup->TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, msg_pt.x, msg_pt.y, this); } }