Incremental Search in BROWSE

Moderator: Rathinagiri

User avatar
Clip2Mania
Posts: 95
Joined: Fri Jun 13, 2014 7:16 am
Location: Belgium
Been thanked: 1 time

Re: Incremental Search in BROWSE

Post by Clip2Mania » Fri Jun 27, 2014 3:17 pm

Oh, sorry I forgot. The latest version (3.3.0 32bit, patch3, ANSI)

Javier Tovar
Posts: 1274
Joined: Tue Sep 03, 2013 4:22 am
Location: Tecámac, México
Has thanked: 1 time
Been thanked: 2 times

Post by Javier Tovar » Sat Jun 28, 2014 11:30 pm

Gracias a todos por compartir! Mol, Sr. Esguici :D

Saludos

User avatar
Clip2Mania
Posts: 95
Joined: Fri Jun 13, 2014 7:16 am
Location: Belgium
Been thanked: 1 time

Post by Clip2Mania » Mon Jun 30, 2014 8:37 am

Had the weekend to find a way around it. :)
Made the Search-string public (although I don't like making a lot of variables public).
For the ones interested (Javier?), this is the code:

Code: Select all

#include <hmg.ch>
function main()
local aHeaders:={"Nummer","Trk","Artiest","Titel"}
local aWidths:={65,35,248,249}
local acFields:={"MUSIC->NR","MUSIC->DTR","MUSIC->ARTIEST","MUSIC->TITEL"}
local cSMsg:="Type to Search - Click on title to Change Sort Order - F2 to clear search"
public cStr:="", cVal

REQUEST DBFNSX
SET BROWSESYNC ON
SET DATE FRENCH

dbUseArea(.T.,"DBFNSX","MUSIC",.F.)
OrdSetFocus(5)
dbGoTop()

DEFINE WINDOW MainForm;
	AT 90,90;
	WIDTH 645;
	HEIGHT 403;
  TITLE "MiniBrowser";
	ON RELEASE Closedb();
	MAIN
	
	ON KEY F2 ACTION ResetSearch()
	
	DEFINE STATUSBAR 
		STATUSITEM cSMsg
		CLOCK
		DATE
		STATUSITEM " " WIDTH 15 //In Windows 7, year is hidden by corner
	END STATUSBAR
		
END WINDOW

@ 5,5 BROWSE br_Main;
  OF MainForm;
  WIDTH 620;
	HEIGHT 332;
	HEADERS aHeaders;
	WIDTHS aWidths;
	WORKAREA MUSIC;
	FIELDS acFields;
	ON HEADCLICK { {||Resort(5)} , {||MsgInfo('No Sort Key')} , {||Resort(1)},{||Resort(2)}};
	JUSTIFY { BROWSE_JTFY_LEFT,BROWSE_JTFY_RIGHT,BROWSE_JTFY_LEFT,BROWSE_JTFY_LEFT}
	
CREATE EVENT PROCNAME QuickSearch() HWND MainForm.br_Main.HANDLE MSG WM_CHAR

MainForm.Center
MainForm.Activate

return NIL

//------------------------
function ResetSearch()
cStr:=""
MainForm.Statusbar.Item(1):=cStr
return NIL
//------------------------
function QuickSearch()
local ch, hWnd
ch := HMG_GetLastCharacter(@hWnd)

if asc(ch) = 8
  cStr:=if(len(cStr)>1,left(cStr,len(cStr)-1),"")
else
   cStr:=cStr+upper(ch)
endif

if !DBSEEK(cStr,.T.)
  DBSKIP(-1)
endif

HMG_CleanLastCharacter()   
MainForm.Statusbar.Item(1):=cStr
MainForm.br_Main.Value:=recno()
MainForm.br_Main.Setfocus
return 1
//-----------------------
function Resort(nNum)
Ordsetfocus(nNum)
cStr:=""
MainForm.Statusbar.Item(1):=cStr
Mainform.br_Main.Refresh
return Nil
//-----------------------
function Closedb()
DBCloseAll()
Return NIL
//-----------------------
Thanks to all who contributed!

User avatar
mol
Posts: 2853
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 123 times
Been thanked: 65 times
Contact:

Post by mol » Mon Jun 30, 2014 9:43 am

Please attach some piece of database to allow testing it!

User avatar
danielmaximiliano
Posts: 2044
Joined: Fri Apr 09, 2010 4:53 pm
Location: Argentina
Has thanked: 87 times
Been thanked: 12 times
Contact:

Post by danielmaximiliano » Mon Jun 30, 2014 12:07 pm

Gracias por compartir Clip2Mania
*´¨)
¸.·´¸.·*´¨) ¸.·*¨)
(¸.·´. (¸.·` *
.·`.HMG : It's magic !
(¸.·``··*

Saludos / Regards
DaNiElMaXiMiLiAnO

Whatsapp. : +54901169026142
Telegram Name : DaNiElMaXiMiLiAnO

User avatar
Clip2Mania
Posts: 95
Joined: Fri Jun 13, 2014 7:16 am
Location: Belgium
Been thanked: 1 time

Post by Clip2Mania » Tue Jul 01, 2014 8:00 am

Please attach some piece of database to allow testing it!
Here is the code & snippet of DB!
Attachments
MiniBrowse.zip
(8.43 KiB) Downloaded 122 times

User avatar
esgici
Posts: 4345
Joined: Wed Jul 30, 2008 9:17 pm
DBs Used: DBF
Location: iskenderun / Turkiye
Has thanked: 229 times
Been thanked: 80 times
Contact:

Post by esgici » Tue Jul 01, 2014 11:52 am

Clip2Mania wrote: Here is the code & snippet of DB!
Good job :arrow:

Thanks to share ;)

By the way, don't worry about PUBLICs, in HMG Lib almost everything is public !
Viva INTERNATIONAL HMG :D

User avatar
Clip2Mania
Posts: 95
Joined: Fri Jun 13, 2014 7:16 am
Location: Belgium
Been thanked: 1 time

Post by Clip2Mania » Tue Jul 15, 2014 10:16 am

In the code above, and also in general:

When you type a character, it is trapped by HMG_GetLastcharacter().
The following phenomenon occurs:

1) if you click in the browse, and then type a character, it is trapped.
2) if you scroll in the browse (with arrows or mouse scroll), and then type a character, the first character is not trapped by HMG_Getlastcharacter(), second one and following are.

