change on line a combo

change on line a combo

Postby Silvio.Falconi » Thu Nov 12, 2020 10:23 am

I wish change on line a combobox items because the final user could select ( and hide) a columns

Image

I have a combobox with the name of the columns of the oBRowse

having the current columns of the oBrowse how do i know if the user has changed the columns and then modify the combobox?

or how do i block the ability to select columns in the browse header?
ok with :lAllowColHiding := .f.


at the beginning I insert a column to create the setcheck

WITH OBJECT oBrw:InsCol(1)
:nwidth:= 30
:bEditValue := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
:SetCheck( nil, .t.)
end

:bLDblClick := { || oBrw:oCol( 1 ):CheckToggle(), oBrw:RefreshCurrent() }


if the user moves the column with the checkbox on third position then it doesn't work well as the user always has to click on the first column to select the record, this is an error that you should fix
Last edited by Silvio.Falconi on Mon Nov 16, 2020 5:21 pm, 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: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: chenge on line a combo

Postby Marc Venken » Thu Nov 12, 2020 12:36 pm

Silvio.Falconi wrote:

if the user moves the column with the checkbox on third position then it doesn't work well as the user always has to click on the first column to select the record, this is an error that you should fix


If you use the header name and not the number of the column, Xbrowse is using the correct field.


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() }

kleuren = name of column in place of the column number. Never have to worry about the position in the browse.
Marc Venken
Using: FWH 23.04 with Harbour
User avatar
Marc Venken
 
Posts: 1343
Joined: Tue Jun 14, 2016 7:51 am
Location: Belgium

Re: chenge on line a combo

Postby Silvio.Falconi » Fri Nov 13, 2020 11:39 am

Marc Venken wrote:
Silvio.Falconi wrote:

if the user moves the column with the checkbox on third position then it doesn't work well as the user always has to click on the first column to select the record, this is an error that you should fix


If you use the header name and not the number of the column, Xbrowse is using the correct field.


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() }

kleuren = name of column in place of the column number. Never have to worry about the position in the browse.


yes But I not Know the name of the columns

a sample :

local aColumns := { "FIRST","LAST","STREET","CITY","STATE"}
local aHdrs := { "Cognome","Nome","Indirizzo","Città", "Provincia"}
local cDbf := "Cust"
USE CUSTOMERI ALIAS CUST

.....

Tabella(aColumns,aHdrs,cDbf,"Selezione Clienti","Cli")

RETURN NIL

Function Tabella(aColumns,aHdrs,cDbf,cTitle,cPrefix)
...

DEFINE DIALOG oTabella

...

@ 100,5 XBROWSE oBrw SIZE 385,130 PIXEL OF oTabella ;
DATASOURCE cDbf ;
COLUMNS aColumns ;
HEADERS aHdrs ;
CELL LINES NOBORDER FOOTERS
,,,,
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: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: chenge on line a combo

Postby Otto » Fri Nov 13, 2020 6:33 pm

Hello Silvio,
Just a suggestion.

All of your questions revolve around the same example. Why don't you post the source code of this example?
Then everyone would benefit from it, and we could try to help you much more quickly.

Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: chenge on line a combo

Postby Otto » Fri Nov 13, 2020 6:34 pm

... continuation of my previous post
I like your design very much.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: chenge on line a combo

Postby Silvio.Falconi » Sat Nov 14, 2020 8:38 am

Otto wrote:Hello Silvio,
Just a suggestion.

All of your questions revolve around the same example. Why don't you post the source code of this example?
Then everyone would benefit from it, and we could try to help you much more quickly.

Best regards,
Otto



Please compile the test xbincflt.prg and select DBF


Image


on First Combo there are the name of the columns you have on xbrowse and you can search a record for these columns

Image

Now, click on header and hide some columns for a sample street

Image

now you should have in the combo the names of the columns left in the xbrowse and instead you always have the same columns and this is wrong.

Image

Question: How do I refresh the columns in case the end user hides a specific column or group of columns?
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: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: chenge on line a combo

Postby Otto » Sat Nov 14, 2020 3:31 pm

Hello Silvio,
I do not have the source.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: chenge on line a combo

Postby Silvio.Falconi » Sat Nov 14, 2020 3:57 pm

Samples folder of fwh
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: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: chenge on line a combo

Postby Otto » Sat Nov 14, 2020 5:17 pm

Silvio,
I am sorry I do not have it.
Maybe I have to update my samples.
Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Re: chenge on line a combo

Postby nageswaragunupudi » Sat Nov 14, 2020 10:47 pm

Code: Select all  Expand view
aItems := {}
AEval( oBrw:aCols, { |o| If( o:lHide,,AAdd( aItems, o:cHeader ) ) } )
 
Regards

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

Re: chenge on line a combo

Postby Silvio.Falconi » Mon Nov 16, 2020 9:40 am

thanks RAO
I must insert it on click on header ?

I tried with

:bLClickHeader := { ||changeBrw(oBrw,aHdrs,oCbx) }



Code: Select all  Expand view


#include 'fivewin.ch'
#include 'ord.ch'
#include 'xbrowse.ch'
#include 'hbcompat.ch'

REQUEST DBFCDX

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

function Main()

   local oDlg, oBrw, oFont, nWild := 2
   local cList, aFlds, aHdrs,oCbx
   local nChoice, uDataSource

   SET DATE ITALIAN
   SET CENTURY ON
   RDDSETDEFAULT( "DBFCDX" )

   cList := "First,Last,Street,State,HireDate"

   nChoice     := ALERT( "Choose Data Souce", { "DBF", "ADO", "ARRAY" } )
   uDataSource := OpenData( nChoice, cList )

   DEFINE FONT oFont NAME "TAHOMA" SIZE 0,-12

   DEFINE DIALOG oDlg SIZE 750,300 PIXEL FONT oFont ;
      TITLE "XBrowse Incremental Filters"

   aFlds := aHdrs := HB_ATokens( cList, ',' )
   if nChoice == 3
      aFlds := Array( Len( aFlds ) )
      AEval( aFlds, { |u,i| aFlds[ i ] := i } )
   endif

   @ 30,10 XBROWSE oBrw SIZE -10,-10 PIXEL OF oDlg ;
      COLUMNS aFlds HEADERS aHdrs ;
      DATASOURCE uDataSource AUTOSORT CELL LINES NOBORDER

   WITH OBJECT oBrw
      :lIncrFilter   := .t.
      :lSeekWild     := ( nWild == 2 )
      :cFilterFld    := "FIRST"
      :nStretchCol   := STRETCHCOL_WIDEST
      :bLClickHeader := { ||changeBrw(oBrw,aHdrs,oCbx) }
   END

   @ 10, 10 COMBOBOX oCbx var  oBrw:cFilterFld ;
      ITEMS aHdrs ;
      ON CHANGE ( oBrw:Seek( "" ), oBrw:SetFocus() ) ;
      SIZE 50,400 PIXEL OF oDlg

   @ 10, 70 COMBOBOX nWild ITEMS { "Starting With", "Containing" } ;
      ON CHANGE ( oBrw:lSeekWild := ( nWild == 2 ), ;
                  oBrw:Seek( If( oBrw:lSeekWild, oBrw:cSeek, "" ) ), ;
                  oBrw:SetFocus() ) ;
      SIZE 70,400 PIXEL OF oDlg

   @ 11,160 SAY oBrw:oSeek PROMPT oBrw:cSeek SIZE 200,10 PIXEL ;
      OF oDlg COLOR CLR_BLACK,CLR_YELLOW PICTURE '@!'

   oBrw:CreateFromCode()

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

   RELEASE FONT oFont

