Change on Vertical show with xbrowse

Change on Vertical show with xbrowse

Postby Silvio.Falconi » Sun Apr 28, 2013 9:36 pm

Antonio publishes on Topic Utilitades/planitllas this sample to show vertical a record on xbrowse

Code: Select all  Expand view  RUN


#include "FiveWin.ch"
#include "xbrowse.ch"

function Main()

   local oDlg, oBrw, oCol, aRecord, nAt := 1
   
   USE Customer
   
   aRecord = Array( Customer->( FCount() ) )
   
   DEFINE DIALOG oDlg SIZE 300, 300

   @ 0, 0 XBROWSE oBrw OF oDlg ARRAY aRecord // AUTOSORT

   oCol = oBrw:AddCol()
   oCol:bStrData = { || Customer->( FieldName( oBrw:nArrayAt ) ) }
   oCol:cHeader = "FieldName"  

   oCol = oBrw:AddCol()
   oCol:bStrData = { || Customer->( FieldGet( oBrw:nArrayAt ) ) }
   oCol:cHeader = "Value"  

   oBrw:nMarqueeStyle = MARQSTYLE_HIGHLROW

   oBrw:CreateFromCode()
   oBrw:bKeyCount = { || Customer->( FCount() ) }
   
   oDlg:oClient = oBrw  
     
   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT oDlg:Resize()
     
return nil
 



This show all fields of customer.dbf

But If we want show only some fields of this dbf How We can do ?

sample If we create two array sample :

aFields:={First,Last ,state,salary }
aNames:={"Name","surname" ,"State","salary" }

and call a function Ut_BrwColVert(cDbf,aFields,aNames)


I tried to create this function but not run well because not take the right field


FUNCTION Ut_BrwColVert(cDbf,aTitles,aFields)
local oDlgVista, oBrw
Local nBottom := 33
Local nRight := 66
Local nWidth := Max( nRight * DLG_CHARPIX_W, 180 )
Local nHeight := nBottom * DLG_CHARPIX_H
lOCAL aStruct

IF LEN(aFields)=0
aStruct := (cdbf)->( DbStruct() )
ELSE
aStruct :=aFields
eNDIF


IF nType =1
If Len( aStruct) != Len(aTitles)
msginfo("Error on titles - fields","ATTENtION!")
return nil
ENDIF

DEFINE DIALOG oDlgVista SIZE nWidth, nHeight ;
Title "Visualizzazione verticale"


@ 0,0 XBROWSE oBrw OF oDlgVista COLUMNS 1 HEADERS "Campi" ;
COLSIZES 140;
ARRAY aStruct CELL LINES NOBORDER SIZE -1,-20

ADD TO oBrw DATA (cdbf)->(FieldGet(oBrw:nArrayAt)) TITLE "Valori"


oBrw:aCols[ 1 ]:bEditValue := { ||aTitles[ oBrw:nArrayAt ] }
oBrw:aCols[ 1 ]:nWidth := 200
oBrw:aCols[ 2 ]:nWidth := 300



oBrw:CreateFromCode()


@ 230, 193 BUTTON oBtn PROMPT "&Uscita" OF oDlgVista SIZE 40, 15;
PIXEL ACTION oDlgVista:end()
ACTIVATE DIALOG oDlgVista center

return nil
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: Change on Vertical show with xbrowse

Postby nageswaragunupudi » Mon Apr 29, 2013 2:09 am

If you want just the same functionality of the above sample, i.e, without editing and navigation of dbf, this simple function works for you.
Code: Select all  Expand view  RUN
#include "FiveWin.Ch"
#include "ord.ch"
#include "xbrowse.ch"

REQUEST DBFCDX

function Main()

   local aCols    := { ;
      { "Name",      "First"  }, ;
      { "SurName",   "Last"   }, ;
      { "State",     "State"  }, ;
      { "Salary",    "Salary" }  }

   USE CUSTOMER NEW ALIAS CUST SHARED VIA "DBFCDX"
   GO TOP
   CUST->( Ut_BrwColVert( aCols ) )
   CLOSE CUST

return (0)

