官方链接:SetWindowPos 函数 (winuser.h) - Win32 apps | Microsoft Learn
BOOL SetWindowPos(
[in] HWND hWnd,
[in, optional] HWND hWndInsertAfter,
[in] int X,
[in] int Y,
[in] int cx,
[in] int cy,
[in] UINT uFlags
);
改编成C#的方法:
[DllImport("user32.dll")]
static extern bool SetWindowPos(
IntPtr intPtr,
int hwndInsertAfter,
int X,
int Y,
int cx,
int cy,
uint uFlags);
备注:
如果注意看的小伙伴会问我,为什么 int hwndInsertAfter是int呢?不应该是IntPtr吗?
这个比较特殊,因为在官方文档里备注了。(如图9所示)
图9 hwndInsertAfter注解
注解的意思是:这里要填数字int
1 放在所有窗口最下面
-2 放在置顶窗口以外的第一层
0 单次置顶
-1 永远置顶
2.参数说明
IntPtr intPtr: 填写你想要控制的句柄 int hwndInsertAfter: 前面讲过,按照需求填一下 int X: 你打算把窗口放在哪个屏幕的哪个位置中的x int Y: 你打算把窗口放在哪个屏幕的哪个位置中的y int cx: 你的窗口分辨率宽(如果全屏显示,这个没有意义) int cy: 你的窗口分辨率高(如果全屏显示,这个没有意义) uint uFlags: 功能很多(如图10所示)
图10 uFlags
你用哪个,就填写下面的数字就行了。
这次我们选择(如图11所示),意思就是,显示窗口,并且可以操作。
图11 0x0040
3.使用方法
using System;
using System.Runtime.InteropServices;
using UnityEngine;
public class myWindowMod : MonoBehaviour
{
[DllImport("user32.dll")]
static extern IntPtr FindWindowExA(IntPtr hWndParent, IntPtr hWndChildAfter, string lpszClass, string lpszWindow);
//引入设置窗口方法
[DllImport("user32.dll")]
static extern bool SetWindowPos(IntPtr intPtr, int hwndInsertAfter, int X, int Y, int cx, int cy, uint uFlags);
public string projectName;
IntPtr intPtr;
void Start()
{
intPtr = FindWindowExA(IntPtr.Zero, IntPtr.Zero, null, projectName);
//设置窗口 //句柄 //放在位置(0,0) //显示窗口并能操作
SetWindowPos(intPtr, -1,0,0,1920,1080, 0x0040);
//永久置顶 //窗口分辨率1920,1080
}
}
文章目录 org.apache.solr.common.SolrException: Exception writing document id MATERIAL-99598435990497269125316 to the index; possible analysis error: cannot change DocValues type from NUMERIC to SORTED_NUMERIC for field "opt_time"Exception writing…