return nil

//----------------------------------------------------------------------------//
Function changeBrw(oBrw,aHdrs,oControl)
aItems:= {}
AEval( oBrw:aCols, { |o| If( o:lHide,,AAdd( aItems, o:cHeader ) ) } )
oControl:setItems(aItems)
oControl:refresh()
return nil

static function OpenData( nSource, cList )

   local oCn, uSource

   SWITCH nSource
   CASE 1
   CASE 3
      USE CUSTOMER SHARED NEW ALIAS CUST
      SET ORDER TO TAG FIRST
      GO TOP
      if nSource == 3
         uSource  := CUST->( FW_DbfToArray( cList ) )
         CLOSE CUST
      else
         uSource  := "CUST"
      endif
      EXIT
   CASE 2
      oCn   := FW_OpenAdoConnection( "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + ;
                                      cFilePath( GetModuleFileName() ) + ;
                                      "xbrtest.mdb;User Id=admin;Password=;" )
      if oCn != nil
         uSource  := FW_OpenRecordSet( oCn, "CUSTOMER" )
      endif
      EXIT
   DEFAULT
      QUIT
   END

return uSource

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

 

but not run
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: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: change on line a combo

Postby Silvio.Falconi » Mon Nov 16, 2020 5:24 pm

I've created a small lookup table
as you can see in this image
I can select from the combobox where to search for a customer or a state


Image


in a dialog I can hide columns and a search still works but when I reinsert the hidden columns it makes me mistake



the test

Code: Select all  Expand view
#include "fivewin.ch"
#include "constant.ch"
#include "ttitle.ch"

REQUEST DBFCDX

static cSeek   := ''
static oSeek
static nField


static  cIniFile

REQUEST HB_Lang_IT
REQUEST HB_CODEPAGE_ITWIN


REQUEST DBFCDX
REQUEST DBFFPT
EXTERNAL ORDKEYNO,ORDKEYCOUNT,ORDCREATE,ORDKEYGOTO


FUNCTION Main()


   local cDbf     := "Cust"
   local aBrowse


    HB_LangSelect("IT")
    HB_SetCodePage("ITWIN")

    SET _3DLOOK ON
    SET CENTURY ON
    SET DATE ITALIAN

    RDDSetDefault( 'DBFCDX' )

   cIniFile    := cFilePath( GetModuleFileName( GetInstance() ) ) + "tabledb.ini"


    USE CUSTOMER  ALIAS CUST
   INDEX ON FIRST  TAG FIRST    TO TMFIRST  MEMORY
   INDEX ON LAST   TAG LAST     TO TMPLAST  MEMORY
   INDEX ON CITY   TAG CITY     TO TMPCITY  MEMORY
   INDEX ON STATE  TAG STATE    TO TMPSTATE MEMORY


    cust->(dbsetorder(1))
    cust->(dbgotop())




     // { field, header, picture, size, justify, sortorder }

    aBrowse   := { { "CUST->FIRST",  "First",,               120, },;
                   { "CUST->LAST",   "Last",,                120, },;
                   { "CUST->STREET", "Street",,              180, },;
                   { "CUST->CITY",   "City",,                150, },;
                   { "CUST->STATE",  "State",,               50, }}


        bedit:= { || MsgInfo( "modify" ) }

   TableDb(aBrowse,cDbf,"Customers table","Cust",bedit)

   RETURN NIL

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

