Faceți căutări pe acest blog

vineri, 18 august 2017

Easter eggs (3)

Peculiarity

I can't catch the 3+4+5. I do any combination of two, i.e. 3+4, 3+5 and 4+5, but not all three of them.
Please try the next demo


CLEAR
PUBLIC ofrm
ofrm = CREATEOBJECT("myform")
ofrm.show()

DEFINE CLASS myform as form
      Autocenter = .T.
      l3 = .F. && .T. while 3 is down (pressed)
      l4 = .F. && .T. while 4 is down (pressed)
      l5 = .F. && .T. while 5 is down (pressed)
      ADD OBJECT txt1 as textbox
      ADD OBJECT cmd as commandbutton WITH top = 50
      PROCEDURE init
            UNBINDEVENTS(This.hwnd)
            BINDEVENT(This.hwnd,0x0100,This,"detectkeydown")
            BINDEVENT(This.hwnd,0x0101,This,"detectkeyup")
      ENDPROC
      PROCEDURE detectkeydown
            LPARAMETERS p1,p2,p3,p4
            * p3 = Virtual-key code
            IF p3 = 0x33 && 3 is pressed
                  This.l3 = .T.
            ENDIF
            IF p3 = 0x34 && 4 is pressed
                  This.l4 = .T.
            ENDIF
            IF p3 = 0x35 && 5 is pressed
                  This.l5 = .T.
            ENDIF
            IF This.l3 AND This.l4 AND This.l5
                  ACTIVATE SCREEN
                  ? 'Bingo!'
                  ? 'An 3+4+5 occures'
            ENDIF
                  ACTIVATE SCREEN
            ?This.l3 ,This.l4 ,This.l5
      ENDPROC
      PROCEDURE detectkeyup
            LPARAMETERS p1,p2,p3,p4
            * p3 = Virtual-key code
            IF p3 = 0x33 && 3 is released
                  This.l3 = .F.
            ENDIF
            IF p3 = 0x34 && 4 is released
                  This.l4 = .F.
            ENDIF
            IF p3 = 0x35 && 5 is released
                  This.l5 = .F.
            ENDIF
      ENDPROC
ENDDEFINE

  Oddly, the keys from the numeric keypad behaves normally.



CLEAR
PUBLIC ofrm
ofrm = CREATEOBJECT("myform")
ofrm.show()

DEFINE CLASS myform as form
      Autocenter = .T.
      l3 = .F. && .T. while 3 is down (pressed)
      l4 = .F. && .T. while 4 is down (pressed)
      l5 = .F. && .T. while 5 is down (pressed)
      ADD OBJECT txt1 as textbox
      ADD OBJECT cmd as commandbutton WITH top = 50
      PROCEDURE init
            UNBINDEVENTS(This.hwnd)
            BINDEVENT(This.hwnd,0x0100,This,"detectkeydown")
            BINDEVENT(This.hwnd,0x0101,This,"detectkeyup")
      ENDPROC
      PROCEDURE detectkeydown
            LPARAMETERS p1,p2,p3,p4
            * p3 = Virtual-key code
            IF p3 = 0x63 && 3 is pressed
                  This.l3 = .T.
            ENDIF
            IF p3 = 0x64 && 4 is pressed
                  This.l4 = .T.
            ENDIF
            IF p3 = 0x65 && 5 is pressed
                  This.l5 = .T.
            ENDIF
            IF This.l3 AND This.l4 AND This.l5
                  ACTIVATE SCREEN
                  ? 'Bingo!'
                  ? 'An 3+4+5 occures'
            ENDIF
                  ACTIVATE SCREEN
            ?This.l3 ,This.l4 ,This.l5
      ENDPROC
      PROCEDURE detectkeyup
            LPARAMETERS p1,p2,p3,p4
            * p3 = Virtual-key code
            IF p3 = 0x63 && 3 is released
                  This.l3 = .F.
            ENDIF
            IF p3 = 0x64 && 4 is released
                  This.l4 = .F.
            ENDIF
            IF p3 = 0x65 && 5 is released
                  This.l5 = .F.
            ENDIF
      ENDPROC
ENDDEFINE

Niciun comentariu:

Trimiteți un comentariu