Hallo
ich bin gerade dabei meine Anwendung über zwei Monitore zu strecken
Das ganze wollte ich via WINAIP machen:
ShitCode
Spoiler anzeigen
problem bei dir ganzen sache ich nun, das wenn ich mir von MoveWindow-Methode das "window" anschaue habe ich ein AktuelleBreite von 1934 und eine AktuelleHöhe von 1094, was aus meiner sicht kein sinn macht, das mein Bildschrim 1920x1080 ist.
Erste frage, wo kommen die 14 Pixel her in W und H?
Zweite frage, Gibt es eine elegantere löschung von WPF heraus?
Dritte ..., wobei es eher eine Antort ist- Code auf Stackoverflow hab ich schon gefunden und musst festellen, das irgendwie auch nicht geht Oo
//Update:
Mit dem hinzufügen und dem manuellen ausrichten, sitzt die anwendung, aber nur, wenn ich sie auf dem Hauptbildschrim starte.
MfG
Facebamm
ich bin gerade dabei meine Anwendung über zwei Monitore zu strecken
Das ganze wollte ich via WINAIP machen:
ShitCode
C#-Quellcode
- private void SetupScreen() {
- if (Screen.AllScreens.Length > 1) {
- Screen[] screen = Screen.AllScreens;
- Screen second = screen.FirstOrDefault(x => !x.Primary);
- Point location = Screen.PrimaryScreen.Bounds.X < second.Bounds.X
- ? PointToScreen(Screen.PrimaryScreen.Bounds.Location.ConvertWinPoint())
- : PointToScreen(second.Bounds.Location.ConvertWinPoint());
- Utils.MoveWindow(this, location.X, 0, CustomWidth = second.Bounds.Width + Screen.PrimaryScreen.Bounds.Width, CustomHeight = second.Bounds.Height);
- }
- }
- ...
- public static void MoveWindow(this Window window,double left, double top, double width, double height) {
- int pxLeft = 0, pxTop = 0;
- if (left != 0 || top != 0)
- window.TransformToPixels(left, top,
- out pxLeft, out pxTop);
- int pxWidth, pxHeight;
- window.TransformToPixels(width, height, out pxWidth, out pxHeight);
- // Adding missing pixel
- //pxWidth +=14; Grash damit
- //pxHeight += 14; Grash damit
- var helper = new WindowInteropHelper(window);
- SetWindowPos(helper.Handle, new IntPtr(0x0), pxLeft, pxTop, pxWidth, pxHeight, 0x0040);
- }
- public static void TransformToPixels(this Visual visual, double unitX, double unitY, out int pixelX, out int pixelY) {
- Matrix matrix;
- var source = PresentationSource.FromVisual(visual);
- if (source != null) {
- matrix = source.CompositionTarget.TransformToDevice;
- } else {
- using (var src = new HwndSource(new HwndSourceParameters())) {
- matrix = src.CompositionTarget.TransformToDevice;
- }
- }
- pixelX = (int)(matrix.M11 * unitX);
- pixelY = (int)(matrix.M22 * unitY);
- }
- [DllImport("user32.dll", CharSet = CharSet.Auto)]
- [return: MarshalAs(UnmanagedType.Bool)]
- private static extern bool SetWindowPos(IntPtr hWnd, IntPtr hWndInsertAfter, int X, int Y, int cx, int cy, int flag);
problem bei dir ganzen sache ich nun, das wenn ich mir von MoveWindow-Methode das "window" anschaue habe ich ein AktuelleBreite von 1934 und eine AktuelleHöhe von 1094, was aus meiner sicht kein sinn macht, das mein Bildschrim 1920x1080 ist.
Erste frage, wo kommen die 14 Pixel her in W und H?
Zweite frage, Gibt es eine elegantere löschung von WPF heraus?
Dritte ..., wobei es eher eine Antort ist- Code auf Stackoverflow hab ich schon gefunden und musst festellen, das irgendwie auch nicht geht Oo
//Update:
Mit dem hinzufügen und dem manuellen ausrichten, sitzt die anwendung, aber nur, wenn ich sie auf dem Hauptbildschrim starte.
MfG
Facebamm
Dieser Beitrag wurde bereits 2 mal editiert, zuletzt von „Facebamm“ ()