Actual code:
FUNCTION list01
// Labor rates list01
// Updated: 7/28/2015 2:59:33 PM
LOCAL oBarLst
PRIVATE oDepartment, oEdit, lFirst := .F.
// Open the labor rate reference database and index
oLaborRate := tLaborRate():New( )
IF oLaborRate:reccount( ) = 0
MsgAlert( "Adding a first record")
oLaborRate:append( )
oLaborRate:save( )
lFirst := .T.
ENDIF
oLaborRate:gotop()
oLaborRateR := TRecord():new( oLaborRate )
oLaborRateR:load()
// Open the dialog using a resource from EMS.DLL
DEFINE DIALOG oDlg RESOURCE "LISTS" BRUSH oBrush transparent OF oWnd TITLE "Labor Rates"
oDlg:nHelpID := 5
// Build the edit controls
REDEFINE SAY oSa1 PROMPT "Charge" ID 4900 OF oDlg
REDEFINE GET oEdit VAR oLaborRateR:charge ID 102 OF oDlg PICTURE "$99999.99" MESSAGE "The charge for this service" UPDATE
REDEFINE SAY oSa2 PROMPT "Service" ID 4901 OF oDlg
REDEFINE GET oLaborRateR:servic ID 103 OF oDlg MESSAGE "A description of the service type" UPDATE
// Create the BROWSE control
REDEFINE XBROWSE oLbx1 ;
DATASOURCE oLaborRate ;
HEADERS " Charge ", " Service ", " " ;
COLUMNS "charge", "servic", " " ;
ID 101 OF oDlg ;
ON CHANGE ( oLaborRateR:load(), oDlg:update()) ;
UPDATE
// Provide the header gradient
oLbx1:bClrGrad := aPubGrad
// Set the styles
oLbx1:nMarqueeStyle := MARQSTYLE_HIGHLROW
oLbx1:nColDividerStyle := LINESTYLE_RAISED
oLbx1:nRowDividerStyle := LINESTYLE_RAISED
oLbx1:nHeadStrAligns := AL_CENTER
oLbx1:nStretchCol := STRETCHCOL_LAST
REDEFINE BUTTONBAR oBarLst ID 105 SIZE 60,60 OF oDlg 2015
oBarLst:bClrGrad := aPubGrad
// Build the button controls
DEFINE BUTTON OF oBarLst RESOURCE "HRADD" PROMPT "Add" TOOLTIP "Add a record" ;
ACTION ( oLbx1:gobottom(), oLaborRate:append( ), oLaborRate:blank( ), oLbx1:refresh(), oLaborRateR:load(), oDlg:update( ),;
oEdit:setfocus( ) ) MESSAGE "Add a new item"
DEFINE BUTTON OF oBarLst RESOURCE "HRSAVE" PROMPT "Save" TOOLTIP "Save changes" ;
ACTION ( oLaborRateR:save( ), oDlg:update( ), oLbx1:refresh(), oLbx1:setfocus( ) ) ;
MESSAGE "Save any changes made to the current item"
DEFINE BUTTON OF oBarLst RESOURCE "HRDELETE" PROMPT "Delete" TOOLTIP "Delete selected record" ;
ACTION ( IIF( MsgYesNo( "Do you wish to delete this item ?"), ( oLaborRate:delete( ),;
oLaborRate:skip(1), oLbx1:refresh(), oLaborRateR:load(), oDlg:update()),)) MESSAGE "Delete the current item"
DEFINE BUTTON OF oBarLst RESOURCE "HRHELP" PROMPT "Help" TOOLTIP "Open OnLine Manual" ;
ACTION WinExec( "hh asw9.chm" )
DEFINE BUTTON OF oBarLst RESOURCE "HREXIT" PROMPT "Exit" TOOLTIP "Exit this list" ;
ACTION oDlg:end() MESSAGE "Exit this list"
// Activate the dialog screen
ACTIVATE DIALOG oDlg ON INIT oReBar:hide( ) CENTERED
// Redisplay the bar
oReBar:show()
// Close the file
oLaborRate:close()
RETURN NIL
.RC code, assembled into the .exe
LISTS DIALOG 0, 0, 660, 410
STYLE WS_POPUP | WS_CAPTION
CAPTION "List Editor"
{
CONTROL "", 105, "TBar", 0|WS_CHILD|WS_VISIBLE, 0,0, 660, 30
CONTROL "",101,"TxBrowse",WS_BORDER | WS_VSCROLL | WS_TABSTOP,10,80,640,310
EDITTEXT 102,110,40,200,13
EDITTEXT 103,110,55,200,13
LTEXT "",4900,10,40,95,13
LTEXT "",4901,10,55,95,13
}
The result:
