c# - USER32 SetWindowPos 隐藏光标
问题描述
我正在尝试从我的控制台应用程序中使用 SetWindowPos定位窗口本身并且它可以工作,但是闪烁的光标消失了。我怎样才能避免它?
const int SWP_NOZORDER = 0x4;
const int SWP_NOACTIVATE = 0x10;
[DllImport("kernel32.dll")]
static extern IntPtr GetConsoleWindow();
[DllImport("user32")]
static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter,int x, int y, int cx, int cy, int flags);
public static void SetWindowPosition(int x, int y, int width, int height)
{
SetWindowPos(GetConsoleWindow(), IntPtr.Zero, x, y, width, height, SWP_NOZORDER | SWP_NOACTIVATE);
}
void run()
{
SetWindowPosition(0, 0, 300, 300);
}
解决方案
推荐阅读
- android - 新鲜的Android studio项目很多错误
- python - Python 和正则表达式将 wrtitten 数字转换为数字
- javascript - 组件加载导致“尚未为上下文加载模块名称”
- macos - 如何在 macOS 上拦截 Thunderbolt 数据包?
- c - AVR 中断的变量在 main 中更新
- python - 如何在张量流上减少 Word2Vec 模型中的损失
- java - Intellij IDEA 的自定义插件可以在其代码中使用 DI 吗?
- python - How to insert strings from one column of pandas DataFrame to another column at specific index?
- mysql - Mysql Query Gives Duplicate Rows
- javascript - 从另一个 html 站点更改段落文本