Esempio n. 1
0
LRESULT WaitingUsersFrame::onContextMenu(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& /*bHandled*/)
{
	RECT rc;
	POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
	m_ctrlList.GetHeader().GetWindowRect(&rc);
	if (PtInRect(&rc, pt))
	{
		m_ctrlList.showMenu(pt);
		return TRUE;
	}
	
	// Create context menu
	// !SMT!-UI
	OMenu contextMenu;
	contextMenu.CreatePopupMenu();
	clearUserMenu(); // [+] IRainman fix.
	
	if (reinterpret_cast<HWND>(wParam) == m_ctrlList && m_ctrlList.GetSelectedCount() > 0)
	{
		if (pt.x == -1 && pt.y == -1)
		{
			WinUtil::getContextMenuPos(m_ctrlList, pt);
		}
		
		appendAndActivateUserItems(contextMenu);
		
		contextMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, m_hWnd);
		return TRUE;
	}
	else if (reinterpret_cast<HWND>(wParam) == ctrlQueued && ctrlQueued.GetSelectedItem() != NULL)
	{
		if (pt.x == -1 && pt.y == -1)
		{
			WinUtil::getContextMenuPos(ctrlQueued, pt);
		}
		else
		{
			UINT a = 0;
			ctrlQueued.ScreenToClient(&pt);
			HTREEITEM ht = ctrlQueued.HitTest(pt, &a);
			if (ht != NULL && ht != ctrlQueued.GetSelectedItem())
				ctrlQueued.SelectItem(ht);
				
			ctrlQueued.ClientToScreen(&pt);
		}
		
		// !SMT!-UI
		reinitUserMenu(getCurrentdUser(), Util::emptyString); // [+] IRainman fix.
		appendAndActivateUserItems(contextMenu);
		
		contextMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, m_hWnd);
		
		WinUtil::unlinkStaticMenus(contextMenu); // TODO - fix copy-paste
		return TRUE;
	}
	return FALSE;
}
Esempio n. 2
0
LRESULT UsersFrame::onContextMenu(UINT /*uMsg*/, WPARAM wParam, LPARAM lParam, BOOL& bHandled)
{
	if (reinterpret_cast<HWND>(wParam) == ctrlUsers && ctrlUsers.GetSelectedCount() > 0)
	{
		POINT pt = { GET_X_LPARAM(lParam), GET_Y_LPARAM(lParam) };
		
		if (pt.x == -1 && pt.y == -1)
		{
			WinUtil::getContextMenuPos(ctrlUsers, pt);
		}
		
		clearUserMenu(); // [+] IRainman fix.
		
		// [+] brain-ripper
		// Make menu dynamic, since its content depends of which
		// user selected (for add/remove favorites item)
		OMenu usersMenu;
		usersMenu.CreatePopupMenu();
		usersMenu.AppendMenu(MF_STRING, IDC_EDIT, CTSTRING(PROPERTIES));
		usersMenu.AppendMenu(MF_STRING, IDC_OPEN_USER_LOG, CTSTRING(OPEN_USER_LOG));
		usersMenu.AppendMenu(MF_STRING, IDC_REMOVE_FROM_FAVORITES, CTSTRING(REMOVE_FROM_FAVORITES)); //[+] NightOrion
		
		tstring x;
		if (ctrlUsers.GetSelectedCount() == 1)
		{
			const auto user = ctrlUsers.getItemData(ctrlUsers.GetSelectedIndex())->getUser();
			if (user->isOnline())
			{
				usersMenu.AppendMenu(MF_SEPARATOR);
				x = user->getLastNickT();
				reinitUserMenu(user, Util::emptyString); // TODO: add hub hint.
				if (!x.empty())
					usersMenu.InsertSeparatorFirst(x);
					
				appendAndActivateUserItems(usersMenu);
			}
		}
		else
		{
			usersMenu.AppendMenu(MF_SEPARATOR);
			appendAndActivateUserItems(usersMenu);
		}
		usersMenu.TrackPopupMenu(TPM_LEFTALIGN | TPM_RIGHTBUTTON, pt.x, pt.y, m_hWnd);
		
		if (!x.empty())
			usersMenu.RemoveFirstItem();
			
		return TRUE;
	}
	bHandled = FALSE;
	return FALSE;
}