Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Special pages
Niidae Wiki
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
PowerBASIC
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
====Graphics==== Both the Console Compiler and Windows Compiler can create graphic windows. The GRAPHICs statements are higher-level than Windows' [[Graphics Device Interface]] (GDI) library functions.<ref>{{cite web |title=PowerBASIC Console Compiler |website=PowerBASIC Peer Support Community |url=https://forum.powerbasic.com/forum/user-to-user-discussions/powerbasic-console-compiler}}</ref><ref>{{cite web |title=PowerBASIC for Windows |website=PowerBASIC Peer Support Community |url=https://forum.powerbasic.com/forum/user-to-user-discussions/powerbasic-for-windows}}</ref> =====Elements of the GRAPHIC statements===== GRAPHIC WINDOWS are dedicated dialogs each containing a single control which fills the dialog's client area. GRAPHIC controls are [[child window]]s which support the same GRAPHIC drawing functionality as GRAPHIC windows. GRAPHIC BITMAPS are also defined, again supporting the GRAPHIC drawing functionality, but as purely memory objects, like [[BMP file format|Windows bitmaps]] or [[BMP file format|DIB sections]]. Keyboard and mouse handling statements are included among the GRAPHIC statements. Character output to a GRAPHIC target uses fonts specified via the FONT NEW statement. =====Creating a GRAPHIC WINDOW application===== A GRAPHIC WINDOW is the equivalent of a Windows [[dialog box]] containing a static control on which drawing operations can be done. A single BASIC statement will create a GRAPHIC WINDOW and specify its size, position and title. It is not essential to specify a [[Windows USER|WNDPROC]] for the GRAPHIC WINDOW. A short source code example for a complete GRAPHIC WINDOW application follows: <syntaxhighlight lang="vbnet"> #Compile Exe ' using either PBCC6 or PBWIN10 compiler #Dim All Function PBMain Local GW As Dword ' start a GRAPHIC WINDOW Graphic Window New "graphic window", 100, 100, 200, 200 to GW ' show a coloured disc Graphic Ellipse (10, 10)-(190, 190), %rgb_Red, %rgb_SeaGreen, 0 ' wait for a keypress Graphic Waitkey$ End Function </syntaxhighlight> =====Comparison of PB GRAPHIC statements with the GDI API===== Using PB GRAPHIC statements, a GRAPHIC (WINDOW, BITMAP, or control) is first selected as the current GRAPHIC target, then operations are done on it without requiring it to be identified again. Contrast this with the GDI API approach, where the [[Device Context]] handle is required for every drawing operation. It is not necessary when using the PB GRAPHIC statements to define a brush or pen as a separate entity, nor is it necessary to redraw the GRAPHIC target (when in view) in response to [[Windows USER|Windows messages]] such as WM_PAINT and WM_ERASEBKGND. GRAPHIC targets are persistent. When GRAPHIC targets are attached, a REDRAW option can be specified which buffers the results of drawing operations until they are specifically requested. Using this technique reduces flicker in a similar way to the technique of drawing on memory [[Graphics Device Interface|DC]]s <ref>Petzold, Charles (1998). Programming Windows Fifth Edition, Microsoft Press, {{ISBN|978-1-57231-995-0}}</ref> when using the GDI API. Pixel operations are possible using the GRAPHIC GET|SET PIXEL statements, in a manner similar to GetPixel/SetPixel of the GDI API. GRAPHIC GET BITS allows the entire bitmap to be loaded into a dynamic string. This can be manipulated either as a string or by mapping an array onto it. It can be placed back into the GRAPHIC target by GRAPHIC SET BITS. =====Complementarity of GRAPHIC statements and the Windows GDI API===== The GRAPHIC statements contain all the commonly used GDI API functions, but if you need one that is not included it is possible to obtain the [[Graphics Device Interface|hDC]] of any GRAPHIC target and thereby use GDI API functions on it.
Summary:
Please note that all contributions to Niidae Wiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Encyclopedia:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Search
Search
Editing
PowerBASIC
(section)
Add topic