You are not logged in or registered. Please login or register to use the full functionality of this board...
SIGN IN Join Our Community For FREE


The Correct Way to $Resize a QB64 Window
08-01-2014, 07:48 AM (This post was last modified: 08-02-2014 02:22 AM by Waltersmind.)
Post: #1
 (Print Post)
The Correct Way to $Resize a QB64 Window
The following demo requires the use of the latest QB64 dirty build to work correctly, at least from 7/30/14 and up.

This demo demonstrates the correct way to resize a QB64 application window.



Code Snippet: [Select]
' *** Turn on the window resizing.
$RESIZE:ON

DeskTop& = _SCREENIMAGE ' *** Capture the Desktop image
DT_Width& = _WIDTH(DeskTop&) ' *** Get the Desktop Width
DT_Height& = _HEIGHT(DeskTop&) ' *** Get the Desktop Height

' *** Create a new image for the demo and make it 200-pixels smaller in height and width than the desktop
MainScreen~& = _NEWIMAGE(DT_Width& - 200, DT_Height& - 200, 32)

' *** Set the SCREEN to our new MainImage
SCREEN MainScreen~&

' *** Center the SCREEN on the Desktop (Only works with the latest QB64-GL dirty build)
_SCREENMOVE (DT_Width& - _WIDTH(MainScreen~&)) / 2, (DT_Height& - _HEIGHT(MainScreen~&)) / 2 - 29

' *** Create a loop for an animation so the user has the chance to play with the window resizing.
DO

    ' *** Draw a bunch of circle outlines
    FOR i = 1 TO 50
        CIRCLE (RND * _WIDTH(MainScreen~&), RND * _HEIGHT(MainScreen~&)), RND * 200, _RGBA(RND * 256, RND * 256, RND * 256, RND * 256)
    NEXT

    ' *** Check to see if the user resized the window. If so, change the SCREEN image to the correct size.
    IF _RESIZE THEN

        ' *** First, create a copy of our first SCREEN image.
        MainScreen2~& = _COPYIMAGE(MainScreen~&)

        ' *** Set the SCREEN to the copied image, releasing the original SCREEN image.
        SCREEN MainScreen2~&

        ' *** Remove (FREE) the original SCREEN image.
        _FREEIMAGE MainScreen~&

        ' *** Create a new "original" SCREEN image.
        MainScreen~& = _NEWIMAGE(_RESIZEWIDTH, _RESIZEHEIGHT, 32)

        ' *** Set the SCREEN to the new "original" image, releasing the copied SCREEN image.
        SCREEN MainScreen~&

        ' *** Remove (FREE) the copied SCREEN image.
        _FREEIMAGE MainScreen2~&

    END IF

LOOP UNTIL _KEYHIT ' *** Continue doing the loop until a key is hit.

All you have to do is run the demo, resize the window a few times to see how it works. Also, this demo creates the application window at 400 pixels smaller, in both directions, than the desktop window, and centers it on screen.


Walter Whitman
the Joyful Programmer

Please help support The Joyful Programmer and The QB64 Edition by visiting our online store provided by Amazon.com. We hand-picked books related to computer programming from Amazon.com and added them to our store. When you make a purchase from our store, we do receive a small commission from the sale. Visit our store at: http://www.thejoyfulprogrammer.com/qb64/...azon-store
Find all posts by this user
Like Post



Forum Jump:


User(s) browsing this thread: 1 Guest(s)




QB64 Member Project - Amazon
QB64 Member Project - Swirl
QB64 Member Project - Martin Fractals version two
QB64 Member Project - Othello
QB64 Member Project - Dakapo
QB64 Member Project - Red Scrolling LED Sign
QB64 Member Project - Sabotage
QB64 Member Project - MAPTRIANGLE
QB64 Member Project - Kings Court
QB64 Member Project - Input
QB64 Member Project - STxAxTIC 3D World
QB64 Member Project - Spiro Roses
QB64 Member Project - Score 4
QB64 Member Project - ARB Checkers
QB64 Member Project - RGB Color Wheel
QB64 Member Project - Algeria Weather
QB64 Member Project - Kobolts Monopoly
QB64 Member Project - Pivot version two
QB64 Member Project - Kings Vallery version two
QB64 Member Project - Basic Dithering
QB64 Member Project - Bowditch curve
QB64 Member Project - Quarto
QB64 Member Project - Martin Fractals version three
QB64 Member Project - Splatter
QB64 Member Project - Touche
QB64 Member Project - Color Rotating Text
QB64 Member Project - Rubix's Magic
QB64 Member Project - 9 Board
QB64 Member Project - Full Color LED Sign
QB64 Member Project - Dreamy Clock
QB64 Member Project - Martin Fractals version four
QB64 Member Project - Spinning Color Wheel
QB64 Member Project - OpenGL Triangles
QB64 Member Project - Isolation
QB64 Member Project - Kings Valley verion one
QB64 Member Project - Domain
QB64 Member Project - Blokus
QB64 Member Project - Martin Fractals version one
QB64 Member Project - Qubic
QB64 Member Project - Pivet version one
QB64 Member Project - Overboard
QB64 Member Project - Foursight
QB64 Member Project - Exit
QB64 Member Project - Connect Four
QB64 Member Project - Color Triangles
QB64 Member Project - Point Blank
QB64 Member Project - Line Thickness
QB64 Member Project - Rotating Background
QB64 Member Project - Inside Moves