FiveTech Support Forums

FiveWin / Harbour / xBase community
Board index FiveWin for Harbour/xHarbour How can I do this in GUI style ?
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM

How can I do this in GUI style ?

Posted: Mon Aug 19, 2013 06:40 PM
Guys:

I've got an old Clipper 5.2e / DOS text routine that receives an array of indexes and builds a small ACHOICE() index / order selection screen.
The window growse or shrinks depending on the number of array elements. How can I get the same functionality in GUI ? Thank you.

Here's the code:
Code (fw): Select all Collapse
FUNCTION RepOrder (acOrder)
   LOCAL GetList := {}, nOldWindow, nWindow, nMaxLength := 0, nMaxCol, ;
         nLeft, nRight, nWindSel := Sx_TagNo(), cOrder

   nOldWindow := WSELECT()
   WSELECT(0)
   AEVAL(acOrder, {|cIndex| nMaxLength := MAX(LEN(cIndex), nMaxLength)})
   nMaxCol := MAXCOL()
   IF nMaxLength >= nMaxCol - 4
      nMaxLength := nMaxCol - 4
   ELSE
      nMaxLength += 4
   ENDIF
   nLeft   := INT((nMaxCol - nMaxLength) / 2)
   nRight  := nLeft + nMaxLength
   nWindow := WOPEN(09,nLeft,MIN(MAXROW(), 12 + LEN(acOrder)),nRight)
   SETCOLOR("GR+/BG+,BG+/N,,,GR/B")
   WBOX()
   @ 0,0 SAY CENTER("Order",,, .T.) COLOR "GR+/BR+"
   @ 1,0 TO 1,MAXCOL()

   nWindSel := ACHOICE(2,1,MAXROW(),MAXCOL() - 1,acOrder, .T., , nWindSel)
   IF nWindSel > 0
      cOrder := acOrder[nWindSel]
        IF nWindSel != Sx_Tagno()
         ORDSETFOCUS(nWindSel)
        ENDIF
   ENDIF
   WCLOSE()
   WSELECT(nOldWindow)
RETURN (cOrder)
// EOF: RepOrder
Posts: 10733
Joined: Sun Nov 19, 2006 05:22 AM

Re: How can I do this in GUI style ?

Posted: Mon Aug 19, 2013 08:30 PM
You may try using this function in the place of AChoice

Code (fw): Select all Collapse
function XChoice( aPrompts, cTitle )

   local nSelect  := 0

   DEFAULT cTitle := "Select"

   XBROWSER aPrompts TITLE cTitle SELECT ( nSelect := oBrw:nArrayAt ) ;
      SETUP ( oBrw:lHeader := .f., oBrw:lRecordSelector := .f., oBrw:lHScroll := .f., ;
      oBrw:oWnd:bInit := { |oDlg| oDlg:aControls[ 1 ]:Hide(), oDlg:aControls[ 2 ]:Hide() } )

return nSelect
Regards



G. N. Rao.

Hyderabad, India
Posts: 723
Joined: Tue Sep 04, 2007 08:45 AM

Re: How can I do this in GUI style ?

Posted: Mon Aug 19, 2013 11:08 PM

Rao:

Great job ! Thank you very much.

Continue the discussion