Page 1 of 1

DCBROWSE Question

Posted: Mon Mar 08, 2010 2:05 pm
by GeneB
In the following code, can someone show me how to exit the browse with a mouse click (or two) and have the two Gets updated to display the information selected in the browse, prior to exiting with the "OK" button. I could change this to an array browse, but would like to know how to do it from a dbf browse. This code is modified from Xsample_43 : AutoSeek 2 Thanks in advance. Gene B




FUNCTION GetCustomer()

local cCustomerID, cCustomerName, oBrowse, getlist:={}

cCustomerID := SPACE(6)
cCustomerName := SPACE(30)

SELECT customer INDEX name
GO TOP

@ 1,1 DCSAY "Customer Number " GET cCustomerID PICT "@!"

@ 3,1 DCSAY "Customer Name " GET cCustomerName PICT "@!" ;
KEYBLOCK {|a,b,o| _KeyReader(a,b,o,oBrowse,@cCustomerName) }

@ 5,1 DCBROWSE oBrowse ALIAS 'customer' SIZE 40,12

DCBROWSECOL FIELD customer->name HEADER "Name" PARENT oBrowse WIDTH 30

DCREAD GUI ;
TITLE "Find A Customer" ;
FIT ;
ADDBUTTONS ;
MODAL

RETURN cCustomerName



STATIC FUNCTION _KeyReader( a, b, o, oBrowse, cCustomerName)

local lClearBuffer := .T., lSoftSeek := Set(_SET_SOFTSEEK,.T.)

IF a == xbeK_UP
oBrowse:up()
ELSEIF a == xbeK_DOWN
oBrowse:down()
ELSEIF a == xbeK_PGUP
oBrowse:pageup()
ELSEIF a== xbeK_PGDN
oBrowse:pagedown()
ELSEIF a == xbeK_END
oBrowse:gobottom()
ELSEIF a == xbeK_HOME
oBrowse:gotop()
ELSE
SEEK AllTrim(o:EditBuffer())
lClearBuffer := .F.
ENDIF

oBrowse:refreshAll()
IF lClearBuffer
cCustomerName := SPACE(30)
o:Get:home()
o:setData()
ENDIF
Set(_SET_SOFTSEEK,lSoftSeek)

RETURN NIL

Re: DCBROWSE Question

Posted: Mon Mar 08, 2010 2:29 pm
by rdonnay
This should work:

Code: Select all

@ .. DCBROWSE .. ;
   ITEMSELECTED {||cCustomerName := CUSTOMER->name,  ;
                   cCustomerID := CUSTOMER->id, ;
                   DC_GetRefresh(GetList), ;
                   SetAppFocus(DC_GetObject(GetList,'DCGUI_BUTTON_OK'))}

Re: DCBROWSE Question

Posted: Mon Mar 08, 2010 3:55 pm
by GeneB
Perfect.
I was always told the key to success was to surround yourself with people that are smarter than you are.
Many thanks, this is finally starting to make sense. GeneB