Skip to content

Instantly share code, notes, and snippets.

@Boggartfly
Created July 25, 2016 17:43
Show Gist options
  • Save Boggartfly/9f035f9fa8610d6108fa5c5217bce672 to your computer and use it in GitHub Desktop.
Save Boggartfly/9f035f9fa8610d6108fa5c5217bce672 to your computer and use it in GitHub Desktop.
var graphics = Graphics.FromHwnd(IntPtr.Zero); // This gets the graphics configuration of the current screen
var scaleX = graphics.DpiX / 96; // 96 was our standard design DPI, remember?
var scaleY = graphics.DpiY / 96;
this.button1.Location = new System.Drawing.Point((int)Math.Round(20 * scaleX), (int)Math.Round(20 * scaleY));
this.button2.Location = new System.Drawing.Point((int)Math.Round(30 * scaleX), (int)Math.Round(30 * scaleY));
//Use this with C# and change x,y values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment