New drop down browse now working

Moderator: Rathinagiri

Post Reply
franco
Posts: 816
Joined: Sat Nov 02, 2013 5:42 am
DBs Used: DBF
Location: Canada

New drop down browse now working

Post by franco »

Hi,all
I HAVE FIXED THIS SAMPLE. IT WILL NOW WORK. JUST CREATE NE PROJECT, THEN ERASE CODE AND COPY THIS
CODE IN PLACE. I~M SORRY MY ORIGINAL POST HAD AN ERROR IN IT ........... FRANCO

Here is a better example of my previous post. This works very well for large tables.

** ** The only problem is any displays under the browse are visible in the browse before it has focus. ******
Has anybody got any ideas ............. thanks Franco

#include <hmg.ch>
#include <minigui.ch>
PROC Main()
tbls()

use inv new shared
index on num1 to num1

DEFINE WINDOW frmQSMain ;
AT 0,0 ;
WIDTH GetDesktopWidth() * 0.75 ;
HEIGHT GetDesktopHeight() * 0.75 ;
TITLE "Quick Search Implementation on HMG Reference Guide" ;
MAIN

ON KEY ESCAPE ACTION frmQSMain.Release
ON KEY ESCAPE ACTION ''


DEFINE COMBOBOX button_1 // FOR BUTTON TO CLICK
ROW 10
COL 211
WIDTH 20
HEIGHT 20 // 20
ON GOTFOCUS { || frmQSMain.textSEARCH.VISIBLE := .T. , frmQSMain.brwItems.VISIBLE := .T. , frmQSMain.textSEARCH.setfocus }
END COMBOBOX

DEFINE BROWSE brwItems
ROW 33 //33
COL 211
WIDTH 240
HEIGHT 290 //290
* DYNAMICBACKCOLOR {128,128,128}
HEADERS { "Item","Description"}
WIDTHS { 100,200 }
WORKAREA inv
FIELDS { 'inv->num1', 'inv->desc' }
ONDBLCLICK { || frmQSMain.text_1.refresh , frmQSMain.textSEARCH.VISIBLE := .F. , frmQSMain.brwItems.VISIBLE := .F. }
ONLOSTFOCUS { || frmQSMain.text_1.refresh , frmQSMain.textSEARCH.VALUE := '' , ;
frmQSMain.brwItems.VISIBLE := .F. , frmQSMain.textSEARCH.VISIBLE := .F. , ;
frmQSMain.textSEARCH.VALUE := ' ' }
ONCHANGE { || dbgoto(this.value) }
NOLINES .T.
END BROWSE // brwItems

DEFINE TEXTBOX textSearch
ROW 10
COL 232
WIDTH 200 // 200 can make 0 so you cannot see
HEIGHT 24
ONCHANGE { || DBSEEK( UPPER( this.Value ), .T. ), frmQSMain.brwItems.value := inv->(RECNO() ) }
ONENTER { || frmQSMain.brwItems.SETFOCUS }
ONLOSTFOCUS { || frmQSMain.brwItems.SETFOCUS}
END TEXTBOX // tbxSearch

DEFINE TEXTBOX text_1
ROW 10
COL 10
WIDTH 200
HEIGHT 24
FIELD INV->NUM1
END TEXTBOX

DEFINE TEXTBOX text_2
ROW 60
COL 132
WIDTH 200
HEIGHT 24
VALUE '********Under Browse ********************'
END TEXTBOX

END WINDOW // frmQSMain
frmQSMain.text_1.SETFOCUS
frmQSMain.textSEARCH.VISIBLE := .F.
frmQSMain.brwItems.VISIBLE := .F.
frmQSMain.Center
frmQSMain.Activate
return
// HMG_HELP Main()

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

*FUNCTION REFRESH

*RETURN

FUNCTION TBLS

LOCAL CF := {}
if ! file('inv.dbf')
CF := {}
aADD(CF,{'NUM1' ,'C' , 15,0})
aADD(CF,{'DESC' ,'C' , 15,0})
DBCREATE( 'INV.DBF',CF )
USE
use inv new
index on num1 to num1
set index to num1
do while recno() < 100000
append blank
replace num1 with alltrim(str(100+recno()))
replace desc with 'DESC' +alltrim(str(100+recno()))
loop
enddo
close inv
endif

return
All The Best,
Franco
Canada
Post Reply