home *** CD-ROM | disk | FTP | other *** search
- *-- PROGRAM FILE -------------------------------------------------------------
- * Application: eXPress++ Library
- * Description: eXPress++ sample programs
- * File Name: xsample6.prg
- * Author: Roger Donnay Tester:
- * Date created: 09/03/00 Date updated: 11/07/2001
- * Copyright: (c) 2001 by DONNAY Software Designs
- *-----------------------------------------------------------------------------
-
- #include "DCDIALOG.CH"
- #include "SET.CH"
- #include "XBP.CH"
- #include "APPEVENT.CH"
- #INCLUDE "inkey.CH"
- #INCLUDE "dcicon.CH"
- #INCLUDE "dcgrump.ch"
- #INCLUDE "dcbitmap.ch"
- #INCLUDE "dcgra.ch"
- #include "dcfields.ch"
- #INCLUDE "dccursor.CH"
- #INCLUDE "dcprint.CH"
- #include "font.ch"
- #include "dcapp.ch"
-
- #define CRLF Chr(13) + Chr(10)
-
-
- FUNCTION X_Samples_6( oDialog )
-
- LOCAL GetList := {}, nTest := 0, cMemo := '', oMemo, i, j, oDlg, ;
- lDebugCreate := .f., lDebugEvent := .f., GetOptions, aApp[1], ;
- cTitle, oDlgWindow, aCoords, oSourceFile, cSource
-
- SET DEFA TO
- SET PATH TO ..\DATA
-
- cTitle := 'eXPress++ Sample Programs (Set 6)'
- nTest := 0
- cMemo := ''
- lDebugEvent := .f.
- lDebugCreate := .f.
-
- FOR i := 1 TO 5
- FOR j := 1 TO 6
- nTest++
- @ j-1,1 + (i-1)*14 DCRADIO nTest ;
- VALUE nTest ;
- PROMPT XSample_Header(nTest) ;
- ACTION {||XSample_Memo(nTest,oMemo,oSourceFile,@cSource)} ;
- COLOR XSample_Color(nTest)
- NEXT j
- NEXT i
- nTest := 1
-
- @ 2,73 DCPUSHBUTTON CAPTION 'Run Sample' ;
- SIZE 12, 1 ;
- ACTION {||XSample_Run(nTest,oDialog,lDebugCreate,lDebugEvent,GetList,GetOptions)}
-
- @ 3,73 DCPUSHBUTTON CAPTION 'Print Source' ;
- SIZE 12, 1 ;
- ACTION {||XSample_Print(cSource)}
-
-
- @ 4,73 DCPUSHBUTTON CAPTION 'Exit' ;
- SIZE 12, 1 ;
- ACTION {||PostAppEvent(xbeP_Close,,,oDlg)}
-
- @ 5,73 DCCHECKBOX lDebugEvent PROMPT 'Debug Events'
-
- @ 6.3,5 DCSAY '' SAYSIZE 60 COLOR GRA_CLR_DARKBLUE ;
- OBJECT oSourceFile FONT '8.Courier Bold'
-
- @ 7,1 DCMULTILINE cMemo ;
- OBJECT oMemo ;
- SIZE 85,12 ;
- FONT '8.Alaska Crt'
-
- DCGETOPTIONS ;
- ICON ICON_EXPRESS ;
- NOBUSY ;
- CASCADE
-
- DCREAD GUI ;
- OPTIONS GetOptions ;
- EVAL {||XSample_Memo(nTest,oMemo,oSourceFile,@cSource)} ;
- APPWINDOW oDialog ;
- PARENT @oDlg ;
- TITLE cTitle ;
- FIT
-
- CLOSE DATABASES
-
- RETURN nil
-
- * ---------------------------- *
-
- STATIC FUNCTION XSample_Memo( nTest, oMemo, oSourceFile, cSource )
-
- LOCAL cFunction, nFound, cSourceFile
-
- cSource := ''
- nTest += 162
- cFunction := 'XSample_' + Alltrim(Str(nTest))
-
- cSourceFile := 'XSAMPLE6.PRG'
- cSource := MemoRead(cSourceFile)
- IF Empty(cSource)
- cSourceFile := '..\PRG\XSAMPLE6.PRG'
- cSource := MemoRead(cSourceFile)
- ENDIF
- IF Empty(cSource)
- cSource := 'XSAMPLE6.PRG cannot be found'
- ENDIF
-
- nFound := AT('FUNCTION ' + cFunction,cSource)
- cSource := Substr(cSource,nFound)
- nFound := AT('*** END OF EXAMPLE ***',cSource)
- cSource := Substr(cSource,1,nFound+21)
-
- IF !Empty(cSource)
- oMemo:setData(cSource)
- oSourceFile:setCaption(cSourceFile)
- ENDIF
- RETURN nil
-
- * -------------------
-
- STATIC FUNCTION XSample_Print( cSource )
-
- LOCAL oPrinter, nLineCount := MLCount(cSource), i, cMemoLine, nRow
-
- DCPRINT ON TO oPrinter PREVIEW FONT '10.Courier' NONSTOP HIDE
- IF Valtype(oPrinter) # 'O' .OR. !oPrinter:lActive
- RETURN nil
- ENDIF
- nRow := 1
- FOR i := 1 TO nLineCount - 1
- cMemoLine := MemoLine( cSource, nil, i )
- @ nRow++,2 DCPRINT SAY cMemoLine PRINTER oPrinter
- IF nRow > 60
- DCPRINT EJECT
- nRow := 1
- ENDIF
- NEXT
- DCPRINT OFF
-
- RETURN nil
-
- * ---------------------------- *
-
- STATIC FUNCTION XSample_Run( nTest, oDialog, lDebugCreate, lDebugEvent, ;
- GetList, GetOptions )
-
- LOCAL nDebug := 0, lVer20, lVer15, lVer17, oThread
-
- #ifdef EXPRESS20
- lVer20 := .t.
- #else
- lVer20 := .f.
- #endif
-
- #ifdef EXPRESS17
- lVer17 := .t.
- #else
- lVer17 := .f.
- #endif
-
- #ifdef EXPRESS15
- lVer15 := .t.
- #else
- lVer15 := .f.
- #endif
-
- DC_Gui(.t.)
-
- nTest += 162
- IF lDebugCreate
- nDebug += DCGUI_DEBUG_CREATE
- ENDIF
- IF lDebugEvent
- nDebug += DCGUI_DEBUG_EVENTS
- ENDIF
- DC_ReadGuiDebug(nDebug)
- CLOSE ALL
- SET DEFA TO
-
- IF nTest = 163 .AND. ( lVer17 .OR. lVer20 )
- XSample_163()
- ELSEIF nTest = 164 .AND. ( lVer17 .OR. lVer20 )
- XSample_164()
- ELSEIF nTest = 165
- XSample_165()
- ELSEIF nTest = 166
- XSample_166()
- ELSEIF nTest = 167
- XSample_167()
- ELSEIF nTest = 168
- XSample_168()
- ELSEIF nTest = 169
- XSample_169()
- ELSEIF nTest = 170
- XSample_170()
- ELSEIF nTest = 171
- XSample_171()
- ELSEIF nTest = 172
- XSample_172()
- ELSEIF nTest = 173
- XSample_173()
- ELSEIF nTest = 174
- XSample_174()
- ELSEIF nTest = 175
- XSample_175()
- ELSEIF nTest = 176
- XSample_176()
- ELSEIF nTest = 177
- XSample_177()
- ELSEIF nTest = 178
- XSample_178()
- ELSEIF nTest = 179
- XSample_179()
- ELSEIF nTest = 180
- XSample_180()
- ELSEIF nTest = 181
- XSample_181()
- ELSEIF nTest = 182
- XSample_182()
- ELSEIF nTest = 183
- XSample_183()
- ELSEIF nTest = 184
- XSample_184()
- ELSEIF nTest = 185
- XSample_185()
- ELSEIF nTest = 186
- XSample_186()
- ELSEIF nTest = 187
- XSample_187()
- ELSEIF nTest = 188
- XSample_188()
- ELSEIF nTest = 189
- XSample_189()
- ELSEIF nTest = 190
- XSample_190()
- ELSEIF nTest = 191
- XSample_191()
- ELSEIF nTest = 192
- XSample_192()
- ELSE
- DC_WinAlert('This sample is available under eXPress++ 1.7 or later')
- ENDIF
-
- DC_ClearEvents()
-
- RETURN nil
-
- * ---------------------------- *
-
- STATIC FUNCTION XSample_Header( nTest )
-
- nTest += 162
-
- IF nTest = 163
- RETURN "Keyboard"
- ELSEIF nTest = 164
- RETURN "TypeAhead"
- ELSEIF nTest = 165
- RETURN "Spin-Get"
- ELSEIF nTest = 166
- RETURN "Change Get"
- ELSEIF nTest = 167
- RETURN "Field Editor"
- ELSEIF nTest = 168
- RETURN "Menu Replace"
- ELSEIF nTest = 169
- RETURN "Folder"
- ELSEIF nTest = 170
- RETURN ""
- ELSEIF nTest = 171
- RETURN ""
- ELSEIF nTest = 172
- RETURN ""
- ELSEIF nTest = 173
- RETURN ""
- ELSEIF nTest = 174
- RETURN ""
- ELSEIF nTest = 175
- RETURN ""
- ELSEIF nTest = 176
- RETURN ""
- ELSEIF nTest = 177
- RETURN ""
- ELSEIF nTest = 178
- RETURN ""
- ELSEIF nTest = 179
- RETURN ""
- ELSEIF nTest = 180
- RETURN ""
- ELSEIF nTest = 181
- RETURN ""
- ELSEIF nTest = 182
- RETURN ""
- ELSEIF nTest = 183
- RETURN ""
- ELSEIF nTest = 184
- RETURN ""
- ELSEIF nTest = 185
- RETURN ""
- ELSEIF nTest = 186
- RETURN ""
- ELSEIF nTest = 187
- RETURN ''
- ELSEIF nTest = 188
- RETURN ''
- ELSEIF nTest = 189
- RETURN ''
- ELSEIF nTest = 190
- RETURN ''
- ELSEIF nTest = 191
- RETURN ''
- ELSEIF nTest = 192
- RETURN ''
- ENDIF
-
- RETURN ''
-
- * ---------------------------- *
-
- STATIC FUNCTION XSample_Color( nTest )
-
- LOCAL lVer20
-
- #ifdef EXPRESS20
- lVer20 := .t.
- #else
- lVer20 := .f.
- #endif
-
- IF lVer20
- RETURN GRA_CLR_BLACK
- ENDIF
-
- nTest += 162
-
- IF AScan({163,164,165,166,167,168},nTest) == 0
- RETURN GRA_CLR_DARKGRAY
- ENDIF
-
- RETURN GRA_CLR_BLACK
-
- * -----------------
-
- STATIC FUNCTION XSample_163()
-
- /* This example shows how to use the Keyboard buffer
- to enter data into a table of Gets */
-
- LOCAL GetList[0], a, b, GetOptions, lTypeAhead := DC_ReadGuiTypeAhead(.t.)
-
- a := " "
- b := " "
-
- KEYBOARD '02' + chr(13) + '011'
-
- @ 1,1 DCSAY "a" get a
- @ 2,1 DCSAY "b" get b
-
- DCGETOPTIONS KEYBOARD ''
- DCREAD GUI FIT ADDBUTTONS MODAL TITLE 'Keyboard Test' ;
- OPTIONS GetOptions
-
- DC_ReadGuiTypeAhead(lTypeAhead)
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ------------------
-
- STATIC FUNCTION XSample_164( nRecur )
-
- /* This example shows how to use TypeAhead to enter
- data into a table of Gets. */
-
- LOCAL GetList[0], cGet := Space(30), GetOptions, ;
- lTypeAhead := DC_ReadGuiTypeAhead(.t.)
-
- DEFAULT nRecur := 0
-
- @ 1,1 DCSAY 'Type Something' GET cGet SAYSIZE 0
-
- @ 3,1 DCSAY 'Press the ALT-N key to invoke a new Window.;' + ;
- 'This will cause a 2 second delay before the;' + ;
- 'new window is painted. Type some text during;' + ;
- 'this 2 seconds. It should appear in the GET;' + ;
- 'of the new window' ;
- SAYWORDBREAK ;
- SAYSIZE 40,4
-
- @ 8,1 DCPUSHBUTTON SIZE 20,2 CAPTION '&New Window' ;
- ACTION {||Sleep(200),XSample_164(++nRecur)}
-
- DCGETOPTIONS _CASCADE nRecur > 0
-
- DCREAD GUI FIT MODAL OPTIONS GetOptions ;
- SETAPPWINDOW TITLE 'Type-Ahead Test'
-
- DC_ReadGuiTypeAhead(lTypeAhead)
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * -------------------
-
- STATIC FUNCTION XSample_165()
-
- /* This example shows how to create a custom Spin-Button
- from a DCGET and two DCPUSHBUTTONs */
-
- LOCAL GetList := {}, oSpin, nSpin := 0, lStartSpin := .f., oThread, ;
- lThreadActive := .t., nMode := 0
-
- oThread := Thread():new()
- oThread:start({||_Spin(@nMode,@nSpin,@oSpin,@lThreadActive,@lStartSpin)})
-
- @ 0,0 DCSAY 'Spin Me' GET nSpin PICT '999.99' GETSIZE 82,26 PIXEL ;
- GETOBJECT oSpin SAYSIZE 130 SAYRIGHTCENTER
-
- @ 5,63 DCPUSHBUTTON CAPTION 't' SIZE 15,10 ;
- FONT '10.Marlett';
- PARENT oSpin ;
- PIXEL ;
- EVAL {|o|o:lbDown:= {||nMode:=1,lStartSpin:=.t.}, ;
- o:lbUp := {||nMode:=0} }
-
- @ 15,63 DCPUSHBUTTON CAPTION 'u' SIZE 15,10 ;
- FONT '10.Marlett' ;
- PARENT oSpin ;
- PIXEL ;
- EVAL {|o|o:lbDown:= {||nMode:=2,lStartSpin:=.t.}, ;
- o:lbUp := {||nMode:=0} }
-
- DCREAD GUI FIT MODAL ADDBUTTONS TITLE 'Spin-Button in a DCGET'
-
- lThreadActive := .f.
-
- RETURN nil
-
- * -----------------
-
- STATIC FUNCTION _Spin( nMode, nSpin, oSpin, lThreadActive, lStartSpin )
-
- LOCAL lStart := .t.
-
- DO WHILE lThreadActive
- IF nMode = 1 .AND. nSpin <= 10.0
- nSpin += .1
- oSpin:setData()
- ELSEIF nMode = 2 .AND. nSpin >= -10.0
- nSpin -= .1
- oSpin:setData()
- ENDIF
- IF lStartSpin
- Sleep(30)
- lStartSpin := .f.
- ELSE
- Sleep(10)
- ENDIF
- ENDDO
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * --------------------
-
- STATIC FUNCTION XSample_166()
-
- /* This example shows two different techiques for updating
- the value of a GET from a VALID function */
-
- LOCAL GetList := {}, GetOptions, cFirstName, cLastName, lOk
-
- cFirstName := Space(30)
- cLastName := Space(30)
-
- @ 02,05 DCSAY "First name" GET cFirstName ;
- SAYSIZE 0 SAYFONT "10.Courier" GETFONT "10.Courier" ;
- VALID {|| CenterIt1(@cFirstName,GetList)}
-
- @ 04,05 DCSAY "Last name " GET cLastName ;
- SAYSIZE 0 SAYFONT "10.Courier" GETFONT "10.Courier" ;
- VALID {|oGet| CenterIt2(@cLastName,oGet)}
-
- DCREAD GUI ;
- MODAL ;
- FIT ;
- ADDBUTTONS ;
- TITLE 'Change GET contents in Valid' ;
- TO lOk
-
- IF (lOk)
- DCMSGBOX "|"+cFirstName+"|"+cLastName+"|"
- ENDIF
-
- RETURN(NIL)
-
- * ----------------
-
- FUNCTION CenterIt1(cName,GetList)
-
- cName:=ALLTRIM(cName)
- cName:=PADC(cName,30)
- DC_GetRefresh(GetList)
-
- RETURN(.T.)
-
- * ----------------
-
- FUNCTION CenterIt2(cName,oGet)
-
- cName:=ALLTRIM(cName)
- cName:=PADC(cName,30)
- oGet:setData()
-
- RETURN(.T.)
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_167()
-
- /*
- Field Editor
-
- This sample uses DCAPPEDIT and DCAPPFIELD to create an Editor for
- ALL FIELDS in a database.
- */
-
- LOCAL GetList := {}, oStatic, oAppEdit, i, aFields, cField
-
- USE COLLECT VIA DBFNTX NEW SHARED
-
- @ 0,0 DCSTATIC XBPSTATIC_TYPE_RAISEDBOX SIZE 78,18.5 ;
- OBJECT oStatic
-
- DCAPPEDIT INTO oAppEdit STYLE 3D POSITION 0,0 PARENT oStatic
-
- aFields := dbStruct()
-
- FOR i := 1 TO Len(aFields)
- cField := '{||COLLECT->' + aFields[i,1] + '}'
- DCAPPFIELD '' INTO oAppEdit ;
- CAPTION aFields[i,1] ;
- COLOR GRA_CLR_BLUE
- ATail(GetList)[bGETLIST_VAR] := &(cField)
- NEXT
-
- DCREAD GUI ;
- TITLE 'Application Edit Demo' ;
- FIT ;
- MODAL ;
- BUTTONS DCGUI_BUTTON_EXIT
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_168()
-
- /* This example shows how to replace a complete menu system
- within a dialog with a new menu at runtime */
-
- LOCAL GetList:={}, dDate := Date(), cString := Space(10), oDialog
-
- @ 0,0 DCGET dDate
- @ 1,0 DCGET cString
-
- @ 3,0 DCPUSHBUTTON CAPTION 'Main Menu' SIZE 50,2 ;
- ACTION {||MenuBar( 1, nil ,oDialog ) }
-
- @ 5,0 DCPUSHBUTTON CAPTION 'Utility Menu' SIZE 50,2 ;
- ACTION {||MenuBar( 2, nil ,oDialog ) }
-
- @ 7,0 DCPUSHBUTTON CAPTION 'Backup Menu' SIZE 50,2 ;
- ACTION {||MenuBar( 3, nil ,oDialog ) }
-
- MenuBar( 1, GetList )
-
- DCREAD GUI ;
- MODAL ;
- TITLE 'Replacing a Menu System' ;
- FIT ;
- PARENT @oDialog
-
- RETURN nil
-
- * ----------
-
- FUNCTION MenuBar( nMenu, GetList, oDialog )
-
- LOCAL oMenuBar, oSubMenu1, oSubMenu2
-
- IF Valtype(oDialog) == 'O'
- GetList := Array(0)
- oMenuBar := XbpMenuBar():new( oDialog ):create()
- ELSE
- DCMENUBAR oMenuBar
- ENDIF
-
- IF nMenu == 1
-
- DCSUBMENU oSubMenu1 PROMPT 'Main Sub Menu 1' PARENT oMenuBar
-
- DCMENUITEM 'Main Menu item 1' PARENT oSubMenu1 ;
- ACTION {||Msgbox('Main Menu Item 1')}
-
- DCSUBMENU oSubMenu2 PROMPT 'Main Sub Menu 2' PARENT oMenuBar
-
- DCMENUITEM 'Main Menu item 2' PARENT oSubMenu2 ;
- ACTION {||Msgbox('Main Menu Item 2')}
-
- ELSEIF nMenu == 2
-
- DCSUBMENU oSubMenu1 PROMPT 'Utility Sub Menu 1' PARENT oMenuBar
-
- DCMENUITEM 'Utility Menu item 1' PARENT oSubMenu1 ;
- ACTION {||Msgbox('Utility Menu Item 1')}
-
- DCSUBMENU oSubMenu2 PROMPT 'Utility Sub Menu 2' PARENT oMenuBar
-
- DCMENUITEM 'Utility Menu item 2' PARENT oSubMenu2 ;
- ACTION {||Msgbox('Utility Menu Item 2')}
-
- ELSEIF nMenu == 3
-
- DCSUBMENU oSubMenu1 PROMPT 'Backup Sub Menu 1' PARENT oMenuBar
-
- DCMENUITEM 'Backup Menu item 1' PARENT oSubMenu1 ;
- ACTION {||Msgbox('Backup Menu Item 1')}
-
- DCSUBMENU oSubMenu2 PROMPT 'Backup Sub Menu 2' PARENT oMenuBar
-
- DCMENUITEM 'Backup Menu item 2' PARENT oSubMenu2 ;
- ACTION {||Msgbox('Backup Menu Item 2')}
-
- DCMENUITEM 'Backup Menu item 2' PARENT oSubMenu2 ;
- ACTION {||Msgbox('Backup Menu Item 3')}
-
- ENDIF
-
- IF Valtype(oDialog) == 'O'
- DCREAD GUI ;
- EXIT ;
- PARENT oDialog
- ENDIF
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_169()
-
- /* This example shows how to create a Windows-style folder
- window with scrollable icons */
-
- LOCAL aGetList[0], aFolder
-
- RETURN nil
-
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_170()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * --------------------
-
- STATIC FUNCTION XSample_171()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_172()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_173()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * --------------------
-
- STATIC FUNCTION XSample_174()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * --------------------
-
- STATIC FUNCTION XSample_175()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * --------------------
-
- STATIC FUNCTION XSample_176()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_177()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_178()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_179()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_180()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_181()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_182()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_183()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_184()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_185()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_186()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_187()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_188()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_189()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_190()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_191()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
- * ---------------------
-
- STATIC FUNCTION XSample_192()
-
- RETURN nil
- *** END OF EXAMPLE ***
-
-
-