Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
$RESIZE questions
#3
I don't know why this crazy stuff happens to me. I'm getting 640x480 using _RESIZEWIDTH and _RESIZEHEIGHT with no $RESIZE:ON directive in the following code.

Change _NEWIMAGE to 800 and 600 and you'll see _RESIZEWIDTH and _RESIZEHEIGHT reflect that too.

Code: (Select All)

OPTION _EXPLICIT

TYPE TYPE_IPOINT
    x AS LONG
    y AS LONG
END TYPE

TYPE TYPE_RECT
    left AS LONG
    top AS LONG
    right AS LONG
    bottom AS LONG
END TYPE



DECLARE DYNAMIC LIBRARY "user32"
    'get current mouse x/y position
    'http://allapi.mentalis.org/apilist/GetCursorPos.shtml
    FUNCTION GetCursorPos% (lpPoint AS TYPE_IPOINT)
    'system window metrics in pixels
    'https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-getsystemmetrics
    FUNCTION GetSystemMetrics% (BYVAL nIndex AS INTEGER)
    '
    '-  4: Window caption height
    '-  5: Window border width
    '-  6: Window border height
    '- 32: The width of the sizing border around the perimeter of a window that can be resized
    '- 33: The height of the sizing border around the perimeter of a window that can be resized
    '
    'To get actual border width : 32 - 5
    'To get actual border height: 33 - 6

    FUNCTION GetWindowRect% (BYVAL hWnd AS _INTEGER64, lpRect AS TYPE_RECT) ' returns desktop coordinates (_SCREENX, _SCREENY)-(x2, y2)
    '
    ' The rectangle returned
    '    - .left  : desktop left  x coordinate
    '    - .top    : desktop top    y coordinate
    '    - .right  : desktop right  x coordinate + 1
    '    - .bottom : desktop bottom y coordinate + 1


    FUNCTION GetClientRect% (BYVAL hWnd AS _INTEGER64, lpRect AS TYPE_RECT) ' returns (0, 0)-(_WIDTH, _HEIGHT)

    FUNCTION IsZoomed% (BYVAL hWnd AS _INTEGER64) ' reports a maximized window (_FULLSCREEN)

END DECLARE


TYPE TYPE_WINDOWAREA '          WINDOW AREA PROPERTIES
    Rect AS TYPE_RECT '          area coordinates
    Width AS INTEGER '          area width
    Height AS INTEGER '          area height
    Border AS INTEGER '          area border
END TYPE

TYPE TYPE_PROGRAMWINDOW '        PROGRAM WINDOW PROPERTIES
    Main AS TYPE_WINDOWAREA '    main  window coordinates, width, height (absolute to desktop)
    Client AS TYPE_WINDOWAREA '  client  area coordinates, width, height (absolute to desktop)
    Caption AS TYPE_WINDOWAREA ' caption area coordinates, width, height (absolute to desktop)
END TYPE

DIM Program AS TYPE_PROGRAMWINDOW ' program window properties
DIM Success AS INTEGER

SCREEN _NEWIMAGE(640, 480, 32)

DO
    _LIMIT 60
    LOCATE 1, 1
    PRINT _RESIZEWIDTH, _RESIZEHEIGHT
    IF _RESIZE THEN
        BEEP
        CLS
        PRINT
        IF ProgramWindowUpdate THEN
            PRINT " Program Width  :"; ProgramWidth
            PRINT " Program Height :"; ProgramHeight
            PRINT " Program Left  :"; ProgramLeft
            PRINT " Program Top    :"; ProgramTop
            PRINT " Program Right  :"; ProgramRight
            PRINT " Program Bottom :"; ProgramBottom
            PRINT " Program Border :"; ProgramBorder
            PRINT
            PRINT " Client Width  :"; ClientWidth
            PRINT " Client Height  :"; ClientHeight
            PRINT " Client Left    :"; ClientLeft
            PRINT " Client Top    :"; ClientTop
            PRINT " Client Right  :"; ClientRight
            PRINT " Client Bottom  :"; ClientBottom
            PRINT " Client Border  :"; ClientBorder
            PRINT
            PRINT " Caption Width  :"; CaptionWidth
            PRINT " Caption Height :"; CaptionHeight
            PRINT " Caption Left  :"; CaptionLeft
            PRINT " Caption Top    :"; CaptionTop
            PRINT " Caption Right  :"; CaptionRight
            PRINT " Caption Bottom :"; CaptionBottom
        ELSE
            PRINT " There was an error retrieveing the program window properties."
        END IF
    END IF
LOOP




