Xbrowse Seek

Xbrowse Seek

Postby Silvio.Falconi » Tue Nov 10, 2020 12:09 pm

my client wants a simple search with a get control (not with a yellow say control) in the dialogs where there are lists of archives (for example customers, articles, etc.) and wants to select the column where to search for the text to search : as soon as he inserts a letter, the xbrowse table must update itself and look for a record that has that requirement

- wants to select the record (aselected)
- he doesn't want to use lgetbar I showed it to him and he doesn't like it,

Code: Select all  Expand view  RUN

#include "fivewin.ch"
 #include "constant.ch"

REQUEST DBFCDX


Function Main()



   local aColumns  :=  { "FIRST","LAST","STREET","CITY","STATE" }
   local aHdrs     :=  {"Cognome","Nome","Indirizzo","Città", "State"}
   local cdbf      :=  "CUST"
   local cTitle    :=  "Searching on customer"


   USE CUSTOMER  ALIAS CUST
   INDEX ON FIRST  TAG FIRST    TO CUSTOMER
   INDEX ON LAST   TAG LAST     TO CUSTOMER
   INDEX ON CITY   TAG CITY     TO CUSTOMER
   INDEX ON STATE  TAG STATE    TO CUSTOMER

   CUST->(dbsetorder(1))
   CUST->(dbgotop())

      SetGetColorFocus(nRGB( 203, 225, 252 ))


   TableDb(aColumns,aHdrs,cDbf,cTitle)

   Return nil

//----------------------------------------------------------//
Function TableDb(aColumns,aHdrs,cDbf,cTitle)
   local  oDlg,oBrw
   local  oFont,oBold
   local  aBtnBrow  := array(4)
   local cField:=""
   local oSayCounter,cCounter
   local nField  :=1


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


       DEFINE DIALOG oDlg SIZE 820, 450 PIXEL FONT oFont ;
      TITLE cTitle


    @ 30, 05 XBROWSE oBrw SIZE 385,160 PIXEL OF oDlg ;
      DATASOURCE  cDbf ;
      COLUMNS aColumns ;
      HEADERS aHdrs;
      CELL LINES NOBORDER  FOOTERS


WITH OBJECT oBrw
    WITH OBJECT oBrw:InsCol(1)
        :bEditValue    := { || AScan( oBrw:aSelected, oBrw:BookMark ) > 0 }
        :SetCheck( nil, .t.)
        :nHeadBmpNo    := { || If( Len( oBrw:aSelected ) == oBrw:nLen, 1, 2 ) }
        :bFooter       := { || Str( Len(oBrw:aSelected)) }
     End


     *:bOnChange     := { |o| o:RefreshFooter() }
     :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() }


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


      :lIncrFilter   := .t.
      :lSeekWild     := .t.
      :cFilterFld    := "Cognome"
      :nStretchCol   := STRETCHCOL_WIDEST


       :bChange  := { || RefreshCont(oSayCounter,"CUST") }
       :lDrawBorder := .t.
       :lHScroll            := .f.
       :nHeaderHeight       := 30
       :nRowHeight          := 30
       :lColDividerComplete := .t.
       :lRecordSelector     := .t.
       :nStretchCol         := -1
       :CreateFromCode()
    END




     @ 12,  11 SAY "Search:"     SIZE  55,   12 PIXEL  OF  oDlg  COLOR 0, 14215660 FONT oFont

     @ 10,  45 GET oBrw:oSeek VAR oBrw:cSeek SIZE 100,12 PIXEL ;
      OF oDlg COLOR CLR_BLACK,CLR_YELLOW PICTURE '@!' ;
      ON CHANGE (  oBrw:lSeekWild :=.t., ;
                   oBrw:Seek( If( oBrw:lSeekWild, oBrw:cSeek, "" ) ), ;
                   oBrw:SetFocus() )  FONT oFont



     @ 12,  181 SAY "in"     SIZE  55,   12 PIXEL  OF  oDlg  COLOR 0, 14215660  FONT oFont
     @ 10,  195 COMBOBOX oBrw:cFilterFld ;
      ITEMS aHdrs ;
      ON CHANGE ( oBrw:Seek( "" ), oBrw:SetFocus() ) ;
      SIZE 50,400 PIXEL OF oDlg  STYLE CBS_DROPDOWN   FONT oFont






 @ 10, oBrw:nWidth-20  BTNBMP aBtnBrow[1]   ;
                FLAT SIZE 15, 14  OF oDlg   PIXEL ;
                COLOR  nRgb(203, 225, 252),nRgb(238,236,219) ;
                BITMAP "REP_CLEAR" NOROUND;
                tooltip "Clear" ;
                ACTION (cSearch:=Space(60),aGet[1]:ctext:=cSearch,;
                         aGet[1]:refresh(),  Clear(oBrw,nField),RefreshCont(oSayCounter,"CUST"))

    cCounter:=lTrim(tran( ( oBrw:cAlias )->(ordKeyNo()),'@E 999,999'))+" / "+lTrim(tran(( oBrw:cAlias )->(ordKeyCount()),'@E 999,999'))

            @ oBrw:nBottom+5, oBrw:nWidth-90  SAY oSayCounter ;
              PROMPT cCounter ;
              SIZE 35, 10  OF oDlg  PIXEL ;
              FONT oFont ;
              COLOR CLR_BLACK ,nRgb(218,214,179)



     oDlg:bPainted := < |hDC|
        RoundBox( hDC, 580,383,668,410,0,0,nRgb(218,214,179), 2 )
      Return nil
      >

    oBrw:bSeek  := nil
         oDlg:lHelpIcon := .f.
ACTIVATE DIALOG oDlg CENTER




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


 Function RefreshCont(oCont,cAlias)
    if oCont != NIL
       cStringa:=ltrim(tran( (cAlias)->(ordKeyNo()),'@E 999,999'))+" / "+lTrim(tran((cAlias)->(ordKeyCount()),'@E 999,999'))
      oCont:settext(cStringa )
     * oCont:refresh()
   endif
return nil

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


Function Clear(oBrw,nField)
   SET FILTER TO !DELETED()
         ( oBrw:cAlias )->(Dbsetorder(nField))
         GO TOP
         oBrw:Refresh()
   return nil

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

Re: Xbrowse Seek

Postby karinha » Tue Nov 10, 2020 1:10 pm

I do it like this, see CHECKBOX.

You must create all indexes of the survey, create a CHECKBOX for your customer to choose what type of survey he wants to do, eg:

NAME - ADDRESS - POSTAL CODE - ETC.

When he chooses, you ARROW the corresponding index and you're done.

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

Re: Xbrowse Seek

Postby Silvio.Falconi » Tue Nov 10, 2020 8:23 pm

karinha wrote:Silvio, look Checkbox:

https://i.imgur.com/5I32lk8.png



Regards.




I RESOLVED


Now my sample run ok with a get control


Image

I sent my code to Antonio
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: 7072
Joined: Thu Oct 18, 2012 7:17 pm


Return to FiveWin for Harbour/xHarbour

Who is online

Users browsing this forum: Surasak and 51 guests