Difference between revisions of "DISPLAY (function)"

From QB64 Wiki
Jump to navigation Jump to search
imported>Clippy
m
imported>Clippy
Line 9: Line 9:
 
* Will return 0 if in the default image.
 
* Will return 0 if in the default image.
 
* Not to be confused with the {{KW|_DISPLAY}} statement that displays the screen if not using {{KW|_AUTODISPLAY}}.
 
* Not to be confused with the {{KW|_DISPLAY}} statement that displays the screen if not using {{KW|_AUTODISPLAY}}.
 +
 +
 +
''Example:'' Creating a mouse cursor using a page number that '''you create''' in memory without setting up page flipping.
 +
{{CodeStart}}
 +
{{Cl|SCREEN (statement)|SCREEN}} {{Cl|_NEWIMAGE}}(640, 480, 32) 'any graphics mode should work without setting up pages
 +
{{Cl|_MOUSEHIDE}}
 +
SetupCursor
 +
{{Cl|PRINT}} "Hello World!"
 +
{{Cl|DO}}: {{Cl|_LIMIT}} 30
 +
  {{Cl|DO}} {{Cl|WHILE}} {{Cl|_MOUSEINPUT}}: {{Cl|LOOP}} 'main loop must contain _MOUSEINPUT 
 +
'      other program code   
 +
{{Cl|LOOP}}
 +
 +
{{Cl|SUB}} SetupCursor
 +
{{Cl|ON TIMER(n)|ON TIMER}}(0.02) UpdateCursor
 +
{{Cl|TIMER}} ON
 +
{{Cl|END SUB}}
 +
 +
{{Cl|SUB}} UpdateCursor
 +
{{Cl|PCOPY}} {{Cl|_DISPLAY (function)|_DISPLAY}}, 100  'any page number as desination with the _DISPLAY function as source
 +
{{Cl|PSET}} ({{Cl|_MOUSEX}}, {{Cl|_MOUSEY}}), {{Cl|_RGB}}(0, 255, 0)
 +
{{Cl|DRAW}} "ND10F10L3F5L4H5L3"
 +
{{Cl|_DISPLAY}}                  'statement shows image
 +
{{Cl|PCOPY}} 100, {{Cl|_DISPLAY (function)|_DISPLAY}} 'function as destination page
 +
{{Cl|END SUB}} '' ''
 +
{{CodeEnd}}
 +
''Note:'' Works with [[_DISPLAY (function)]] as the other page. If mouse reads are not crucial, put the _MOUSEINPUT loop inside of the UpdateCursor Sub.
  
  

Revision as of 04:26, 8 November 2010

The _DISPLAY function returns the handle of the current image that is displayed on the screen.


Syntax

result& = _DISPLAY


Description

  • Will return 0 if in the default image.
  • Not to be confused with the _DISPLAY statement that displays the screen if not using _AUTODISPLAY.


Example: Creating a mouse cursor using a page number that you create in memory without setting up page flipping.

SCREEN _NEWIMAGE(640, 480, 32) 'any graphics mode should work without setting up pages _MOUSEHIDE SetupCursor PRINT "Hello World!" DO: _LIMIT 30 DO WHILE _MOUSEINPUT: LOOP 'main loop must contain _MOUSEINPUT ' other program code LOOP SUB SetupCursor ON TIMER(0.02) UpdateCursor TIMER ON END SUB SUB UpdateCursor PCOPY _DISPLAY, 100 'any page number as desination with the _DISPLAY function as source PSET (_MOUSEX, _MOUSEY), _RGB(0, 255, 0) DRAW "ND10F10L3F5L4H5L3" _DISPLAY 'statement shows image PCOPY 100, _DISPLAY 'function as destination page END SUB

Note: Works with _DISPLAY (function) as the other page. If mouse reads are not crucial, put the _MOUSEINPUT loop inside of the UpdateCursor Sub.


See also

  • SCREEN (note the QB64 use of SCREEN to set which image to display)
  • PCOPY



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