C#C
C#3y ago
Thalnos

❔ need help fixing Bug in WPF app

I got code to place windows on the screen where the MainWindow is located by grabbing it's handler. I then set window's top to the handler's top location and same for left. On most devices works as expected, window spawns on top left edge of mainwindow's screen.
However on two clients out of roughly 20, there is a bug.
On those clients, when opening on a certain screen of the three screens they're using, window spawns in nirvana, far more in the top RIGHT than visible. on the other two screen's they're using the window spawns in the center of screen on top rather than left top. On the other 18 clients, whatever screen you use it will always work as expected and spawn on top left edge of mainwindow's screen
Those two clients facing the bugg have the exact same environment as the 18 clients where it works as expected, that is same Hardwares, same OS and same display settings. I'm lost how to debug this.
there is no error in the event viewer.
when you move the window using windows key + arrows it moves into appearance
public void PositionOnMainWindowScreen(Window window)
        {
            var mainwindowSource = PresentationSource.FromVisual(this) as HwndSource;
            var mainWindowScreen = Screen.FromHandle(mainwindowSource.Handle);
            window.WindowStartupLocation = WindowStartupLocation.Manual;
            window.Left = mainWindowScreen.WorkingArea.Left;
            window.Top = mainWindowScreen.WorkingArea.Top;
        }
Was this page helpful?