function Ut_BrwColVert( aCols )

   local oDlg, oBrw, cAlias

   cAlias   := Alias()

   DEFINE DIALOG oDlg SIZE 300,200 PIXEL TITLE cAlias
   @ 10,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      DATASOURCE aCols ;
      COLUMNS 1, { || ( cAlias )->&( oBrw:aRow[ 2 ] ) } ;
      HEADERS "ColumnName", "ColumnValue" ;
      CELL LINES NOBORDER

   WITH OBJECT oBrw
      :nStretchCol      := 2
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED ON INIT ( oBrw:SetFocus(), .f. )

return nil
 
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10656
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Change on Vertical show with xbrowse

Postby nageswaragunupudi » Mon Apr 29, 2013 2:30 am

I suggest you first compile and test the code above.

Here I am posting a more elaborate function. This function provides
(1) editing the field
(2) buttons to navigate the dbf
(3) resizes the dialog to fit the contents of the browse.

Code: Select all  Expand view  RUN
/*
*
*  XBRVERT.PRG
*  Apr 29-2013 05:13 AM
*
*/


#include "FiveWin.Ch"
#include "ord.ch"
#include "xbrowse.ch"

//----------------------------------------------------------------------------//

REQUEST DBFCDX

//----------------------------------------------------------------------------//

function Main()

   local aCols    := { ;
      { "Name",      "First"  }, ;
      { "SurName",   "Last"   }, ;
      { "State",     "State"  }, ;
      { "Salary",    "Salary" }  }

   USE CUSTOMER NEW ALIAS CUST SHARED VIA "DBFCDX"
   GO TOP

   CUST->( FldVertBrowse( aCols ) )

   CLOSE CUST

return (0)

//----------------------------------------------------------------------------//

init procedure PrgInit

   SET DATE ITALIAN
   SET CENTURY ON
   SET TIME FORMAT TO "HH:MM:SS"
   SET EPOCH TO YEAR(DATE())-50

   SET DELETED ON
   SET EXCLUSIVE OFF

   RDDSETDEFAULT( "DBFCDX" )

   XbrNumFormat( 'E', .t. )
   SetKinetic( .f. )
   SetGetColorFocus()

return

//----------------------------------------------------------------------------//

function FldVertBrowse( aCols )

   local oDlg, oBrw, oFont, nRec, hRes
   local nSelect  := SELECT()
   local aBrw     := AClone( aCols )

   nRec           := RecNo()

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
   DEFINE DIALOG oDlg SIZE 600,600 PIXEL TITLE Alias() FONT oFont

   // --------- BUTTONS FOR NAVIGATION OF DBF --------------------//

   hRes           := GetResources()
   SET RESOURCES TO "PREV32.DLL"

   @ 05, 10 BUTTONBMP SIZE 16,16 PIXEL BITMAP "Top2" OF oDlg ;
      WHEN ( nSelect )->( OrdKeyNo() ) > 1 ;
      ACTION ( ( nSelect )->( DbGoTop(), nRec := RecNo()    ), oDlg:Update(), oDlg:AEvalWhen(), oBrw:SetFocus() )
   @ 05, 30 BUTTONBMP SIZE 16,16 PIXEL BITMAP "Previous2" OF oDlg ;
      WHEN ( nSelect )->( OrdKeyNo() ) > 1 ;
      ACTION ( ( nSelect )->( DbSkip(-1), nRec := RecNo()   ), oDlg:Update(), oDlg:AEvalWhen(), oBrw:SetFocus() )

   @ 00,050 SAY "RecNo" SIZE 40,09 PIXEL OF oDlg CENTER
   @ 10,050 GET nRec PICTURE "9999" SIZE 40,12 PIXEL OF oDlg RIGHT UPDATE ;
      VALID ( ( nSelect )->( DbGoTo( nRec ), nRec := RecNo() ), oDlg:Update(), oDlg:AEvalWhen(), oBrw:SetFocus(), .t. )

   @ 05, 95 BUTTONBMP SIZE 16,16 PIXEL BITMAP "Next2" OF oDlg ;
      WHEN ( nSelect )->( OrdKeyNo() < OrdKeyCount() ) ;
      ACTION ( ( nSelect )->( DbSkip( 1), nRec := RecNo()   ), oDlg:Update(), oDlg:AEvalWhen(), oBrw:SetFocus() )
   @ 05,115 BUTTONBMP SIZE 16,16 PIXEL BITMAP "Bottom2" OF oDlg ;
      WHEN ( nSelect )->( OrdKeyNo() < OrdKeyCount() ) ;
      ACTION ( ( nSelect )->( DbGoBottom(), nRec := RecNo() ), oDlg:Update(), oDlg:AEvalWhen(), oBrw:SetFocus() )

   SetResources( hRes )

   //------------ XBROWSE DEFINITION --------------------//

   @ 30, 10 XBROWSE oBrw SIZE 280,260 PIXEL OF oDlg ;
      DATASOURCE aBrw ;
      COLUMNS 1, { || ( nSelect )->( &( oBrw:aRow[ 2 ] ) ) } ;
      HEADERS  "Column", "ColumnValue" ;
      CELL LINES NOBORDER FASTEDIT UPDATE

   WITH OBJECT oBrw
      :lHScroll       := .f.
      oBrw:aCols[ 1 ]:bClrStd := { || { CLR_BLACK, oBrw:nRecSelColor } }

      WITH OBJECT oBrw:aCols[ 2 ]
         :nEditType     := EDIT_GET
         :bOnPostEdit   := { |o,x,n| ( nSelect )->( If( n != VK_ESCAPE .and. DbRLock(), ;
               ( FieldPut( FieldPos( o:oBrw:aRow[ 2 ] ), x ), DbRUnlock() ), nil ) ) }
      END
      //
      :CreateFromCode()
   END

   // -------------- ACTIVATE DIALOG -------------------//

   ACTIVATE DIALOG oDlg ON INIT DlgInit( oBrw )
   RELEASE FONT oFont

