Newbie Question : XBROWSE

Newbie Question : XBROWSE

Postby Jimmy » Fri Nov 25, 2022 6:30 am

hi,

i try to use XBROWSE but hae some Problem

Code: Select all  Expand view  RUN
PROCEDURE DoShowDBF(cPath,cFile)
LOCAL oWnd, oBrwDBF

   SELECT 99
   USE (cPath+cFile) VIA "DBFCDX" ALIAS "TEMP" EXCLUSIVE

   DEFINE WINDOW oWnd FROM 0, 0 TO 800, 700 PIXEL TITLE "DBF "+cFile ICON "A1M

   @ 0, 0 XBROWSE oBrwDBF OF oWnd ;
         FONT oFontDefault      ;
         ALIAS "
TEMP" AUTOCOLS FASTEDIT

#IFDEF __HMG__
   END WINDOW
#ENDIF

   oBrwDBF:CreateFromCode()
   oWnd:oClient := oBrwDBF

   ACTIVATE WINDOW oWnd ON INIT MakeTop( oWnd, oBrwDBF ) CENTER

   SELECT 99
   CLOSE

   SELECT 1
RETURN

i have figure out that a need CreateFromCode() ... what does it mean :?:

now i can "see" my Data but when "move" vitcal Scrollbar it crash : no WorkArea :shock:
Error description: Error DBCMD/2001 Workarea not in use: DBGOTO


Newbie need some help, who can point me to a "simple" Demo

---

there are a lot of Sample ... but they are not "sort"
when search for XBROWSE Sample i find a lot ... but as Newbie i don´t know which to use
if Sample are "sort" into Folder e.g. \XBROWSE it would be much better for Newbie to learn
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Newbie Question : XBROWSE

Postby Marc Venken » Fri Nov 25, 2022 8:16 am

Here is some code snippeds for setting up Xbrowses. I think you can find usefull code inside it.

I left the remarks // because they are sometimes coded because I found them on forum and wanted to test.

Code: Select all  Expand view  RUN

/////////////////////////////////////////////////////////////////  BRW /////////////////////////////////////////////////
   aVelden :=  { ;
   { "ID"       , "Id"      ,nil,  90 }, ;
   { "orgfoto"  , "Coverfoto" ,nil, 100 }, ;
   { "naam"     , "Benaming",nil, 120 }, ;
   { "pagina"   , "Pag"     ,nil,  40 }, ;
   { "reflev"   , "RefLev"  ,nil,  70 }, ;
   { "shoptrad" , "Shop"     ,nil,  35 }, ;
   { "zoeken"   , "Zoekterm",nil,  15 }, ;
   { "fabrikan" , "Merk"    ,nil,  50 }, ;
   { "Online"   , "Onl"     ,nil,  30 }, ;
   { "picfound" , "Foto"     ,nil,  30 }, ;
   { "kleur"    , "Kleur"   ,nil, 70 }, ;
   { "size"     , "Maat"    ,nil, 70 }, ;
   { "memotxt"  , "Memotxt" ,nil, 60 }, ;
   { "selected" , "Sel"     ,nil,  30 }, ;
   { "aankoop"  , "Aank"    ,nil,  45 }, ;
   { "Prijs"    , "Prijs"   ,nil,  45 }, ;
   { "Korting"  , "Kort"    ,nil,  45 }, ;
   { "stockid"  , "Sto"     ,nil,  30 }, ;
   { "layover"  , "Lay"     ,nil,  30 }, ;
   { "uitass"   , "Uit"     ,nil,  30 }, ;
   { "Wissen"   , "Wis"     ,nil,  30 } }
/*
   { "colaantal", "Col"     ,nil,  25 }, ;
   { "colaanatt", "Att"     ,nil,  25 }, ;
   { "colaanpic", "Pic"     ,nil,  25 }, ;
*/

   /*
   AEval( aVelden, { | a | AAdd( aFields, a[ 1 ] ),;
                           AAdd( aHeaders, a[ 2 ] ),;
                           AAdd( aSizes, a[ 3 ] ) } )
    */


   //lFastDraw = .T.


   @ 250,10 XBROWSE oBrw SIZE 1200,250 ;
      PIXEL OF oWnd font oFont3;
      DATASOURCE "nofoto" ;
      COLUMNS aVelden;
      CELL LINES NOBORDER FASTEDIT

      oBrw:nEditTypes = EDIT_GET
      oBrw:SetChecks()
      // oBrw:lRowBox = .t.
      // Color Header
      oBrw:memotxt:bClrHeader := { || { CLR_GREEN, 155 } }
      oBrw:kleur:bClrHeader := { || { CLR_GREEN, 155 } }
      oBrw:onl:bClrHeader := { || { CLR_GREEN, 155 } }
      oBrw:Sel:bClrHeader := { || { CLR_GREEN, 155 } }
      oBrw:Shop:bClrHeader := { || { CLR_GREEN, 155 } }

      oBrw:foto:nFooterType := AGGR_COUNT
      oBrw:foto:bSumCondition := { || nofoto->picfound }

      oBrw:Shop:nFooterType := AGGR_COUNT
      oBrw:Shop:bSumCondition := { || !nofoto->shoptrad }

      // Action to header
      oBrw:memotxt:bLClickHeader := { |r,c,f,oCol| FRichedit(oCol:Value),oBrw:refresh() }
      //oBrw:memotxt:bLClickHeader := { |r,c,f,oCol| edit_memo(oCol:Value),oBrw:refresh() }
      oBrw:kleur:bLClickHeader := { |r,c,f,oCol| edit_kleur(oCol:Value),oBrw:refresh() }
      oBrw:onl:bLClickHeader := { |r,c,f,oCol| mark_online(oCol:Value),oBrw:gotop(),oBrw:setfocus(),oBrw:refresh() }
      oBrw:Sel:bLClickHeader := { |r,c,f,oCol| mark_selection(oCol:Value),oBrw:refresh() }
      oBrw:Shop:bLClickHeader := { |r,c,f,oCol| mark_shop_selection(oCol:Value),oBrw:refresh() }

      oBrw:bRClickHeaders := { || XbrColSelector( oBrw ) }  // Kies welke velden tezien zijn
//     oBrw[1]:bRClickHeaders := { || XbrColSelector( oBrw[1] ) }
//     oBrw[1]:bRClicked := { || XbrShowSizes( oBrw[1] )  }



//don't forget

//ReleaseDC(hDC) after oDlg:End()


   WITH OBJECT oBrw
//      :lEditMode := .T.
      :lFooter          := .t.
      :bRecSelHeader    := { || "" }
      :bRecSelData      := { |o| o:KeyNo }
      :bRecSelFooter    := { |o| o:nLen }
      :oRecSelFont      := oFont3  // optional
      :nRecSelWidth     := "99999" // required size
      :lHScroll         := .F.


      //:picfound:SetCheck()
      //:nStretchCol   := 3

//      :bChange       := { || SET_SCOPE(oBrw2),('foto')->(DBGOTOP()),oBrw2:Refresh(),oBrw4:gotop(),oBrw4:Refresh(),oImage:Refresh(),oImage2:Refresh(),Obrw:refresh(),Oget:refresh(),oGet2:refresh() }

//      :bChange       := { || scopetimer(oBrw),('foto')->(DBGOTOP()),oBrw2:Refresh(),oBrw4:gotop(),oBrw4:Refresh(),oImage:Refresh(),oImage2:Refresh(),Obrw:refresh(),Oget:refresh(),oGet2:refresh() }

      //:bChange       := { || SET_SCOPE(oBrw2) }

      //:bChange    := { || nSecs := SECONDS(), scope_nofoto(), oBrw2:refresh() }
      :bChange    := { || nSecs := SECONDS(), oBrwEan:gotop(), oBrwEan:refresh() , scope_nofoto(), oBrw2:refresh() }


//    :bChange       := { |nRow,nCol,oCol,nKey| oImage:Refresh() }

