Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Precisely adjust window size
#1
After executing the following code, the measured window X coordinate is -7, the measured window width is 1373, and the height is 553.

The reason for this result seems to be that there is a certain margin between the left border, right border, and bottom border of the window.
Can optional parameters be added to solve this problem?
 
Code:
Copy      Help
var wc = wnd.find(1, "* - Google Chrome", "Chrome_WidgetWin_1");
wc.Move(0, 0, 1386, 560);
#2
It seems that only certain specific windows(E.g: Chrome) have borders; most windows can be precisely moved using the Move command.
#3
I tested on Windows 11. Chrome and other windows are exactly where moved.

Code:
Copy      Help
var w = wnd.find(1, "* - Google Chrome", "Chrome_WidgetWin_1");
w.Move(0, 0, 1386, 560);
print.it(w.Rect); //{L=0 T=0 W=1386 H=560}
500.ms();
print.it(w.Rect); //{L=0 T=0 W=1386 H=560}
#4
My previous expression may not have been accurate.
What I meant was the actual position, width, and height of the window after it's been moved on the screen.

The left border of the window is positioned at a certain distance from the left edge of the screen after it's been moved.

My System Win10 Pro 1909

Demo:
https://i.ibb.co/WxhqVGd/abc.gif
#5
Code:
Copy      Help
var w = wnd.find(1, "* - Google Chrome", "Chrome_WidgetWin_1");
w.MoveVisibleArea(0, 0, 1386, 560);
print.it(w.Rect);
if (w.GetRect(out var r, withoutExtendedFrame: true)) print.it(r);


static class MyExtWnd {
    /// <summary>
    ///
Moves this window as if its rectangle does not include the transparent frame.
    /// </summary>
    ///
<exception cref="AuWndException">Invalid window.</exception>
    public static void MoveVisibleArea(this wnd t, RECT r) {
        if (!t.GetRect(out var rTrue) || !t.GetRect(out var rVisible, withoutExtendedFrame: true)) throw new AuWndException(t);
        if (rVisible != rTrue) {
            r.left -= rVisible.left - rTrue.left;
            r.right += rTrue.right - rVisible.right;
            r.bottom += rTrue.bottom - rVisible.bottom;
        }

        t.MoveL(r);
    }

    
    /// <inheritdoc cref="MoveVisibleArea(wnd, RECT)"/>
    public static void MoveVisibleArea(this wnd t, int left, int top, int width, int height)
        => MoveVisibleArea(t, new(left, top, width, height));
}
#6
Got it, thank you.
It would be more convenient to use if the above functionality could be added as a parameter to the Move function's properties.

w.MoveVisibleArea(0, 0, 500, 300);

out:

{L=0 T=0 W=502 H=300}
#7
In next LA Move etc have parameter visibleRect. Thank you.
 

Quote:{L=0 T=0 W=502 H=300}

The window refuses to be smaller than 502.


Forum Jump:


Users browsing this thread: 1 Guest(s)