public static RECTAPI calClientToScreen() { RECTAPI ClientRectHwnd = new RECTAPI(); //下面代码限制鼠标在窗口 //RECTAPI rectHwnd = new RECTAPI(); //bool resultWindowRect = GameLogicAPI.GetWindowRect(m_WindowHwnd, ref rectHwnd); //下面代码限制鼠标在窗口客户区 bool resultGetClientRect = GameLogicAPI.GetClientRect(Initialize.m_WindowHwnd, out ClientRectHwnd); //编辑器下要减去顶部工具栏高度 #if !UNITY_STANDALONE_WIN ClientRectHwnd.top += 24; #endif POINTAPI pointCTS = new POINTAPI(); pointCTS.x = ClientRectHwnd.left; pointCTS.y = ClientRectHwnd.top; bool resultCTS = GameLogicAPI.ClientToScreen(Initialize.m_WindowHwnd, ref pointCTS); ClientRectHwnd.left = pointCTS.x; ClientRectHwnd.top = pointCTS.y; pointCTS.x = ClientRectHwnd.right - 1; pointCTS.y = ClientRectHwnd.bottom - 1; resultCTS = GameLogicAPI.ClientToScreen(Initialize.m_WindowHwnd, ref pointCTS); ClientRectHwnd.right = pointCTS.x; ClientRectHwnd.bottom = pointCTS.y; return(ClientRectHwnd); }
private void RenderBorder() { IntPtr hdc = NativeUser32Api.GetWindowDC(this.Handle); RECTAPI s = new RECTAPI(); NativeUser32Api.GetWindowRect(this.Handle, ref s); using (Graphics g = Graphics.FromHdc(hdc)) { DrawingTools.DrawBorder((ControlBorderStyle)(int)this.BorderStyle, this.BorderColor, g, new Rectangle(0, 0, s.Width, s.Height)); } NativeUser32Api.ReleaseDC(this.Handle, hdc); }
/// <summary> /// 鼠标是否限制在游戏窗口内 /// </summary> /// <param name="_bLock">true:限制窗口内,false:不限制</param> public static void LockMouseInWindow(bool _bLock) { RECTAPI CTSRect = new RECTAPI(); if (_bLock) { CTSRect = calClientToScreen(); GameLogicAPI.ClipCursor(ref CTSRect); } else { GameLogicAPI.ClipCursor(IntPtr.Zero); } }
public static extern bool GetClientRect(IntPtr hwnd, out RECTAPI lpRect);
public static extern bool GetClipCursor(out RECTAPI rcClip);
public static extern bool ClipCursor(ref RECTAPI rcClip);
public static extern bool GetWindowRect(IntPtr hWnd, ref RECTAPI lpRect);
private void StartRecord() { if (!bOpenREC) { return; } if (GameLogicAPI.isMainMap(SceneManager.Instance.getCurrentMapId())) { return; } string rootPath = ViewConfigManager.DataUserPath; if (rootPath == "") { return; } string tempPath = rootPath + "/" + szTempPathName; if (!Directory.Exists(tempPath)) { Directory.CreateDirectory(tempPath); } gameview_start_screenCapture data = new gameview_start_screenCapture(); if (Application.isEditor) { data.point_x = 0; data.point_y = 0; int width, height; ImageSetting.GetMainMonitorSize(out width, out height); data.width = width; data.height = height; } else { RECTAPI rect = new RECTAPI(); GameLogicAPI.GetWindowRect(Initialize.m_WindowHwnd, ref rect); data.point_x = rect.left; data.point_y = rect.top; int titleHeight = GameLogicAPI.GetSystemMetrics((int)ESystemMetrics.SM_CYCAPTION); //int frameBorder = GameLogicAPI.GetSystemMetrics((int)ESystemMetrics.SM_CXFRAME); data.width = rect.right - rect.left; data.height = rect.bottom - rect.top; if (rect.top > 0) { data.point_y += titleHeight; data.height -= titleHeight; } } data.width = Mathf.Abs(data.width % 2 == 0 ? data.width : data.width - 1); data.height = Mathf.Abs(data.height % 2 == 0 ? data.height : data.height - 1); data.szTempFilePath = tempPath; ViewEventHelper.Instance.SendCommand <gameview_start_screenCapture>(GameLogicDef.GVIEWCMD_SCREENOPEN_OPEN, ref data); bRECValid = false; nHeroID = 0; checkPointTime = 0; recType = EMScreenRECType.EMSS_Invalid; recState = EMRECState.EMREC_RECORD; }