//      :bKeyDown   := { |nKey| If( nKey == VK_DELETE, (oBrw:cAlias)->( BrwDelete( oBrw ) ), nil ) }

      :bKeyDown   := { |nKey| If( nKey == VK_DELETE, (oBrw:cAlias)->( BrwDelselect( oBrw ) ), nil ) }

      :lMultiSelect     := .T.

      oBrw:kleur:bToolTip :=  { | oBrw,r,c,f,oMouseCol,nMouseRow| MyColToolTip( oBrw,r,c,f,oMouseCol,nMouseRow ) }
      oBrw:memotxt:bToolTip :=  { | oBrw,r,c,f,oMouseCol,nMouseRow| MyColToolTip( oBrw,r,c,f,oMouseCol,nMouseRow ) }
      oBrw:Pag:bClrStd := { || IF( nofoto->shoptrad , { CLR_BLACK,CLR_WHITE } , { CLR_WHITE ,CLR_HRED} ) }
      oBrw:Prijs:bClrStd := { || IF( nofoto->prijs > 0 , { CLR_BLACK,CLR_WHITE } , { CLR_WHITE ,CLR_HRED} ) }

      WITH OBJECT:shop
         :nFooterType  := AGGR_COUNT
         :bSumCondition := { || !nofoto->shoptrad }
      END


      WITH OBJECT:prijs
         :nFooterType  := AGGR_COUNT
         :bSumCondition := { || nofoto->prijs = 0 }
      END


      WITH OBJECT:kleur
         :nEditType     := EDIT_GET_BUTTON
         :bClrSel          := { || { CLR_BLACK, CLR_HGRAY }}
         :bEditBlock    := { |r,c,oCol| fotoSelect( oCol:Value ) }
      //   :bOnChange     := { |oCol,uOldVal| oBrw:kleur:VarPut( tempfoto->foto ) }
      ENDWITH
      /*
      WITH OBJECT:pos
         :bOnChange     := { |oCol,uOldVal| oBrw:gotop(), oBrw:refresh()  }
      ENDWITH
      */



      WITH OBJECT :oCol( 1 )
         :nEditType     := EDIT_GET_BUTTON

         :bClrSel          := { || { CLR_BLACK, CLR_YELLOW }}
         :bEditBlock    := { |r,c,oCol| LookupArt( oCol:Value ) }
         //:bOnChange     := { |oCol,uOldVal| oData:FieldValue:VarPut( PRD->VELD ) }

      ENDWITH

      WITH OBJECT :oCol( 2 )
         :nEditType     := EDIT_GET_BUTTON

         :bClrSel          := { || { CLR_BLACK, CLR_YELLOW }}
         :bEditBlock    := { |r,c,oCol| LookupPic( oCol:Value ) }
         //:bOnChange     := { |oCol,uOldVal| oData:FieldValue:VarPut( PRD->VELD ) }

      ENDWITH

      WITH OBJECT:memotxt
         :nEditType     := EDIT_GET

         :bClrSel          := { || { CLR_BLACK, CLR_YELLOW }}
         :bEditBlock    := { |r,c,oCol| edit_memo( oCol:Value ) }
         //:bOnChange     := { |oCol,uOldVal| oData:FieldValue:VarPut( PRD->VELD ) }

      ENDWITH
   /*
   WITH OBJECT :pag2
      :uBarGetVal    := uValBlank( :Value )
      :nEditType     := EDIT_GET_LISTBOX
      :aEditListTxt  := aPaginas
      :aBarGetList:= aPaginas
   ENDWITH
   WITH OBJECT :pag3
      :uBarGetVal    := uValBlank( :Value )
      :nEditType     := EDIT_GET_LISTBOX
      :aEditListTxt  := aPaginas
      :aBarGetList:= aPaginas
   ENDWITH
   */


   WITH OBJECT :merk
      :uBarGetVal    := uValBlank( :Value )
      :nEditType     := EDIT_GET_LISTBOX
      :aEditListTxt  := aLeveranciers
      //:bOnChange := { |oCol, uOldVal| OnGroepChange( oBrw, oCol, uOldVal ) }
      :aBarGetList:= aLeveranciers
   ENDWITH

/*
      WITH OBJECT :oCol( 11 )
         :nEditType     := EDIT_BUTTON
      ENDWITH
*/



      // Toon memo met meer regels
      //:aCols[ 9 ]:bEditValue := { || StrTran( oBrw:aRow[ 9 ], "<br>", CRLF ) }
      //:nDataLines := 4

      :bClrEdits        := { || { CLR_BLACK, CLR_YELLOW }}
      :nMarqueeStyle    := MARQSTYLE_HIGHLROWMS
      :bClrRowFocus     := { || { CLR_BLACK, RGB(185,220,255) } }

      :CreateFromCode()
   END
   //oBrw:bRClicked     := { |r,c,f,oStru| msginfo("Code naar Clipbord : "+nofoto->ID),oClp:SetText(alltrim(nofoto->ID)) }
   oBrw:MakeTotals()
   oBrw:bGotFocus := {|| updatescreen(),oBrw:MakeTotals(),oBrw:refresh() }
   oBrw:wis:bClrStd := { || IF( nofoto->wissen , { CLR_HRED,CLR_WHITE } , { CLR_BLACK,CLR_WHITE } ) }
   oBrw:uit:bClrStd := { || IF( nofoto->uitass , { CLR_BLACK,CLR_HGREEN } , { CLR_HRED,CLR_WHITE } ) }

   //oBrw:lHoverSelect := .t.


//   oBrw:bToolTips   := ;
//         { | oBrw,r,c,f,oMouseCol,nMouseRow| MyColToolTip( oBrw,r,c,f,oMouseCol,nMouseRow ) }

//   oBrw:bToolTips   := ;
//         { | oBrw,r,c,f,oMouseCol,nMouseRow| MyTip( oBrw,r,c,f,oMouseCol,nMouseRow ) }



   //oBrw:att:bClrStd := { || IF( nofoto->colaanatt <> val (nofoto->colaantal) , { CLR_BLACK,CLR_HRED } , { CLR_BLACK,CLR_WHITE } ) }
   //oBrw:pic:bClrStd := { || IF( nofoto->colaanpic <> val (nofoto->colaantal) , { CLR_BLACK,CLR_HRED } , { CLR_BLACK,CLR_WHITE } ) }
   //oBrw:foto:bClrStd := { || IF( !nofoto->picfound , { CLR_BLACK,CLR_HRED } , { CLR_HRED,CLR_WHITE } ) }


// @  830,100 say oGet PROMPT shownice(nofoto->memotxt) SIZE 700,200 PIXEL OF oWnd FONT oFont3 UPDATE

// @  330,1610 say oGet PROMPT shownice(nofoto->memotxt) SIZE 500,400 PIXEL OF oWnd FONT oFont3 UPDATE

 //@  330,1610 say oGet PROMPT nofoto->memotxt SIZE 370,400 PIXEL OF oWnd FONT oFont3 UPDATE
// @  590,1610 say oGet2 PROMPT master->memotxt SIZE 500,400 PIXEL OF oWnd FONT oFont3 UPDATE

//   @  60,1650 GET oGet VAR ( StrTran( nofoto->memo, "<br>", CRLF ) ) SIZE 370,400 PIXEL OF oWnd FONT oFont3 UPDATE


   //oBrw:aCols[ 1 ]:nEditType = 0 // Don't allow to edit first column
  // oBrw:aCols[ 2 ]:bOnChange = { || oBtnSave:Enable() }
   //oBrw:aCols[ 2 ]:lWillShowABtn = .T.
   //oBrw:nMarqueeStyle = MARQSTYLE_HIGHLROW
   /*
   oBrw:bClrStd = { || If( oBrw:KeyNo() % 2 == 0, ;
                         { CLR_BLACK, RGB( 198, 255, 198 ) }, ;
                         { CLR_BLACK, RGB( 232, 255, 232 ) } ) }
   oBrw:bClrSel = { || { CLR_WHITE, RGB( 0x33, 0x66, 0xCC ) } }
   oBrw:SetColor( CLR_BLACK, RGB( 232, 255, 232 ) )
   */



