CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Windows/W32Util/ContextMenu.cpp
Views: 1401
// Copyright (c) 2021- PPSSPP Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.1617#include "Windows/W32Util/ContextMenu.h"18#include "Windows/resource.h"1920static HMENU g_hPopupMenus;2122void ContextMenuInit(HINSTANCE inst) {23g_hPopupMenus = LoadMenu(inst, (LPCWSTR)IDR_POPUPMENUS);24}2526ContextPoint ContextPoint::FromCursor() {27ContextPoint result;28GetCursorPos(&result.pos_);29return result;30}3132ContextPoint ContextPoint::FromClient(const POINT &clientPoint) {33ContextPoint result;34result.pos_ = clientPoint;35result.isClient_ = true;36return result;37}3839ContextPoint ContextPoint::FromEvent(LPARAM lParam) {40ContextPoint result;41result.pos_.x = LOWORD(lParam);42result.pos_.y = HIWORD(lParam);43result.isClient_ = true;44return result;45}4647HMENU GetContextMenu(ContextMenuID which) {48return GetSubMenu(g_hPopupMenus, (int)which);49}5051int TriggerContextMenu(ContextMenuID which, HWND wnd, const ContextPoint &pt) {52POINT pos = pt.pos_;53if (pt.isClient_) {54ClientToScreen(wnd, &pos);55}5657HMENU menu = GetContextMenu(which);58if (!menu)59return -1;6061return TrackPopupMenuEx(menu, TPM_RIGHTBUTTON | TPM_RETURNCMD, pos.x, pos.y, wnd, 0);62}636465