Difference between revisions of "FULLSCREEN (function)"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>Clippy
(added ex)
Line 16: Line 16:


'''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.
'''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.
<center>'''BEWARE: Using custom FONTS with [[_FULLSCREEN]] can cause monitor or Windows Desktop problems or kill a program!'''</center>


''Example:'' Shows how fonts and _FULLSCREEN are used to resize a program window.
{{CodeStart}}
{{Cl|CLS}}
fontpath$ = {{Cl|ENVIRON$}}("SYSTEMROOT") + "\fonts\lucon.ttf" 'Find Windows Folder Path.
f& = _FONT: defaultf& = f&
{{Cl|DO}}
  {{Cl|INPUT}} "1) DEFAULT  2) SIZE {{Cl|WINDOW}}  3) FULL {{Cl|SCREEN (statement)|SCREEN}}  4) FULL STRETCHED  Q) QUIT: ", winmode$
  {{Cl|IF}} {{Cl|UCASE$}}(winmode$) = "Q" {{Cl|THEN}} {{Cl|SYSTEM}}
  style$ = "MONOSPACE"
  {{Cl|SELECT CASE}} winmode$
    {{Cl|CASE}} "1"
      full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}}  'get current full screen mode
      {{Cl|IF}} full <> 0 {{Cl|THEN}} _FULLSCREEN _{{Cl|OFF}}
      {{Cl|GOSUB}} ChangeFont
    {{Cl|CASE}} "2"
      {{Cl|DO}}
        {{Cl|PRINT}}
        {{Cl|INPUT}} "Enter a FONT SIZE 5 to 25: ", fontsize%
      {{Cl|LOOP}} {{Cl|UNTIL}} fontsize% > 4 {{Cl|AND (boolean)|AND}} fontsize% < 26
      {{Cl|DO}}
        {{Cl|PRINT}}
        {{Cl|INPUT}} "Enter (0) for  REGULAR or (1) for ITALIC FONT: ", italic%
      {{Cl|LOOP}} {{Cl|UNTIL}} italic% = 0 or italic% = 1
      {{Cl|DO}}
      {{Cl|PRINT}}
      {{Cl|INPUT}} "Enter (0) for REGULAR or (1) for BOLD FONT: ", bold%
            {{Cl|LOOP}} {{Cl|UNTIL}} italic% = 0 or italic% = 1
            {{Cl|IF}} italic% = 1 {{Cl|THEN}} style$ = style$ + ", ITALIC"
            {{Cl|IF}} bold% = 1 {{Cl|THEN}} style$ = style$ + ", BOLD"
            full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}}  'get current full screen mode
            {{Cl|IF}} full <> 0 {{Cl|THEN}} {{Cl|_FULLSCREEN}} _OFF           
            {{Cl|GOSUB}} ChangeFont
        {{Cl|CASE}} "3"
            {{Cl|GOSUB}} ChangeFont
            {{Cl|_FULLSCREEN}} _SQUAREPIXELS
            full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}}  'get current full screen mode
            {{Cl|IF}} full = 0 {{Cl|THEN}} {{Cl|GOSUB}} nofull
        {{Cl|CASE}} "4"
            {{Cl|GOSUB}} ChangeFont
            {{Cl|_FULLSCREEN}}
            full = {{Cl|_FULLSCREEN (function)|_FULLSCREEN}}  'get current full screen mode
            {{Cl|IF}} full = 0 {{Cl|THEN}} {{Cl|GOSUB}} nofull
    {{Cl|END SELECT}}
    {{Cl|PRINT}}
{{Cl|LOOP}}
nofull:
{{Cl|_FULLSCREEN}} _{{Cl|OFF}}: {{Cl|SOUND}} 100, .75
{{Cl|RETURN}}
ChangeFont:
{{Cl|IF}} winmode$ <> "2" {{Cl|THEN}}
    {{Cl|_FONT|_FONT}} 16 'select inbuilt 8x16 default font
    currentf& = _FONT
        {{Cl|ELSE}}
    currentf& = {{Cl|_LOADFONT}}(fontpath$, fontsize%, style$)
    {{Cl|_FONT|_FONT}} currentf&
{{Cl|END IF}}
{{Cl|IF}} currentf& <> f& {{Cl|AND (boolean)|AND}} f& <> defaultf& {{Cl|THEN}} {{Cl|_FREEFONT}} f&
f& = currentf&
{{Cl|RETURN}}
{{CodeEnd}}




{{PageSeeAlso}}
{{PageSeeAlso}}
*{{KW|_FULLSCREEN}} (statement)
*{{KW|_FULLSCREEN}} (statement)



Revision as of 00:14, 23 August 2010

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


== Syntax ==: full% = _FULLSCREEN


  • 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.

BEWARE: Using custom FONTS with _FULLSCREEN can cause monitor or Windows Desktop problems or kill a program!


Example: Shows how fonts and _FULLSCREEN are used to 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 SYSTEM 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 full = _FULLSCREEN 'get current full screen mode IF full = 0 THEN GOSUB nofull CASE "4" GOSUB ChangeFont _FULLSCREEN full = _FULLSCREEN 'get current full screen mode IF full = 0 THEN GOSUB nofull END SELECT PRINT LOOP nofull: _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


See also




Navigation:
Keyword Reference - Alphabetical
Keyword Reference - By Usage
Main Wiki Page