FUNCTION ProgramWindowUpdate% ()

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties
    DIM Rect AS TYPE_RECT '                rectangle structure
    DIM Success AS INTEGER '              0 if API call failed, non zero otherwise

    _DELAY .1 ' LOOK ------------------------------------------------------------------>  this delay may need to be longer
    Success = GetWindowRect(_WINDOWHANDLE, Rect) '                                        get program window desktop coordinates
    IF Success THEN '                                                                    were the coordinates gotten successfully?
        Program.Client.Border = GetSystemMetrics(5) '                                    yes, client area border width/height
        Program.Main.Width = Rect.right - Rect.left '                                    width of main program window
        Program.Main.Height = Rect.bottom - Rect.top '                                    height of main program window
        Program.Main.Rect.left = Rect.left '                                              desktop left  x coordinate of main program window (_SCREENX)
        Program.Main.Rect.top = Rect.top '                                                desktop top    y coordinate of main program window (_SCREENY)
        Program.Main.Rect.right = Rect.right - 1 '                                        desktop right  x coordinate of main program window
        Program.Main.Rect.bottom = Rect.bottom - 1 '                                      desktop bottom y coordinate of main program window
        Program.Main.Border =      (Program.Main.Width - _WIDTH(0)) \ 2 - _
                                  Program.Client.Border '                                main program window border width/height
        Program.Client.Height = _HEIGHT '                                                height of client area
        Program.Caption.Height =  Program.Main.Height - Program.Client.Height - _
                                  Program.Main.Border * 2 - Program.Client.Border * 2 '  caption area height
        Program.Client.Width = _WIDTH '                                                  width of client area
        Program.Client.Rect.left = Program.Main.Rect.left + Program.Main.Border + _
                                  Program.Client.Border '                                desktop left  x coordinate of client area
        Program.Client.Rect.top =  Program.Main.Rect.top + Program.Main.Border + _
                                  Program.Caption.Height + Program.Client.Border '      desktop top    y coordinate of client area
        Program.Client.Rect.right = Program.Client.Rect.left + _WIDTH - 1 '              desktop right  x coordinate of client area
        Program.Client.Rect.bottom = Program.Client.Rect.top + _HEIGHT - 1 '              desktop bottom y coordinate of client area
        Program.Caption.Width = Program.Client.Width '                                    width of caption area
        Program.Caption.Rect.left = Program.Client.Rect.left '                            desktop left x coordinate of caption area
        Program.Caption.Rect.top = Program.Main.Border + Program.Client.Border '          desktop top y coordinate of caption area
        Program.Caption.Rect.right = Program.Client.Rect.right '                          desktop right x coordinate of caption area
        Program.Caption.Rect.bottom = Program.Caption.Rect.top + Program.Caption.Height ' desktop bottom y coordinate of caption area
        ProgramWindowUpdate% = Success '                                                  return success status of operation
    END IF

END FUNCTION


FUNCTION ProgramWidth% ()

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    ProgramWidth% = Program.Main.Width '  yes, return the set value

END FUNCTION

FUNCTION ProgramHeight% ()

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    ProgramHeight% = Program.Main.Height

END FUNCTION

FUNCTION ProgramLeft% ()

    ' Note: Same as _SCREENX

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    ProgramLeft% = Program.Main.Rect.left

END FUNCTION

FUNCTION ProgramTop% ()

    ' Note: Same as _SCREENY

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    ProgramTop% = Program.Main.Rect.top

END FUNCTION

FUNCTION ProgramRight% ()

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    ProgramRight% = Program.Main.Rect.right

END FUNCTION

FUNCTION ProgramBottom% ()

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    ProgramBottom% = Program.Main.Rect.bottom

END FUNCTION

FUNCTION ProgramRect% (ReturnRect AS TYPE_RECT)

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    ReturnRect = Program.Main.Rect

END FUNCTION

FUNCTION ProgramBorder% ()

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    ProgramBorder% = Program.Main.Border

END FUNCTION

FUNCTION ClientWidth% ()

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    ClientWidth% = Program.Client.Width

END FUNCTION

FUNCTION ClientHeight% ()

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    ClientHeight% = Program.Client.Height

END FUNCTION

FUNCTION ClientLeft% ()

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    ClientLeft% = Program.Client.Rect.left

END FUNCTION

FUNCTION ClientTop% ()

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    ClientTop% = Program.Client.Rect.top

END FUNCTION

FUNCTION ClientRight% ()

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    ClientRight% = Program.Client.Rect.right

END FUNCTION

FUNCTION ClientBottom% ()

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    ClientBottom% = Program.Client.Rect.bottom

END FUNCTION

FUNCTION ClientRect% (ReturnRect AS TYPE_RECT)

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    ReturnRect = Program.Client.Rect

END FUNCTION

FUNCTION ClientBorder% ()

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    ClientBorder% = Program.Client.Border

END FUNCTION

FUNCTION CaptionWidth% ()

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    CaptionWidth% = Program.Caption.Width

END FUNCTION

FUNCTION CaptionHeight% ()

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    CaptionHeight% = Program.Caption.Height

END FUNCTION

FUNCTION CaptionLeft% ()

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    CaptionLeft% = Program.Caption.Rect.left

END FUNCTION

FUNCTION CaptionTop% ()

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    CaptionTop% = Program.Caption.Rect.top

END FUNCTION

FUNCTION CaptionRight% ()

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    CaptionRight% = Program.Caption.Rect.right

END FUNCTION

FUNCTION CaptionBottom% ()

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    CaptionBottom% = Program.Caption.Rect.bottom

END FUNCTION

FUNCTION CaptionRect% (ReturnRect AS TYPE_RECT)

    SHARED Program AS TYPE_PROGRAMWINDOW ' program window properties

    ReturnRect = Program.Caption.Rect

END FUNCTION
New to QB64pe? Visit the QB64 tutorial to get started.
QB64 Tutorial
Reply


Messages In This Thread
$RESIZE questions - by TerryRitchie - 06-06-2024, 09:09 PM
RE: $RESIZE questions - by SMcNeill - 06-06-2024, 10:22 PM
RE: $RESIZE questions - by TerryRitchie - 06-07-2024, 12:30 AM
RE: $RESIZE questions - by SMcNeill - 06-07-2024, 12:36 AM
RE: $RESIZE questions - by TerryRitchie - 06-07-2024, 12:38 AM
RE: $RESIZE questions - by SMcNeill - 06-07-2024, 12:40 AM
RE: $RESIZE questions - by TerryRitchie - 06-07-2024, 04:37 AM
RE: $RESIZE questions - by SMcNeill - 06-07-2024, 08:05 AM
RE: $RESIZE questions - by TerryRitchie - 06-07-2024, 03:38 PM



Users browsing this thread: 1 Guest(s)