| xHarbour Reference Documentation > Command Reference |
![]() |
![]() |
![]() |
Creates a Get object as push button and displays it to the screen.
@ <nRow>, <nCol> ;
GET <lLogicVar> ;
PUSHBUTTON ;
[CAPTION <cCaption>] ;
[MESSAGE <cMessage>] ;
[WHEN <lWhen>] ;
[VALID <lValid>] ;
[COLOR <cColor>] ;
[FOCUS <bFocus>] ;
[STATE <bState>] ;
[STYLE <cStyle>] ;
[SEND <msg>] ;
[GUISEND <guimsg>]
Color values for push buttons
| Color value | Description |
|---|---|
| 1 | Color when the push button does not have input focus |
| 2 | Color when the push button has input focus |
| 3 | Color for the push button is pressed |
| 4 | Color for the push button's accelerator key |
A character string of eight characters defines the border drawn around the pushbutton. They are used in the same way as with the DispBox() function. The #define constants available in Box.ch can be used:
Constants for borders
| Constant | Description |
|---|---|
| B_SINGLE | Single-line border |
| B_DOUBLE | Double-line border |
| B_SINGLE_DOUBLE | Single-line top, double-line sides |
| B_DOUBLE_SINGLE | Double-line top, single-line sides |
If <cStyle> has eight characters, the push button has a height of three screen rows, otherwise it is displayed in one screen row.
The @...GET PUSHBUTTON command creates a Get() object and assigns a HbPushButton() object to the oGet:control instance variable. The HbPushButton() object displays a push button in text mode and allows a user to press it while the READ command is active. The variable <lLogicVar> contains always .F. (false) when READ is terminated.
The Get object created with @...GET PUSHBUTTON is stored in the current Getlist array. The Get object communicates with the associated HbPushButton object while the READ command is active. This communication ensures that focus and state changes are properly displayed on the screen.
| See also: | @...GET, Get(), HbPushButton() |
| Category: | Get system , Input commands |
| Source: | rtl\pushbtn.prg |
| LIB: | xhb.lib |
| DLL: | xhbdll.dll |
// The example demonstrates how push buttons can be integrated
// in the Get list and are activated during READ
PROCEDURE Main
LOCAL cLName, cFName
LOCAL lBtn1 := .F.
LOCAL lBtn2 := .F.
LOCAL lBtn3 := .F.
LOCAL nBtn := 0
LOCAL cGetClr := "W+/B,W+/R,N/BG,GR+/BG"
LOCAL cBtnClr := "N/G,W+/G,GR+/N,GR+/G"
SET EVENTMASK TO INKEY_ALL
SET COLOR TO N/BG
CLS
USE Customer ALIAS Cust
cFName := Cust->FirstName
cLName := Cust->LastName
@ 8, 20 GET cFName ;
CAPTION "&First name:" ;
COLOR cGetClr
@ 10, 20 GET cLName ;
CAPTION " &Last name:" ;
COLOR cGetClr
@ 12, 20 GET lBtn1 PUSHBUTTON ;
CAPTION " &Save " ;
COLOR cBtnClr ;
STATE {|| nBtn := IsPressed( 1 ) }
@ 12, 30 GET lBtn2 PUSHBUTTON ;
CAPTION " &Undo " ;
COLOR cBtnClr ;
STATE {|| nBtn := IsPressed( 2 ) }
@ 12, 40 GET lBtn3 PUSHBUTTON ;
CAPTION " E&xit " ;
COLOR cBtnClr ;
STATE {|| nBtn := IsPressed( 3 ) }
DO WHILE .T.
READ SAVE
DO CASE
CASE nBtn == 1
IF RLock()
REPLACE Cust->FirstName WITH cFName
REPLACE Cust->LastName WITH cLName
DbUnlock()
EXIT
ELSE
Alert( "Unable to save;Retry again later" )
ENDIF
CASE nBtn == 2
cFName := Cust->FirstName
cLName := Cust->LastName
nBtn := 0
AEval( GetList, {|oGet| oGet:display() } )
CASE nBtn == 3
EXIT
ENDCASE
ENDDO
ASize( GetList, 0 )
CLOSE ALL
RETURN
http://www.xHarbour.com