[Gambas-user] Fit Form to PictureBox
Gian
bagoneo at ...69...
Wed Dec 31 15:55:26 CET 2014
Il 31/12/2014 15:30, Tobias Boege ha scritto:
> On Wed, 31 Dec 2014, Gian wrote:
>> Il 31/12/2014 01:25, Tobias Boege ha scritto:
>>> Hi,
>>>
>>> I'm trying to have FMain automatically adjust its size according to its sole
>>> (for demonstration) child control PictureBox1. The PictureBox1 itself is
>>> AutoResize = True and gets a big Picture. (Attached is a little project.)
>>>
>>> What happens is that PictureBox1 resizes accordingly, so I thought I set
>>> FMain.AutoResize = True but FMain does not react to the growing PictureBox1.
>>> The interplay between AutoResize, Expand, the parent's Arrangement and a
>>> PictureBox' Stretch has always been obscure to me. Does anyone have a
>>> solution?
>>>
>>> Regards,
>>> Tobi
>>>
>>>
>>>
>>> ------------------------------------------------------------------------------
>>> Dive into the World of Parallel Programming! The Go Parallel Website,
>>> sponsored by Intel and developed in partnership with Slashdot Media, is your
>>> hub for all things parallel software development, from weekly thought
>>> leadership blogs to news, videos, case studies, tutorials and more. Take a
>>> look and join the conversation now. http://goparallel.sourceforge.net
>>>
>>>
>>>
>>> _______________________________________________
>>> Gambas-user mailing list
>>> Gambas-user at lists.sourceforge.net
>>> https://lists.sourceforge.net/lists/listinfo/gambas-user
>>>
>>
>> Tobia,
>> I'm embarrassed to answer, you are a guru and surely you know this:
>> Picture PictureBox1.Picture = ["icon: / 96 / access"]
>> Me.H = PictureBox1.H
>> Me.W = PictureBox1.W
>> because it does not satisfy you?
>
> You're right, this solves the (accidentally over-)simplified scenario I
> described. What I havent't told you is that my actual application will have
> some levels of layout containers (Panel, HBox, VBox) and then a PictureBox.
> Of course there will be other controls and containers next to this hierarchy
> and thus using W and H to calculate the correct dimensions will be tedious.
>
> Meanwhile I had a look at the sources and it turns out I need to make gb.qt4
> call a thing called arrange_now(). I can achieve that by the sequence
>
> myContainer.AutoResize = False
> myContainer.AutoResize = True
>
> and indeed if the PictureBox' immediate parent is a Panel or Form and has
> Arrangement = Horizontal when executing this sequence, the container will
> grow in width together with the picture, and so forth up the container
> hierarchy.
>
> My next problem was to have the parents not only grow in width but in width
> and height. This happens when arrange_now() is called once with Arrangement
> = Horizontal and once with Arrangement = Vertical. The change of Arrangement
> also triggers a call to arrange_now(), so I just have to do
>
> myContainer.Arrangement = Arrange.Vertical
> myContainer.Arrangement = Arrange.Horizontal
>
> in addition to AutoResize being True, to force a re-layout (for Panel and
> Form containers). The only problem is other controls which are unwantedly
> resized during the Arrangement change but I can deal with it by setting
> those controls' Ignore = True temporarily. Not pretty but it works, as you
> can see in the attached project.
>
> Now it's up to Benoit to decide if this is worth adding another method, like
> Container.Rearrange(). It would call arrange_now() and somehow have
> AutoResize containers re-calculate their dimensions (preferably recursive).
> (Or to wire this stuff into Container.Refresh()). I'm not particularly happy
> with my hack but I don't care enough to insist that there be a new method
> for this scenario. But to rephrase my initial question: what is AutoResize
> supposed to do (or *when*) if it cannot automatically resize a container
> when children resize? (I noticed that the automatic resizing is done
> perfectly in both directions and automatically if I put the large picture
> into the PictureBox before the form is shown at all...)
>
> Regards,
> Tobi
>
>
>
> ------------------------------------------------------------------------------
> Dive into the World of Parallel Programming! The Go Parallel Website,
> sponsored by Intel and developed in partnership with Slashdot Media, is your
> hub for all things parallel software development, from weekly thought
> leadership blogs to news, videos, case studies, tutorials and more. Take a
> look and join the conversation now. http://goparallel.sourceforge.net
>
>
>
> _______________________________________________
> Gambas-user mailing list
> Gambas-user at lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/gambas-user
>
Hello Tobias,
I was sure that answering to you I would have done a good business :)
happy new year
Gianluigi
More information about the User
mailing list