A Sample GUI Program

This little program displays multiplication tables based on the Button that the user clicks.

Tiny Times

Here is the complete program BCX source code for Tiny Times Table.


 '========================================================================
 ' Tiny Times Table by Kevin Diggins(2000) -- A BCX BASIC sample program
 '========================================================================
 GUI "TINY_TIMES_TABLE"
 '========================================================================
 CONST  ID_Edit     = 100
 CONST  ID_Edit1    = 101
 CONST  ID_Button1  = 102
 CONST  ID_Button2  = 103
 CONST  ID_Button3  = 104
 CONST  ID_Button4  = 105
 CONST  ID_Button5  = 106
 CONST  ID_Button6  = 107
 CONST  ID_Button7  = 108
 CONST  ID_Button8  = 109
 CONST  ID_Button9  = 110
 CONST  ID_Button10 = 111
 CONST  ID_Exit     = 112
 '========================================================================
 DIM    Form1      AS CONTROL
 DIM    Edit1      AS CONTROL
 DIM    Button[10] AS CONTROL
 '========================================================================
 GLOBAL MainMenu   AS HMENU
 GLOBAL FileMenu   AS HMENU
 '========================================================================
  
  
 SUB FormLoad
   DIM RAW counter
 
   Form1 = BCX_FORM("Tiny Times Table", 0, 0, 150, 165)
   Edit1 = BCX_EDIT("", Form1, ID_Edit, 5, 5, 110, 140)
  
   FOR counter = 0 TO 9
     Button[counter] = BCX_BUTTON(TRIM$(STR$(counter + 1)), _
     Form1, 102 + counter, 120, 5 + (counter * 14), 20, 15)
   NEXT
  
  '========================================================================
  '                          Start Building Menus
  '========================================================================
   MainMenu = CreateMenu()   ' CreateMenu returns a MENU HANDLE
   FileMenu = CreateMenu()   ' CreateMenu returns a MENU HANDLE
  
  '========================================================================
  '                     Build the File Menu First
  '========================================================================
   AppendMenu(FileMenu,MF_STRING   ,ID_Exit  ,"E&xit")
  
  '========================================================================
  '                        Build the Main Menu Next
  '========================================================================
  '                  Attach the File menu to the main menu
  '========================================================================
   InsertMenu(MainMenu, ID_Edit , MF_POPUP , FileMenu ,"File")
  '========================================================================
  
   SetMenu(Form1,MainMenu)      ' Activate the menu
  
   CENTER(Form1)
   SHOW(Form1)
 END SUB
  
 BEGIN EVENTS
   SELECT CASE CBMSG
  '**********************
   CASE WM_COMMAND
  '**********************
     IF CBCTL = ID_Button1  THEN BuildTable(1)
     IF CBCTL = ID_Button2  THEN BuildTable(2)
     IF CBCTL = ID_Button3  THEN BuildTable(3)
     IF CBCTL = ID_Button4  THEN BuildTable(4)
     IF CBCTL = ID_Button5  THEN BuildTable(5)
     IF CBCTL = ID_Button6  THEN BuildTable(6)
     IF CBCTL = ID_Button7  THEN BuildTable(7)
     IF CBCTL = ID_Button8  THEN BuildTable(8)
     IF CBCTL = ID_Button9  THEN BuildTable(9)
     IF CBCTL = ID_Button10 THEN BuildTable(10)
     IF CBCTL = ID_Exit     THEN PostQuitMessage(0)
  
     EXIT FUNCTION
   END SELECT
 END EVENTS
  
 SUB BuildTable(A)
   DIM RAW I
  
   LOCAL Buf$ * 5000
   Buf$ = ""
   FOR I = 1 TO 15
     Buf$ = Buf$ & "   " & STR$(A) & "  X " & STR$(I) & " = " & STR$(I * A) & CRLF$
   NEXT
   SetWindowText(Edit1, Buf$)
 END SUB