Function TableDb(aBrowse,cDbf,cTitle,cPrefix,bedit)

   local oTabella
   local oBrw,oSay1,oSay2
   local oFont,oFontSmall,oBold
   local  oCursorBtn :=TCursor():New(,'HAND')

   local  nBottom   := 28
   local  nRight    := 99.9
   local  nWidth    :=  Max( nRight * DLG_CHARPIX_W, 180 )
   local  nHeight   := nBottom * DLG_CHARPIX_H

   local  aBtnBrow  := array(4)
   local  aBtnNav   := array(4)

   local  cSearch:=space(20)
   local aGet[2]
   local cField:=""
   local aHdrs := {}  //Headers
   local aColumns := {}
   local n


    // da personalizzare

   local cImage:= "C:\Work\fwh\bitmaps\contact.bmp"
   local cTitle1:= "Customers"
   local cTitle2:= "Insert the customer to search"
  // local bNew,bEdit,bDel,bSearch,bPrint,bOk,bExit


    local cSelected   := ";"

   if File( "CUSTSEL.TXT" )
      cSelected   := MEMOREAD( "CUSTSEL.TXT" )
   endif

   if Empty( cSelected )
      cSelected   := ";"
   endif


   nField  :=1
   //header
       for n= 1 to Len(aBrowse)
          AAdd( aHdrs, aBrowse[n][2] )
          AAdd( aColumns, aBrowse[n][1] )
       next



     DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -16
     DEFINE FONT oFontSmall NAME 'Tahoma' SIZE 0, -14
     DEFINE FONT oBold  NAME 'Tahoma' SIZE 0, -14 BOLD



      DEFINE DIALOG oTabella  TITLE cTitle   ;
      SIZE nWidth, nHeight  FONT  oFont ;
      PIXEL TRUEPIXEL RESIZABLE COLOR CLR_BLACK,  nRgb( 245,244,234)



  @ 0,0 TITLE  oTitle OF oTabella size oTabella:nwidth, 60 BORDER SHADOW NOSHADOW   ;
                       GRADIENT { { 1, CLR_WHITE, CLR_WHITE } }
  @ 10, 12 TITLETEXT OF oTitle TEXT cTitle1 FONT oBold COLOR CLR_GRAY
  @ 28, 12 TITLETEXT OF oTitle TEXT cTitle2 FONT oFont COLOR CLR_HGRAY
  @ 10, 12  TITLEIMG oImg  OF oTitle  BITMAP cImage  SIZE 50,50 TRANSPARENT

  @ 66,3 SAY oSay1 Prompt "Search " ;
            FONT oBold SIZE 120,20 PIXEL OF oTabella  TRANSPARENT
  @ 42,  181 Say oSay2 Prompt  "in"  ;
           FONT oBold SIZE  55,   20 PIXEL   OF oTabella  TRANSPARENT


       DEFINE BUTTONBAR oBar OF oTabella SIZE 70,70  BOTTOM NOBORDER  2010
       DEFINE BUTTON OF oBar PROMPT "New"          ACTION If( oBrw:bEdit == nil, oBrw:Edit( .t. ), oBrw:EditSource( .t. ) )
       DEFINE BUTTON OF oBar PROMPT "Modify"   GROUP  ACTION If( oBrw:bEdit == nil, oBrw:Edit(), oBrw:EditSource() )
       DEFINE BUTTON OF oBar PROMPT "Delete"    ACTION ( If( MsgNoYes( "Delete Record?" ), oBrw:Delete(), nil ), oBrw:SetFocus() )
       DEFINE BUTTON OF oBar PROMPT "Print"       ACTION  If( Empty( oBrw:bPrint ), oBrw:Report(), oBrw:Print() )
       DEFINE BUTTON OF oBar PROMPT "Exit"         GROUP ACTION oTabella:End()


      oBar:bClrGrad := { | lPressed | If( ! lPressed,;
                       { { 1,  nRgb(233,229,206),nRgb(233,229,206) } },;
                       { {  1, nRgb( 245,244,234), nRgb( 245,244,234) } } ) }




        @ 100,5 XBROWSE oBrw  ;
           SIZE 385,130 PIXEL;
           OF oTabella ;
           ALIAS cDbf COLUMNS aBrowse NOBORDER  FOOTERS


    FOR i := 1 TO LEN(oBrw:aCols)
      oCol := oBrw:aCols[ i ]
      oCol:bClrSelFocus  := { || { CLR_BLACK, nRGB(202,224,252) } }
    NEXT


   WITH OBJECT oBrw
      WITH OBJECT oBrw:InsCol(1)
        :nwidth:= 30
        :bEditValue    := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
        :SetCheck( nil, .t.)
        :nHeadBmpNo    := { || If( Len( oBrw:aSelected ) == oBrw:nLen, 1, 2 ) }
        :bFooter       := { || ltrim(Str( Len(oBrw:aSelected))) }
        :bLClickHeader := { || oBrw:SelectRow( If( Len( oBrw:aSelected ) == oBrw:nLen, 0, 4 ) ), oBrw:Refresh() }

     End

      :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() }




      WITH OBJECT oBrw:aCols[ 2 ]
         :bFooter   := { || Ltrim( Str( oBrw:KeyNo() ) ) + " / " + LTrim( Str( oBrw:KeyCount() ) )+" customers" }
      END




      :bChange  := { |o| o:RefreshFooters() }
      :bKeyChar   := { |k| If( k == VK_SPACE, ( oBrw:oCol( 1 ):CheckToggle(), oBrw:RefreshCurrent(), 0 ), nil ) }
      :bLDblClick := { || oBrw:oCol( 1 ):CheckToggle(), oBrw:RefreshCurrent() }
      :bClrStd    := { || { CLR_BLACK, If( oBrw:oCol( 1 ):Value, 0x80ffff, CLR_WHITE ) } }
      //


   :l2007:=.f.
   :lColDividerComplete := .t.
   :lRecordSelector     := .t.
   :lHScroll            := .f.
   :nHeaderHeight       := 30
   :nRowHeight          := 30
   :nFooterHeight       := 30
   :nStretchCol         := -1
   :lDrawBorder := .t.
  *  :lIncrFilter   := .t.
  *  :lSeekWild     := .f.
   :lAllowColHiding := .f.

  :nRecSelColor     :=   nRgb( 245,244,234)
  :bClrHeader       := {|| { ,nRgb(233,229,206) } }
  :bClrFooter       := {|| { ,nRgb( 245,244,234) } }
  :nColDividerStyle := LINESTYLE_LIGHTGRAY
  :nRowDividerStyle := LINESTYLE_LIGHTGRAY
 END



     @ 40,  45  GET aGet[1] VAR cSearch  SIZE  250,  25  PIXEL OF oTabella ON CHANGE  (oBrw:cSeek:=AllTrim( cSearch )   )    UPDATE
     @ 40,  195 COMBOBOX aGet[2] var nField ITEMS aHdrs  SIZE  130, 90  PIXEL;
     OF oTabella HEIGHTGET 20  UPDATE

      aGet[1]:bKeyDown := { | nKey | KeyChar( oBrw, nKey,nField,cDbf,acolumns[nField],aGet[1]) }


    oBrw:CreateFromCode()




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

      @ 40, oBrw:nWidth-20  BTNBMP aBtnBrow[1]   ;
                FLAT SIZE 30, 30  OF oTabella   PIXEL ;
                COLOR  nRgb(203, 225, 252),nRgb(238,236,219) ;
                BITMAP ".\bitmaps\rinfresca.bmp" NOROUND;
                tooltip "Clear the search" ;
                ACTION ( (cDbf)->( DbClearFilter() )        ,;
                         (cDbf)->( Dbgotop() )              ,;
                         oBrw:refresh()                   ,;
                         cSearch:=space(60)               ,;
                         aGet[1]:SetText( cSearch )       ,;
                         aGet[1]:refresh()                ,;
                         cSeek   := ''                    ,;
                         oBrw:cSeek:=AllTrim( cSearch )   ,;
                         aGet[1]:setfocus()        )



     @ oBrw:nBottom+2, oBrw:nWidth-50 BTNBMP aBtnBrow[2]   ;
                FLAT  SIZE 30, 30  OF oTabella   PIXEL ;
                COLOR  nRgb(238,236,219),nRgb(238,236,219) ;
                BITMAP ".\bitmaps\su.bmp" NOROUND;
                ACTION oBrw:KeyDown(VK_UP, 0)

   @ oBrw:nBottom+2, oBrw:nWidth-35 BTNBMP aBtnBrow[3] ;
                FLAT  SIZE 30, 30  OF oTabella   PIXEL ;
                COLOR  nRgb(238,236,219),nRgb(238,236,219) ;
                BITMAP ".\bitmaps\giu.bmp" NOROUND;
                ACTION oBrw:KeyDown(VK_DOWN, 0)

   @ oBrw:nBottom+2, oBrw:nWidth-20 BTNBMP aBtnBrow[4] ;
                FLAT  SIZE 30, 30  OF oTabella   PIXEL ;
                COLOR  nRgb(238,236,219),nRgb(238,236,219) ;
                BITMAP ".\bitmaps\impostazioni.bmp" NOROUND;
                ACTION ::ShowPopUp( { |oBtn| MenuContextual(oBtn,oBrw,cPrefix+"Aux",cDbf,aGet)  } )


      For n= 1 to 4
              aBtnBrow[n]:bClrGrad = { | lInvert | If( ! lInvert,;
                    { { 1, RGB( 225, 225, 225 ), RGB( 225, 225, 225 ) } },;
                    { { 1, RGB( 229,241,251 ), RGB( 229,241,251 ) } } ) }
             aBtnBrow[n]:nClrBorder := nRgb(218,214,179)
             aBtnBrow[n]:oCursor:=   oCursorBtn
          next


      oTabella:bResized  := <||
           local oRect       := oTabella:GetCliRect()
           oTitle:nWidth     := oRect:nRight
           oBrw:nWidth       := oRect:nRight-10
           oBrw:nHeight      := oRect:nbottom-210
           oImg:aImgs[2]     := oRect:nRight-60
           aGet[1]:nTop      := oTitle:nBottom+5
           aGet[1]:nLeft     := oRect:nLeft+90
           oSay1:nTop        := oTitle:nBottom+7
           oSay1:nLeft       := oRect:nLeft+10
           oSay2:nTop        := oTitle:nBottom+7
           oSay2:nLeft       := oRect:nLeft+360
           aGet[2]:nTop      := oTitle:nBottom+5
           aGet[2]:nLeft     := oRect:nLeft+380
           aBtnBrow[1]:nTop  := oTitle:nBottom+5
           aBtnBrow[1]:nLeft := oRect:nRight-37
           aBtnBrow[2]:nTop  := oBrw:nBottom+5
           aBtnBrow[2]:nLeft := oRect:nRight-112
           aBtnBrow[3]:nTop  := oBrw:nBottom+5
           aBtnBrow[3]:nLeft := oRect:nRight-75
           aBtnBrow[4]:nTop  := oBrw:nBottom+5
           aBtnBrow[4]:nLeft :=oRect:nRight-37



           return nil
             >

        oTabella:aMinMaxInfo := { nil, nil, nil, nil, 650,350, nil, nil }


