logo
down
shadow

WPF Window reserves space for scrollbar in client area when maximized


WPF Window reserves space for scrollbar in client area when maximized

By : Monik Pamecha
Date : November 17 2020, 11:55 AM
fixed the issue. Will look into that further The reason is that you are setting MaxWidth to be too small when it's maximized.
If the window is maximized, the size of Window will be 1382 x 744 (in order to "go to fullscreen". That's basically (1366 + 2*ClientWIndowEdges) x (768 - some amount stripped away from titlebar and bottom).
code :
<Window x:Class="myNamespace.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
    <Window.Style>
        <Style TargetType="Window">
            <Style.Setters>
                <Setter Property="MaxWidth" Value="1366" />
                <Setter Property="MaxHeight" Value="768"></Setter>

            </Style.Setters>

            <Style.Triggers>
                <Trigger Property="WindowState" Value="Maximized">
                    <Setter Property="MaxWidth" Value="9999" />
                    <Setter Property="MaxHeight" Value="9999"></Setter>
                </Trigger>
            </Style.Triggers>
        </Style>
    </Window.Style>

    <Grid Background="LightBlue"></Grid>
</Window>
private readonly int _maxHeight = 760;
private readonly int _maxWidth = 1366;

public MainWindow()
{
    InitializeComponent();

    DependencyPropertyDescriptor dpd = DependencyPropertyDescriptor.FromProperty
          (WindowStateProperty, typeof (MainWindow));

    dpd.AddValueChanged(this, (sender, args) =>
    {
        if (WindowState == WindowState.Maximized)
        {
            var interopHelper = new WindowInteropHelper(this);
            var barInfo = PInvokeWrapper.GetTitleBarInfoEx(interopHelper.Handle);

            var borderWidth = barInfo.rcTitleBar.Left;

            MaxWidth = _maxWidth + borderWidth;
        }
        else
        {
            MaxWidth = _maxWidth;
            MaxHeight = _maxHeight;
        }
    });

    WindowState = WindowState.Normal;
 }


Share : facebook icon twitter icon
IE reserves space for scrollbar in frame

IE reserves space for scrollbar in frame


By : user3373303
Date : March 29 2020, 07:55 AM
wish helps you Sorry i cant comment under the question.
Did you try to replace the scrolling with an oveflow?
Receive a signal when the window in focus is maximized and when it leaves maximized mode

Receive a signal when the window in focus is maximized and when it leaves maximized mode


By : Richie
Date : March 29 2020, 07:55 AM
will help you I'm not aware of any solution ready to be used out of the box but you can easily accomplish what requested by leveraging libwnck. In the following a quite basic example that catches any maximization on the current screen:
code :
/* gcc $(pkg-config --cflags --libs libwnck-1.0) test.c -o test */

#include <gdk/gdk.h>

#define WNCK_I_KNOW_THIS_IS_UNSTABLE
#include <libwnck/libwnck.h>


static void
geometry_changed(WnckWindow *window)
{
    if (wnck_window_is_maximized(window)) {
        g_print("A window has been maximized\n");
    }
}

static void
window_opened(WnckScreen *screen, WnckWindow *window)
{
    g_signal_connect(window, "geometry-changed",
                     G_CALLBACK(geometry_changed), NULL);

    /* Force a geometry-changed emission on already opened windows:
     * remove it if you need to catch only *new* maximizations */
    geometry_changed(window);
}

gint
main(gint argc, gchar *argv[])
{
    GMainLoop *loop;
    WnckScreen *screen;

    gdk_init(&argc, &argv);

    screen = wnck_screen_get(0);
    g_signal_connect(screen, "window-opened",
                     G_CALLBACK(window_opened), NULL);

    loop = g_main_loop_new(NULL, FALSE);
    g_main_loop_run(loop);
    g_main_loop_unref(loop);

    return 0;
}
static void
active_window_changed(WnckScreen *screen)
{
    WnckWindow *active_window = wnck_screen_get_active_window(screen);
    if (wnck_window_is_maximized(active_window)) {
        g_print("The active window is maximized\n");
    }
}

...
g_signal_connect(screen, "active-window-changed",
                 G_CALLBACK(active_window_changed), NULL);
...
Obtain non-maximized window position/size when window is maximized

Obtain non-maximized window position/size when window is maximized


By : hoanggiang12
Date : March 29 2020, 07:55 AM
should help you out The best way to solve this I found is to use the RestoreBounds structure. When a window is maximized, RestoreBounds will refer to the old (non-maximized) size and position. Here is the code to find out these values. Simply save these values upon closing, and then when the program is reopened, you can set the Width, Height, Location.X and Location.Y of the form back to these saved values.
code :
bool b = WindowState == FormWindowState.Maximized;
int xpos = !b? Location.X : RestoreBounds.X;
int ypos = !b? Location.Y : RestoreBounds.Y;
int width = !b? Width : RestoreBounds.Width;
int height = !b? Height : RestoreBounds.Height;
Python Tkinter : Area of Scrollbar Frame Window Expand Vertically when main window is resized

Python Tkinter : Area of Scrollbar Frame Window Expand Vertically when main window is resized


By : Alex Blackburn
Date : March 29 2020, 07:55 AM
it fixes the issue I'm not entirely what you mean by "frame window" -- those terms are mutually exclusive. A frame is a widget that is in a window. I'm going to assume you want the frame full of widgets to expand.
You have a couple of problems working against you. The first is that you're putting the canvas in a frame, but you haven't configured the frame to expand. If the frame doesn't expand, the canvas can't either.
code :
myframe.pack(side="top", fill="both", expand=True, padx=10, pady=10)
myframe.place(x=10,y=10, relwidth=1.0, relheight=1.0, width=-20, height=-20)
canvas.pack(side="left", fill="both", expand=True)
How do I create a new python tkinter window so fits exactly in the available desktop area, but isn't maximized?

How do I create a new python tkinter window so fits exactly in the available desktop area, but isn't maximized?


By : user3159093
Date : March 29 2020, 07:55 AM
I wish this help you I GOT IT! The trick is that as long as the window's visible (even if it's somewhere offscreen), you can do this:
code :
titlebarHeight = window.winfo_rooty() - window.winfo_y()
borderSize= window.winfo_rootx() - window.winfo_x()
WindowWidth = WindowWidth - (borderSize * 2)
WindowHeight = (WindowHeight - titlebarHeight) - borderSize
#Get screen height and width WITHOUT including the taskbar.
#This part works fine - I've tested the result and it's good.
from win32api import GetMonitorInfo, MonitorFromPoint
monitorInfo = GetMonitorInfo(MonitorFromPoint((0,0)))
workArea = monitorInfo.get("Work")
screenAvailableWidth = workArea[2]
screenAvailableHeight = workArea[3]

#Create a tkinter window
from tkinter import Tk 
window = Tk()

#Set new window height & width
#--------------------------------------------
#-----   HERE. This is what changed:    -----
#--------------------------------------------
#Make window visible so we can get some geometry
window.update_idletasks()
#Calculate title bar and border size
titlebarHeight = window.winfo_rooty() - window.winfo_y()
borderSize= window.winfo_rootx() - window.winfo_x()

#Start with full available screen
windowWidth = screenAvailableWidth
windowHeight = screenAvailableHeight

#Adjust for title bar and borders
windowWidth = windowWidth - (borderSize * 2 )
windowHeight = (windowHeight - titlebarHeight) - borderSize
#--------------------------------------------

#Show debug info
print("")
print("screenAvailableWidth:",screenAvailableWidth,
      " screenAvailableHeight:",screenAvailableHeight)
print("windowWidth:\t",windowWidth," windowHeight:\t",windowHeight)

#Set the new window to upper left corner and height &
# width of screen (after adjustment)
window.geometry("{}x{}+0+0".format(windowWidth,windowHeight))

#Show the window
window.mainloop()
shadow
Privacy Policy - Terms - Contact Us © ourworld-yourmove.org