Incremental Search with Combo Box

General Help regarding HMG, Compilation, Linking, Samples

Moderator: Rathinagiri

User avatar
Rathinagiri
Posts: 5480
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Incremental Search with Combo Box

Post by Rathinagiri »

We may ask Roberto to add sort .t. and ondisplaychange event to the in-place-edit combobox controls.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
sudip
Posts: 1456
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: Incremental Search with Combo Box

Post by sudip »

Hi Esgici,
Regarding HMG documentation, COMBOBOX under COLUMNCONTROLS property of GRID have only one property /parameter : acItems; neither event, nor method.
Can COLUMNVALID {....} code block array be used for this?

With best regards.

Sudip
With best regards,
Sudip
User avatar
Rathinagiri
Posts: 5480
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Incremental Search with Combo Box

Post by Rathinagiri »

Nope. For using the incremental search, either we have to use sort .t. or ondisplaychange event.

IMHO Columnvalid event would be fired only when the control losts its focus.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Incremental Search with Combo Box

Post by esgici »

Hi

Another ( unsuccessful ) try for incremental search.

Not in Combo box, but somewhat similar it : combined a text box and a listbox, namely Combined Search Box :idea:

At beginning, the idea look liked me feasible, until terminated :(

For seeing the problem please uncomment line 27 :

Code: Select all

@ 55, 190 TEXTBOX txbMessy
Any idea for surmount this problem ?

Regards

--

Esgici
Attachments
CSBox.zip
Combined Search Box try
(2.71 KiB) Downloaded 287 times
Viva INTERNATIONAL HMG :D
User avatar
Rathinagiri
Posts: 5480
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Incremental Search with Combo Box

Post by Rathinagiri »

OMG! It is really fantastic Esgici. It shows various possibilities of HMG.

My suggestions: (I am also trying)

1. To do away the problem of overlapping controls behind the listbox, we can write a "HideControlsBehind()" function for the "on gotfocus" event of the text box, for all the controls that have either row or col or having visibility in that region of listbox. And, "on lostfocus" event would do "ShowControlsBehind()" of course.

2. We can have an "On Enter/On lostfocus" event for the textbox to select and hide the listbox once the user presses enter key at any time.
East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
sudip
Posts: 1456
Joined: Sat Mar 07, 2009 11:52 am
Location: Kolkata, WB, India

Re: Incremental Search with Combo Box

Post by sudip »

Esgici,

Excellent !!! :D

Regards.

Sudip
With best regards,
Sudip
User avatar
Rathinagiri
Posts: 5480
Joined: Tue Jul 29, 2008 6:30 pm
DBs Used: MariaDB, SQLite, SQLCipher and MySQL
Location: Sivakasi, India
Contact:

Re: Incremental Search with Combo Box

Post by Rathinagiri »

Hi Esgici,

I think, I had done away the overlapping controls problem.

Try this code. I am further modifying...

CSBox.prg

Code: Select all

/*
  

  CSBox ( Combined Search Box ) try


*/

#include "minigui.ch"

PROC Main()

   aCountries := HB_ATOKENS( MEMOREAD( "Countries.lst" ),   CRLF )
   
   ASORT( aCountries )                    // This Array MUST be sorted
       
   DEFINE WINDOW frmCSBTest ;
      AT 0,0 ;
      WIDTH 550 ;
      HEIGHT 300 ;
      TITLE 'CSBox ( Combined Search Box ) Test' ;
      MAIN ;
      ON INIT MakeCSBs()
      
      ON KEY ESCAPE ACTION frmCSBTest.Release
      
     @ 55, 190 TEXTBOX txbMessy
   
   END WINDOW // frmCSBTest
   
   frmCSBTest.Center
   
   frmCSBTest.Activate

      
RETU // Main()

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.


PROC MakeCSBs()                           // Making CSBox(s)

   DefnCSBox( ThisWindow.Name, 'Country',;         // Names suffix
                               'Country Name :',;  // Prompt
                               25,;                // CSBox Box Row No 
                               100,;               // CSBox Box Col No 
                               200,;               // Text Box Width  
                               20,;                // Text Box Height 
                               aCountries )   
                               
   frmCSBTest.TxBCountry.SetFocus()
   
RETU // MakeCSBs()

*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.

PROC DefnCSBox( ;                           // Define a CSBox  
              cFrmName,;    // Form / Window Name
              cCSBName,;    // CSBox Name
              cLblValu,;    // Prompt
              nCSBRow,;     // CSBox Row No
              nCSBCol,;     // CSBox Col No   
              nTxBWidth,;   // Text Box Width
              nTxBHeight,;  // Text Box Height
              aArray )      // Search array  
              
    LOCAL cLblName := "Lbl" + cCSBName,;
          cTxBName := "TxB" + cCSBName,;
          cLsBName := "LsB" + cCSBName,;
          nLblWidt := 0,;
          nTxBCol  := 0,; 
          nLsBRow  := 0    
    DEFINE LABEL &cLblName  
       PARENT    &cFrmName
       ROW        nCSBRow
       COL        nCSBCol
       HEIGHT     nTxBHeight
       VALUE      cLblValu
       RIGHTALIGN .T.
       AUTOSIZE   .T.
    END LABEL // &lblName      

    nLblWidt := GetProperty( cFrmName, cLblName, "WIDTH" ) 
    nTxBCol  := nCSBCol + nLblWidt + 5
 
    DEFINE TEXTBOX &cTxBName 
       PARENT   &cFrmName
       ROW      nCSBRow - 2
       COL      nTxBCol
       WIDTH    nTxBWidth
       HEIGHT   nTxBHeight
       ONCHANGE SetCSBoxVal( cFrmName, this.name , aArray )
    END TEXTBOX // &cTxBName   

    nLsBRow := GetProperty( cFrmName, cTxBName, "ROW" ) + nTxBHeight - 1
       
    DEFINE LISTBOX &cLsBName
       PARENT   &cFrmName
       COL      nTxBCol
       ROW      nLsBRow 
       WIDTH    nTxBWidth
       HEIGHT   200
       ITEMS    {}
    END LISTBOX
    
    SetProperty( cFrmName, cLsBName, "VISIBLE", .F. )
    
RETU // DefnCSBox()   
   
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.

PROC SetCSBoxVal( ;                       // Setting CSBox values
                  cFrmName,;   // Form / Windows name 
                  cTxBName,;   // Text Box Name 
                  aList )      // Items list 
   
   LOCAL cCurval  := GetProperty( cFrmName, cTxBName, "Value" ),;
         nFrmHeig := GetProperty( cFrmName, "HEIGHT" ),;
         aResults := {},;
         n1Result := 0,;
         cLsBName := "LsB" + SUBSTR( cTxBName, 4 ),;
         c1Found  := '',;
         cMethod  := '',;
         lNoResult := .F.
  
          
    IF !EMPTY( cCurval ) 
       WHILE ( n1Result := ASCAN( aList, { | c1 | UPPER( LEFT( c1, LEN( cCurval ) ) ) == UPPER( cCurval )}, n1Result + 1 ) )  > 0  ;
             .AND. n1Result < LEN( aList )
          AADD( aResults, aList[ n1Result ] )
       ENDDO
       IF !EMPTY( aResults )
       
          nLsBRow  := GetProperty( cFrmName, cLsBName, "ROW" )
          nLsBCol  := GetProperty( cFrmName, cLsBName, "COL" )
          nLsBLeng := GetProperty( cFrmName, cLsBName, "WIDTH" )
          
          nLsBHeig := MAX( MIN( LEN( aResults ) * 15,  nFrmHeig - nLsBRow - 40 ), 20 )  
          
          DoMethod( cFrmName, cLsBName, "Release" ) 
          
          for i := 1 to len(_hmg_sysdata[1])
           
             
                if ((_hmg_sysdata[18,i] > nLsBRow .and. _hmg_sysdata[18,i] < nLsBRow + nLsBHeig) .or. (_hmg_sysdata[18,i]+_hmg_sysdata[21,i] > nLsBRow .and. _hmg_sysdata[18,i]+_hmg_sysdata[21,i] < nLsBRow + nLsBHeig)) .and. ((_hmg_sysdata[19,i] > nLsBCol .and. _hmg_sysdata[19,i] < nLsBCol + nLsBLeng) .or. (_hmg_sysdata[19,i]+_hmg_sysdata[20,i] > nLsBCol .and. _hmg_sysdata[19,i]+_hmg_sysdata[20,i] < nLsBCol + nLsBLeng)) .and. _hmg_sysdata[4,i] == GetFormHandle(CFrmName)
					setproperty(cFrmName,_hmg_sysdata[2,i],"VISIBLE",.f.)
                endif
             
          next i
          
          DEFINE LISTBOX &cLsBName
             PARENT     &cFrmName
             ROW        nLsBRow
             COL        nLsBCol 
             WIDTH      nLsBLeng
             HEIGHT     nLsBHeig
             ITEMS      aResults
             VALUE      1 
             ONDBLCLICK {||SetProperty( cFrmName, cTxBName, "VALUE", this.item( this.value ) ),;
						   SetProperty( cFrmName, cLsBName, "VISIBLE", .F. ),;
					       CSBoxSearchOver()}
          END LISTBOX
                     
          SetProperty( cFrmName, cLsBName, "VISIBLE", .T. )
          
       ELSE 
          lNoResult := .T.
       ENDIF !EMPTY( aResults )
    ELSE   
       lNoResult := .T.
    ENDIF !EMPTY( cCurval ) 
    
    IF lNoResult
       SetProperty( cFrmName, cLsBName, "VISIBLE", .F. )
    ENDIF

RETU // SetCSBoxVal()   
   
function CSBoxSearchOver()
Local nLsBRow := this.row
Local nLsBCol := this.col
Local nLsBLeng := this.width
Local nLsBHeig := this.height
Local cFrmname := thiswindow.name

          for i := 1 to len(_hmg_sysdata[1])
           
             
                if ((_hmg_sysdata[18,i] > nLsBRow .and. _hmg_sysdata[18,i] < nLsBRow + nLsBHeig) .or. (_hmg_sysdata[18,i]+_hmg_sysdata[21,i] > nLsBRow .and. _hmg_sysdata[18,i]+_hmg_sysdata[21,i] < nLsBRow + nLsBHeig)) .and. ((_hmg_sysdata[19,i] > nLsBCol .and. _hmg_sysdata[19,i] < nLsBCol + nLsBLeng) .or. (_hmg_sysdata[19,i]+_hmg_sysdata[20,i] > nLsBCol .and. _hmg_sysdata[19,i]+_hmg_sysdata[20,i] < nLsBCol + nLsBLeng)) .and. _hmg_sysdata[4,i] == GetFormHandle(CFrmName)
					setproperty(cFrmName,_hmg_sysdata[2,i],"VISIBLE",.t.)
                endif
             
          next i


return nil
*-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.-._.

East or West HMG is the Best.
South or North HMG is worth.
...the possibilities are endless.
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Incremental Search with Combo Box

Post by esgici »

Hi Rathi

Thanks your interest an participations.

I'll try.

My expectation is an intervention by Roberto.

Regards

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Incremental Search with Combo Box

Post by esgici »

sudip wrote: Excellent !!! :D
Thanks Sudip, but
May I differ with you?
:(

Regards

--

Esgici
Viva INTERNATIONAL HMG :D
User avatar
esgici
Posts: 4543
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Contact:

Re: Incremental Search with Combo Box

Post by esgici »

rathinagiri wrote:I had done away the overlapping controls problem.
Try this code. I am further modifying...
Hi Rathi

Thanks a lot, tried, works fine, without overlapping :)

Now, I am working to understand your code :)

Regards

--

Esgici
Viva INTERNATIONAL HMG :D
Post Reply