oBrw:bSeek  := nil
ACTIVATE DIALOG oTabella CENTER  ;
ON INIT  (otabella:resize(),EVAL( oTabella:bResized)  )



 return nil



//-----------------------------------------------------------------------------------------------------//
Function ChangeBrowse(oBrw,oControl)
    local aItems:= {}
    AEval( oBrw:aCols, { |o| If( o:lHide,,AAdd( aItems, o:cHeader ) ) } )
    oControl[2]:setItems(aItems)
    oControl[2]:refresh()
return nil
//-----------------------------------------------------------------------------------------------------//
 function SelectColumns( oBrowse )

   local oDlg, oBrw,oFont,oBold
   local aSave    := aCopy( oBrowse:aCols )
   Local cSaveState:= oBrowse:SaveState()

       DEFINE FONT oFont NAME 'Tahoma' SIZE 0, -16
       DEFINE FONT oBold  NAME 'Tahoma' SIZE 0, -14 BOLD

       DEFINE DIALOG oDlg SIZE 400,400 PIXEL TRUEPIXEL ;
       TITLE "Position  Columns";
       COLOR CLR_BLACK,nRgb(245,244,234)

       DEFINE BUTTONBAR oBar OF oDlg SIZE 64,70 2010 BOTTOM NOBORDER
       DEFINE BUTTON OF oBar PROMPT "Exit"     FILE "NO_DLG";
                                ACTION ( oDlg:end( IDCANCEL ) )

       DEFINE BUTTON OF oBar PROMPT "ok"  FILE "OK_DLG";
       ACTION ( oDlg:end( IDOK ) )   BTNRIGHT

      oBar:bClrGrad := { | lPressed | If( ! lPressed,;
                       { { 1, nRgb(233,229,206),nRgb(233,229,206) } },;
                       { { 1, nRgb( 245,244,234), nRgb( 245,244,234) } } ) }



       @ 10,20 XBROWSE oBrw SIZE -10,-90 PIXEL OF oDlg ;
      DATASOURCE oBrowse:aCols ;
      COLUMNS "cHeader", "lHide";
      HEADERS "Columns","" ;
      COLSIZES 100, 40 ;
       NOBORDER FONT oFont

   WITH OBJECT oBrw
           :l2007:=.f.
          :nStretchCol   := STRETCHCOL_WIDEST
          :lDrawBorder := .t.
          :bClrHeader       := {|| { ,nRgb(233,229,206) } }
          :bClrFooter       := {|| { ,nRgb( 245,244,234) } }
          :nColDividerStyle := LINESTYLE_LIGHTGRAY
          :lRecordSelector     := .f.
          :lHScroll            := .f.

      WITH OBJECT :aCols[ 2 ]
         :bEditValue    := { |x| If( x == nil, !oBrw:aRow:lHide, oBrw:aRow:lHide := !x ) }
         :SetCheck( nil, .t. )
         :nHeadBmpNo    := 2
      END
      :CreateFromCode()
   END

   ACTIVATE DIALOG oDlg CENTERED;
     ON INIT (oDlg:resize())
       RELEASE oFont,oBold

       IF oDlg:nresult == IDOK
           oBrowse:refresh()
        ENDIF

return nil













 #define EM_GETSEL          176

static function KeyChar( oBrw, nKey,n,cdbf,cField,oControl,oSayCounter)
   local nPos, cText

   *If nKey == VK_BACK .and. ! Empty( cSeek )
      If nKey == VK_BACK .and. cSeek != nil .and. Len( cSeek ) > 0
        ( oBrw:cAlias )->( IncrFilter( oBrw, Left( cSeek, Len( cSeek ) -1 ),n,cdbf,cField,oControl) )


      nPos     = nLoWord( oControl:SendMsg( EM_GETSEL ) ) + 1
      if nPos < 1
         return 0
      endif
      cText    = oControl:GetText()
      cText    := HB_UTF8LEFT( cText, nPos - 2 ) + HB_UTF8SUBSTR( cText, nPos )
      oControl:SetText( cText )
      oControl:oGet:buffer = oControl:GetText()
      oControl:oGet:pos := oControl:nPos := --nPos
      oControl:SetPos( nPos )


       oControl:setfocus() //get

       return 0

  * elseIf nKey > 31
   elseIf nKey > 31   .and. nKey != Asc( '*' ) .and. nKey != Asc( '?' )

      ( oBrw:cAlias )->( IncrFilter( oBrw, cSeek + Chr( nKey ),n,cdbf,cField,oControl) )



     oControl:setfocus()  //get

      return 0
   Endif


return nil

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

