The EASY way to make a C# Windows.forms app really per monitor DPI aware

For .Net 8.0 WinForms apps go HERE (Also 7.0 and 6.0)

The below is for .Net Framework, latest being 4.8.

As posted in another post, many apps have problems with windows scaling.

See these screen-dumps from Windows lengthy guide that was found here

UPDATE 2020. After Windows “Creators update”, they made things slightly more complicated, sorry…

Here is a reasonably minimalistic approach. You will often just need code like this:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
public partial class Form1 : Form {
     public Form1() {
         InitializeComponent();
         DPI_Per_Monitor.TryEnableDPIAware(this, SetUserFonts);
     }
     void SetUserFonts(float scaleFactorX, float scaleFactorY) {
        var OldFont = Font;
        Font = new Font(OldFont.FontFamily, 11f * scaleFactorX, OldFont.Style, GraphicsUnit.Pixel);
        Refresh();
        OldFont.Dispose();
     }
     protected override void DefWndProc(ref Message m) {
         DPI_Per_Monitor.Check_WM_DPICHANGED(SetUserFonts,m, this.Handle);
         base.DefWndProc(ref m);
     }
 }

You will need to obey a few rules, but often it can be implemented in existing code in minutes!

Continue reading “The EASY way to make a C# Windows.forms app really per monitor DPI aware”

Cases/shells for the Pro1, DIY experiments

There are no official case(s) for the FxTec Pro1, so I have ordered over a score of cases/shells for various phones of dimensions close the keyboard part…

Ten have arrived, nine Nov 13., and here are the preliminary results, and a flip case fitted

Add Nov 21, two more have arrived, for Huawei P20  Pro and Note 7

Add Dec 28, two more have arrived a week ago, Flip cases for Huawei P20  Pro and they are better (the above image)

Add Jan 23, a little more on a P20 Pro flip, reverting the inner part

Add Apr 1, a better shell case with strengthened corners.

Add Aug 6, a protector for the top half – disabling edge interaction

(Will update if any of the remaining ones proves a better fit)

Continue reading “Cases/shells for the Pro1, DIY experiments”

Save and restore positions of windows, WindowsPosSaveNRestore

WindowsPosSaveNRestore is a tool to save the position of windows for later restore

This is primarily useful if you frequently change display configuration, say add/remove external monitor(s) e.g. by docking, or turning a device with autorotate active.

Windows also has the bug that it sometimes cram all open windows (and icons [+]) on the primary screen on sleep.

Continue reading “Save and restore positions of windows, WindowsPosSaveNRestore”

A little post on keyboard phones, and the few alternatives available

Since BlackBerry-phones are now seeming to come to a complete end (not even licensed devices), the options for keyboard phones are even more sparse.

I guess no one reading the blog is unaware that I go for the Pro1.

But in all fairness there are alternatives.

2020-04-12 Updated with the Astroslide announced for spring 2021.

Continue reading “A little post on keyboard phones, and the few alternatives available”