using .NET Framework 4.7.1
the frame or form Window size shrink after calling Keyboard.GetKeyStates Is there any reason for that ? or its a bug ? I am checking if ctrl is down or toggle on other window .
if (((int)Keyboard.GetKeyStates(Key.LeftCtrl) == 1 || (int)Keyboard.GetKeyStates(Key.LeftCtrl) == 3)) { Console.WriteLine("pressed"); }
As can be seen in the pictures:
CodePudding user response:
as TnTinMn comment its Dpi aware problem ,I have found the solution here also tried to change the dpi option from app manifest ,did not work .
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());
}
}