static function IncrFilter( oBrw,cPattern,n,cdbf,cField,oControl,oSayCounter)

   local cFilter:="", lFound := .f.
   local nRecNo, cSaveFilt, lStay
   local cField_name :=alltrim(cField)


         (cdbf)->(OrdSetFocus(n))

   if ValType( cPattern ) == 'C'
      if Empty( cPattern )
         cSeek       := ""
        //
        *  oSeek:SetText( cSeek )
        * oSeek:cText( cSeek )
        * oSeek:REFRESH()


       //
         SET FILTER TO !DELETED()
         GO TOP
         oBrw:Refresh()
         lFound      := .t.

      else
         cFilter     := 'WildMatch( "*' + Upper(cPattern) + '*",    Upper( '+cField_name+'))  .AND. !DELETED()'
         cSaveFilt   := DBFILTER()
         nRecNo      := RECNO()
         lStay       := &cFilter
         SET FILTER TO &cFilter
         GO TOP
         if OrdKeyCount() == 0
            SET FILTER TO &cSaveFilt
            GO TOP
            DBGOTO( nRecNo )

         else
             (cdbf)->(OrdSetFocus(n))

            cSeek    := cPattern
           //
           * oSeek:cText( cSeek )
           * oSeek:REFRESH()

          //
            if lStay
               DBGOTO( nRecNo )
               oBrw:Refresh()
            else
               oBrw:Refresh( .t. )
            endif
            lFound   := .t.
         endif
      endif
   endif



return lFound
//-------------------------------------------------------------------------------------------//


    Function MenuContextual(oControl,oBrw,cIniEntry,cDbf,aGet)
           local oMenu

        MENU oMenu POPUP
        MENUITEM "Seleziona la linea corrente" ;
        ACTION  NIL
           MENUITEM "Seleziona tutto"
           MENUITEM "Esporta" Action NIL
           MENUITEM "Colonne" ACTION ( SelectColumns( oBrw ),;
                                       ChangeBrowse(oBrw,aGet) )



         ENDMENU

         return oMenu


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



 



Any solution please ?
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: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: change on line a combo

Postby karinha » Tue Nov 17, 2020 3:47 pm

Congratulations Silvio, excellent example. I modified it a little for my taste. Some things, I didn't understand, so I can't help much. Very good.

Code: Select all  Expand view

// Cambiado por: kapiabafwh@gmail.com - 17/11/2020 - Covid-19.

#Include "fivewin.ch"
#Include "constant.ch"
#Include "ttitle.ch"
#Include "Combos.ch"

#Define CLR_LGREEN     nRGB( 190, 215, 190 )

STATIC cSeek   := ''
STATIC oSeek
STATIC nField
STATIC cIniFile

REQUEST HB_Lang_IT
REQUEST HB_CODEPAGE_ITWIN

ANNOUNCE RDDSYS
REQUEST OrdKeyNo, OrdKeyCount, OrdCreate, OrdKeyGoto
REQUEST DBFCDX, DBFFPT

FUNCTION Main()

   FIELD FIRST, LAST, CITY, STATE, CUST

   LOCAL cDbf    := "Cust"
   LOCAL aBrowse := ARRAY( 10 )
   LOCAL BEDIT

   HB_LangSelect( "IT" )
   HB_SetCodePage( "ITWIN" )

   SET CENTURY ON
   SET DATE ITALIAN
   SET EPOCH TO YEAR( DATE() ) - 30

   RDDSetDefault( 'DBFCDX' )

   // ??? Para que sirve, Silvio?
   cIniFile := cFilePath( GetModuleFileName( GetInstance() ) ) + "tabledb.ini"

   USE CUSTOMER NEW ALIAS CUST

   INDEX ON FIRST TAG FIRST TO TMFIRST  MEMORY
   INDEX ON LAST  TAG LAST  TO TMPLAST  MEMORY
   INDEX ON CITY  TAG CITY  TO TMPCITY  MEMORY
   INDEX ON STATE TAG STATE TO TMPSTATE MEMORY

   GO TOP

   // { field, header, picture, size, justify, sortorder }

   aBrowse   := { { "CUST->FIRST",  "First",,   120, }, ;
                  { "CUST->LAST",   "Last", ,   120, }, ;
                  { "CUST->STREET", "Street", , 180, }, ;
                  { "CUST->CITY",   "City", ,   150, }, ;
                  { "CUST->STATE",  "State", ,   50, } }

   bedit := { || MsgInfo( "modify" ) }

   TableDb( aBrowse, cDbf, "Customers table", "Cust", bedit )

RETURN NIL

