Example Program - Popup menus within grids

The following example draws a Grid containing random numbers. Left clicking on the grid will display a popup menu, although the grid has only been designed to display the menu for columns 2 to 6.

DEFFORM Form1()={.form,.form$,.Style=0x50C000C4,.Width=310,.Height=196,.Text$="Mouse left and right actions",.Id=1024},\
{.ok,.button$,.Style=0x50010001,.Left=255,.Top=5,.Width=50,.Height=14,.Text$="OK",.__Anchor=5,.Id=1},\
{.cancel,.button$,.Style=0x50010000,.Left=255,.Top=22,.Width=50,.Height=14,.Text$="Cancel",.__Anchor=5,.Id=2},\
{.txtControl1,.static$,.Style=0x50000000,.Left=18,.Top=130,.Width=197,.Height=55,.Text$="When you left click on a cell the whole row is selected, right click on a cell and the whole column is selected.  This is done with the LeftAction, RightAction, LeftSelect and RightSelect properties.",.Id=1001},\
{.menu1,.Menu$,.Style=0x01,.Id=1002,.option1={.Text$="Option 1"},.option2={.Flag=16,.Text$="Option 2"},.option2suboption1={.Text$="Sub option 1"},.suboption1suboption2={.Flag=128,.Text$="Sub option 2"},.separator={.Flag=2048},.option3={.Text$="Option 3"},.option4={.Flag=128,.Text$="Option 4"}},\
{.GridControl1,.KCMLgrid$,.Style=0x50010030,.Left=21,.Top=13,.Width=223,.Height=100,.Id=1000,.Rows=10,.Cols=8,.FixedRows=1}
DEFEVENT Form1.Enter()
	LOCAL DIM row,col
	FOR row = 1 TO 10
	FOR col = 1 TO 8
		IF (col == 1)
			.GridControl1.Cell(row, col).Text$ = row
			CONTINUE
		END IF
		.GridControl1.Cell(row, col).Text$ = INT(RND(1) * 1000)
		.GridControl1.Cell.LeftAction = &.Click
		.GridControl1.LeftSelect = &.Row
		.GridControl1.Cell.RightAction = &.Click
		.GridControl1.RightSelect = &.Col
	NEXT col
	NEXT row
END EVENT
DEFEVENT Form1.GridControl1.LeftClick()
	.menu1.TrackPopup(..MouseX + ..Left, ..MouseY + ..Top)
END EVENT
DEFEVENT Form1.GridControl1.RightClick()
	Form1.GridControl1.LeftClick()
END EVENT
FORM END Form1
Form1.Open()