Resize window keep proportion

  1. 2 months ago

    Hello,
    how can i keep the proportions -> width:height of a window on a window resizing-event?

    Thanks

    its that simple (0.666 is the ratio window height / window width)

    dim w as integer=self.Width
    self.Height=w*0.666

    works fine in resizing-event!

  2. Emile S

    May 15 Europe (France, Strasbourg)

    Compute the scale factor (use actual width and target width) and apply that value to Window1.Width and Window1.Height.

  3. i did but get an stack overflow exception

    dim w,h,wtarget,htarget as Double
    w=window1.Width
    h=Window1.Height
    dim factor as Double = w/h
    wtarget=w*factor
    htarget=h*factor
    
    window1.Width=wtarget
    window1.Height=htarget
  4. Emile S

    May 15 Europe (France, Strasbourg)
    Edited 2 months ago

    Strange… I use that trick to resize images and draw them in Canvas…

    I try and come back.

    You do not tell where (in which event) you execute the code…

    Do you do that in the Resized Event ?

  5. Edited 2 months ago

    in window.resizing-event because it should proportionally live resize

  6. Emile S

    May 15 Europe (France, Strasbourg)
    Edited 2 months ago

    That’s it: I moved it in a pushbutton and it works fine.

    Now, the questio is: why do you apply a code resize in the user’s back ?
    In other words, what your interface is that needs that kind of resize ?

    There may be a different way to achieve that goal, maybe.

  7. Emile S

    May 15 Europe (France, Strasbourg)

    @Marco W window.resizing-event

    How many times a second this event is fired ?
    (no, it's a rethorical question only).

  8. Sascha S

    May 15 Pre-Release Testers, Xojo Pro Germany

    @Marco W window1.Width=wtarget
    window1.Height=htarget

    I'd not recommend to do this in the Resizing Event ;)

  9. Emile S

    May 15 Europe (France, Strasbourg)

    Nor Resized Event, thus my test in a PushButton, then the question about why wanting to do so.

  10. as i wrote, live resize a window proportionally... ;-)

  11. Emile S

    May 15 Europe (France, Strasbourg)

    Yes, I understand that, but what is your motivation to do that; why the window size have to be changed after the user does it ?

    Example:
    Do you have a Canvas with an image that have to be resized proportionally ?

  12. Emile S

    May 15 Europe (France, Strasbourg)

    I may not be clear enough:

    doing a code resize while the window is resizing resized generate the stack overflow exception. So, uness using a timer / a thread / something to delegate the moment to execute the code, you will always get a stack overflow exception.

  13. no, there is a custom movie player on it and i don't want black bars so it has to resize proportionally...

  14. Beatrix W

    May 15 Pre-Release Testers Europe (Germany)

    If you do your code in the Resizing event, this will trigger a new Resizing event. Therefore, you get the StackOverflow. Try to move your code into the Resized event. Or manage your Resizing event with a boolean property.

  15. Emile S

    May 15 Europe (France, Strasbourg)

    Yes !

    Apply the resize there and make to window resize using the MoviePlayer Width/Height.

    Sorry not clear, but I hope you understand what I mean.

  16. Emile S

    May 15 Europe (France, Strasbourg)

    @Beatrix W Resized

    Same trouble there.

  17. Edited 2 months ago

    its that simple (0.666 is the ratio window height / window width)

    dim w as integer=self.Width
    self.Height=w*0.666

    works fine in resizing-event!

or Sign Up to reply!