FUNCTION TableDb( aBrowse, cDbf, cTitle, cPrefix, bedit )

   LOCAL oTabella, oBar, oCol, I, oImg, oTitle
   LOCAL oBrw, oSay1, oSay2
   LOCAL oFont, oFontSmall, oBold
   LOCAL oCursorBtn := TCursor():New( , 'HAND' )
   LOCAL nBottom  := 28
   LOCAL nRight   := 99.9
   LOCAL nWidth   :=  Max( nRight * DLG_CHARPIX_W, 180 )
   LOCAL nHeight  := nBottom * DLG_CHARPIX_H
   LOCAL aBtnBrow := array( 4 )
   LOCAL aBtnNav  := array( 4 )
   LOCAL cSearch  := SPACE( 20 )
   LOCAL aGet     := ARRAY( 5 )
   LOCAL cField   := ""
   LOCAL aHdrs    := {}  //Headers
   LOCAL aColumns := {}
   LOCAL n
   // da personalizzare
   // LOCAL cImage := "C:\Work\fwh\bitmaps\contact.bmp"
   LOCAL cImage := "C:\FWH1701\bitmaps\browse.bmp"
   LOCAL cTitle1 := "Customers"
   // LOCAL cTitle2 := "Insert the customer to search"
   LOCAL cTitle2 := "Busqueda Incremental:"
   LOCAL cSelected   := ";"

   IF File( "CUSTSEL.TXT" )
      cSelected   := MEMOREAD( "CUSTSEL.TXT" )
   ENDIF

   IF Empty( cSelected )
      cSelected   := ";"
   ENDIF

   nField  := 1

   //header
   FOR n = 1 TO Len( aBrowse )
      AAdd( aHdrs, aBrowse[n][2] )
      AAdd( aColumns, aBrowse[n][1] )
   NEXT

   SetGetColorFocus( CLR_LGREEN )

   SetBalloon( .T. ) // Balloon shape required for tooltips
   SkinButtons()     // Botoes Coloridos nas novas versoes

   DEFINE FONT oFont      NAME 'Tahoma' SIZE 0, -16
   DEFINE FONT oFontSmall NAME 'Tahoma' SIZE 0, -14
   DEFINE FONT oBold      NAME 'Tahoma' SIZE 0, -14 BOLD

   DEFINE DIALOG oTabella  TITLE cTitle SIZE nWidth, nHeight FONT oFont      ;
      PIXEL TRUEPIXEL RESIZABLE COLOR CLR_BLACK,  nRgb( 245, 244, 234 )

   @ 0, 0 TITLE oTitle SIZE oTabella:nwidth, 60 OF oTabella SHADOW NOSHADOW  ;
      GRADIENT { { 0.5, RGB(0xfa,0xfc,0xfd), RGB(0xe6,0xf0,0xfa) },          ;
                 { 0.5, RGB(0xdc,0xe6,0xf4), RGB(0xdd,0xe9,0xf7) } }

   @ 10, 12 TITLETEXT OF oTitle TEXT cTitle1 FONT oBold COLOR CLR_GRAY

   @ 28, 12 TITLETEXT OF oTitle TEXT cTitle2 FONT oFont COLOR CLR_HGRAY

   @ 10, 12  TITLEIMG oImg  OF oTitle  BITMAP cImage  SIZE 50, 50 TRANSPARENT

   @ 66, 3 SAY oSay1 PROMPT "Busqueda:" FONT oBold SIZE 120, 20 PIXEL        ;
      OF oTabella TRANSPARENT COLORS CLR_CYAN, CLR_WHITE UPDATE

   // IN
   @ 42, 180 SAY oSay2 PROMPT "Por:" FONT oBold SIZE 55, 20 PIXEL OF oTabella ;
       TRANSPARENT COLORS CLR_CYAN, CLR_WHITE UPDATE

   DEFINE BUTTONBAR oBar OF oTabella SIZE 70, 70  BOTTOM NOBORDER 2007 //2010

   oBar:bClrGrad := { | lPressed | If( ! lPressed,         ;
      { { 1,  nRgb( 233,229,206 ),nRgb( 233,229,206 ) } }, ;
      { { 1, nRgb( 245,244,234 ), nRgb( 245,244,234 ) } } ) }

   DEFINE BUTTON OF oBar PROMPT "New"                                        ;
      ACTION If( oBrw:bEdit == nil, oBrw:Edit( .T. ), oBrw:EditSource( .T. ) )

   DEFINE BUTTON OF oBar PROMPT "Modify" GROUP                               ;
      ACTION If( oBrw:bEdit == nil, oBrw:Edit(), oBrw:EditSource() )

   DEFINE BUTTON OF oBar PROMPT "Delete"                                     ;
     ACTION ( If( MsgNoYes( "Delete Record?" ), oBrw:Delete(), nil ), oBrw:SetFocus() )

   DEFINE BUTTON OF oBar PROMPT "Print"                                      ;
      ACTION  If( Empty( oBrw:bPrint ), oBrw:Report(), oBrw:Print() )

   DEFINE BUTTON OF oBar PROMPT "Exit" GROUP ACTION( oTabella:End() )

   @ 100, 5 XBROWSE oBrw  ;
      SIZE 385, 130 PIXEL;
      OF oTabella ;
      ALIAS cDbf COLUMNS aBrowse NOBORDER  FOOTERS

   FOR i := 1 TO LEN( oBrw:aCols )
      oCol := oBrw:aCols[ i ]
      oCol:bClrSelFocus  := { || { CLR_BLACK, nRGB( 202,224,252 ) } }
   NEXT

   WITH OBJECT oBrw

      WITH OBJECT oBrw:InsCol( 1 )

         :nwidth := 30
         :bEditValue    := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
         :SetCheck( nil, .T. )
         :nHeadBmpNo    := { || If( Len( oBrw:aSelected ) == oBrw:nLen, 1, 2 ) }
         :bFooter       := { || ltrim( Str( Len(oBrw:aSelected ) ) ) }
         :bLClickHeader := { || oBrw:SelectRow( If( Len( oBrw:aSelected ) == oBrw:nLen, 0, 4 ) ), oBrw:Refresh() }

      End

      :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() }

      WITH OBJECT oBrw:aCols[ 2 ]

         :bFooter   := { || Ltrim( Str( oBrw:KeyNo() ) ) + " / " + LTrim( Str( oBrw:KeyCount() ) ) + " customers" }

      END

      :bChange  := { |o| o:RefreshFooters() }
      :bKeyChar   := { |k| If( k == VK_SPACE, ( oBrw:oCol( 1 ):CheckToggle(), oBrw:RefreshCurrent(), 0 ), nil ) }
      :bLDblClick := { || oBrw:oCol( 1 ):CheckToggle(), oBrw:RefreshCurrent() }
      :bClrStd    := { || { CLR_BLACK, If( oBrw:oCol( 1 ):Value, 0x80ffff, CLR_WHITE ) } }

      :l2007 := .F.
      :lColDividerComplete := .T.
      :lRecordSelector     := .T.
      :lHScroll            := .F.
      :nHeaderHeight       := 30
      :nRowHeight          := 30
      :nFooterHeight       := 30
      :nStretchCol         := - 1
      :lDrawBorder := .T.
      // :lIncrFilter   := .t.
      // :lSeekWild     := .f.
      :lAllowColHiding := .F.

      :nRecSelColor     :=   nRgb( 245, 244, 234 )

      :bClrHeader       := {|| { ,nRgb( 233,229,206 ) } }
      :bClrFooter       := {|| { ,nRgb( 245,244,234 ) } }

      :nColDividerStyle := LINESTYLE_LIGHTGRAY
      :nRowDividerStyle := LINESTYLE_LIGHTGRAY

   END

   IF Set( _SET_INSERT, ! Set( _SET_INSERT ) )

      Set( _SET_INSERT, ! Set( _SET_INSERT ) )

   ENDIF

   @ 40,  45  GET aGet[1] VAR cSearch  SIZE  250,  25  PIXEL OF oTabella     ;
      ON CHANGE  ( oBrw:cSeek := AllTrim( cSearch )   ) UPDATE

   // EN:( IN )
   @ 40, 195 COMBOBOX aGet[2] VAR nField ITEMS aHdrs  SIZE  130, 90  PIXEL   ;
      OF oTabella STYLE CBS_DROPDOWN HEIGHTGET 20 UPDATE                     ;
      ON CHANGE ( RETORNE_FOCUS( aGet ) )  // NEW

   aGet[1]:bKeyDown := { | nKey | KeyChar( oBrw, nKey, nField, cDbf, acolumns[nField], aGet[1] ) }

   oBrw:CreateFromCode()

   @ 40, oBrw:nWidth - 20  BTNBMP aBtnBrow[1]             ;
      FLAT SIZE 30, 30  OF oTabella   PIXEL               ;
      COLOR  nRgb( 203, 225, 252 ), nRgb( 238, 236, 219 ) ;
      BITMAP "C:\FWH1701\bitmaps\new3.bmp" NOROUND        ;
      tooltip "Clear the search"                          ;
      ACTION ( ( cDbf )->( DbClearFilter() )            , ;
               ( cDbf )->( Dbgotop() )                  , ;
               oBrw:refresh()                           , ;
               cSearch := space( 60 )                   , ;
               aGet[1]:SetText( cSearch )               , ;
               aGet[1]:refresh()                        , ;
               cSeek   := ''                            , ;
               oBrw:cSeek := AllTrim( cSearch )         , ;
               aGet[1]:setfocus() )

   @ oBrw:nBottom + 2, oBrw:nWidth - 50 BTNBMP aBtnBrow[2] ;
      FLAT  SIZE 30, 30  OF oTabella   PIXEL               ;
      COLOR  nRgb( 238, 236, 219 ), nRgb( 238, 236, 219 )  ;
      BITMAP "c:\fwh1701\bitmaps\new3.bmp" NOROUND         ;
      ACTION oBrw:KeyDown( VK_UP, 0 )

   @ oBrw:nBottom + 2, oBrw:nWidth - 35 BTNBMP aBtnBrow[3] ;
      FLAT  SIZE 30, 30  OF oTabella   PIXEL               ;
      COLOR  nRgb( 238, 236, 219 ), nRgb( 238, 236, 219 )  ;
      BITMAP "c:\fwh1701\bitmaps\new3.bmp" NOROUND         ;
      ACTION oBrw:KeyDown( VK_DOWN, 0 )

   @ oBrw:nBottom + 2, oBrw:nWidth - 20 BTNBMP aBtnBrow[4] ;
      FLAT  SIZE 30, 30  OF oTabella   PIXEL               ;
      COLOR  nRgb( 238, 236, 219 ), nRgb( 238, 236, 219 )  ;
      BITMAP "c:\fwh1701\bitmaps\new3.bmp" NOROUND         ;
      ACTION ::ShowPopUp( { |oBtn| MenuContextual( oBtn,oBrw,cPrefix + "Aux",cDbf,aGet )  } )

   FOR n = 1 TO 4
      aBtnBrow[n]:bClrGrad = { | lInvert | If( ! lInvert, ;
         { { 1, RGB( 225, 225, 225 ), RGB( 225, 225, 225 ) } }, ;
         { { 1, RGB( 229,241,251 ), RGB( 229,241,251 ) } } ) }
      aBtnBrow[n]:nClrBorder := nRgb( 218, 214, 179 )
      aBtnBrow[n]:oCursor :=   oCursorBtn
   NEXT

   // No comprendo esto. Mucho trabajo por nada.
   oTabella:bResized := < ||
   LOCAL oRect       := oTabella:GetCliRect()

   oTitle:nWidth     := oRect:nRight

   oBrw:nWidth       := oRect:nRight - 10
   oBrw:nHeight      := oRect:nbottom - 210

   oImg:aImgs[2]     := oRect:nRight - 60

   aGet[1]:nTop      := oTitle:nBottom + 5
   aGet[1]:nLeft     := oRect:nLeft + 90

   oSay1:nTop        := oTitle:nBottom + 7
   oSay1:nLeft       := oRect:nLeft + 10

   oSay2:nTop        := oTitle:nBottom + 7
   oSay2:nLeft       := oRect:nLeft + 350  // 360  // EN/IN/POR

   // Controle del GET
   aGet[2]:nTop      := oTitle:nBottom + 5
   aGet[2]:nLeft     := oRect:nLeft + 385  // 380

   aBtnBrow[1]:nTop  := oTitle:nBottom + 5
   aBtnBrow[1]:nLeft := oRect:nRight - 37
   aBtnBrow[2]:nTop  := oBrw:nBottom + 5
   aBtnBrow[2]:nLeft := oRect:nRight - 112
   aBtnBrow[3]:nTop  := oBrw:nBottom + 5
   aBtnBrow[3]:nLeft := oRect:nRight - 75
   aBtnBrow[4]:nTop  := oBrw:nBottom + 5
   aBtnBrow[4]:nLeft := oRect:nRight - 37

   RETURN nil

   >

   oTabella:aMinMaxInfo := { nil, nil, nil, nil, 650, 350, nil, nil }

   oBrw:bSeek  := nil

   ACTIVATE DIALOG oTabella CENTER  ;
      ON INIT ( otabella:resize(), EVAL( oTabella:bResized )  )

   IF Set( _SET_INSERT, ! Set( _SET_INSERT ) )

      Set( _SET_INSERT, ! Set( _SET_INSERT ) )

   ENDIF

   oFont:End()
   oFontSmall:End()
   oBold:End()

