注册 登录
编程论坛 VFP论坛

如何实现鼠标单击不同位置三次,分别 显示三个坐标值

bilimyar 发布于 2023-05-04 14:16, 141 次点击
我成功实现了会显示鼠标所在的位置单击后的坐标值
mousedown 事件
thisform.label1.caption="x= "+ str(nxcoord)  +","
thisform.label2.caption="y= "+str(nxcoord)

但是,鼠标位置不同  Label1,label2 的坐标值也会改的
我的意思是第一次单击的坐标显示在Label1,label2
          第二次单击的坐标显示在Label3,label4
          第一次单击的坐标显示在Label5,label6
需要高手的帮忙,谢谢
只有本站会员才能查看附件,请 登录
4 回复
#2
sdta2023-05-04 14:26
设定个变量值,用MOD() 或 % 除3判断下即可
余1 第1次
余2 第2次
余0 第3次
#3
sdta2023-05-04 16:25
程序代码:
Public oForm
oForm=NEWOBJECT("form1")
oForm.Show
DEFINE CLASS form1 AS form
    DoCreate = .T.
    Caption = "Form1"
    Name = "Form1"
    ADD OBJECT label1 AS label WITH ;
        AutoSize = .T., ;
        Caption = "Label1", ;
        Height = 16, ;
        Left = 72, ;
        Top = 48, ;
        Width = 38, ;
        Name = "Label1"
    ADD OBJECT label2 AS label WITH ;
        AutoSize = .T., ;
        Caption = "Label2", ;
        Height = 16, ;
        Left = 72, ;
        Top = 96, ;
        Width = 38, ;
        Name = "Label2"
    ADD OBJECT label3 AS label WITH ;
        AutoSize = .T., ;
        Caption = "Label3", ;
        Height = 16, ;
        Left = 72, ;
        Top = 144, ;
        Width = 38, ;
        Name = "Label3"
    PROCEDURE MouseDown
        LPARAMETERS nButton, nShift, nXCoord, nYCoord
        thisform.lnjs = thisform.lnjs + 1
        DO CASE
            CASE MOD(thisform.lnjs, 3) = 1
                thisform.label1.Caption = TRANSFORM(nXCoord) + "," + TRANSFORM(nYCoord)
            CASE MOD(thisform.lnjs, 3) = 2
                thisform.label2.Caption = TRANSFORM(nXCoord) + "," + TRANSFORM(nYCoord)
            CASE MOD(thisform.lnjs, 3) = 0
                thisform.label3.Caption = TRANSFORM(nXCoord) + "," + TRANSFORM(nYCoord)
        ENDCASE
    ENDPROC
    PROCEDURE Init
        thisform.AddProperty("lnjs", 0)
    ENDPROC
ENDDEFINE
#4
schtg2023-05-04 18:13
回复 3楼 sdta
好!
#5
bilimyar2023-05-05 13:43
回复 2楼 sdta
感谢你,给我提供解决方法,很满意
牛顿曾经说过:如果说我看得比别人更远些,那是因为我站在巨人的肩膀上。(If I have seen further, it is by standing on the shoulders of giants.)
1