return nil

//----------------------------------------------------------------------------//

static function DlgInit( oBrw )

   local oDlg     := oBrw:oWnd
   local aDim     := { oBrw:nWidth, oBrw:nHeight }

   // ----- RESIZE DIALOG TO FIT THE CONTENTS OF BROWSE -------//

   oBrw:BrwFitSize( .t. )
   if oBrw:nWidth < 284
      oBrw:nWidth := 284
      oBrw:nStretchCol  := 2
   endif
   oDlg:nWidth    += ( oBrw:nWidth  - aDim[ 1 ] )
   oDlg:nHeight   += ( oBrw:nHeight - aDim[ 2 ] )

   WITH OBJECT oBrw
      :ColStretch()
      :oWnd:Center()
      :SetFocus()
   END

return .f.

//----------------------------------------------------------------------------//
 


I have used 'prev32.dll' for the button bitmaps. If your dll name is different, please change in the program.
Regards

G. N. Rao.
Hyderabad, India
User avatar
nageswaragunupudi
 
Posts: 10656
Joined: Sun Nov 19, 2006 5:22 am
Location: India

Re: Change on Vertical show with xbrowse

Postby Silvio.Falconi » Mon Apr 29, 2013 8:02 am

Thanks Mr. Rao, this is that I mean!
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: Change on Vertical show with xbrowse

Postby Silvio.Falconi » Mon Apr 29, 2013 9:45 am

I made some modifies : I insert a buttonbar and insert your buttons and get....only the say is not transparent ( Isaw on rpreview but not run ok)

Image




