QB64 Phoenix Edition
Can I restrict attempted resizing of a screen to an invalid side? - Printable Version

+- QB64 Phoenix Edition (https://staging.qb64phoenix.com)
+-- Forum: Chatting and Socializing (https://staging.qb64phoenix.com/forumdisplay.php?fid=11)
+--- Forum: General Discussion (https://staging.qb64phoenix.com/forumdisplay.php?fid=2)
+--- Thread: Can I restrict attempted resizing of a screen to an invalid side? (/showthread.php?tid=359)



Can I restrict attempted resizing of a screen to an invalid side? - hanness - 05-06-2022

Apologies for so many questions. Unfortunately, there are just some things I cannot seem to figure out on my own :-)

Let's assume a create a screen like this:

 
Code: (Select All)
                oldimage& = handle&
                handle& = _NewImage(Horizontal, Vertical, 256)
                Screen handle&
                _FullScreen _Off
                _FreeImage oldimage&

I allow the user to resize the screen, but I want to restrict them from making the windows smaller than 400 x 400. That part I can do. I simply check the width and height after resizing the screen and if either width or height is less than 400 I change it to 400.

My concern is that while the user is dragging a corner of the screen to resize it, they can drag it to a point where it causes my program to crash while they are still dragging the corner but before I can check it and resize it. See the screenshot below for an example.

Put another way, I can check the size of the screen AFTER they have resized it, but I can't prevent them from dragging the corners to a ridiculously small size that causes a crash. Is there any way to prevent this?

   


RE: Can I restrict attempted resizing of a screen to an invalid side? - Pete - 05-07-2022

If there isn't a technical way to do it, I'd just error trap it and have the error routine resize the window to the minimum size. Maybe even put up a warning for the user.

Look up ON ERROR

Pete


RE: Can I restrict attempted resizing of a screen to an invalid side? - SMcNeill - 05-07-2022

About the only way I know to handle such issues flawlessly is to turn $RESIZE off and then handle sizing internally via some user dialog.

INPUT "How wide would you like the screen (400 to _DESKTOPWIDTH) pixels: ", wide
If wide < 400 then SlapTheUser_SetWideTo400


RE: Can I restrict attempted resizing of a screen to an invalid side? - hanness - 05-09-2022

I managed to get this working. I implement it in the "Word Clock" program that I posted yesterday. If the user attempts to resize to something smaller than 200 pixels high or wide, the program automatically forces it back to the minimum of 200 x 200.