Follow along with the video below to see how to install our site as a web app on your home screen.
Note: This feature may not be available in some browsers.
local o
o = createobject("frmOne")
o.show()
read events
*** Form class ***
define class frmOne as form
docreate = .t.
autocenter = .t.
datasession = 2
height = 342
width = 486
borderstyle = 2
caption = "Grid with context menu (i.e. PopUp)"
add object grdOne as grdOne with ;
deletemark = .f., ;
left = 12, ;
top = 12, ;
height = 254, ;
width = 468
add object txtOne as textbox with ;
left = 12, ;
top = 288, ;
width = 468
* protected procedure destroy
protected procedure destroy
release popup GridContextPopUp
clear events
endproc
* protected procedure error
procedure error
lparameters nError, cMethod, nLine
local array aErrors[1]
aerror(aErrors)
if nError = 1429 .and. aErrors[1,3] == "Procedure canceled."
return
endif
* some other error!
set step on
endproc
* protected procedure load
protected procedure load
create cursor testit (field1 c(10), field2 i)
for i = 1 to 1000
insert into testit ;
(field1, field2) values ;
("field"+padl(trans(i),5,"0"),rand()*1000)
next
go top
define popup GridContextPopUp from 3,20 to 12,35 margin mover scroll title "Help"
for i = 1 to 20
define bar i of GridContextPopUp prompt 'Bar'+padl(trans(i),2,"0")
next
on selection popup GridContextPopUp ;
_vfp.activeform.popupchoice( ;
prompt( ), popup( ),_vfp.activeform.activecontrol.value ;
)
endproc
* Procedure: InvokeContextMenu
procedure InvokeContextMenu
move popup GridContextPopUp to mrow(),mcol()
activate popup GridContextPopUp
endproc
* Procedure: PopupChoice
procedure PopupChoice
lparam cPrompt, cPop, vValue
this.txtOne.value = "You've chosen "+cPrompt+;
" of "+cPop+" with a field value of "+trans(vValue)
deactivate popup GridContextPopUp
endproc
enddefine
*** Grid Class ***
define class grdOne as grid
columncount = -1
add object column1 as clsCols
add object column2 as clsCols
procedure init
this.column1.header1.caption = "Field1"
this.column2.header1.caption = "Field2"
endproc
enddefine
*** Column class ***
define class clsCols as column
add object txtInvoker as clsInvoker
enddefine
*** Textbox class ***
define class clsInvoker as textbox
procedure rightclick
thisform.InvokeContextMenu()
endproc
enddefine
I'd like the popup to show with relitive position to the active cell.
*** Calculate where the popup calendar should be instantiated
*** So it pops up directly below the date text box
*** SYSMETRIC( 9 ) is the height of the Form's title bar in case you were curious
lnTop = OBJTOCLIENT( Thisform, 1 ) + OBJTOCLIENT( This, 1 ) + This.Height + ;
IIF( Thisform.TitleBar = 1, SYSMETRIC( 9 ) + 2, 2 )
lnLeft = OBJTOCLIENT( Thisform, 2 ) + OBJTOCLIENT( This, 2 )
DO FORM Calendar WITH lnTop, lnLeft, This.txtDate.Value TO luValue
LPARAMETERS tnTop, tnLeft, tdInitialDate
*** Initialize the combo with the passed date
*** Default to today if empty
WITH Thisform
*** Position it correctly
.Top = IIF( NOT EMPTY( tnTop ), tnTop, 0 )
.Left = IIF( NOT EMPTY( tnLeft ), tnLeft, 0 )
ENDWITH