Code: Select all  Expand view  RUN

   /*
    *
    *  XBRVERT.PRG
    *  Apr 29-2013 05:13 AM
    *
    */


    #include "FiveWin.Ch"
    #include "ord.ch"
    #include "xbrowse.ch"
    #include "constant.ch"

      #define LIGHTCYAN        nRGB( 203, 225, 252 )


    //----------------------------------------------------------------------------//

    REQUEST DBFCDX

    //----------------------------------------------------------------------------//

    function Main()
               /*
       local aCols    := { ;
          { "Name",      "First"  }, ;
          { "SurName",   "Last"   }, ;
          { "State",     "State"  }, ;
          { "Salary",    "Salary" }  }
                 */



            local aCols    := { ;
              {"Name","FIRST"  }, ;
              {"Surname" , "LAST" }, ;
              {"Address","STREET" }, ;
              {"City","CITY"   }, ;
              {"State","STATE"  }, ;
              {"HireDate","HIREDATE" }, ;
              {"Married","MARRIED" }, ;
              {"Age","AGE"    }, ;
              {"Salary","SALARY" }, ;
              {"Notes","NOTES"  } }






       USE CUSTOMER NEW ALIAS CUST SHARED VIA "DBFCDX"
       GO TOP

       CUST->( FldVertBrowse( aCols ) )

       CLOSE CUST

    return (0)

    //----------------------------------------------------------------------------//

    init procedure PrgInit

       SET DATE ITALIAN
       SET CENTURY ON
       SET TIME FORMAT TO "HH:MM:SS"
       SET EPOCH TO YEAR(DATE())-50

       SET DELETED ON
       SET EXCLUSIVE OFF

       RDDSETDEFAULT( "DBFCDX" )

       XbrNumFormat( 'E', .t. )
       SetKinetic( .f. )
       SetGetColorFocus()

    return

    //----------------------------------------------------------------------------//

    function FldVertBrowse( aCols )

       local oDlg, oBrw, oFont, nRec, hRes
       local nSelect  := SELECT()
       local aBrw     := AClone( aCols )

        Local nBottom   := 37
        Local nRight    := 75
        Local nWidth :=  Max( nRight * DLG_CHARPIX_W, 180 )
        Local nHeight := nBottom * DLG_CHARPIX_H

          nRec           := RecNo()

       DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-14
       DEFINE DIALOG oDlg  SIZE nWidth,nHeight ;
       Title "Visualizzazione verticale" FONT oFont ;
       GRADIENT { { 1,CLR_WHITE, LIGHTCYAN } }


       //------------ XBROWSE DEFINITION --------------------//

       @ 14, 0 XBROWSE oBrw  SIZE 296,250 PIXEL OF oDlg ;
          DATASOURCE aBrw ;
          COLUMNS 1, { || ( nSelect )->( &( oBrw:aRow[ 2 ] ) ) } ;
          HEADERS  "Colonna", "Valore" ;
          CELL LINES NOBORDER FASTEDIT UPDATE

       WITH OBJECT oBrw
          :lHScroll       := .f.
          oBrw:aCols[ 1 ]:bClrStd := { || { CLR_BLACK, oBrw:nRecSelColor } }
          oBrw:aCols[ 1 ]:nWidth  := 100
          oBrw:aCols[ 2 ]:nWidth  := 200
          WITH OBJECT oBrw:aCols[ 2 ]
             :nEditType     := EDIT_GET
             :bOnPostEdit   := { |o,x,n| ( nSelect )->( If( n != VK_ESCAPE .and. DbRLock(), ;
                   ( FieldPut( FieldPos( o:oBrw:aRow[ 2 ] ), x ), DbRUnlock() ), nil ) ) }
          END
          //
          :CreateFromCode()
       END




       @ 138,98 Button "&Exit" Action odlg:end() SIZE 40,10 PIXEL

       // -------------- ACTIVATE DIALOG -------------------//

       ACTIVATE DIALOG oDlg ON INIT (DlgInit( oBrw ),oDlgBar(oDlg,oBrw,nSelect,nRec))
       RELEASE FONT oFont

       return nil


        static function oDlgBar(oDlg,oBrw,nSelect,nRec)
           Local oBar,oFontBar,oSay,oRec
           Local hRes:= GetResources()
           SET RESOURCES TO "PREV32.DLL"



           DEFINE BUTTONBAR oBar _3D SIZE 24, 24 OF oDlg  2007

                 DEFINE BUTTON OF oBar ;
                 RESOURCE "Top2"       ;
                 WHEN ( nSelect )->( OrdKeyNo() ) > 1 ;
                 ACTION ( ( nSelect )->( DbGoTop(), nRec := RecNo()    ),oRec:refresh(), oDlg:Update(),;
                 oDlg:AEvalWhen(), oBrw:SetFocus() );
                 NOBORDER


                 DEFINE BUTTON OF oBar ;
                 RESOURCE "Previous2"  ;
                 WHEN ( nSelect )->( OrdKeyNo() ) > 1 ;
                 ACTION ( ( nSelect )->( DbSkip(-1), nRec := RecNo()   ),oRec:refresh(), oDlg:Update(),;
                 oDlg:AEvalWhen(), oBrw:SetFocus() ) ;
                 NOBORDER



                  @ 2,100 SAY oSay PROMPT  "RecNo :" SIZE 40,20 PIXEL OF oBar CENTER

                  @ 2,150 GET oRec VAR  nRec PICTURE "9999" SIZE 65,20 PIXEL OF oBar RIGHT UPDATE ;
                        VALID ( ( nSelect )->( DbGoTo( nRec ), nRec := RecNo() ), oDlg:Update(),;
                       oDlg:AEvalWhen(), oBrw:SetFocus(), .t. )

                 @ 2,290 SAY oSay PROMPT  "" SIZE 0.5,20 PIXEL OF oBar CENTER   FONT oFontBar
                  oSay:lTransparent = .T.

                    #define NULL_BRUSH 5
                     FixSays( oBar:hWnd, GetStockObject( NULL_BRUSH ) )







                 DEFINE BUTTON OF oBar ;
                 RESOURCE "Next2"      ;
                 WHEN ( nSelect )->( OrdKeyNo() < OrdKeyCount() ) ;
                 ACTION ( ( nSelect )->( DbSkip( 1), nRec := RecNo()   ),oRec:refresh(), oDlg:Update(),;
                 oDlg:AEvalWhen(), oBrw:SetFocus() ) ;
                 NOBORDER

                 DEFINE BUTTON OF oBar ;
                 RESOURCE "Bottom2"    ;
                 WHEN ( nSelect )->( OrdKeyNo() < OrdKeyCount() ) ;
                 ACTION ( ( nSelect )->( DbGoBottom(), nRec := RecNo() ),oRec:refresh(), oDlg:Update(),;
                 oDlg:AEvalWhen(), oBrw:SetFocus() );
                 NOBORDER
                SetResources( hRes )

         return nil

    //----------------------------------------------------------------------------//

    static function DlgInit( oBrw )

       local oDlg     := oBrw:oWnd
       local aDim     := { oBrw:nWidth, oBrw:nHeight }

       // ----- RESIZE DIALOG TO FIT THE CONTENTS OF BROWSE -------//

       oBrw:BrwFitSize( .t. )
       if oBrw:nWidth < 284
          oBrw:nWidth := 284
          oBrw:nStretchCol  := 2
       endif
       oDlg:nWidth    += ( oBrw:nWidth  - aDim[ 1 ] )
       oDlg:nHeight   += ( oBrw:nHeight - aDim[ 2 ] )

       WITH OBJECT oBrw
          :ColStretch()
          :oWnd:Center()
          :SetFocus()
       END

    return .f.

    //----------------------------------------------------------------------------//
 






