D
D
Dmitry2011-10-17 19:15:44
GTK+
Dmitry, 2011-10-17 19:15:44

How to correctly restore the window size on application startup in Gtk# ?

I am writing an application in C# using GTK#.

There is a small problem, which, upon closer examination, has turned into not at all “small”.
I need to save the application window size and maximize flag between launches.
I save the data in the config, this is not a problem. But when trying to restore the saved window size at application startup, I ran into inadequate difficulties.
Tried the following methods:

this.SetSizeRequest((int)config["windowwidth"], (int)config["windowheight"]);


this.SetDefaultSize((int)config["windowwidth"], (int)config["windowheight"]);


this.Resize((int)config["windowwidth"], (int)config["windowheight"]);


Some of these methods do nothing at all, while others work strangely: they set the window to the wrong size, make the window expand indefinitely, and so on.

I also have a single widget size limit:

Gdk.Geometry geom = new Gdk.Geometry();
geom.MinWidth = 800;
geom.MinHeight = 400;
this.SetGeometryHints(BoxNotebook, geom, Gdk.WindowHints.MinSize);


When I use it all together, it turns into a completely misbehaving window.

How all the same it is correct to restore the size of a window at application start?

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question