How come? Is there a solution to this?

Thanks,
Erik

User avatar
Agil Abdullah
Posts: 204
Joined: Mon Aug 25, 2014 11:57 am
Location: Jakarta, Indonesia
Contact:

Post by Agil Abdullah » Wed Sep 03, 2014 10:19 am

Hi Marek,

I tried to compiled your codes written down above, by inserting #include hmg.ch and minigui.ch before making Function Main().

But it generated errors as below:
----------------------------------------------------------------------------------------
Harbour 3.2.0dev (r1407111333)
Copyright (c) 1999-2014, http://harbour-project.org/" onclick="window.open(this.href);return false;
C:/Users/toshiba/AppData/Local/Temp/hbmk_dd8s3c.dir/inboxfind.o:inboxfind.c:(.data+0x58): undefined reference to `HB_FUN_OKNOSZYBKATABELATOWAROW_AKTUALIZUJPODGLAD'
C:/Users/toshiba/AppData/Local/Temp/hbmk_dd8s3c.dir/inboxfind.o:inboxfind.c:(.data+0x78): undefined reference to `HB_FUN_OKNOSZYBKATABELATOWAROW_ZWROCKODTOWARU'
C:/Users/toshiba/AppData/Local/Temp/hbmk_dd8s3c.dir/inboxfind.o:inboxfind.c:(.data+0x88): undefined reference to `HB_FUN_ZMIENKLUCZTOWARU'
collect2: ld returned 1 exit status
hbmk2: Error: Running linker. 1
gcc.exe C:/Users/toshiba/AppData/Local/Temp/hbmk_dd8s3c.dir/inboxfind.o C:/Users/toshiba/AppData/Local/Temp/hbmk_dd8s3c.dir/hbmk_h89g4y.o D:/hmg00/_temp.o -Wl,--nxcompat -Wl,--dynamicbase -mwindows -Wl,--start-group -lhmg -lcrypt -ledit -leditex -lgraph -lini -lreport -lhfcl -lmsvfw32 -lvfw32 -lhbct -lhbwin -lhbmzip -lminizip -lhbmemio -lhbmisc -lhbmysql -lmysql -lhbtip -lhbsqlit3 -lsddodbc -lrddsql -lsddmy -lhbodbc -lodbc32 -lhbhpdf -lhbfimage -lhbpgsql -lhbnetio -lxhb -lpng -llibhpdf -lhbvpdf -lhbzebra -lhbextern -lhbdebug -lhbvmmt -lhbrtl -lhblang -lhbcpage -lgtcgi -lgtpca -lgtstd -lgtwin -lgtwvt -lgtgui -lhbrdd -lhbuddall -lhbusrrdd -lrddntx -lrddcdx -lrddnsx -lrddfpt -lhbrdd -lhbhsx -lhbsix -lhbmacro -lhbcplr -lhbpp -lhbcommon -lhbmainwin -lkernel32 -luser32 -lgdi32 -ladvapi32 -lws2_32 -liphlpapi -lwinspool -lcomctl32 -lcomdlg32 -lshell32 -luuid -lole32 -loleaut32 -lmpr -lwinmm -lmapi32 -limm32 -lmsimg32 -lwininet -lhbpcre -lhbzlib -Wl,--end-group -oinboxfind.exe -Ld:/HMG331/harbour/lib/win/mingw -Ld:/HMG331/lib

hbmk2: Error: Referenced, missing, but unknown function(s):
OKNOSZYBKATABELATOWAROW_AKTUALIZUJPODGLAD(),
OKNOSZYBKATABELATOWAROW_ZWROCKODTOWARU(), ZMIENKLUCZTOWARU()
----------------------------------------------------------------------------------------

Pls tell me how fix it. Thanks.
Agil Abdullah Albatati (just call me Agil)
Programmer Never Surrender

User avatar
mol
Posts: 2853
Joined: Thu Sep 11, 2008 5:31 am
Location: Myszków, Poland
Has thanked: 123 times
Been thanked: 65 times
Contact:

Post by mol » Wed Sep 03, 2014 12:51 pm

these functions are defined in my project.
This function updates only additional informations on screen (product describe, image of product):

Code: Select all

function OknoSzybkaTabelaTowarow_AktualizujPodglad
	OknoTabTowarow.T_DodatOpis.Value := towary->DodatOpis
	if lPodgladZdjecia
		cOkno := "OknoTabTowarow"
		if IsControlDefined(IM_ZdjecieTowaru, OknoTabTowarow)
			if file(cFolderZdjecTowarow+"T"+towary->towar+".jpg")
				SetProperty(cOkno,"IM_ZdjecieTowaru","Picture",cFolderZdjecTowarow+"T"+towary->towar+".jpg")
			elseif file(cFolderZdjecTowarow+"T"+towary->towar+"_1.jpg")
				SetProperty(cOkno,"IM_ZdjecieTowaru","Picture",cFolderZdjecTowarow+"T"+towary->towar+"_1.jpg")
			else
				SetProperty(cOkno,"IM_ZdjecieTowaru","Picture",'RC_BRAKZDJECIA')
			endif
		endif
	endif
return
second:

Code: Select all

function OknoSzybkaTabelaTowarow_ZwrocKodTowaru
	local StObsBledu
	local lKontynuacja := .t.
	
	ZwrotnyTowar := OknoTabTowarow.B_Towary.Value
	towary->(DBGoTo(ZwrotnyTowar))
	if !empty(cFunkcjaZapisuPozycji)
		lKontynuacja := &cFunkcjaZapisuPozycji
	endif

	if !lKontynuacja
		OknoTabTowarow.Release
	else
		OknoTabTowarow.T_Wyszukaj.Value := ""
		//OknoTabTowarow.SetFocus
	endif
	
 return
you can see macro calling: &cFunkcjaZapisuPozycji
It realize special action after selecting item, you can set it by cFunkcjaZapisuPozycji := ""

And the last changes index:

Code: Select all


function ZmienKluczTowaru
	param NrKlucza

	DbSetOrder(NrKlucza)
	SetProperty(ThisWindow.Name, "B_Towary","Value" ,towary->(recno()) )
	DoMethod(ThisWindow.name, "B_Towary","Refresh")
 	DoMethod(ThisWindow.name, "T_Wyszukaj","SetFocus")
 return .t.
I'm afraid you will find it hard to implement. But try!

Post Reply