Making a config dialog

Making a config dialog

Postby Silvio » Sun Jan 04, 2009 4:10 am

I saved on a file INI the state of Xbrowse.


for sample I have a dbf with 4 fields
First
Last
Street
City

for each colums I save the state on file INI:

the number of column
the size of column
the name of header
and the logic variable if itis shoed or not


look this please


CuState=21;1:150:First:S;2:150:Last:S;3:150:Street:S;4:150:City:S

Now I want create a config dialog to set these parameters
to config each columns
Code: Select all  Expand view
FUNCTION  xbrowseconfig(oGrid,cIniFile,cState )
LOCAL oDlg
LOCAL cTitle :="Configurazione Tabella"
Local aOriginal  := {}
Local aMoved := {}


  if Empty( cState )
      return nil
   endif


   nLen   := len( oGrid:aCols )
   nHeight := Val(StrToken( cState, 1, ";" ) )

   if Empty( nHeight )
      return nil
   endif



  // Check integrity
   nLen   := len( oGrid:aCols )
   for nFor := 1 to nLen
      cCol := StrToken( cState, nFor + 1, ";" )
      if Empty( cCol )
      return nil
      endif
   next


oGrid:nRowHeight := nHeight



for nFor := 1 to nLen
      cCol   := StrToken( cState, nFor + 1, ";" )
      nOrder := Val( StrToken( cCol, 1, ":" ) )
      nWidth := Val( StrToken( cCol, 2, ":" ) )
      lHide  := ( Alltrim( StrToken( cCol, 3, ":" ) ) == "H" )

      nAt := Ascan( oGrid:aCols, {|v| v:nCreationOrder == nOrder } )
      if nAt > 0
         oCol := oGrid:aCols[ nAt ]
         oCol:lHide  := lHide
         oCol:nWidth := nWidth
      endif
      Aadd( aMoved, oGrid:aCols[ nOrder ])
   next



oGrid:aCols := aMoved


//Now I save the header to acolonne array

nLen := len(  aMoved )
       for nFor := 1 to nLen
          oCol    := aMoved[ nFor ]
          nAt := Ascan( aMoved, {|v| v:nCreationOrder == oCol:nCreationOrder } )
            oCol := aMoved[ nAt ]
             cPrompt :=  oCol:cHeader
              AADD(aColonne,  cPrompt)
            NEXT


//Now I save  the orinal array to aOriginal

for n := 1 to len( aMoved )
               aadd( aOriginal, aMoved[n] )
          next

//OPen the dialog

DEFINE DIALOG oDlg ;
       FROM 317, 412 TO 525, 732 PIXEL ;
       TITLE  cTitle 


@ 4, 3 SAY "Puoi cambiare l'ordine dei campi oppure mostrarli" ;
             SIZE 83, 6 PIXEL OF oDlg


@ 5,3 LISTBOX oLbx  OF oDlg;
            FIELDS HEADER "","campi" UPDATE ;
            SIZES 55, 100
            ON DBLCLICK ( IF( aMoved[oLbx:nAt, oLbx:nColAct] = 'S', ;
                                                aMoved[oLbx:nAt, oLbx:nColAct] := 'N', ;
                                                aMoved[oLbx:nAt, oLbx:nColAct] := 'S'), ;
                                             oLbx:Drawselect() )


  oLbx:setArray(aMoved )

  oLbx:bLine:={|| {  aMoved[oLbx:nAt,1],;
                         IF( aMoved[oLbx:nAt,2] = 'S', oBmpYes, oBmpNo )  } }


@ 65,3 SAY "Larghezza della colonna :" ;
             SIZE 83, 20 PIXEL OF oDlg

      @ 65, 70 GET oGet VAR oCol:nWidth SIZE 10, 5 PIXEL OF oDlg RIGHT PICTURE "999";
                 SPINNER Min 50 Max 150  valid (oGet:Refresh(), .T.)

  ACTIVATE DIALOG oDlg CENTERED




but it make error ....why ?

can I use xbrowse instead a listbox ? and how ?
I want create checkboxs for the first column and the fields names on the second colum
and select each chechbox to select if show a field or not .
Some can help me pls ?
Best Regards, Saludos

Falconi Silvio
User avatar
Silvio
 
Posts: 3107
Joined: Fri Oct 07, 2005 6:28 pm
Location: Teramo,Italy

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 85 guests