void CDirectoryTreeCtrl::OnContextMenu(CWnd* /*pWnd*/, CPoint point) { CPoint ptMenu(-1, -1); if (point.x != -1 && point.y != -1) { ptMenu = point; ScreenToClient(&point); } else { HTREEITEM hSel = GetNextItem(TVI_ROOT, TVGN_CARET); if (hSel) { CRect rcItem; if (GetItemRect(hSel, &rcItem, TRUE)) { ptMenu.x = rcItem.left; ptMenu.y = rcItem.top; ClientToScreen(&ptMenu); } } else ClientToScreen(&(ptMenu = (0, 0))); } HTREEITEM hItem = HitTest(point); // create the menu CTitleMenu SharedMenu; SharedMenu.CreatePopupMenu(); SharedMenu.AddMenuTitle(GetResString(IDS_SHAREDFOLDERS)); bool bMenuIsEmpty = true; // add all shared directories int iCnt = 0; for (POSITION pos = m_lstShared.GetHeadPosition(); pos != NULL; iCnt++) { CString strDisplayPath(m_lstShared.GetNext(pos)); PathRemoveBackslash(strDisplayPath.GetBuffer(strDisplayPath.GetLength())); strDisplayPath.ReleaseBuffer(); SharedMenu.AppendMenu(MF_STRING,MP_SHAREDFOLDERS_FIRST+iCnt, GetResString(IDS_VIEW1) + strDisplayPath); bMenuIsEmpty = false; } // add right clicked folder, if any if (hItem) { m_strLastRightClicked = GetFullPath(hItem); if (!IsShared(m_strLastRightClicked)) { CString strDisplayPath(m_strLastRightClicked); PathRemoveBackslash(strDisplayPath.GetBuffer(strDisplayPath.GetLength())); strDisplayPath.ReleaseBuffer(); if (!bMenuIsEmpty) SharedMenu.AppendMenu(MF_SEPARATOR); SharedMenu.AppendMenu(MF_STRING, MP_SHAREDFOLDERS_FIRST-1, GetResString(IDS_VIEW1) + strDisplayPath + GetResString(IDS_VIEW2)); bMenuIsEmpty = false; } } // display menu if (!bMenuIsEmpty) SharedMenu.TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON, ptMenu.x, ptMenu.y, this); VERIFY( SharedMenu.DestroyMenu() ); }
void CHTRichEditCtrl::OnContextMenu(CWnd* /*pWnd*/, CPoint point) { if (point.x != -1 || point.y != -1) { CRect rcClient; GetClientRect(&rcClient); ClientToScreen(&rcClient); if (!rcClient.PtInRect(point)) { Default(); return; } } long lSelStart, lSelEnd; GetSel(lSelStart, lSelEnd); // ugly, simulate a left click to get around the text cursor problem when right clicking. if (point.x != -1 && point.y != -1 && lSelStart == lSelEnd) { ASSERT( GetStyle() & ES_NOHIDESEL ); // this works only if ES_NOHIDESEL is set CPoint ptMouse(point); ScreenToClient(&ptMouse); SendMessage(WM_LBUTTONDOWN, MK_LBUTTON, MAKELONG(ptMouse.x, ptMouse.y)); SendMessage(WM_LBUTTONUP, MK_LBUTTON, MAKELONG(ptMouse.x, ptMouse.y)); } int iTextLen = GetWindowTextLength(); CTitleMenu menu; menu.CreatePopupMenu(); menu.AddMenuTitle(GetResString(IDS_LOGENTRY)); // ==> more icons - Stulle /* menu.AppendMenu(MF_STRING | (lSelEnd > lSelStart ? MF_ENABLED : MF_GRAYED), MP_COPYSELECTED, GetResString(IDS_COPY)); menu.AppendMenu(MF_SEPARATOR); menu.AppendMenu(MF_STRING | (iTextLen > 0 ? MF_ENABLED : MF_GRAYED), MP_SELECTALL, GetResString(IDS_SELECTALL)); menu.AppendMenu(MF_STRING | (iTextLen > 0 ? MF_ENABLED : MF_GRAYED), MP_REMOVEALL , GetResString(IDS_PW_RESET)); menu.AppendMenu(MF_STRING | (iTextLen > 0 ? MF_ENABLED : MF_GRAYED), MP_SAVELOG, GetResString(IDS_SAVELOG) + _T("...")); */ menu.AppendMenu(MF_STRING | (lSelEnd > lSelStart ? MF_ENABLED : MF_GRAYED), MP_COPYSELECTED, GetResString(IDS_COPY), _T("COPY")); menu.AppendMenu(MF_SEPARATOR); menu.AppendMenu(MF_STRING | (iTextLen > 0 ? MF_ENABLED : MF_GRAYED), MP_SELECTALL, GetResString(IDS_SELECTALL), _T("SEARCHFILETYPE_DOCUMENT")); menu.AppendMenu(MF_STRING | (iTextLen > 0 ? MF_ENABLED : MF_GRAYED), MP_REMOVEALL , GetResString(IDS_PW_RESET), _T("INCOMPLETE")); menu.AppendMenu(MF_STRING | (iTextLen > 0 ? MF_ENABLED : MF_GRAYED), MP_SAVELOG, GetResString(IDS_SAVELOG) + _T("..."), _T("SAVE")); // <== more icons - Stulle menu.AppendMenu(MF_SEPARATOR); menu.AppendMenu(MF_STRING | (m_bAutoScroll ? MF_CHECKED : MF_UNCHECKED), MP_AUTOSCROLL, GetResString(IDS_AUTOSCROLL)); if (point.x == -1 && point.y == -1) { point.x = 16; point.y = 32; ClientToScreen(&point); } // Cheap workaround for the "Text cursor is showing while context menu is open" glitch. It could be solved properly // with the RE's COM interface, but because the according messages are not routed with a unique control ID, it's not // really useable (e.g. if there are more RE controls in one window). Would to envelope each RE window to get a unique ID.. m_bForceArrowCursor = true; menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); m_bForceArrowCursor = false; VERIFY( menu.DestroyMenu() ); }
void CServerListCtrl::OnContextMenu(CWnd* pWnd, CPoint point) { // get merged settings bool bFirstItem = true; int iSelectedItems = GetSelectedCount(); int iStaticServers = 0; UINT uPrioMenuItem = 0; POSITION pos = GetFirstSelectedItemPosition(); while (pos) { const CServer* pServer = (CServer*)GetItemData(GetNextSelectedItem(pos)); iStaticServers += pServer->IsStaticMember() ? 1 : 0; UINT uCurPrioMenuItem = 0; if (pServer->GetPreferences() == SRV_PR_LOW) uCurPrioMenuItem = MP_PRIOLOW; else if (pServer->GetPreferences() == SRV_PR_NORMAL) uCurPrioMenuItem = MP_PRIONORMAL; else if (pServer->GetPreferences() == SRV_PR_HIGH) uCurPrioMenuItem = MP_PRIOHIGH; else ASSERT(0); if (bFirstItem) uPrioMenuItem = uCurPrioMenuItem; else if (uPrioMenuItem != uCurPrioMenuItem) uPrioMenuItem = 0; bFirstItem = false; } CTitleMenu ServerMenu; ServerMenu.CreatePopupMenu(); ServerMenu.AddMenuTitle(GetResString(IDS_EM_SERVER), true); ServerMenu.AppendMenu(MF_STRING | (iSelectedItems > 0 ? MF_ENABLED : MF_GRAYED), MP_CONNECTTO, GetResString(IDS_CONNECTTHIS), _T("CONNECT")); ServerMenu.SetDefaultItem(iSelectedItems > 0 ? MP_CONNECTTO : -1); CMenu ServerPrioMenu; ServerPrioMenu.CreateMenu(); if (iSelectedItems > 0){ ServerPrioMenu.AppendMenu(MF_STRING, MP_PRIOLOW, GetResString(IDS_PRIOLOW)); ServerPrioMenu.AppendMenu(MF_STRING, MP_PRIONORMAL, GetResString(IDS_PRIONORMAL)); ServerPrioMenu.AppendMenu(MF_STRING, MP_PRIOHIGH, GetResString(IDS_PRIOHIGH)); ServerPrioMenu.CheckMenuRadioItem(MP_PRIOLOW, MP_PRIOHIGH, uPrioMenuItem, 0); } ServerMenu.AppendMenu(MF_POPUP | (iSelectedItems > 0 ? MF_ENABLED : MF_GRAYED), (UINT_PTR)ServerPrioMenu.m_hMenu, GetResString(IDS_PRIORITY), _T("PRIORITY")); // enable add/remove from static server list, if there is at least one selected server which can be used for the action ServerMenu.AppendMenu(MF_STRING | (iStaticServers < iSelectedItems ? MF_ENABLED : MF_GRAYED), MP_ADDTOSTATIC, GetResString(IDS_ADDTOSTATIC), _T("ListAdd")); ServerMenu.AppendMenu(MF_STRING | (iStaticServers > 0 ? MF_ENABLED : MF_GRAYED), MP_REMOVEFROMSTATIC, GetResString(IDS_REMOVEFROMSTATIC), _T("ListRemove")); ServerMenu.AppendMenu(MF_SEPARATOR); ServerMenu.AppendMenu(MF_STRING | (iSelectedItems > 0 ? MF_ENABLED : MF_GRAYED), MP_REMOVE, GetResString(IDS_REMOVETHIS), _T("DELETESELECTED")); ServerMenu.AppendMenu(MF_STRING | (GetItemCount() > 0 ? MF_ENABLED : MF_GRAYED), MP_REMOVEALL, GetResString(IDS_REMOVEALL), _T("DELETE")); ServerMenu.AppendMenu(MF_STRING | (iSelectedItems > 0 ? MF_ENABLED : MF_GRAYED), MP_GETED2KLINK, GetResString(IDS_DL_LINK1), _T("ED2KLINK")); ServerMenu.AppendMenu(MF_STRING | (theApp.IsEd2kServerLinkInClipboard() ? MF_ENABLED : MF_GRAYED), MP_PASTE, GetResString(IDS_PASTE), _T("PASTELINK")); ServerMenu.AppendMenu(MF_SEPARATOR); ServerMenu.AppendMenu(MF_ENABLED | (GetItemCount() > 0 ? MF_ENABLED : MF_GRAYED), MP_FIND, GetResString(IDS_FIND), _T("Search")); GetPopupMenuPos(*this, point); ServerMenu.TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON, point.x, point.y, this); VERIFY( ServerPrioMenu.DestroyMenu() ); VERIFY( ServerMenu.DestroyMenu() ); }
void CFeedIcoItemListCtrl::OnContextMenu(CWnd* /*pWnd*/, CPoint point) { // TODO: 在此处添加消息处理程序代码 CTitleMenu menuRSS; menuRSS.CreatePopupMenu(); menuRSS.AppendMenu(MF_STRING,MP_OPEN,GetResString(IDS_OPEN),_T("OPEN")); menuRSS.AppendMenu(MF_STRING,MP_OPENFOLDER, GetResString(IDS_OPENFOLDER), _T("OPENFOLDER")); //menuRSS.AppendMenu(MF_STRING|MF_SEPARATOR); menuRSS.AppendMenu(MF_STRING,MP_DOWNLOAD_ALL, GetResString(IDS_RSSBTN_ALLDL), _T("RESUME"));//下载所有 menuRSS.AppendMenu(MF_STRING, MP_RESUME, GetResString(IDS_DOWNLOAD), _T("RESUME")); menuRSS.AppendMenu(MF_STRING, MP_PAUSE, GetResString(IDS_PAUSE), _T("PAUSE")); menuRSS.AppendMenu(MF_STRING,MP_CANCEL, GetResString(IDS_DELETE_FILE), _T("DELETE")); //menuRSS.AppendMenu(MF_STRING|MF_SEPARATOR); menuRSS.AppendMenu(MF_STRING,MP_REFRESH, GetResString(IDS_SV_UPDATE), NULL ); menuRSS.AppendMenu(MF_STRING,MP_OPTIONS, GetResString(IDS_RW_RSS_CONFIG), NULL ); //menuRSS.AppendMenu(MF_STRING, MP_STOP, GetResString(IDS_DL_STOP), _T("STOP")); menuRSS.EnableMenuItem(MP_OPEN, MF_GRAYED); menuRSS.EnableMenuItem(MP_OPENFOLDER, MF_GRAYED); menuRSS.EnableMenuItem(MP_DOWNLOAD_ALL, MF_GRAYED); menuRSS.EnableMenuItem(MP_RESUME, MF_GRAYED); menuRSS.EnableMenuItem(MP_PAUSE, MF_GRAYED); menuRSS.EnableMenuItem(MP_CANCEL, MF_GRAYED); menuRSS.EnableMenuItem(MP_REFRESH, MF_GRAYED); menuRSS.EnableMenuItem(MP_OPTIONS, MF_GRAYED); //menuRSS.EnableMenuItem(MP_STOP, MF_GRAYED); UpdateMenuState(menuRSS); m_pMenuXP = new CMenuXP(); m_pMenuXP->AddMenu(&menuRSS, TRUE); menuRSS.TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON, point.x, point.y, this); menuRSS.DestroyMenu(); delete m_pMenuXP; m_pMenuXP = NULL; }
void CIrcNickListCtrl::OnContextMenu(CWnd*, CPoint point) { int iCurSel = GetNextItem(-1, LVIS_SELECTED | LVIS_FOCUSED); if (iCurSel == -1) { return; } Nick* pNick = (Nick*)GetItemData(iCurSel); if( !pNick ) { return; } CTitleMenu menuNick; menuNick.CreatePopupMenu(); menuNick.AddMenuTitle(GetResString(IDS_IRC_NICK) + _T(" : ") + pNick->m_sNick); menuNick.AppendMenu(MF_STRING, Irc_Priv, GetResString(IDS_IRC_PRIVMESSAGE)); menuNick.AppendMenu(MF_STRING, Irc_AddFriend, GetResString(IDS_IRC_ADDTOFRIENDLIST)); if (!m_pParent->GetSendFileString().IsEmpty()) menuNick.AppendMenu(MF_STRING, Irc_SendLink, GetResString(IDS_IRC_SENDLINK) + m_pParent->GetSendFileString()); else menuNick.AppendMenu(MF_STRING, Irc_SendLink, GetResString(IDS_IRC_SENDLINK) + GetResString(IDS_IRC_NOSFS)); menuNick.AppendMenu(MF_STRING, Irc_Kick, GetResString(IDS_IRC_KICK)); menuNick.AppendMenu(MF_STRING, Irc_Ban, _T("Ban")); //Ban currently uses chanserv to ban which seems to kick also.. May change this later.. // menuNick.AppendMenu(MF_STRING, Irc_KB, _T("Kick/Ban")); menuNick.AppendMenu(MF_STRING, Irc_Slap, GetResString(IDS_IRC_SLAP)); int iLength = m_sUserModeSettings.GetLength(); if( iLength > 0 ) { CString sMode, sModeSymbol; for( int iIndex = 0; iIndex < iLength; iIndex++) { sMode = m_sUserModeSettings.Mid(iIndex,1); sModeSymbol = m_sUserModeSymbols.Mid(iIndex,1); if( pNick->m_sModes.Find(sModeSymbol[0]) == -1 ) menuNick.AppendMenu(MF_STRING, Irc_OpCommands+iIndex, _T("Set +") + sMode + _T(" ( Add ") + sModeSymbol + _T(" )") ); else menuNick.AppendMenu(MF_STRING, Irc_OpCommands+iIndex+25, _T("Set -") + sMode + _T(" ( Remove ") + sModeSymbol + _T(" )") ); } } GetPopupMenuPos(*this, point); menuNick.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); VERIFY( menuNick.DestroyMenu() ); }
void CDownloadClientsCtrl::OnContextMenu(CWnd* /*pWnd*/, CPoint point) { int iSel = GetNextItem(-1, LVIS_SELECTED | LVIS_FOCUSED); const CUpDownClient* client = (iSel != -1) ? (CUpDownClient*)GetItemData(iSel) : NULL; CTitleMenu ClientMenu; ClientMenu.CreatePopupMenu(); ClientMenu.AddMenuTitle(GetResString(IDS_CLIENTS), true); ClientMenu.AppendMenu(MF_STRING | (client ? MF_ENABLED : MF_GRAYED), MP_DETAIL, GetResString(IDS_SHOWDETAILS), _T("CLIENTDETAILS")); ClientMenu.SetDefaultItem(MP_DETAIL); ClientMenu.AppendMenu(MF_STRING | ((client && client->IsEd2kClient() && !client->IsFriend()) ? MF_ENABLED : MF_GRAYED), MP_ADDFRIEND, GetResString(IDS_ADDFRIEND), _T("ADDFRIEND")); ClientMenu.AppendMenu(MF_STRING | ((client && client->IsEd2kClient()) ? MF_ENABLED : MF_GRAYED), MP_MESSAGE, GetResString(IDS_SEND_MSG), _T("SENDMESSAGE")); ClientMenu.AppendMenu(MF_STRING | ((client && client->IsEd2kClient() && client->GetViewSharedFilesSupport()) ? MF_ENABLED : MF_GRAYED), MP_SHOWLIST, GetResString(IDS_VIEWFILES), _T("VIEWFILES")); if (Kademlia::CKademlia::IsRunning() && !Kademlia::CKademlia::IsConnected()) ClientMenu.AppendMenu(MF_STRING | ((client && client->IsEd2kClient() && client->GetKadPort()!=0 && client->GetKadVersion() > 1) ? MF_ENABLED : MF_GRAYED), MP_BOOT, GetResString(IDS_BOOTSTRAP)); ClientMenu.AppendMenu(MF_STRING | (GetItemCount() > 0 ? MF_ENABLED : MF_GRAYED), MP_FIND, GetResString(IDS_FIND), _T("Search")); GetPopupMenuPos(*this, point); ClientMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); }
void CFeedIcoItemListCtrl::UpdateMenuState(CTitleMenu & menuRSS) { if( !CGlobalVariable::IsRunning() ) { return; } //设置菜单状态 int iSelectedItems = GetSelectedCount(); if(iSelectedItems && iSelectedItems == 1) { int nIndex = GetCurrSelectIndex(); if ( nIndex >= 0 ) { if ( CRssFeed* pFeed = GetFeed(nIndex) ) { //删除不用的menu项 menuRSS.DeleteMenu(MP_OPEN,MF_STRING); menuRSS.DeleteMenu(MP_RESUME,MF_STRING); //下载所有||暂停 if (pFeed->ExistDownloadingItem()) { menuRSS.EnableMenuItem(MP_PAUSE, MF_ENABLED); } if (pFeed->ExistUnloadItem()) { menuRSS.EnableMenuItem(MP_DOWNLOAD_ALL, MF_ENABLED); } menuRSS.EnableMenuItem(MP_CANCEL, MF_ENABLED); menuRSS.EnableMenuItem(MP_REFRESH, MF_ENABLED); menuRSS.EnableMenuItem(MP_OPTIONS, MF_ENABLED); menuRSS.EnableMenuItem(MP_OPENFOLDER, MF_ENABLED); } } } else//空白处右键 { menuRSS.DeleteMenu(MP_OPEN,MF_STRING); menuRSS.DeleteMenu(MP_OPENFOLDER,MF_STRING); menuRSS.DeleteMenu(MP_DOWNLOAD_ALL,MF_STRING); menuRSS.DeleteMenu(MP_RESUME,MF_STRING); menuRSS.DeleteMenu(MP_PAUSE,MF_STRING); menuRSS.DeleteMenu(MP_CANCEL,MF_STRING); menuRSS.DeleteMenu(MP_OPTIONS,MF_STRING); //menuRSS.DeleteMenu(MF_SEPARATOR,MF_STRING); if ( this->GetItemCount() > 0 ) { menuRSS.EnableMenuItem(MP_REFRESH, MF_ENABLED); } else { menuRSS.DeleteMenu(MP_REFRESH,MF_STRING); } } }
void CUploadListCtrl::OnContextMenu(CWnd* /*pWnd*/, CPoint point) { int iSel = GetNextItem(-1, LVIS_SELECTED | LVIS_FOCUSED); const CUpDownClient* client = (iSel != -1) ? (CUpDownClient*)GetItemData(iSel) : NULL; CTitleMenu ClientMenu; ClientMenu.CreatePopupMenu(); ClientMenu.AddMenuTitle(GetResString(IDS_CLIENTS), true); ClientMenu.AppendMenu(MF_STRING | (client ? MF_ENABLED : MF_GRAYED), MP_DETAIL, GetResString(IDS_SHOWDETAILS), _T("CLIENTDETAILS")); ClientMenu.SetDefaultItem(MP_DETAIL); //Xman friendhandling ClientMenu.AppendMenu(MF_SEPARATOR); //Xman end ClientMenu.AppendMenu(MF_STRING | ((client && client->IsEd2kClient() && !client->IsFriend()) ? MF_ENABLED : MF_GRAYED), MP_ADDFRIEND, GetResString(IDS_ADDFRIEND), _T("ADDFRIEND")); //Xman friendhandling ClientMenu.AppendMenu(MF_STRING | (client && client->IsFriend() ? MF_ENABLED : MF_GRAYED), MP_REMOVEFRIEND, GetResString(IDS_REMOVEFRIEND), _T("DELETEFRIEND")); ClientMenu.AppendMenu(MF_STRING | (client && client->IsFriend() ? MF_ENABLED : MF_GRAYED), MP_FRIENDSLOT, GetResString(IDS_FRIENDSLOT), _T("FRIENDSLOT")); ClientMenu.CheckMenuItem(MP_FRIENDSLOT, (client && client->GetFriendSlot()) ? MF_CHECKED : MF_UNCHECKED); ClientMenu.AppendMenu(MF_SEPARATOR); //Xman end ClientMenu.AppendMenu(MF_STRING | ((client && client->IsEd2kClient()) ? MF_ENABLED : MF_GRAYED), MP_MESSAGE, GetResString(IDS_SEND_MSG), _T("SENDMESSAGE")); ClientMenu.AppendMenu(MF_STRING | ((client && client->IsEd2kClient() && client->GetViewSharedFilesSupport()) ? MF_ENABLED : MF_GRAYED), MP_SHOWLIST, GetResString(IDS_VIEWFILES), _T("VIEWFILES")); if (Kademlia::CKademlia::IsRunning() && !Kademlia::CKademlia::IsConnected()) ClientMenu.AppendMenu(MF_STRING | ((client && client->IsEd2kClient() && client->GetKadPort()!=0 && client->GetKadVersion() > 1) ? MF_ENABLED : MF_GRAYED), MP_BOOT, GetResString(IDS_BOOTSTRAP)); ClientMenu.AppendMenu(MF_STRING | (GetItemCount() > 0 ? MF_ENABLED : MF_GRAYED), MP_FIND, GetResString(IDS_FIND), _T("Search")); // - show requested files (sivka/Xman) ClientMenu.AppendMenu(MF_SEPARATOR); ClientMenu.AppendMenu(MF_STRING | (GetItemCount() > 0 ? MF_ENABLED : MF_GRAYED),MP_LIST_REQUESTED_FILES, GetResString(IDS_LISTREQUESTED), _T("FILEREQUESTED")); //Xman end GetPopupMenuPos(*this, point); ClientMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); VERIFY( ClientMenu.DestroyMenu() ); // XP Style Menu [Xanatos] - Stulle }
void CSharedDirsTreeCtrl::OnContextMenu(CWnd* pWnd, CPoint point) { CDirectoryItem* pSelectedDir = GetSelectedFilter(); if (pSelectedDir != NULL && pSelectedDir->m_eItemType != SDI_UNSHAREDDIRECTORY && pSelectedDir->m_eItemType != SDI_FILESYSTEMPARENT){ int iSelectedItems = m_pSharedFilesCtrl->GetItemCount(); int iCompleteFileSelected = -1; UINT uPrioMenuItem = 0; bool bFirstItem = true; for (int i = 0; i < iSelectedItems; i++) { const CKnownFile* pFile = (CKnownFile*)m_pSharedFilesCtrl->GetItemData(i); int iCurCompleteFile = pFile->IsPartFile() ? 0 : 1; if (bFirstItem) iCompleteFileSelected = iCurCompleteFile; else if (iCompleteFileSelected != iCurCompleteFile) iCompleteFileSelected = -1; UINT uCurPrioMenuItem = 0; if (pFile->IsAutoUpPriority()) uCurPrioMenuItem = MP_PRIOAUTO; else if (pFile->GetUpPriority() == PR_VERYLOW) uCurPrioMenuItem = MP_PRIOVERYLOW; else if (pFile->GetUpPriority() == PR_LOW) uCurPrioMenuItem = MP_PRIOLOW; else if (pFile->GetUpPriority() == PR_NORMAL) uCurPrioMenuItem = MP_PRIONORMAL; else if (pFile->GetUpPriority() == PR_HIGH) uCurPrioMenuItem = MP_PRIOHIGH; else if (pFile->GetUpPriority() == PR_VERYHIGH) uCurPrioMenuItem = MP_PRIOVERYHIGH; else ASSERT(0); if (bFirstItem) uPrioMenuItem = uCurPrioMenuItem; else if (uPrioMenuItem != uCurPrioMenuItem) uPrioMenuItem = 0; bFirstItem = false; } bool bWideRangeSelection = true; if(pSelectedDir->m_nCatFilter != -1 || pSelectedDir->m_eItemType == SDI_NO){ // just avoid that users get bad ideas by showing the comment/delete-option for the "all" selections // as the same comment for all files/all incimplete files/ etc is probably not too usefull // - even if it can be done in other ways if the user really wants to do it bWideRangeSelection = false; } m_SharedFilesMenu.EnableMenuItem((UINT_PTR)m_PrioMenu.m_hMenu, iSelectedItems > 0 ? MF_ENABLED : MF_GRAYED); m_PrioMenu.CheckMenuRadioItem(MP_PRIOVERYLOW, MP_PRIOAUTO, uPrioMenuItem, 0); m_SharedFilesMenu.EnableMenuItem(MP_OPENFOLDER, (pSelectedDir != NULL && pSelectedDir->m_eItemType == SDI_NO) ? MF_ENABLED : MF_GRAYED); m_SharedFilesMenu.EnableMenuItem(MP_REMOVE, (iCompleteFileSelected > 0 && !bWideRangeSelection) ? MF_ENABLED : MF_GRAYED); m_SharedFilesMenu.EnableMenuItem(MP_CMT, (iSelectedItems > 0 && !bWideRangeSelection) ? MF_ENABLED : MF_GRAYED); m_SharedFilesMenu.EnableMenuItem(MP_DETAIL, iSelectedItems > 0 ? MF_ENABLED : MF_GRAYED); m_SharedFilesMenu.EnableMenuItem(thePrefs.GetShowCopyEd2kLinkCmd() ? MP_GETED2KLINK : MP_SHOWED2KLINK, iSelectedItems > 0 ? MF_ENABLED : MF_GRAYED); CTitleMenu WebMenu; WebMenu.CreateMenu(); WebMenu.AddMenuTitle(NULL, true); int iWebMenuEntries = theWebServices.GetFileMenuEntries(&WebMenu); UINT flag2 = (iWebMenuEntries == 0 || iSelectedItems != 1) ? MF_GRAYED : MF_STRING; m_SharedFilesMenu.AppendMenu(flag2 | MF_POPUP, (UINT_PTR)WebMenu.m_hMenu, GetResString(IDS_WEBSERVICES), _T("WEB")); GetPopupMenuPos(*this, point); m_SharedFilesMenu.TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON,point.x,point.y,this); m_SharedFilesMenu.RemoveMenu(m_SharedFilesMenu.GetMenuItemCount()-1,MF_BYPOSITION); VERIFY( WebMenu.DestroyMenu() ); } else if(pSelectedDir != NULL && pSelectedDir->m_eItemType == SDI_UNSHAREDDIRECTORY){ m_ShareDirsMenu.EnableMenuItem(MP_UNSHAREDIR, FileSystemTreeIsShared(pSelectedDir->m_strFullPath) ? MF_ENABLED : MF_GRAYED); m_ShareDirsMenu.EnableMenuItem(MP_UNSHAREDIRSUB, (FileSystemTreeIsShared(pSelectedDir->m_strFullPath) || FileSystemTreeHasSharedSubdirectory(pSelectedDir->m_strFullPath)) ? MF_ENABLED : MF_GRAYED); m_ShareDirsMenu.EnableMenuItem(MP_SHAREDIR, !FileSystemTreeIsShared(pSelectedDir->m_strFullPath) ? MF_ENABLED : MF_GRAYED); m_ShareDirsMenu.EnableMenuItem(MP_SHAREDIRSUB, FileSystemTreeHasSubdirectories(pSelectedDir->m_strFullPath) ? MF_ENABLED : MF_GRAYED); GetPopupMenuPos(*this, point); m_ShareDirsMenu.TrackPopupMenu(TPM_LEFTALIGN |TPM_RIGHTBUTTON,point.x,point.y,this); } }
void CRichEditCtrlX::OnContextMenu(CWnd* /*pWnd*/, CPoint point) { if (point.x != -1 || point.y != -1) { CRect rcClient; GetClientRect(&rcClient); ClientToScreen(&rcClient); if (!rcClient.PtInRect(point)) { Default(); return; } } long iSelStart, iSelEnd; GetSel(iSelStart, iSelEnd); int iTextLen = GetWindowTextLength(); // Context menu of standard edit control // // Undo // ---- // Cut // Copy // Paste // Delete // ------ // Select All bool bReadOnly = (GetStyle() & ES_READONLY)!=0; // ==> XP Style Menu [Xanatos] - Stulle /* CMenu menu; menu.CreatePopupMenu(); if (!bReadOnly){ menu.AppendMenu(MF_STRING, MP_UNDO, GetResString(IDS_UNDO)); menu.AppendMenu(MF_SEPARATOR); } if (!bReadOnly) menu.AppendMenu(MF_STRING, MP_CUT, GetResString(IDS_CUT)); menu.AppendMenu(MF_STRING, MP_COPYSELECTED, GetResString(IDS_COPY)); if (!bReadOnly){ menu.AppendMenu(MF_STRING, MP_PASTE, GetResString(IDS_PASTE)); menu.AppendMenu(MF_STRING, MP_REMOVESELECTED, GetResString(IDS_DELETESELECTED)); } menu.AppendMenu(MF_SEPARATOR); menu.AppendMenu(MF_STRING, MP_SELECTALL, GetResString(IDS_SELECTALL)); */ CTitleMenu menu; menu.CreatePopupMenu(); menu.AddMenuTitle(GetResString(IDS_LOGENTRY)); if (!bReadOnly){ menu.AppendMenu(MF_STRING, MP_UNDO, GetResString(IDS_UNDO), _T("UNDO")); menu.AppendMenu(MF_SEPARATOR); } if (!bReadOnly) menu.AppendMenu(MF_STRING, MP_CUT, GetResString(IDS_CUT), _T("CUT")); menu.AppendMenu(MF_STRING, MP_COPYSELECTED, GetResString(IDS_COPY), _T("COPY")); if (!bReadOnly){ menu.AppendMenu(MF_STRING, MP_PASTE, GetResString(IDS_PASTE), _T("PASTE")); menu.AppendMenu(MF_STRING, MP_REMOVESELECTED, GetResString(IDS_DELETESELECTED), _T("DELETE")); } menu.AppendMenu(MF_SEPARATOR); menu.AppendMenu(MF_STRING, MP_SELECTALL, GetResString(IDS_SELECTALL), _T("SEARCHFILETYPE_DOCUMENT")); // <== XP Style Menu [Xanatos] - Stulle menu.EnableMenuItem(MP_UNDO, CanUndo() ? MF_ENABLED : MF_GRAYED); menu.EnableMenuItem(MP_CUT, iSelEnd > iSelStart ? MF_ENABLED : MF_GRAYED); menu.EnableMenuItem(MP_COPYSELECTED, iSelEnd > iSelStart ? MF_ENABLED : MF_GRAYED); menu.EnableMenuItem(MP_PASTE, CanPaste() ? MF_ENABLED : MF_GRAYED); menu.EnableMenuItem(MP_REMOVESELECTED, iSelEnd > iSelStart ? MF_ENABLED : MF_GRAYED); menu.EnableMenuItem(MP_SELECTALL, iTextLen > 0 ? MF_ENABLED : MF_GRAYED); if (point.x == -1 && point.y == -1) { point.x = 16; point.y = 32; ClientToScreen(&point); } // Cheap workaround for the "Text cursor is showing while context menu is open" glitch. It could be solved properly // with the RE's COM interface, but because the according messages are not routed with a unique control ID, it's not // really useable (e.g. if there are more RE controls in one window). Would to envelope each RE window to get a unique ID.. m_bForceArrowCursor = true; menu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); m_bForceArrowCursor = false; VERIFY( menu.DestroyMenu() ); // XP Style Menu [Xanatos] - Stulle }
void CIrcChannelTabCtrl::OnContextMenu(CWnd*, CPoint point) { int iCurTab = GetTabUnderMouse(point); if (iCurTab < 2) { return; } TCITEM item; item.mask = TCIF_PARAM; GetItem(iCurTab, &item); Channel* pChan = FindChannelByName(((Channel*)item.lParam)->m_sName); if( !pChan ) { return; } CTitleMenu menuChat; menuChat.CreatePopupMenu(); menuChat.AddMenuTitle(GetResString(IDS_IRC)+_T(" : ")+pChan->m_sName); menuChat.AppendMenu(MF_STRING, Irc_Close, GetResString(IDS_FD_CLOSE)); if (iCurTab < 2) // no 'Close' for status log and channel list menuChat.EnableMenuItem(Irc_Close, MF_GRAYED); int iCurIndex = 0; int iLength = m_sChannelModeSettingsTypeA.GetLength(); CString sMode; for( int iIndex = 0; iIndex < iLength; iIndex++) { sMode = m_sChannelModeSettingsTypeA.Mid(iIndex,1); if( pChan->m_sModesA.Find(sMode) == -1 ) { menuChat.AppendMenu(MF_STRING, Irc_ChanCommands+iCurIndex, _T("ModeA Set +") + sMode + _T(" ( Not Supported Yet )") ); menuChat.EnableMenuItem(Irc_ChanCommands+iCurIndex, MF_GRAYED); } else { menuChat.AppendMenu(MF_STRING, Irc_ChanCommands+iCurIndex+50, _T("ModeA Set -") + sMode + _T(" ( Not Supported Yet )") ); menuChat.EnableMenuItem(Irc_ChanCommands+iCurIndex+50, MF_GRAYED); } iCurIndex++; } iLength = m_sChannelModeSettingsTypeB.GetLength(); for( int iIndex = 0; iIndex < iLength; iIndex++) { sMode = m_sChannelModeSettingsTypeB.Mid(iIndex,1); if( pChan->m_sModesB.Find(sMode) == -1 ) { menuChat.AppendMenu(MF_STRING, Irc_ChanCommands+iCurIndex, _T("ModeB Set +") + sMode + _T(" ( Not Supported Yet )") ); menuChat.EnableMenuItem(Irc_ChanCommands+iCurIndex, MF_GRAYED); } else { menuChat.AppendMenu(MF_STRING, Irc_ChanCommands+iCurIndex+50, _T("ModeB Set -") + sMode + _T(" ( Not Supported Yet )") ); menuChat.EnableMenuItem(Irc_ChanCommands+iCurIndex+50, MF_GRAYED); } iCurIndex++; } iLength = m_sChannelModeSettingsTypeC.GetLength(); for( int iIndex = 0; iIndex < iLength; iIndex++) { sMode = m_sChannelModeSettingsTypeC.Mid(iIndex,1); if( pChan->m_sModesC.Find(sMode) == -1 ) { menuChat.AppendMenu(MF_STRING, Irc_ChanCommands+iCurIndex, _T("ModeC Set +") + sMode + _T(" ( Not Supported Yet )") ); menuChat.EnableMenuItem(Irc_ChanCommands+iCurIndex, MF_GRAYED); } else { menuChat.AppendMenu(MF_STRING, Irc_ChanCommands+iCurIndex+50, _T("ModeC Set -") + sMode + _T(" ( Remove ") + sMode + _T(" )") ); } iCurIndex++; } iLength = m_sChannelModeSettingsTypeD.GetLength(); for( int iIndex = 0; iIndex < iLength; iIndex++) { sMode = m_sChannelModeSettingsTypeD.Mid(iIndex,1); if( pChan->m_sModesD.Find(sMode) == -1 ) { menuChat.AppendMenu(MF_STRING, Irc_ChanCommands+iCurIndex, _T("ModeD Set +") + sMode + _T(" ( Add ") + sMode + _T(" )") ); } else { menuChat.AppendMenu(MF_STRING, Irc_ChanCommands+iCurIndex+50, _T("ModeD Set -") + sMode + _T(" ( Remove ") + sMode + _T(" )") ); } iCurIndex++; } menuChat.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); VERIFY( menuChat.DestroyMenu() ); }
void CFriendListCtrl::OnContextMenu(CWnd* /*pWnd*/, CPoint point) { CTitleMenu ClientMenu; ClientMenu.CreatePopupMenu(); ClientMenu.AddMenuTitle(GetResString(IDS_FRIENDLIST), true); const CFriend* cur_friend = NULL; int iSel = GetNextItem(-1, LVIS_SELECTED | LVIS_FOCUSED); if (iSel != -1) { cur_friend = (CFriend*)GetItemData(iSel); ClientMenu.AppendMenu(MF_STRING,MP_DETAIL, GetResString(IDS_SHOWDETAILS), _T("CLIENTDETAILS")); ClientMenu.SetDefaultItem(MP_DETAIL); } ClientMenu.AppendMenu(MF_STRING, MP_ADDFRIEND, GetResString(IDS_ADDAFRIEND), _T("ADDFRIEND")); ClientMenu.AppendMenu(MF_STRING | (cur_friend ? MF_ENABLED : MF_GRAYED), MP_REMOVEFRIEND, GetResString(IDS_REMOVEFRIEND), _T("DELETEFRIEND")); ClientMenu.AppendMenu(MF_STRING | (cur_friend ? MF_ENABLED : MF_GRAYED), MP_MESSAGE, GetResString(IDS_SEND_MSG), _T("SENDMESSAGE")); ClientMenu.AppendMenu(MF_STRING | ((cur_friend==NULL || (cur_friend && cur_friend->GetLinkedClient(true) && !cur_friend->GetLinkedClient(true)->GetViewSharedFilesSupport())) ? MF_GRAYED : MF_ENABLED), MP_SHOWLIST, GetResString(IDS_VIEWFILES) , _T("VIEWFILES")); ClientMenu.AppendMenu(MF_STRING, MP_FRIENDSLOT, GetResString(IDS_FRIENDSLOT), _T("FRIENDSLOT")); ClientMenu.AppendMenu(MF_STRING | (GetItemCount() > 0 ? MF_ENABLED : MF_GRAYED), MP_FIND, GetResString(IDS_FIND), _T("Search")); ClientMenu.EnableMenuItem(MP_FRIENDSLOT, (cur_friend)?MF_ENABLED : MF_GRAYED); ClientMenu.CheckMenuItem(MP_FRIENDSLOT, (cur_friend && cur_friend->GetFriendSlot()) ? MF_CHECKED : MF_UNCHECKED); // MORPH START - Modified by Commander, Friendlinks [emulEspaa] - added by zz_fly ClientMenu.AppendMenu(MF_SEPARATOR); ClientMenu.AppendMenu(MF_STRING | (theApp.IsEd2kFriendLinkInClipboard() ? MF_ENABLED : MF_GRAYED), MP_PASTE, GetResString(IDS_PASTE), _T("PASTELINK")); ClientMenu.AppendMenu(MF_STRING | (cur_friend ? MF_ENABLED : MF_GRAYED), MP_GETFRIENDED2KLINK, GetResString(IDS_GETFRIENDED2KLINK), _T("ED2KLINK")); ClientMenu.AppendMenu(MF_STRING | (cur_friend ? MF_ENABLED : MF_GRAYED), MP_GETHTMLFRIENDED2KLINK, GetResString(IDS_GETHTMLFRIENDED2KLINK), _T("ED2KLINK")); // MORPH END - Modified by Commander, Friendlinks [emulEspaa] // - show requested files (sivka/Xman) ClientMenu.AppendMenu(MF_SEPARATOR); ClientMenu.AppendMenu(MF_STRING | (cur_friend && cur_friend->GetLinkedClient() ? MF_ENABLED : MF_GRAYED),MP_LIST_REQUESTED_FILES, GetResString(IDS_LISTREQUESTED), _T("FILEREQUESTED")); //Xman end GetPopupMenuPos(*this, point); ClientMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, point.x, point.y, this); VERIFY( ClientMenu.DestroyMenu() ); // XP Style Menu [Xanatos] - Stulle }