Getting Started
Introduction
Sample Programs
IDEs
History
Advice
Mini-Tutorial
Tutorials
Code Snippets

Resources
Web Sites
More Tutorials
Forums
Vendors/Tools
Books
Magazines
Newsletters
NewsGroups
User Groups
Talk Shows
Blogs

Controls
Overview
Button
Check3State
Checkbox
ComboBox
Frame
Graphic
Image
ImageX
ImgButton
ImgButtonX
Label
Line
ListBox
ListView
Option
Progress Bar
Scrollbar
StatusBar
TAB
TextBox
Toolbar
TreeView

GBIC >> PowerBASIC >> Tutorials >> API

PowerBASIC Information Center Tutorials
These tutorials were written to help you get a quick, but thorough, understanding of PowerBASIC - the scope of the language as well as it's specific capabilities.

Introduction       Projects       Language           Messages       Functions           Advanced
  • Overview
  • Examples
  • IDE
  • Compilation
  • Distribution
  • Project Files
  • DDT Windows
  • Controls
  • Menus
  • Dialogs  
  • Help Files
  • Resources  
  • Templates  
  • Project Shell  
  • Syntax
  • Operators
  • Data Types
  • Variables
  • Scope
  • Declarations  
  • Procedures
  • Flow Control
  • Windows
  • Messages
  • Callbacks
  • Mouse
  • Keyboard
  • Dialogs
  • Controls
  • Subclassing
  • Arithmetic
  • Trig  
  • Strings
  • Arrays
  • Date/Time
  • Printing
  • Files
  • Folders
  • Keyboard
  • Mouse
  • Sound
  • System
  • Error Traps
  • Debugging
  • Objects
  • Graphics
  • Databases
  • API
  • DLLs
  • ASM
  • Threads
  • Using API With PowerBASIC
    A Windows installation includes a wide variety of files which contain all of the various functions that comprise the total set of capabilities offerred by Windows - file control, device control, graphics, sound, etc. Microsoft documents many of the features found in these files and provides programmers with instructions on how to access these features from within their own programs.

    The entire set of Windows functions which can be accessed by applications is typically called the application programming interface, usually shortened to just API.

    Declare
    PowerBASIC applications use the API by simply adding a line of code which tells the compiler which API function to use. The line of code looks like this:

        DECLARE Function MyFunc LIB "user.dll" ALIAS "MyFunctA" (x as Long) AS Long
    

    The Windows installation files typically hold many API functions, so the Declare function must not only tell the file name, but the function name as well. Also, each function has a unique list of arguments that must be specified in the Declare statement.

    Win32API.inc
    PowerBASIC makes it easy to use API by installing the "Win32API.inc" text file, which simply has the Declare statements for many of the most useful Windows API. The file is updated regularly and can be downloaded from the PowerBASIC home page.

    To use the Declare statement found within Win32API.inc, a PowerBASIC program must include the following compiler directive.

    #INCLUDE "Win32API.inc"
    

    The full path name of the file is not required, since the compiler knows where the file was installed by PowerBASIC.

    Which API To Use?
    There simply isn't a single list of all API a PowerBASIC programmer will find useful. The PowerBASIC sample applications provide some examples, and there is sample code in the PowerBASIC forums. But there is no systematic, categorized listing of PowerBASIC source code for useful API.

    Most programmers collect such code one API at a time as they write application requiring features offerred by Windows API.

    Declare Syntax
    PowerBASIC applications use the API by simply adding a line of code which tells the compiler which API function to use. The line of code looks like this:

        DECLARE FUNCTION ProcName LIB "LibName" ALIAS "AliasName" (arguments) AS type
    

    • ProcName - name of the function in LIB
    • LIB - library file name (contains API functions)
    • ALIAS - alternate name for function
    • (arguments) - list of values needed/returned by the API functions
    • As type - function data return type

    If you have any suggestions or corrections, please let me know.