/////////////////////////////////////////////////////////////////  BRW 2 /////////////////////////////////////////////////



   @ 75,860 XBROWSE oBrw2 SIZE 280,170 ;
      PIXEL OF oWnd font oFont3;
      DATASOURCE "Foto";
      COLUMNS "foto","foto" ;
      HEADERS "Foto","Pic";
      COLSIZES 150,50;
      AUTOSORT CELL LINES FOOTERS NOBORDER fastedit

      //oBrw2:bGotFocus := {|| oImage2:Refresh(), oBrwP:gotop(), oBrwP:refresh() }
      //oBrw:bGotFocus := {|| oBrw2:seek(alltrim(nofoto->art_lev)),oImage2:Refresh()}

   for n := 1 to Len( oBrw2:aCols )
      WITH OBJECT oBrw2:aCols[ n ]
         :bClrEdit      := { || { CLR_BLACK, CLR_YELLOW }}
         if :cDataType != 'L'
            :uBarGetVal    := uValBlank( :Value )
            :cBarGetPic    := :cEditPicture
         endif
      END
   next

   WITH OBJECT oBrw2


      :lFooter          := .t.
      :bRecSelHeader    := { || "Row" }
      :bRecSelData      := { |o| o:KeyNo }
      :bRecSelFooter    := { |o| o:nLen }
      :oRecSelFont      := oFont3  // optional
      :nRecSelWidth     := "99999" // required size

      //:nStretchCol   := 1
    //  :lIncrFilter   := .t.
    //  :lSeekWild     := ( nWild == 2 )
      //:cFilterFld    := "foto"
      :lHScroll         := .F.

      :nRowHeight    := 70

      //:bFooters         := { |oCol| If( Empty( oCol:cOrder ), "", oBrw2:cSeek("") ) }
      :oSeek            := TSeek():New( oBrw2 )

      WITH OBJECT:pic
         :bStrImage     := { || "d:\pictures\smal\"+alltrim(foto->foto) }
         :oDataFont     := oFontXS
         :nDataStrAlign := AL_CENTER + AL_BOTTOM
         :nDataBmpAlign := AL_CENTER
         :aImgRect      := { nil, nil, -15, nil }
      END

  //    :bChange       := { || oImage2:Refresh() }
  //    :bOnChange     := { || oData:RefreshCurrent() }

      :CreateFromCode()
   END
   oBrw2:lGetBar   := .T.


   /*
   @ 40, 870 SAY oBrw2:oSeek PROMPT oBrw2:cSeek SIZE 100,20 PIXEL OF oDlg COLOR CLR_BLACK,CLR_YELLOW PICTURE '@!'
   @ 40,1000 BUTTON "
Zoek Filter"   size 80,20 pixel OF oDlg ACTION (("foto")->( ORDSCOPE(0, "" ) ),("foto")->( ORDSCOPE(1, "" ) ),('foto')->(DBGOTOP()),oBrw2:seek(alltrim(nofoto->zoeken)),oBrw2:refresh(),oBrw2:SetFocus()) font oFont3
   @ 40,1100 BUTTON "
Clear Filter"   size 80,20 pixel OF oDlg ACTION (("foto")->( ORDSCOPE(0, "" ) ),("foto")->( ORDSCOPE(1, "" ) ),('foto')->(DBGOTOP()),oBrw2:seek(""),oBrw2:refresh(),oBrw2:SetFocus()) font oFont3
   @ 40,1200 BUTTON "
Selecteren"   size 80,20 pixel OF oDlg ACTION (piccopy(),oBrw:refresh(),oBrw:SetFocus(),oImage:Refresh()) font oFont3
   */
   @ 40,850 BTNBMP PROMPT "
Set Filter" ;
      SIZE 100,25 PIXEL OF oWnd FLAT ;
      ACTION ( oBrw2:cAlias )->( ("
foto")->( ORDSCOPE(0, "" ) ),("foto")->( ORDSCOPE(1, "" )),SetFilter( oBrw2 ) )
   @ 40,970 BTNBMP PROMPT "
Clear Filter" ;
      SIZE 100,25 PIXEL OF oWnd FLAT ;
      ACTION ( oBrw2:cAlias )->( DBCLEARFILTER(),("
foto")->( ORDSCOPE(0, "" ) ),("foto")->( ORDSCOPE(1, "" ) ),oBrw2:gotop(),oBrw2:Refresh(), oBrw2:SetFocus() )
   @ 40,1080 BTNBMP PROMPT "
Copy Foto" ;
      SIZE 100,25 PIXEL OF oWnd FLAT ;
      ACTION ( msginfo("
Copy foto"),oBrw:refresh() )

*/



////////////////////////////////////////////////////////////////  BRW 3 /////////////////////////////////////////////////
/*
   @ 40,10 XBROWSE oBrw3 SIZE 470,280 ;
      PIXEL OF oWnd font oFont3;
      DATASOURCE "
fotoinde" ;
      COLUMNS "
CODE","Titel","Index","Afdruk","Online","Uploaded","aantal" ;
      HEADERS 'Pag', 'Menu', 'Submenu',"
Sel","Online","upload","Aan";
      COLSIZES 40,100,100,30,70,30,30;
      AUTOSORT CELL LINES NOBORDER FASTEDIT
 */

   @ 40,10 XBROWSE oBrw3 SIZE 470,200 ;
      PIXEL OF oWnd font oFont3;
      DATASOURCE "
fotoinde" ;
      COLUMNS "
CODE","Titel","Index","menu3","Afdruk","Online","Uploaded","drukcode","aantal","toupload" ;
      HEADERS 'Pag', 'Menu', 'Submenu',"
Submenu3","Sel","Online","upload","Act","Aan","upL";
      COLSIZES 40,100,80,80,30,68,30,30,30;
      AUTOSORT CELL LINES NOBORDER FOOTERS

      //FASTEDIT

   oBrw3:aCols[2]:bClrStd := { || IF( !fotoinde->afdruk , { CLR_BLACK,CLR_WHITE } , { CLR_HRED,CLR_WHITE } ) }
   oBrw3:SetChecks()

   oBrw3:sel:nFooterType := AGGR_COUNT
   oBrw3:sel:bSumCondition := { || fotoinde->afdruk }
   oBrw3:MakeTotals()

   WITH OBJECT oBrw3

      :nStretchCol   := 3
      :nEditTypes  := EDIT_GET
      :bClrEdits        := { || { CLR_BLACK, CLR_YELLOW }}
      :nMarqueeStyle    := MARQSTYLE_HIGHLROWMS
      :bClrRowFocus     := { || { CLR_BLACK, RGB(185,220,255) } }
      //:lHScroll         := .F.

      //:Afdruk:SetCheck()


      :lIncrFilter   := .t.
      :lSeekWild     := ( nWild == 1 )
      :cFilterFld    := "
code"


      :bChange       := { || SET_SCOPE_nobrowse(oBrw),('nofoto')->(DBGOTOP()),oBrw:Refresh(),oImage:Refresh(),oImage2:Refresh() }
      :bKeyDown   := { |nKey| If( nKey == VK_DELETE, (oBrw3:cAlias)->( Erase_detail( oBrw3 ) ), nil ) }

      :CreateFromCode()
   END

   @ 220,500 BUTTON "
Add"   size 40,20 pixel OF oDlg ACTION (indexadd(),oBrw3:refresh()) font oFont3
   @ 220,550 BUTTON "
Xls"   size 40,20 pixel OF oDlg ACTION (xbrowser("fotoinde"),oBrw3:refresh()) font oFont3
   @ 220,600 BUTTON "
->" size 40,20 pixel OF oDlg ACTION (Pic_smal_org(), oImage2:refresh(),oImage:refresh(),oBrw:setfocus() ) font oFont3
   @ 220,650 BUTTON "
Copy cover to ID"   size 120,20 pixel OF oDlg ACTION (copy_covertoid(),oBrw:refresh(),oBrw:setfocus() ) font oFont3
   @ 220,800 BUTTON "
<-" size 40,20 pixel OF oDlg ACTION (Pic_org_smal(), oImage:refresh(),oImage2:refresh(),oBrw:setfocus() ) font oFont3
   //@ 360,10 BTNBMP oBtn OF oDlg SIZE 120,30 PROMPT "
Toevoegen" 2007 FONT oFont BOTTOM FILE "..\BITMAPS\sms.bmp" ACTION (indexadd(),oBrw3:refresh()) font oFont3

/////////////////////////////////////////////////////////////////  BRW 4 /////////////////////////////////////////////////

   select master

   aVelden4 :=  { ;
   { "
selection", "Sel"      ,nil,  30 }, ;
   { "
code"     , "Code"     ,nil,  60 }, ;
   { "
naam"     , "Naam"     ,nil, 180 }, ;
   { "
lev_naam" , "Lever"    ,nil,  60 }, ;
   { "
lev_ref"  , "LevCode"  ,nil,  60 }, ;
   { "
fab_naam" , "Fabrikant",nil,  60 }, ;
   { "
fab_ref"  , "FabCode"  ,nil,  60 }, ;
   { "
Pagina"   , "Pag"      ,nil,  40 }, ;
   { "
cat_main" , "Cat_Main" ,nil,  60 }, ;
   { "
cat_sub1" , "Cat_sub"  ,nil,  60 }, ;
   { "
bruto"    , "Bruto"    ,nil,  40 }, ;
   { "
aankoop"  , "Aank"     ,nil,  40 }, ;
   { "
brutokor" , "Kor"      ,nil,  40 }, ;
   { "
kleuren"  , "kleuren"  ,nil,  50 }, ;
   { "
maten"    , "Maten"    ,nil,  50 }, ;
   { "
picture"  , "Picture"  ,nil,  50 }, ;
   { "
memotxt"  , "Memotxt"  ,nil,  50 }, ;
   { "
filename" , "Database" ,nil,  60 } }



   @ 510,10 XBROWSE oBrw4 SIZE 1200,260 ;
      PIXEL OF oWnd font oFont3;
      DATASOURCE "
MASTER" ;
      COLUMNS aVelden4;
      autosort CELL LINES FOOTERS NOBORDER fastedit
      /*;
      ON CHANGE ( ;
         If( Empty( oBrw4:SelectedCol():cOrder ), ;
           ( oBrw4:SelectedCol():SetOrder(), oBrw4:seek("
"), oBrw4:Refresh() ), ;
         nil ) )
      */

   oBrw4:SetChecks()
   //oBrw4:nStretchCol         := STRETCHCOL_WIDEST
   for n := 1 to Len( oBrw4:aCols )
      WITH OBJECT oBrw4:aCols[ n ]
         if :cDataType != 'L'
            :uBarGetVal    := uValBlank( :Value )
            :cBarGetPic    := :cEditPicture
         endif
      END
   next


   // End of Relevant Code
   oBrw4:bGotFocus := {|| oBrw4:refresh(),oImage_master:Refresh()}
   /*
   for nFor := 1 to Fcount()
      oBrw:aCols[ nFor ]:bRClickHeader := {doheaders(oBrw4) }
      //oBrw:aCols[ nFor ]:blDClickData  := {|r,c,f,o| Msginfo("
Left double click on column data " + o:cHeader, "TXBrowse power") }
   next
   */

//   oBrw4:aCols[ 14 ]:bLClickHeader := { doheaders(oBrw4),oBrw:refresh() }

//   oBrw4:aCols[ 15 ]:bLClickHeader := { |r,c,f,oCol| head_col(oCol:Value),oBrw:refresh() }

//   oBrw4:aCols[ (oBrw4:oCol:kleuren) ]:bLClickHeader := { |r,c,f,oCol| head_col(oCol:Value),oBrw:refresh() }
//   oBrw4:aCols[ (oBrw4:kleuren) ]:bLClickHeader := { |r,c,f,oCol| head_col(oCol:Value),oBrw:refresh() }

//   oBrw4:aCols[ (oCol:kleuren) ]:bLClickHeader := { |r,c,f,oCol| head_col(oCol:Value),oBrw:refresh() }



   oBrw4:kleuren:bLClickHeader := { |r,c,f,oCol| head_col(oCol:Value),oBrw:refresh() }
   oBrw4:maten:bLClickHeader := { |r,c,f,oCol| head_size(oCol:Value),oBrw:refresh() }
   oBrw4:picture:bLClickHeader := { |r,c,f,oCol| head_pic(oCol:Value),oBrw:refresh(),oImage:refresh() }
   oBrw4:memotxt:bLClickHeader := { |r,c,f,oCol| head_memo(oCol:Value),oBrw:refresh() }

   oBrw4:Database:bLClickHeader := { |r,c,f,oCol| oBrw4:SetSize(oWnd:nWidth-35, oWnd:nHeight-670) }


   //oBrw4:aCols[ 4 ]:bRClickHeader := {|r,c,f,o| Msginfo("
Right click on column header " + o:cHeader, "TXBrowse power") }

   //oBrw4:aCols[ 4 ]:bClrHeader := { |r,c,f,oCol| If( Empty( oCol:cOrder ),{ CLR_BLACK, nRGB(248,195,34) },{ CLR_BLACK, nRGB(240,240,240) }) }

   // index
   oBrw4:aCols[2]:bClrHeader := { || { CLR_RED, 155 } }
   oBrw4:aCols[3]:bClrHeader := { || { CLR_RED, 155 } }
   oBrw4:aCols[4]:bClrHeader := { || { CLR_RED, 155 } }
   oBrw4:aCols[5]:bClrHeader := { || { CLR_RED, 155 } }
   oBrw4:aCols[7]:bClrHeader := { || { CLR_RED, 155 } }

   // copy action
   oBrw4:kleuren:bClrHeader := { || { CLR_GREEN, 155 } }
   oBrw4:maten:bClrHeader := { || { CLR_GREEN, 155 } }
   oBrw4:picture:bClrHeader := { || { CLR_GREEN, 155 } }
   oBrw4:memotxt:bClrHeader := { || { CLR_GREEN, 155 } }


   oBrw4:Database:bClrHeader := { || { CLR_BLUE, 155 } }

   WITH OBJECT oBrw4

      //:nEditTypes  := EDIT_GET

      :lFooter          := .t.
      :bRecSelHeader    := { || "
" }
      :bRecSelData      := { |o| o:KeyNo }
      :bRecSelFooter    := { |o| o:nLen }
      :oRecSelFont      := oFont3  // optional
      :nRecSelWidth     := "
99999" // required size

      //:lIncrFilter   := .t.
      :lSeekWild     := .t.  //( nWild == 2 )
      :cFilterFld    := "
naam"
      :lHScroll         := .F.


      :lColChangeNotify := .t.
      :lSortDescend     := .f.
      //:bFooters         := { |oCol| If( Empty( oCol:cOrder ), "
", oBrw4:cSeek ) }
      :bFooters         := { |oCol| If( Empty( oCol:cOrder ), "
", oBrw4:cSeek("") ) }

      :oSeek            := TSeek():New( oBrw4 )

      :nHeaderHeight    := 40 // optional
      :oHeaderFonts     := oBold
      :bClrEdits        := { || { CLR_HRED, CLR_YELLOW } }
      :nMarqueeStyle    := MARQSTYLE_HIGHLROWMS
      :bClrRowFocus     := { || { CLR_BLACK, RGB(185,220,255) } }

      //  :bRClicked        := { || xbrowse( oBrw4:aSelected, "
SELECTED ROWS" ) }
//       :bRClicked     := { || markselected(oBrw4),oBrw4:refresh() }
       :bRClicked        := {|nRow, nCol| MenuPop( nRow,nCol, oBrw4 ),oBrw4:refresh() }

//      :bRClicked        := {|| oBrw4:SetSize(oWnd:nWidth-35, oWnd:nHeight-670) }

/*
        :bRClicked        := {|| (oWnd:Move( GetSysMetrics( SM_YVIRTUALSCREEN  ),;
                             GetSysMetrics( SM_YVIRTUALSCREEN  ),;
                             GetSysMetrics( SM_CXVIRTUALSCREEN ),;
                             GetSysMetrics( SM_CYVIRTUALSCREEN ), .T. ) ),;
                             oBrw4:SetSize(oWnd:nWidth-50, oWnd:nHeight-150) }
*/
 */



      WITH OBJECT :Fabrikant
         :nEditType     := EDIT_GET
         :bClrEdit      := { || { CLR_BLACK, CLR_YELLOW }}
         :bOnChange     := { || oBrw4:RefreshCurrent() }
      END
*/

      //:nMarqueeStyle    := MARQSTYLE_HIGHLROW
      :lMultiSelect     := .T.
      //:bClrSelFocus     := { || { CLR_BLACK, CLR_HGRAY } }

     /*
      :aCols[ 1 ]:bClrSelFocus := { ||{  CLR_BLACK, CLR_WHITE } }
      :bLClicked        := { |r,c,f,oBrw| If( oBrw:MouseColPos( c ) == 1 , ;
                           If( ( f := AScan( oBrw:aSelected, oBrw:BookMark ) ) == 0, ;
                           AAdd( oBrw:aSelected, oBrw:BookMark ), ;
                           ADel( oBrw:aSelected, f, .t. ) ), nil ), ;
                           oBrw:RefreshCurrent() }
      */

      :bKeyDown   := { |nKey| If( nKey == VK_DELETE, (oBrw4:cAlias)->( BrwDelselect( oBrw4 ) ), nil ) }

      //:bChange       := { || SET_MASTER(oBrw4),('foto')->(DBGOTOP()),oBrw2:Refresh(),oImage2:Refresh()}

      //:bChange       := { || SET_MASTER(oBrw4),('foto')->(DBGOTOP()),oBrw2:Refresh(),oImage2:Refresh()}
      :bChange       := { || oImage_master:refresh() }

      :CreateFromCode()
   END

   oBrw4:lGetBar   := .F.
   oBrw4:bToolTips   := ;
         { | oBrw4,r,c,f,oMouseCol,nMouseRow| MyColToolTip( oBrw4,r,c,f,oMouseCol,nMouseRow ) }
   oBrw4:aCols[2]:bClrStd := { || IF( !empty(master->online) , { CLR_BLACK,CLR_HGREEN } , { CLR_HRED,CLR_WHITE } ) }


/////////////////////////////////////////////////////////////////  BRW EANCODE /////////////////////////////////////////////////

   select ean

   aVelden5 :=  { ;
   { "
code     ", "Code"     ,nil,  80 }, ;
   { "
kleuren"  , "Kleuren"  ,nil,  80 }, ;
   { "
maten"    , "Maten"    ,nil,  50 }, ;
   { "
picture"  , "Picture"  ,nil, 100 }, ;
   { "
filename" , "File"     ,nil,  60 }, ;
   { "
ean"      , "Ean"      ,nil,  80 } }


   @ 40,1510 XBROWSE oBrwEan SIZE 450,700 ;
      PIXEL OF oWnd font oFont3;
      DATASOURCE "
EAN" ;
      COLUMNS aVelden5;
      autosort CELL LINES FOOTERS NOBORDER fastedit

   oBrwean:SetChecks()
   //oBrw4:nStretchCol         := STRETCHCOL_WIDEST
   //oBrwEan:picture:bClrStd := { || IF( file("
d:\pictures\smal\"+alltrim(ean->picture)) , { CLR_BLACK,CLR_HGREEN } , { CLR_BLACK,CLR_HRED } ) }



   WITH OBJECT oBrwEan

      //:nEditTypes  := EDIT_GET

      :lFooter          := .t.
      :bRecSelHeader    := { || "
" }
      :bRecSelData      := { |o| o:KeyNo }
      :bRecSelFooter    := { |o| o:nLen }
      :oRecSelFont      := oFont3  // optional
      :nRecSelWidth     := "
99999" // required size

      :lColChangeNotify := .t.
      :lSortDescend     := .f.

      :nHeaderHeight    := 30 // optional
      :nRowHeight    := 100
      :oHeaderFonts     := oBold
      :bClrEdits        := { || { CLR_HRED, CLR_YELLOW } }
      :nMarqueeStyle    := MARQSTYLE_HIGHLROWMS
      :bClrRowFocus     := { || { CLR_BLACK, RGB(185,220,255) } }

      :lMultiSelect     := .T.

      WITH OBJECT:picture
         :bStrImage     := { || "
d:\pictures\smal\"+alltrim(ean->picture) }
         :oDataFont     := oFontXS
         :nDataStrAlign := AL_CENTER + AL_BOTTOM
         :nDataBmpAlign := AL_CENTER
         :aImgRect      := { nil, nil, -15, nil }
      END

      hDC := oBrwEan:GETDC()

/*
      oBrwAtt:bRClicked := {| nRow, nCol | nColor := GETPIXEL( hDC, nCol, nRow ), ;
        MsgAlert( "
Color : " + LTRIM(STR(nColor)) + CRLF + ;
        "
Row : " + LTRIM(STR(nRow)) + CRLF + ;
        "
Col : " + LTRIM(STR(nCol)), "Position"),ATT->ColDec = ltrim(str(nColor)) }
*/

//      oBrwAtt:bRClicked := {| nRow, nCol | nColor := GETPIXEL( hDC, nCol, nRow ), ATT->ColDec = ltrim(str(nColor)), oBrwAtt:refresh() }

//      oBrwAtt:bRClicked := {| nRow, nCol | GetHex(hDc,nCol,nRow),oBrwAtt:refresh() }

//      oBrwATT:Dec:bClrStd := { || showcolors(oBrwATT:Dec:Value)  }

      //oBrwATT:bGotFocus := {|| oBrwATT:refreshcurrent() }
      //oBrwATT:bGotFocus := {|| getfotos(oBrwATT) }

//      oBrwATT:nRowHeight:= 70
//      oBrwATT:aCols[ 4 ]:cDatatype := "
F"

      //oBrwATT:COLPIC := EDIT_GET







      //hDC := oBrw:GETDC(0)
      //oBrwAtt:bRClicked := {| nRow, nCol | GetHex(hDc,nCol,nRow),oBrwAtt:refresh() }

    //  oBrwEan:bRClicked := {| nRow, nCol | cColor := GetHexCol(nCol,nRow) }



      oBrwEan:bRClicked := { || eanfotoupdate() }

      :bChange       := { || oImgean:Refresh() }

      :bKeyDown   := { |nKey| If( nKey == VK_DELETE, (oBrwEan:cAlias)->( BrwDelselect( oBrwEan ) ), nil ) }


      :CreateFromCode()
   END

////////////////////////////////////////////////////////////////////////////////  EINDE BROWSERS


   //oBrw:SetGroupHeader( cGrpHdr, [nFrom], [nUpto], [oFont], [nAlign] )
   //oBrw4:SetGroupHeader( "
Section 1", 3, 5 )

   //  Pic from master
   @ 700,1220 XIMAGE oImgean SIZE 120,120 OF oWnd SOURCE "
d:\pictures\smal\"+alltrim(ean->picture)
   oImgean:lBmpTransparent := .f.


   @ 250,1220 BTNBMP PROMPT { || If( oBrw4:lGetBar, "
Hide GetBar", "ShowGetBar" ) } ;
      SIZE 100,25 PIXEL OF oWnd FLAT ;
      ACTION ( oBrw4:lGetBar := ! oBrw4:lGetBar, oBrw4:Refresh() )

   @ 280,1220 BTNBMP PROMPT "
Set Filter" ;
      SIZE 100,25 PIXEL OF oWnd FLAT ;
      ACTION ( oBrw4:cAlias )->( SetFilter( oBrw4 ) )

   @ 310,1220 BTNBMP PROMPT "
Clear Filter" ;
      SIZE 100,25 PIXEL OF oWnd FLAT ;
      ACTION ( oBrw4:cAlias )->( DBCLEARFILTER(),("
master")->( ORDSCOPE(0, "" ) ),("master")->( ORDSCOPE(1, "" ) ),oBrw4:gotop(),oBrw4:Refresh(), oBrw4:SetFocus() )

   @ 340,1220 BTNBMP PROMPT "
<- Copy 1 Rec" ;
      SIZE 100,25 PIXEL OF oWnd FLAT ;
      ACTION ( copy_to_selection(),oBrw:refresh() )

   @ 370,1220 BTNBMP PROMPT "
<- Bulk Copy" ;
      SIZE 100,25 PIXEL OF oWnd FLAT ;
      TOOLTIP "
Importeer alle geselecteerde artikels van de onderste tabel" ;
      ACTION ( Bulkcopy(),oBrw:gotop(),oBrw:refresh() )

   @ 400,1220 BTNBMP PROMPT "
<- Blanco" ;
      SIZE 100,25 PIXEL OF oWnd FLAT ;
      ACTION ( nofoto_add(),oBrw:gobottom(),oBrw:refresh() )

   @ 430,1220 BTNBMP PROMPT "
<- Clear Sel" ;
      SIZE 100,25 PIXEL OF oWnd FLAT ;
      ACTION ( Clearselection(),oBrw4:refresh() )

   @ 460,1220 BTNBMP PROMPT "
<- Prijs CTRL" ;
      SIZE 100,25 PIXEL OF oWnd FLAT ;
      ACTION ( prijscontrole(),oBrw:gotop(),oBrw:refresh() )

   @ 490,1220 BTNBMP PROMPT "
<- Rapport" ;
      SIZE 100,25 PIXEL OF oWnd FLAT ;
      ACTION oBrw:Report( nil, nil, nil, { |oRep,brw| MyReportSetup( oRep, brw ) } )


   // Top, Left                     Lengte, Bottom                                                            _
    @ 40,500 XIMAGE oImage SIZE 170, 170 OF oWnd SOURCE "
d:\pictures\smal\"+alltrim(nofoto->orgfoto)
      //oImage:lBmpTransparent := .f.


   //@ 40,680 XIMAGE oImage2 SIZE 170,170 OF oWnd SOURCE "
d:\pictures\smal\"+alltrim(foto->foto)
   @ 40,680 XIMAGE oImage2 SIZE 170,170 OF oWnd SOURCE "
d:\pictures\origineel\"+alltrim(nofoto->orgfoto)
    oImage2:bLClicked:={|| imagetestnew("
d:\pictures\origineel\"+alltrim(nofoto->orgfoto))}

   //  Pic from master
   @ 520,1220 XIMAGE oImage_Master SIZE 120,120 OF oWnd SOURCE "
d:\pictures\smal\"+alltrim(master->picture)
    oImage_master:bLClicked:={|| imagetestnew("
d:\pictures\smal\"+alltrim(master->picture))}
      //oImage:lBmpTransparent := .f.


   //@ 32,860 XIMAGE oImage2 SIZE 550,-300 OF oWnd SOURCE oBrw:aRow[2]

   //oImage:SetBrush( oBrush )
   //oImage2:SetBrush( oBrush2 )


   WITH OBJECT oWnd
      :nWidth     := ScreenWidth()  //* 0.6
      :nHeight    := ScreenHeight() //* 0.6
   END

   //@ 410,1750 BUTTON "
Maak Webshop"   size 80,20 pixel OF oDlg ACTION (makeshop()) font oFont3

   @  70,1150 BTNBMP oBtn OF oDlg SIZE 90, 20 NOBORDER PROMPT "
Prestashop" 2007 ACTION ( makeshop(),updatescreen() ) FONT oFont4 CENTER
   @  70,1240 BTNBMP oBtn OF oDlg SIZE 90, 20 NOBORDER PROMPT "
Shoptrader" 2007 ACTION ( shoptrader(),updatescreen() ) FONT oFont4 CENTER
   @  90,1150 BTNBMP oBtn1 OF oDlg SIZE 120, 20 NOBORDER PROMPT "
Toon Foto's" 2007 ACTION (showimg(),oBrw:setfocus(),oBrw:refresh(),oBrw:drawselect() ) FONT oFont4 CENTER
   @ 110,1270 BTNBMP oBtn1 OF oDlg SIZE 60, 20 NOBORDER PROMPT "PicLijst" 2007 ACTION (printimg()) FONT oFont4
   @ 130,1270 BTNBMP oBtn1 OF oDlg SIZE 60, 20 NOBORDER PROMPT "PicUpload" 2007 ACTION (printuploadimg()) FONT oFont4
   @ 110,1150 BTNBMP oBtn1 OF oDlg SIZE 120, 20 NOBORDER PROMPT " Print Foto'
s" 2007 ACTION (printcatalogus()) FONT oFont4
   @ 130,1150 BTNBMP oBtn1 OF oDlg SIZE 120, 20 NOBORDER PROMPT "
Move to Temp" 2007 TOOLTIP "Copy alle geselecteerde naar temp" ACTION (movetotemp(),oBrw:refresh()) FONT oFont4 LEFT
   @ 150,1150 BTNBMP oBtn1 OF oDlg SIZE 120, 20 NOBORDER PROMPT "
Copy to Temp" 2007 ACTION (Seltotemp()) FONT oFont4 LEFT
   @ 170,1150 BTNBMP oBtn1 OF oDlg SIZE 120, 20 NOBORDER PROMPT "
Temp to Selection" 2007 ACTION (temptosel(),oBrw:refresh()) FONT oFont4 LEFT
   @ 190,1150 BTNBMP oBtn1 OF oDlg SIZE 120, 20 NOBORDER PROMPT "
Clear Temp/Sel" 2007 ACTION (cleartemptosel(),oBrw:refresh()) FONT oFont4 LEFT
   @ 210,1150 BTNBMP oBtn1 OF oDlg SIZE 120, 20 NOBORDER PROMPT "
To Upload" 2007 ACTION toUpload() FONT oFont4 LEFT

   //@ 285,1320 BTNBMP oBtn1 OF oDlg SIZE 120, 25 NOBORDER PROMPT "
To Exel" 2007 ACTION oBrw:ToExcel(NIL,NIL,aExelcol1)

   //DEFINE BUTTON OF oBar FILE "
img\excel.bmp" PROMPT "Excel"  GROUP TOOLTIP "Export to Excel" ACTION oBrw[1]:ToExcel(NIL,NIL,aExelCol1)



   //@ 470,1750 BUTTON "
Toon Foto's"   size 80,20 pixel OF oDlg ACTION (showimg()) font oFont3
   //@ 510,1750 BUTTON "Print Foto'
s"   size 80,20 pixel OF oDlg ACTION (printimg()) font oFont3

   /////////////////////////////////////////////////////////  BROWSE  5  //////////////////////////////////////////////////////////////////////////////////////////////// BRW 5

   /*
   @ 40,1450 XBROWSE oBrwP OF oWnd SIZE 250,600 PIXEL DATASOURCE "
ATT" ;
      COLUMNS "
COLNAAM","COLPIC + COLNAAM";
      colsizes 100,100 ;
      CELL LINES NOBORDER

   WITH OBJECT oBrwP
      :nRowHeight := 100
      WITH OBJECT :aCols[ 2 ]
         :bStrImage     := { || "
d:\pictures\origineel\"+alltrim(ATT->colpic) }
         :oDataFont     := oFontS
         :nDataStrAlign := AL_CENTER + AL_BOTTOM
         :nDataBmpAlign := AL_CENTER
         :aImgRect      := { nil, nil, -40, nil }
      END
      //
      :CreateFromCode()
   END
   */

//      COLUMNS "
left(COLPIC,15)+chr(13)+alltrim(COLNAAM)";

   @ 40,1350 XBROWSE oBrwP OF oWnd SIZE 150,700 PIXEL DATASOURCE "
FOTO" ;
      COLUMNS "
foto";
      HEADERS "
Foto Select";
      colsizes 110 ;
      CELL LINES NOBORDER

   WITH OBJECT oBrwP
      :nRowHeight := 80
      :bLDblClick    := { || Imagetestnew("
d:\pictures\smal\"+alltrim(foto->foto)) }

      :lFooter          := .t.
      :bRecSelHeader    := { || "
" }
      :bRecSelData      := { |o| o:KeyNo }
      :bRecSelFooter    := { |o| o:nLen }
      :oRecSelFont      := oFont3  // optional
      :nRecSelWidth     := "
99" // required size
      :lHScroll         := .F.

      WITH OBJECT :aCols[ 1 ]
         //:bStrImage     := { || "
d:\pictures\smal\"+alltrim(ATT->colpic) }
         :bStrImage     := { || "
d:\pictures\smal\"+alltrim(foto->foto) }
         :oDataFont     := oFontS
         :nDataStrAlign := AL_CENTER + AL_BOTTOM
         //:nDataStrAlign := AL_LEFT + AL_BOTTOM
         :nDataBmpAlign := AL_CENTER
         :aImgRect      := { nil, nil, -20, nil }
      END
      //
      :CreateFromCode()
   END

//   oBrwP:bRClicked     := { || picATTcopy(),oBrw:refresh(),oBrw:SetFocus(),oImage:Refresh(),oImage2:Refresh() }
//      oBrwP:bRClicked := {| nRow, nCol | cColor := GetHexCol(nCol,nRow) }
    oBrwP:bRClicked := {| nRow, nCol | nofoto->orgfoto = foto->foto,obrw:refreshcurrent(),msginfo("
Copy done") }


   //ACTIVATE WINDOW oWnd CENTERED on init (oBrw3:setfocus())

   //ACTIVATE DIALOG oDlg ON INIT DlgInit( oDlg, oBrw )


   ACTIVATE WINDOW oWnd on init (DlgInit( oWnd, oBrw ),;
   SET_SCOPE_nobrowse(oBrw),('nofoto')->(DBGOTOP()),;
   oBrw:Refresh(),oImage:Refresh(),oImage2:Refresh(),oBrw3:setfocus())

   RELEASE FONT oFont
   RELEASE BRUSH oBrush

Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1439
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Newbie Question : XBROWSE

Postby Marc Venken » Fri Nov 25, 2022 8:26 am

Jimmy,

Also, check the function xbrowser() It is the best for a very quick lookup for any data type. (In devellop mode)

XBROWSER aPics TITLE "WEB IMAGES" SETUP ( oBrw:nRowHeight := 200, oBrw:aCols[ 1 ]:nWidth := 300, ;
oBrw:aCols[ 1 ]:cDataType := 'F', oBrw:aCols[ 1 ]:nDataBmpAlign := AL_CENTER )

XBROWSER aPics TITLE "DOWNLOADED IMAGES" COLUMNS 1,1 SETUP ( oBrw:cHeaders := { "FileName", "Image" }, ;
oBrw:nRowHeight := 200, oBrw:aCols[ 2 ]:nWidth := 300, ;
oBrw:aCols[ 2 ]:cDataType := 'F', oBrw:aCols[ 2 ]:nDataBmpAlign := AL_CENTER )

MENUITEM "NoFoto" ACTION xBrowser("nofoto")
MENUITEM "Master" ACTION xBrowser("master")

DEFINE BUTTON OF oBar PROMPT "# Kleur" CENTER ACTION xbrowser("kleuren") FASTEDIT SETUP (oBrw:bchange := { || selecteankleur() } )

ADIR("d:\pictures\origineel\*.jpg", aDbf)
xbrowser(aDbf)

odata = XBROWSER oCn:ListTables TITLE "SELECT TO VIEW" SELECT XBrowse( oCn:RowSet( oBrw:aCols[ 1 ]:Value ), oBrw:aCols[ 1 ]:Value )

// Quick select from a browse
Xbrowser aGroepen TITLE "Groepen lijst" SETUP (oBrw:cHeaders := {"Groep"}) SELECT cZoek:= oBrw:Groep:Value

xBrowser(oBrw)
xBrowser(Hash)
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1439
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Newbie Question : XBROWSE

Postby Marc Venken » Fri Nov 25, 2022 8:43 am

I'm a absolut fan of Xbrowse ))))

I would suggest to use it a primary browse system since it is so usefull and can do almost anything.
Xbrowse has also a buttonbar (see pic) look at that also !

BTW : Thanks FWteam and specially Mr. Rao for FW's best tool :wink:

Image

Folder 10 : 2 xbrowse

Image
Last edited by Marc Venken on Fri Nov 25, 2022 9:19 am, edited 1 time in total.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1439
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Newbie Question : XBROWSE

Postby Marc Venken » Fri Nov 25, 2022 9:14 am

If you are thinking of using many xbrowses like me, than consider a xbrowse designer. I made a small version of it

my code for the browse from previous post :
Almost anything is done in the data driven getxBrowser function

So xbrowser can be programmed with 1 line of code

Folder 10 has 2 xbrowser on 1 folder (master/slave)

The easy part is that I can change many parameters when i'm using the browse. No need to change the code if field are added, changed etc...

Code: Select all  Expand view  RUN

   //  FOLDER 6  -----------------------------------------------------------------------------------------------

   oBrw[6] = getXBrowser("WEBSHOPPRIJZEN",oFld:aDialogs[FOL_WEBSHOP_PRIJZEN])

   WITH OBJECT oBrw[ 6 ]
      :SetGroupHeader( "ShopTrader", oBrw[6]:oCol("shopbruto"):nCreationOrder, oBrw[6]:oCol("Aan"):nCreationOrder )
      :SetGroupHeader( "OffLine", oBrw[6]:oCol("bruto"):nCreationOrder, oBrw[6]:oCol("promoprijs"):nCreationOrder )
      :SetGroupHeader( "Nieuwe prijzen", oBrw[6]:oCol("new_bruto"):nCreationOrder, oBrw[6]:oCol("new_diff"):nCreationOrder )
   END

   oBrw[6]:bruto:bClrStd := { || If( oBrw[6]:bruto:value <> oBrw[6]:new_bruto:value,;
      {nClrTxtBrw, if( oBrw[6]:bruto:value < oBrw[6]:new_bruto:value ,MY_LIGHTYELLOW,if( oBrw[6]:new_bruto:value = 0,MY_PAARS,MY_ORANGE)) } ,;
      {nClrTxtBrw, If( oBrw[6]:KeyNo() % 2 == 0, CLR_BROWSE2, CLR_BROWSE1 )}    )}

   oBrw[6]:shopbruto:bClrStd := { || If( oBrw[6]:shopbruto:value <> oBrw[6]:bruto:value,;
      {nClrTxtBrw, if( oBrw[6]:bruto:value < oBrw[6]:shopbruto:value ,MY_LIGHTYELLOW,if( oBrw[6]:shopbruto:value = 0,MY_PAARS,MY_ORANGE)) } ,;
      {nClrTxtBrw, If( oBrw[6]:KeyNo() % 2 == 0, CLR_BROWSE2, CLR_BROWSE1 )}    )}

   oBrw[6]:shopkort:bClrStd := { || If( oBrw[6]:shopkort:value <> oBrw[6]:korting:value,;
      {nClrTxtBrw, if( oBrw[6]:shopkort:value < oBrw[6]:korting:value ,MY_LIGHTYELLOW,if( oBrw[6]:korting:value = 0,MY_PAARS,MY_ORANGE)) } ,;
      {nClrTxtBrw, If( oBrw[6]:KeyNo() % 2 == 0, CLR_BROWSE2, CLR_BROWSE1 )}    )}

   oBrw[6]:bKeyDown   := {| k | IF ( K == VK_F2, if(oBrw[6]:selected:value = .f., oBrw[6]:selected:Varput( .t. ), oBrw[6]:selected:Varput( .F. ) ) , NIL ) }
   oBrw[6]:bChange    := { || showpicture("WEBSHOP") }

   oBrw[6]:korting:bOnChange = { |oCol,uOldVal| webshopprijzen("SHOPKORTING",oBrw[6]) }

   //  FOLDER 8  -----------------------------------------------------------------------------------------------

   oBrw[8] = getXBrowser("WEBSHOP_STAFFEL",oFld:aDialogs[FOL_WEBSHOP_STAFFEL])
   oBrw[8]:bChange     := { || Pos_Artikel(webshop->id), oIDArt:refresh(),oIDNofoto:refresh() }

   //  FOLDER 9  -----------------------------------------------------------------------------------------------

   oBrw[9] = getXBrowser("WEBSHOP_TEKSTEN",oFld:aDialogs[FOL_WEBSHOP_TEKSTEN])
   oBrw[9]:bChange     := { || oMemo:refresh(),cGetnaam = webshop->naamshop,nofoto->(dbseek(webshop->brandid)),oMemo2:refresh(), oMemo3:refresh() }

   //  FOLDER 10  -----------------------------------------------------------------------------------------------

   oBrw[10] = getXBrowser("WEBSHOP_KLEUREN",oFld:aDialogs[FOL_WEBSHOP_KLEUREN])
   oBrw101  = getXBrowser("WEBSHOP_KLEUREN_NAAM",oFld:aDialogs[FOL_WEBSHOP_KLEUREN])
   oBrw[10]:bChange    := { ||  showpicture("WEBSHOP_KLEUREN"),oBrw101:refresh() }


 
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1439
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Newbie Question : XBROWSE

Postby Jimmy » Fri Nov 25, 2022 9:32 am

hi Marc,

thx for Answer.

as i can see you do define Column but i do not know Structure of DBF
i "just" want to open DBF as "Viewer" and navigate in DBF
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Newbie Question : XBROWSE

Postby Jimmy » Fri Nov 25, 2022 9:37 am

hi,

i have search in Help File for XBROWSE which point me to CLASS TXBrowse -> xBrowseNew()
Code: Select all  Expand view  RUN
xBrowseNew( <oWnd>, <nRow>, <nCol>, <nWidth>, <nHeight>, <aFlds>, <aHeaders>, <aColSizes>, <bChange>, <bLDblClick>, <bRClick>, <oFont>, <oCursor>, <nClrFore>, <nClrBack>, <cMsg>, <lUpdate>, <cAlias>, <bWhen>, <lDesign>, <bValid> ) --> oBrw  

but when search for AUTOCOLS or FASTEDIT i got no Result :(

so i search in \INCLUDE and found in XBROWSE.CH but order seems different and does not match above :?

Code: Select all  Expand view  RUN
  [ <design: DESIGN> ] ;
   [ VALID <uValid> ] ;
   [ <autosort: AUTOSORT> ] ;
   [ <autocols: AUTOCOLS> ] ;
   [ <footers: FOOTERS> ] ;
   [ <fasted: FASTEDIT> ] ;
   ...
   => ;
   <oBrw> := XbrowseNew( <oWnd>, <nRow>, <nCol>, <nWidth>, <nHeigth>,;
   ...
   <.design.>, <{uValid}>, <.pixel.>, [<nID>], <.autosort.>, <.autocols.> , ;
 

so i´m total confuse what to do :?:
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Newbie Question : XBROWSE

Postby anserkk » Fri Nov 25, 2022 9:46 am

Jimmy wrote:now i can "see" my Data but when "move" vitcal Scrollbar it crash : no WorkArea :shock:
Error description: Error DBCMD/2001 Workarea not in use: DBGOTO

As per your first post in the thread you are using a Window. The DBF is getting closed immediately after the ACTIVATE WINDOW and that's the reason that you getting the error "no work area".

Instead of closing the DBF immediately after the ACTIVATE WINDOW, Close the DBF in the VALID close of ACTIVATE WINDOW

ACTIVATE WINDOW oWnd VALID
User avatar
anserkk
 
Posts: 1333
Joined: Fri Jun 13, 2008 11:04 am
Location: Kochi, India

Re: Newbie Question : XBROWSE

Postby Marc Venken » Fri Nov 25, 2022 10:01 am

Jimmy wrote:hi Marc,

thx for Answer.

as i can see you do define Column but i do not know Structure of DBF
i "just" want to open DBF as "Viewer" and navigate in DBF


For this, simply so :

xbrowser("dbf")

later for extra's look at samples of xbrowser :

Xbrowser is the shorter function version of xbrowse that need to be setup
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1439
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: Newbie Question : XBROWSE

Postby Jimmy » Fri Nov 25, 2022 10:09 am

hi,
anserkk wrote:As per your first post in the thread you are using a Window. The DBF is getting closed immediately after the ACTIVATE WINDOW and that's the reason that you getting the error "no work area".

Instead of closing the DBF immediately after the ACTIVATE WINDOW, Close the DBF in the VALID close of ACTIVATE WINDOW
Code: Select all  Expand view  RUN
ACTIVATE WINDOW oWnd VALID

YES, now i can navigate in DBF without crash, thx :D
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Newbie Question : XBROWSE

Postby Jimmy » Fri Nov 25, 2022 10:11 am

hi Marc,
Marc Venken wrote:For this, simply so :
Code: Select all  Expand view  RUN
xbrowser("dbf")

YES, this is what i search

Marc Venken wrote:later for extra's look at samples of xbrowser :
Xbrowser is the shorter function version of xbrowse that need to be setup

Ok, will have a look at it, thx
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Newbie Question : XBROWSE

Postby nageswaragunupudi » Sat Nov 26, 2022 5:44 am

Please refer to the first post of Mr. Jimmy and the correct answer of Mr. Anser KK.

The problem has nothing to do with XBrowse at all and there is no point in discussing about xbrowse in depth here. If we create any controls other than xbrowse, which require access to an open DBF, we would have got similar errors.

The real issue is the difference in handling Modal Vs Non-Modal activation of Windows/Dialogs.

Windows:

In an application, the Window that is first activated is the Main Window. During the application, we can query this window by "oWndMain := WndMain()". Activation of the main window is always MODAL.
Activation of ALL other windows are NONMODAL invariably.

Dialogs:
All dialogs are activated as MODAL by default, except when we activate with NOMODAL clause.

MODAL ACTIVATION
Code: Select all  Expand view  RUN

   ACTIVATE WINDOW oMainWnd / ACTIVATE DIALOG oDlg
   <CleanupCode:closing tables,releasing resources,etc.>
return nil
 

In these cases of MODAL activation, it is guranteed that the execution of the code next to ACTIVATE command is executed only after the modal window/dialog ends and all the child controls are destroyed. In these cases, keeping the <cleanupCode> just after the statement ACTIVATE .. is ok.

NONMODAL ACTIVATION:
Code: Select all  Expand view  RUN

   ACTIVATE WINDOW oWnd / ACTIVATE DIALOG oDlg NOMODAL
   <CleanupCode:closing tables,releasing resources,etc.>
return nil
 

In these cases, immediately after non-modal activation, execution continues till the end of procedure/function (till return statement), without waiting for the end of the window/dialog.
So, the <CleanupCode> is executed immediately after activation, while the window/dialog is still active on the screen. Some of the controls may still need access to open files/data or resources, but they were already closed/releasted, just like pulling the carpet under the feet.
Naturally, this situation results in fatal runtime errors.

So,
RIGHT WAY TO HANDLE NONMODAL EXECUTION
Code: Select all  Expand view  RUN

   ACTIVATE WINDOW oWnd / ACTIVATE DIALOG oDlg NOMODAL ;
      VALID ( <CleanupCode>, .t. )
return nil
 


MODAL:
Windows: MainWindow only
Dialogs: All dialogs except those activated with NOMODAL clause.

NONMODAL:
Windows: All windows, except the Main Window.
Dialogs: Only those dialogs activated with NOMODAL clause.

In light of the above, the program in the first post is revised as below:
Code: Select all  Expand view  RUN
PROCEDURE DoShowDBF(cPath,cFile)
LOCAL oWnd, oBrwDBF

   USE (cPath+cFile) NEW VIA "DBFCDX" ALIAS "TEMP" EXCLUSIVE

   DEFINE WINDOW oWnd FROM 0, 0 TO 800, 700 PIXEL TITLE "DBF "+cFile ICON "A1M

   @ 0, 0 XBROWSE oBrwDBF OF oWnd ;
         FONT oFontDefault      ;
         DATASOURCE "
TEMP" AUTOCOLS FASTEDIT

#IFDEF __HMG__
   END WINDOW
#ENDIF

   oBrwDBF:CreateFromCode()
   oWnd:oClient := oBrwDBF

   oWnd:bValid := <||
                     CLOSE TEMP
                     return .t.
                  >

   ACTIVATE WINDOW oWnd ON INIT MakeTop( oWnd, oBrwDBF ) CENTER

RETURN


It is much simpler to use Dialogs instead of windows, except for the main window.
Regards

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

Re: Newbie Question : XBROWSE

Postby nageswaragunupudi » Sat Nov 26, 2022 8:30 am

i "just" want to open DBF as "Viewer" and navigate in DBF


If this is the only purpose, the best way is
Code: Select all  Expand view  RUN
XBROWSER cFileDBF [FASTEDIT] [AUTOSORT]


This command opens the DBF, browses and then closes the DBF.
Optional FASTEDIT clause is to enable editing if you need. in addition to inline edit, add/edit dialogs are also availble.
If you need, AUTOSORT clause not only allows column sort and also incremental seek, filter, with / without wild expessions.
Regards

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

Re: Newbie Question : XBROWSE

Postby Jimmy » Sun Nov 27, 2022 4:51 am

hi,

interesting ... "where" can i read about it in Help File :?:

---

when using DIALOG instead of WINDOW i can not "maximize" :shock:
also BUTTONBAR does not appear when use oWnd:oClient := oBrwDBF ...

so DIALOG is only when i do not want "resize" (which i most allow)
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Re: Newbie Question : XBROWSE

Postby Jimmy » Sun Nov 27, 2022 5:27 am

hi,

Offtopic WINDOWS vs. DIALOG

have change some WINDOW to DIALOG but "something" is different ...
Image
normal it look like this
Image
greeting,
Jimmy
User avatar
Jimmy
 
Posts: 1732
Joined: Thu Sep 05, 2019 5:32 am
Location: Hamburg, Germany

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Google [Bot] and 56 guests