I am using Windows Forms to host DirectX-rendered content using SharpDX RenderForm. The issue is that when I set the form Size, it scales it by the scaling factor of my display, which is not what I need because I do pixel-based rendering.
I've tried to set form's AutoScaleMode to None, which appears to have no effect.
I also played with DpiAwareness in System.Windows.Forms.ApplicationConfigurationSection and the corresponding setting in the application manifest.
My goal is to do everything in pixels.
This line run before creating the main form worked for me:
The reason is that by explicitly declaring awareness of scaling you opt out from Windows Forms handling it for you by implicitly multiplying all sizes.
AutoScaleModeturned out not to be needed.According to
SetHighDpiModedocumentation, the manifest method should have worked too, but I suspect some fluke prevented it from being picked up when launching the project from JetBrains Rider.