Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Snapback Windows
#1
Code: (Select All)
DECLARE LIBRARY
    FUNCTION glutGet& (BYVAL what&)
    SUB glutReshapeWindow (BYVAL width&, BYVAL height&)
END DECLARE

$RESIZE:ON
_DELAY 2
ClearTheFlag = _RESIZE

DO
    CLS , 3
    IF _RESIZE THEN
        RSW = _RESIZEWIDTH
        RSH = _RESIZEHEIGHT
        W = RSW \ _FONTWIDTH
        H = RSH \ _FONTHEIGHT
        IF W < 40 THEN W = 40
        IF H < 15 THEN H = 15
        IF W > 120 THEN W = 120
        IF H > 50 THEN H = 50
        f = _FONT
        WIDTH W, H
        _FONT f
        IF _WIDTH * _FONTWIDTH <> WindowWidth OR _HEIGHT * _FONTHEIGHT <> WindowHeight THEN
            glutReshapeWindow _WIDTH * _FONTWIDTH, _HEIGHT * _FONTHEIGHT
        END IF
        ClearTheFlag = _RESIZE
    END IF
    PRINT _WIDTH, _HEIGHT
    _DISPLAY
LOOP

FUNCTION WindowWidth
    WindowWidth = glutGet(102) '102 is the const value of GLUT_WINDOW_WIDTH
END FUNCTION

FUNCTION WindowHeight
    WindowHeight = glutGet(103) '103 is the const value of GLUT_WINDOW_HEIGHT
END FUNCTION

It's been a long time since I've had such a simple concept cause me such a large headache, so I can honestly say that this is one of the code snippets that I'm most proud of right now.

What's the basic concept here?   

Just make a resizable screen that refuses to go beyond the minimal/maximal boundaries set for it.

I'm not going to go into all the issues I ran into coming up with this, but if you want a nice challenge, try it for yourself -- Just write a simple little program with $RESIZE, where you can limit the minimum and maximum size that the user can drag that window and make it.

The only solution I found to this issue was to completely sidestep out of QB64 itself and step back over into glut, and make it do all the heavy lifting and work for us.  Sad

If one of you guys can come up with a native way to do this reliably with just QB64PE code, I'd love to see it.  I've broken my brain trying to get things to work as intended here.  (And I'm still not 110% certain that it still isn't going to break under some odd condition which I'm just not finding with my own testing at the moment!)
Reply


Messages In This Thread
Snapback Windows - by SMcNeill - 10-11-2023, 12:58 PM
RE: Snapback Windows - by TempodiBasic - 10-11-2023, 02:56 PM
RE: Snapback Windows - by James D Jarvis - 10-11-2023, 03:15 PM
RE: Snapback Windows - by SMcNeill - 10-11-2023, 05:32 PM



Users browsing this thread: 5 Guest(s)