RETURN nil

FUNCTION RETORNE_FOCUS( aGet )

   aGet[1]:Refresh()

   XFOCUS( aGet[1] )

RETURN( .T. )
//-------------------------------------------------------------------------//
// As vezes simples SetFocus( oObj ) nao faz um objeto ganhar foco
// neste caso pode apelar para estas duas funcoes a seguir
// Forcar foco para um objeto especifico - Ednaldo Rolim... yes!
//-------------------------------------------------------------------------//
FUNCTION xFocus( oObj )

   xSetFocus( oObj )
   xSetFocus( oObj )

RETURN( .T. )

FUNCTION xSetFocus( oObj )    

   LOCAL _oWnd := oObj:oWnd, _oTempo := ""

   DEFINE TIMER _oTempo INTERVAL 10 OF _oWnd ;
          ACTION ( oObj:SetFocus(), _oTempo:End() )

   ACTIVATE TIMER _oTempo

RETURN( .T. )

FUNCTION ChangeBrowse( oBrw, oControl )

   LOCAL aItems := {}

   AEval( oBrw:aCols, { |o| If( o:lHide,,AAdd( aItems, o:cHeader ) ) } )

   oControl[2]:setItems( aItems )
   oControl[2]:refresh()

RETURN nil

FUNCTION SelectColumns( oBrowse )

   LOCAL oDlg, oBrw, oFont, oBold, oBar
   LOCAL aSave    := aCopy( oBrowse:aCols )
   LOCAL cSaveState := oBrowse:SaveState()

   DEFINE FONT oFont NAME 'Tahoma' SIZE 0, - 16
   DEFINE FONT oBold NAME 'Tahoma' SIZE 0, - 14 BOLD

   DEFINE DIALOG oDlg SIZE 400, 400 PIXEL TRUEPIXEL ;
      TITLE "Position  Columns";
      COLOR CLR_BLACK, nRgb( 245, 244, 234 )

   DEFINE BUTTONBAR oBar OF oDlg SIZE 64, 70 2010 BOTTOM NOBORDER

   DEFINE BUTTON OF oBar PROMPT "Exit"     FILE "NO_DLG";
      ACTION ( oDlg:end( IDCANCEL ) )

   DEFINE BUTTON OF oBar PROMPT "ok"  FILE "OK_DLG";
      ACTION ( oDlg:end( IDOK ) )   BTNRIGHT

   oBar:bClrGrad := { | lPressed | If( ! lPressed, ;
      { { 1, nRgb( 233,229,206 ),nRgb( 233,229,206 ) } }, ;
      { { 1, nRgb( 245,244,234 ), nRgb( 245,244,234 ) } } ) }

   @ 10, 20 XBROWSE oBrw SIZE - 10, - 90 PIXEL OF oDlg ;
      DATASOURCE oBrowse:aCols ;
      COLUMNS "cHeader", "lHide";
      HEADERS "Columns", "" ;
      COLSIZES 100, 40 ;
      NOBORDER FONT oFont

   WITH OBJECT oBrw

      :l2007 := .F.
      :nStretchCol      := STRETCHCOL_WIDEST
      :lDrawBorder      := .T.
      :bClrHeader       := {|| { ,nRgb( 233,229,206 ) } }
      :bClrFooter       := {|| { ,nRgb( 245,244,234 ) } }
      :nColDividerStyle := LINESTYLE_LIGHTGRAY
      :lRecordSelector  := .F.
      :lHScroll         := .F.

      WITH OBJECT :aCols[ 2 ]
         :bEditValue    := { |x| If( x == nil, !oBrw:aRow:lHide, oBrw:aRow:lHide := !x ) }
         :SetCheck( nil, .T. )
         :nHeadBmpNo    := 2
      END

      :CreateFromCode()

   END

   ACTIVATE DIALOG oDlg CENTERED ;
      ON INIT ( oDlg:resize() )

   RELEASE oFont, oBold

   IF oDlg:nresult == IDOK
      oBrowse:refresh()
   ENDIF

