首页 > 学院 > 开发设计 > 正文

UnityWebPlayer屏蔽右键及全屏

2019-11-08 03:25:59
字体:
来源:转载
供稿:网友
/// <summary>/// 过滤鼠标右键./// </summary>/// <param name="m">The m.</param>/// <returns></returns>public bool PReFilterMessage(ref System.Windows.Forms.Message m){ try { if (this.unityPlayer == null) { return false; } if (m.Msg == WMConst.WM_KEYUP || m.Msg == WMConst.WM_SYSKEYUP) { int param = m.WParam.ToInt32(); if (param == (int)Keys.F11) { Interop_KeyUp_F11(); return true; } }System.Drawing.Rectangle area = new System.Drawing.Rectangle(this.unityPlayer.Location, this.unityPlayer.Size); Point pos = Control.MousePosition; if (area.Contains(this.PointToClient(pos))) { switch (m.Msg) { case WMConst.WM_RBUTTONDOWN: if (this.ContextMenuStrip != null) { pos = this.unityPlayer.PointToClient(pos); this.m_contextMenuStrip.Show(this.unityPlayer, new Point(pos.X, pos.Y)); } return true; case WMConst.WM_RBUTTONUP: return true; case WMConst.WM_RBUTTONDBLCLK: return true; default: return false; } } return false; } catch (Exception ex) { return false; }} /// <summary>/// 截获F11设置全屏./// </summary>public void Interop_KeyUp_F11(){ try { this.m_fullScreen = !this.m_fullScreen; if (this.m_fullScreen) { this.Dock = DockStyle.None; this.Left = 0; this.Top = 0; this.Width = Screen.PrimaryScreen.Bounds.Width; this.Height = Screen.PrimaryScreen.Bounds.Height; Methods.SetParent(this.Handle, IntPtr.Zero); base.Parent.Hide(); } else { Methods.SetParent(this.Handle, base.Parent.Handle); base.Parent.Show(); } } catch (Exception ex) { }}
发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表