如何在表单上双击直接输入当前系统日期时间到表字段中
请教,如何在表单上双击直接输入当前系统日期时间到表字段中,怎样让快捷菜单在表单,查询状态下右键显现。
#DEFINE K_ESC 27 * * 弹出式菜单 * DEFINE CLASS _PopupMenu AS ListBox AutoHideScrollBar = 1 PROCEDURE Init(taList[]) DODEFAULT() IF PCOUNT() > 0 WITH This .Clear LOCAL lnIndex AS Integer FOR lnIndex = 1 TO ALEN(taList,1) .AddItem(taList[lnIndex,1]) NEXT .Top = MROW(0,3) .Left = MCOL(0,3) .Height = .ListCount * FONTMETRIC(1, .FontName, .FontSize) * 1.4 .Width = LEN(taList[1,1]) * FONTMETRIC(6, .FontName, .FontSize) * 1.4 .ListIndex = 1 .AddProperty("Command_List[" + ALLTRIM(STR(.ListCount)) + "]") FOR lnIndex = 1 TO .ListCount .Command_List[lnIndex] = taList[lnIndex,2] NEXT ENDWITH ENDIF ENDPROC PROCEDURE Click EVALUATE([This.ListIndex]) RELEASE This ENDPROC PROCEDURE MouseLeave(tnButton AS Integer, tnShift AS Integer, tnXCoord AS Integer, tnYCoord AS Integer) IF (tnXCoord < OBJTOCLIENT(This, 2)) .OR. (tnXCoord > OBJTOCLIENT(This, 3)) .OR. (tnYCoord < OBJTOCLIENT(This, 1)) .OR. (tnYCoord > OBJTOCLIENT(This, 4)) RELEASE This ENDIF ENDPROC PROCEDURE KeyPress(tnKeyCode AS Integer, tnShiftAltCtrl AS Integer) IF tnKeyCode == K_ESC RELEASE This ENDIF ENDPROC ENDDEFINE
SET PROCEDURE TO PopupMenu ADDITIVATE DIMENSION menu[3,2] && 二维数组,第一列是菜单项文字,第二列是需要执行的命令 menu[1,1] = "菜单命令1" menu[1,2] = "GETFILE()" menu[2,1] = "菜单命令2" menu[2,2] = "GETDIR()" menu[3,1] = "菜单命令3" menu[3,2] = "MESSAGEBOX('弹出菜单测试')" menu[4,1] = "菜单命令4" menu[4,2] = "RELEASE This" ThisForm.AddObject("mnu_PopupMenu", "_PopupMenu") ThisForm.mnu_PopupMenu.Init(@menu) ThisForm.mnu_PopupMenu.Visible = .T. ThisForm.mnu_PopupMenu.SetFocus
#DEFINE K_ESC 27 Main() RETURN PROCEDURE Main() LOCAL loForm loForm = NEWOBJECT("_MainForm") loForm.Show READ EVENTS ENDPROC * 主表单 DEFINE CLASS _MainForm AS Form Caption = "弹出菜单测试" ADD OBJECT Label1 AS Label WITH Caption = "鼠标右击我弹出菜单", ; Top = 5, ; Left = 5, ; Width = 200, ; Height = 25, ; BorderStyle = 1, ; Alignment = 2 PROCEDURE Label1.RightClick LOCAL laMenu[3,2] && 二维数组,第一列是菜单项文字,第二列是需要执行的命令 laMenu[1,1] = "菜单命令1" laMenu[1,2] = "GETFILE()" laMenu[2,1] = "菜单命令2" laMenu[2,2] = "GETDIR()" laMenu[3,1] = "菜单命令3" laMenu[3,2] = "MESSAGEBOX('弹出菜单测试')" ThisForm.AddObject("mnu_PopupMenu", "_PopupMenu") WITH ThisForm.mnu_PopupMenu .Init(@laMenu) .Visible = .T. .SetFocus ENDWITH ENDPROC PROCEDURE Destroy CLEAR EVENTS ENDPROC ENDDEFINE * * 弹出式菜单 * DEFINE CLASS _PopupMenu AS ListBox AutoHideScrollBar = 1 PROCEDURE Init(taList[]) DODEFAULT() IF PCOUNT() > 0 WITH This .Clear LOCAL lnIndex AS Integer FOR lnIndex = 1 TO ALEN(taList,1) .AddItem(SPACE(4) + taList[lnIndex,1] + SPACE(4)) NEXT .Top = MROW(0,3) .Left = MCOL(0,3) .Height = .ListCount * FONTMETRIC(1, .FontName, .FontSize) * 1.4 .Width = (LEN(taList[1,1]) + 8) * FONTMETRIC(6, .FontName, .FontSize) * 1.4 .ListIndex = 1 .AddProperty("Command_List[" + ALLTRIM(STR(.ListCount)) + "]") FOR lnIndex = 1 TO .ListCount .Command_List[lnIndex] = taList[lnIndex,2] NEXT ENDWITH ENDIF ENDPROC PROCEDURE Click EVALUATE([This.ListIndex]) RELEASE This ENDPROC PROCEDURE MouseLeave(tnButton AS Integer, tnShift AS Integer, tnXCoord AS Integer, tnYCoord AS Integer) IF (tnXCoord < OBJTOCLIENT(This, 2)) .OR. (tnXCoord > OBJTOCLIENT(This, 3)) .OR. (tnYCoord < OBJTOCLIENT(This, 1)) .OR. (tnYCoord > OBJTOCLIENT(This, 4)) RELEASE This ENDIF ENDPROC PROCEDURE KeyPress(tnKeyCode AS Integer, tnShiftAltCtrl AS Integer) IF tnKeyCode == K_ESC RELEASE This ENDIF ENDPROC ENDDEFINE