FULLSCREEN (function): Difference between revisions

From QB64 Phoenix Edition Wiki
Jump to navigation Jump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 21: Line 21:
{{CodeStart}}
{{CodeStart}}
{{Cl|CLS}}
{{Cl|CLS}}
fontpath$ = {{Cl|ENVIRON$}}("SYSTEMROOT") + "\fonts\lucon.ttf" 'Find Windows Folder Path.
fontpath$ = {{Cl|ENVIRON$}}({{Text|<nowiki>"SYSTEMROOT"</nowiki>|#FFB100}}) + {{Text|<nowiki>"\fonts\lucon.ttf"</nowiki>|#FFB100}} {{Text|<nowiki>'Find Windows Folder Path.</nowiki>|#919191}}
f& = {{Cl|_FONT (function)|_FONT}}: defaultf& = f&
f& = {{Cl|_FONT (function)|_FONT}}: defaultf& = f&
{{Cl|DO}}
{{Cl|DO}}
  {{Cl|INPUT}} "1) DEFAULT  2) SIZE WINDOW  3) FULL SCREEN  4) FULL STRETCHED  Q) QUIT: ", winmode$
    {{Cl|INPUT}} {{Text|<nowiki>"1) DEFAULT  2) SIZE WINDOW  3) FULL SCREEN  4) FULL STRETCHED  Q) QUIT: "</nowiki>|#FFB100}}, winmode$


  {{Cl|IF}} {{Cl|UCASE$}}(winmode$) = "Q" {{Cl|THEN}} {{Cl|EXIT DO}}
    {{Cl|IF}} {{Cl|UCASE$}}(winmode$) = {{Text|<nowiki>"Q"</nowiki>|#FFB100}} {{Cl|THEN}} {{Cl|EXIT DO}}


  style$ = "MONOSPACE"
    style$ = {{Text|<nowiki>"MONOSPACE"</nowiki>|#FFB100}}


  {{Cl|SELECT CASE}} winmode$
    {{Cl|SELECT CASE}} winmode$
    {{Cl|CASE}} "1"
        {{Cl|CASE}} {{Text|<nowiki>"1"</nowiki>|#FFB100}}
      full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}} 'get current full screen mode
            full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}} {{Text|<nowiki>'get current full screen mode</nowiki>|#919191}}
      {{Cl|IF}} full <> 0 {{Cl|THEN}} {{Cl|_FULLSCREEN}} _OFF
            {{Cl|IF}} full <> {{Text|0|#F580B1}} {{Cl|THEN}} {{Cl|_FULLSCREEN}} {{Cl|_OFF}}
      {{Cl|GOSUB}} ChangeFont
            {{Cl|GOSUB}} ChangeFont


    {{Cl|CASE}} "2"
        {{Cl|CASE}} {{Text|<nowiki>"2"</nowiki>|#FFB100}}
      {{Cl|DO}}
            {{Cl|DO}}
        {{Cl|PRINT}}
                {{Cl|PRINT}}
        {{Cl|INPUT}} "Enter a FONT SIZE 5 to 25: ", fontsize%
                {{Cl|INPUT}} {{Text|<nowiki>"Enter a FONT SIZE 5 to 25: "</nowiki>|#FFB100}}, fontsize%
      {{Cl|LOOP}} {{Cl|UNTIL}} fontsize% > 4 {{Cl|AND (boolean)|AND}} fontsize% < 26
            {{Cl|DO...LOOP|LOOP UNTIL}} fontsize% > {{Text|4|#F580B1}} {{Cl|AND (boolean)|AND}} fontsize% < {{Text|26|#F580B1}}


      {{Cl|DO}}
            {{Cl|DO}}
        {{Cl|PRINT}}
                {{Cl|PRINT}}
        {{Cl|INPUT}} "Enter (0) for REGULAR or (1) for ITALIC FONT: ", italic%
                {{Cl|INPUT}} {{Text|<nowiki>"Enter (0) for REGULAR or (1) for ITALIC FONT: "</nowiki>|#FFB100}}, italic%
      {{Cl|LOOP}} {{Cl|UNTIL}} italic% = 0 or italic% = 1
            {{Cl|DO...LOOP|LOOP UNTIL}} italic% = {{Text|0|#F580B1}} {{Cl|OR (boolean)|OR}} italic% = {{Text|1|#F580B1}}


      {{Cl|DO}}
            {{Cl|DO}}
        {{Cl|PRINT}}
                {{Cl|PRINT}}
        {{Cl|INPUT}} "Enter (0) for REGULAR or (1) for BOLD FONT: ", bold%
                {{Cl|INPUT}} {{Text|<nowiki>"Enter (0) for REGULAR or (1) for BOLD FONT: "</nowiki>|#FFB100}}, bold%
      {{Cl|LOOP}} {{Cl|UNTIL}} italic% = 0 or italic% = 1
            {{Cl|DO...LOOP|LOOP UNTIL}} italic% = {{Text|0|#F580B1}} {{Cl|OR (boolean)|OR}} italic% = {{Text|1|#F580B1}}


      {{Cl|IF}} italic% = 1 {{Cl|THEN}} style$ = style$ + ", ITALIC"
            {{Cl|IF}} italic% = {{Text|1|#F580B1}} {{Cl|THEN}} style$ = style$ + {{Text|<nowiki>", ITALIC"</nowiki>|#FFB100}}
      {{Cl|IF}} bold% = 1 {{Cl|THEN}} style$ = style$ + ", BOLD"
            {{Cl|IF}} bold% = {{Text|1|#F580B1}} {{Cl|THEN}} style$ = style$ + {{Text|<nowiki>", BOLD"</nowiki>|#FFB100}}
      full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}} 'get current full screen mode
            full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}} {{Text|<nowiki>'get current full screen mode</nowiki>|#919191}}
      {{Cl|IF}} full <> 0 {{Cl|THEN}} {{Cl|_FULLSCREEN}} _OFF          
            {{Cl|IF}} full <> {{Text|0|#F580B1}} {{Cl|THEN}} {{Cl|_FULLSCREEN}} {{Cl|_OFF}}
      {{Cl|GOSUB}} ChangeFont
            {{Cl|GOSUB}} ChangeFont


    {{Cl|CASE}} "3"
        {{Cl|CASE}} {{Text|<nowiki>"3"</nowiki>|#FFB100}}
      {{Cl|GOSUB}} ChangeFont
            {{Cl|GOSUB}} ChangeFont
      {{Cl|_FULLSCREEN}} _SQUAREPIXELS
            {{Cl|_FULLSCREEN}} {{Cl|_SQUAREPIXELS}}
      {{Cl|GOSUB}} CheckFull
            {{Cl|GOSUB}} CheckFull
 
        {{Cl|CASE}} {{Text|<nowiki>"4"</nowiki>|#FFB100}}
            {{Cl|GOSUB}} ChangeFont
            {{Cl|_FULLSCREEN}} {{Cl|_STRETCH}}
            {{Cl|GOSUB}} CheckFull


    {{Cl|CASE}} "4"
      {{Cl|GOSUB}} ChangeFont
      {{Cl|_FULLSCREEN}} _STRETCH
      {{Cl|GOSUB}} CheckFull
           
     {{Cl|END SELECT}}
     {{Cl|END SELECT}}


     {{Cl|PRINT}}: {{Cl|PRINT}} "_FullScreen mode ="; {{Cl|_FULLSCREEN (function)|_FULLSCREEN}}
     {{Cl|PRINT}}: {{Cl|PRINT}} {{Text|<nowiki>"_FullScreen mode ="</nowiki>|#FFB100}}; {{Cl|_FULLSCREEN (function)|_FULLSCREEN}}
     {{Cl|PRINT}}
     {{Cl|PRINT}}
{{Cl|LOOP}}
{{Cl|LOOP}}
Line 76: Line 76:
{{Cl|END}}
{{Cl|END}}


CheckFull:   '<<<<<<<<<<<<<< turn off full screen if function returns 0!
CheckFull: {{Text|<nowiki>'<<<<<<<<<<<<<< turn off full screen if function returns 0!</nowiki>|#919191}}
full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}} 'get current full screen mode  
full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}} {{Text|<nowiki>'get current full screen mode</nowiki>|#919191}}
{{Cl|IF}} full = 0 {{Cl|THEN}} {{Cl|_FULLSCREEN}} _{{Cl|OFF}}: {{Cl|SOUND}} 100, .75
{{Cl|IF}} full = {{Text|0|#F580B1}} {{Cl|THEN}} {{Cl|_FULLSCREEN}} {{Cl|_OFF}}: {{Cl|SOUND}} {{Text|100|#F580B1}}, {{Text|.75|#F580B1}}
{{Cl|RETURN}}
{{Cl|RETURN}}


ChangeFont:
ChangeFont:
{{Cl|IF}} winmode$ <> "2" {{Cl|THEN}}
{{Cl|IF}} winmode$ <> {{Text|<nowiki>"2"</nowiki>|#FFB100}} {{Cl|THEN}}
  {{Cl|_FONT}} 16 'select inbuilt 8x16 default font
    {{Cl|_FONT}} {{Text|16|#F580B1}} {{Text|<nowiki>'select inbuilt 8x16 default font</nowiki>|#919191}}
     currentf& = {{Cl|_FONT (function)|_FONT}}
     currentf& = {{Cl|_FONT (function)|_FONT}}
{{Cl|ELSE}}
{{Cl|ELSE}}
  currentf& = {{Cl|_LOADFONT}}(fontpath$, fontsize%, style$)
    currentf& = {{Cl|_LOADFONT}}(fontpath$, fontsize%, style$)
  {{Cl|_FONT}} currentf&
    {{Cl|_FONT}} currentf&
{{Cl|END IF}}
{{Cl|END IF}}


{{Cl|IF}} currentf& <> f& {{Cl|AND (boolean)|AND}} f& <> defaultf& {{Cl|THEN}} {{Cl|_FREEFONT}} f&
{{Cl|IF}} currentf& <> f& {{Cl|AND (boolean)|AND}} f& <> defaultf& {{Cl|THEN}} {{Cl|_FREEFONT}} f&
f& = currentf&
f& = currentf&
{{Cl|RETURN}}  
{{Cl|RETURN}}
{{CodeEnd}}
{{CodeEnd}}



Latest revision as of 10:44, 29 March 2023

The _FULLSCREEN function returns the present full screen mode setting of the screen window.


Syntax

full% = _FULLSCREEN


Description

  • Function returns:
    • 0 = _OFF (any positive non-0 value means fullscreen is on)
    • 1 = _STRETCH
    • 2 = _SQUAREPIXELS
  • It cannot be assumed that calling _FULLSCREEN will succeed. It cannot be assumed that the type of full screen will match the requested one. Always check the _FULLSCREEN (function) return in your programs.
  • Warning: Despite your software, the user's hardware, drivers and monitor may not function in some modes. Thus, it is highly recommended that you manually confirm with the user whether the switch to full screen was successful. This can be done "quietly" in some cases by getting the user to click on a button on screen with their mouse or press an unusual key. If the user does not respond after about 8 seconds, switch them back to windowed mode.
Using large fonts with _FULLSCREEN can cause monitor or Windows Desktop problems or kill a program.


Examples

Example: Shows how fonts and the _FULLSCREEN mode can resize a program window.

CLS
fontpath$ = ENVIRON$("SYSTEMROOT") + "\fonts\lucon.ttf" 'Find Windows Folder Path.
f& = _FONT: defaultf& = f&
DO
    INPUT "1) DEFAULT  2) SIZE WINDOW  3) FULL SCREEN   4) FULL STRETCHED  Q) QUIT: ", winmode$

    IF UCASE$(winmode$) = "Q" THEN EXIT DO

    style$ = "MONOSPACE"

    SELECT CASE winmode$
        CASE "1"
            full = _FULLSCREEN 'get current full screen mode
            IF full <> 0 THEN _FULLSCREEN _OFF
            GOSUB ChangeFont

        CASE "2"
            DO
                PRINT
                INPUT "Enter a FONT SIZE 5 to 25: ", fontsize%
            LOOP UNTIL fontsize% > 4 AND fontsize% < 26

            DO
                PRINT
                INPUT "Enter (0) for REGULAR or (1) for ITALIC FONT: ", italic%
            LOOP UNTIL italic% = 0 OR italic% = 1

            DO
                PRINT
                INPUT "Enter (0) for REGULAR or (1) for BOLD FONT: ", bold%
            LOOP UNTIL italic% = 0 OR italic% = 1

            IF italic% = 1 THEN style$ = style$ + ", ITALIC"
            IF bold% = 1 THEN style$ = style$ + ", BOLD"
            full = _FULLSCREEN 'get current full screen mode
            IF full <> 0 THEN _FULLSCREEN _OFF
            GOSUB ChangeFont

        CASE "3"
            GOSUB ChangeFont
            _FULLSCREEN _SQUAREPIXELS
            GOSUB CheckFull

        CASE "4"
            GOSUB ChangeFont
            _FULLSCREEN _STRETCH
            GOSUB CheckFull

    END SELECT

    PRINT: PRINT "_FullScreen mode ="; _FULLSCREEN
    PRINT
LOOP
GOSUB ChangeFont
END

CheckFull: '<<<<<<<<<<<<<< turn off full screen if function returns 0!
full = _FULLSCREEN 'get current full screen mode
IF full = 0 THEN _FULLSCREEN _OFF: SOUND 100, .75
RETURN

ChangeFont:
IF winmode$ <> "2" THEN
    _FONT 16 'select inbuilt 8x16 default font
    currentf& = _FONT
ELSE
    currentf& = _LOADFONT(fontpath$, fontsize%, style$)
    _FONT currentf&
END IF

IF currentf& <> f& AND f& <> defaultf& THEN _FREEFONT f&
f& = currentf&
RETURN

Explanation: The _FULLSCREEN function can avoid screen display and monitor problems when used to monitor the success of the full screen operation. If a full screen mode is not achieved (the function will return 0), call _FULLSCREEN OFF


See also



Navigation:
Main Page with Articles and Tutorials
Keyword Reference - Alphabetical
Keyword Reference - By usage
Report a broken link