使用 .NET 框架 4.7.1
呼叫 Keyboard.GetKeyStates 后框架或表單視窗大小縮小 有什么原因嗎?還是它的一個錯誤?我正在檢查 ctrl 是否關閉或在其他視窗上切換。
if (((int)Keyboard.GetKeyStates(Key.LeftCtrl) == 1 || (int)Keyboard.GetKeyStates(Key.LeftCtrl) == 3)) { Console.WriteLine("pressed"); }
從圖片中可以看出:
大圖
呼叫 GetKeyStates 后
uj5u.com熱心網友回復:
由于 TnTinMn評論其 Dpi 感知問題,我在這里找到了解決方案 , 也嘗試更改應用程式清單中的 dpi 選項,但沒有奏效。
static class Program
{
/// <summary>
/// The main entry point for the application.
/// </summary>
[STAThread]
//add this line
[System.Runtime.InteropServices.DllImport("user32.dll")]
private static extern bool SetProcessDPIAware();
static void Main()
{
//add this line
if (Environment.OSVersion.Version.Major >= 6)
SetProcessDPIAware();
Application.EnableVisualStyles();
Application.SetCompatibleTextRenderingDefault(false);
Application.Run(new Form1());
}
}
轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/372226.html
上一篇:如何訪問反序列化json中的“文本”和“音頻”物件?
下一篇:如何隱藏輸入法編輯器
