Using the entire desktop area
by Richard Russell, October 2006
Normally you will want your BBC BASIC program either to use the default window size (this is appropriate for simple programs outputting only textual information) or to fix the window to a specific size in pixels (this will generally make incorporating graphics much easier, and makes your program independent of display resolution). The latter can be achieved either by using the MODE statement or the VDU 23,22 command.
If, however, you want to operate 'full screen' then using MODE is not appropriate. Although there is quite likely to be a MODE with the same dimensions as your screen (for example MODE 22 is 1024×768, which is a common display resolution) this does not take account of the window borders, title bar and task bar. Selecting MODE 22 on such a screen will result in Windows reducing the size of your window to fit, with undesirable consequences (for example your text and graphics may not correctly line up, and your program will not be compatible with other display resolutions).
If you really want to fill the entire screen, without any border, title bar or even the Windows task bar (for example as some games do) then you can use the code listed in the main documentation under Using the entire screen. In this case you will need to provide an obvious means for the user to terminate your program, because the normal facilities in the title bar or task bar will be absent.
An alternative to filling the entire screen is simply to maximise your window. You can do that using the following code:
SW_MAXIMIZE = 3 SYS "ShowWindow", @hwnd%, SW_MAXIMIZE VDU 26
The VDU 26 causes BBC BASIC to reset its text and graphics viewports to the new window size. Unfortunately a maximised window isn't necessarily ideal because the borders are hidden. If you want your window to be as large as possible without losing any of the borders or title bar etc. then you can use the following code:
PROCfitworkarea(x%, y%, 0) VDU 23,22,x%;y%;8,16,16,128 END DEF PROCfitworkarea(RETURN x%, RETURN y%, menu%) GWL_STYLE = -16 SPI_GETWORKAREA = 48 LOCAL rc{}, style% DIM rc{l%,t%,r%,b%} SYS "SystemParametersInfo", SPI_GETWORKAREA, 0, rc{}, 0 x% = rc.r%-rc.l% y% = rc.b%-rc.t% SYS "GetWindowLong", @hwnd%, GWL_STYLE TO style% SYS "AdjustWindowRect", rc{}, style%, menu% x% -= rc.r%-rc.l%-x% y% -= rc.b%-rc.t%-y% ENDPROC
Because VDU 23,22… assumes there isn't a menu bar (even if there is!) you should usually set the last parameter of PROCfitworkarea to zero, as shown. Set it to 1 only if you want to know the size of the client area excluding the menu bar. See also Effect of menu bar on window size.
Whenever you run 'full screen' using any of the methods listed above you will need to write your program to take account of different display resolutions and shapes (unless you are content for it to work only on your own PC). You can discover the current size of your window's client area (to which you can output) using the system variables “@vdu%!208” (width in pixels) and “@vdu%!212” (height in pixels). Since the origin for text coordinates is the top left and the origin for graphics coordinates is the bottom left you may need to take some care in order to ensure text and graphics line up correctly whatever the display resolution.