RETURN nil

#define EM_GETSEL          176

STATIC FUNCTION KeyChar( oBrw, nKey, n, cdbf, cField, oControl, oSayCounter )

   LOCAL nPos, cText

   //If nKey == VK_BACK .and. ! Empty( cSeek )

   IF nKey == VK_BACK .AND. cSeek != nil .AND. Len( cSeek ) > 0
      ( oBrw:cAlias )->( IncrFilter( oBrw, Left( cSeek, Len( cSeek ) - 1 ),n,cdbf,cField,oControl ) )

      nPos     = nLoWord( oControl:SendMsg( EM_GETSEL ) ) + 1

      IF nPos < 1
         RETURN 0
      ENDIF

      cText    = oControl:GetText()
      cText    := HB_UTF8LEFT( cText, nPos - 2 ) + HB_UTF8SUBSTR( cText, nPos )

      oControl:SetText( cText )
      oControl:oGet:buffer = oControl:GetText()
      oControl:oGet:pos := oControl:nPos := --nPos
      oControl:SetPos( nPos )


      oControl:setfocus() //get

      RETURN 0

      // elseIf nKey > 31
   ELSEIF nKey > 31   .AND. nKey != Asc( '*' ) .AND. nKey != Asc( '?' )

      ( oBrw:cAlias )->( IncrFilter( oBrw, cSeek + Chr( nKey ),n,cdbf,cField,oControl ) )

      oControl:setfocus()  //get

      RETURN 0
   ENDIF

RETURN nil

STATIC FUNCTION IncrFilter( oBrw, cPattern, n, cdbf, cField, oControl, oSayCounter )

   LOCAL cFilter := "", lFound := .F.
   LOCAL nRecNo, cSaveFilt, lStay
   LOCAL cField_name := alltrim( cField )

   ( cdbf )->( OrdSetFocus( n ) )

   IF ValType( cPattern ) == 'C'

      IF Empty( cPattern )

         cSeek       := ""

         //
         // oSeek:SetText( cSeek )
         // oSeek:cText( cSeek )
         // oSeek:REFRESH()

         //
         SET FILTER TO .NOT. DELETED()

         GO TOP

         oBrw:Refresh()

         lFound      := .T.

      ELSE

         cFilter     := 'WildMatch( "*' + Upper( cPattern ) + '*", Upper( ' + cField_name + '))  .AND. .NOT. DELETED()'

         cSaveFilt   := DBFILTER()

         nRecNo      := RECNO()

         lStay       := &cFilter

         SET FILTER TO &cFilter

         GO TOP

         IF OrdKeyCount() == 0

            SET FILTER TO &cSaveFilt
            GO TOP

            DBGOTO( nRecNo )

         ELSE

            ( cdbf )->( OrdSetFocus( n ) )

            cSeek    := cPattern

            // oSeek:cText( cSeek )
            // oSeek:REFRESH()

            IF lStay

               DBGOTO( nRecNo )
               oBrw:Refresh()

            ELSE

               oBrw:Refresh( .T. )

            ENDIF

            lFound   := .T.

         ENDIF

      ENDIF

   ENDIF

RETURN lFound

FUNCTION MenuContextual( oControl, oBrw, cIniEntry, cDbf, aGet )

   LOCAL oMenu

   MENU oMenu POPUP
   MENUITEM "Seleziona la linea corrente" ;
      ACTION  NIL

   MENUITEM "Seleziona tutto"

   MENUITEM "Esporta" Action NIL

   MENUITEM "Colonne" ACTION ( SelectColumns( oBrw ), ;
      ChangeBrowse( oBrw, aGet ) )

   ENDMENU

RETURN oMenu
 


Regards, saludos.
João Santos - São Paulo - Brasil - Phone: +55(11)95150-7341
User avatar
karinha
 
Posts: 7214
Joined: Tue Dec 20, 2005 7:36 pm
Location: São Paulo - Brasil

Re: change on line a combo

Postby Silvio.Falconi » Tue Nov 17, 2020 4:32 pm

/ ??? Para que sirve, Silvio?
cIniFile := cFilePath( GetModuleFileName( GetInstance() ) ) + "tabledb.ini"


for save the state and other things
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: 6768
Joined: Thu Oct 18, 2012 7:17 pm

Re: change on line a combo

Postby Otto » Tue Nov 17, 2020 4:34 pm

Silvio,
can you please try this:

Function ChangeBrowse( oBrw, oControl)
local aItems:= {}

AEval( oBrw:aCols, { |o| If( o:lHide,, iif( len(alltrim(o:cHeader))>0, AAdd( aItems, o:cHeader ) , ) ) } )
oControl[2]:setItems(aItems)
oControl[2]:refresh()

oBrw:Setfocus()
return nil
//-----------------------------------------------------------------------------------------------------//


Best regards,
Otto
********************************************************************
mod harbour - Vamos a la conquista de la Web
modharbour.org
https://www.facebook.com/groups/modharbour.club
********************************************************************
User avatar
Otto
 
Posts: 6005
Joined: Fri Oct 07, 2005 7:07 pm

Next

Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: No registered users and 57 guests