I'd like insert it on lookup xbrowse main ( I create a button bar where I call XBRVERT.PRG)
and how I can to create acols from xbrowse ?

I thiked this :

LOCAL nLen := Len( oBrowse:aCols )
LOCAL aHeader [ nLen ]
LOCAL aShow [ nlen ]
LOCAL aSizes [ nLen ]
LOCAL aArray [ nLen ]

FOR n := 1 TO nLen
aHeader [ n ] := oBrowse:aCols[ n ]:cHeader
aShow [ n ] := ! oBrowse:aCols[ n ]:value
aArray [ n ] := {aHeader[n],aShow[n]}
NEXT

xbrowse.....oBrw:SetArray(aArray)

it can run ?
Last edited by Silvio.Falconi on Mon Apr 29, 2013 10:15 am, edited 1 time in total.
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm

Re: Change on Vertical show with xbrowse

Postby Silvio.Falconi » Mon Apr 29, 2013 10:04 am

Image








I made ( but it run bad)
oBrowse is the main xbrowse table


Code: Select all  Expand view  RUN


Function testsilvio(cDbf, oBrowse)
LOCAL nLen := Len( oBrowse:aCols )
LOCAL aHeader [ nLen ]
LOCAL aShow [ nlen ]
LOCAL aSizes [ nLen ]
LOCAL aArray [ nLen ]

    FOR n := 1 TO nLen
       aHeader [ n ] := oBrowse:aCols[ n ]:cHeader
       aShow [ n ] := oBrowse:aCols[ n ]:Value

       aArray [ n ] := {aHeader[n],aShow[n]}
NEXT


//call your vertical function
   FldVertBrowse(aArray )

 RETUR NIL




strange If I made xbrowser aArray I can see good !!!
Since from 1991/1992 ( fw for clipper Rel. 14.4 - Momos)
I use : FiveWin for Harbour November 2023 - January 2024 - Harbour 3.2.0dev (harbour_bcc770_32_20240309) - Bcc7.70 - xMate ver. 1.15.3 - PellesC - mail: silvio[dot]falconi[at]gmail[dot]com
User avatar
Silvio.Falconi
 
Posts: 7075
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 93 guests