Jump to content
Fivewin Brasil

Associar Alt+F12 a uma função em todo o programa


Narlem

Recommended Posts

Olá,

Eu Preciso associar uma função tipo sair do sistema às teclas alt+f12, e estando em qualquer lugar do sistema ao acionar estas teclas a função seria chamada independente de onde esteja no sistema.

Eu tentei usar o setkey() no inicio do programa mas nao funcionou.

Alguém sabe como fazer isto?

 

Narlem

 

 

Link to comment
Share on other sites

Static Function Faz_Pesquisa( nKey, Alias, oSay, oLbx )
	    Local nOldPos := (Alias)->(Recno())
	    Memvar cPesq
	    cPesq := ""
	    // Backspace Para Apagar Caracteres Digitados
    If nKey==VK_BACK
	        If Len(cPesq) > 0
            cPesq:=Left(cPesq,Len(cPesq)-1)
         Else
            Tone(500,1)
            Return(.F.)
        Endif
	    Endif
	    If ( nKey >=  32   .And. ;
         nKey <= 255 ) .Or.  ;
         nKey=VK_BACK
	        If nKey!=VK_BACK
	            cPesq+=UPPER(Chr(nKey))
	        Endif
	        If !(Alias)->(DbSeek(cPesq))
	            cPesq := Left( cPesq, Len( cPesq ) -1 )
            DbGoto(nOldPos)
            Return( .F. )
	        Endif
	    Endif
	    If oSay!=Nil
	        oSay:cTitle(cPesq) // Mostra o que foi digitado
	    Endif
	    DO CASE
	       CASE ( nKey == Asc( "A" ) .OR. nKey == Asc( "a" ) ) .AND. ;
              GetKeyState( VK_CONTROL )
              ? 'Control+A-For Nilson'
       CASE ( nKey == Asc( "B" ) .OR. nKey == Asc( "b" ) ) .AND. ;
              GetKeyState( VK_CONTROL )
              ? 'Control+B-For Nilson'
       CASE ( nKey == Asc( "C" ) .OR. nKey == Asc( "c" ) ) .AND. ;
              GetKeyState( VK_CONTROL )
              ? 'Control+C-For Nilson'
       CASE ( nKey == Asc( "D" ) .OR. nKey == Asc( "d" ) ) .AND. ;
              GetKeyState( VK_CONTROL )
              ? 'Control+D-For Nilson'
       CASE ( nKey == Asc( "E" ) .OR. nKey == Asc( "e" ) ) .AND. ;
              GetKeyState( VK_CONTROL )
              ? 'Control+E-For Nilson'
       CASE ( nKey == Asc( "F" ) .OR. nKey == Asc( "f" ) ) .AND. ;
              GetKeyState( VK_CONTROL )
              ? 'Control+F-For Nilson'
       CASE ( nKey == Asc( "G" ) .OR. nKey == Asc( "g" ) ) .AND. ;
              GetKeyState( VK_CONTROL )
              ? 'Control+G-For Nilson'
       CASE ( nKey == Asc( "H" ) .OR. nKey == Asc( "h" ) ) .AND. ;
              GetKeyState( VK_CONTROL )
              ? 'Control+H-For Nilson'
       CASE ( nKey == Asc( "I" ) .OR. nKey == Asc( "i" ) ) .AND. ;
              GetKeyState( VK_CONTROL )
              ? 'Control+I-For Nilson'
       CASE ( nKey == Asc( "P" ) .OR. nKey == Asc( "p" ) ) .AND. ;
              GetKeyState( VK_CONTROL )
              ? 'Control+P-For Nilson'
       CASE ( nKey == Asc( "T" ) .OR. nKey == Asc( "t" ) ) .AND. ;
              GetKeyState( VK_CONTROL )
              ? 'Control+T-For Nilson'
	       //CASE ( nKey == Asc( "Z" ) .OR. nKey == Asc( "z" ) ) .AND. ;
       //       GetKeyState( VK_CONTROL )
       //       ? 'Control+Z-For Nilson'
	       CASE ( nKey == VK_INSERT  .AND. GetKeyState( VK_SHIFT   ) ) .OR. ;
            ( nKey == ASC( "V" ) .AND. GetKeyState( VK_CONTROL ) ) .OR. ;
            ( nKey == ASC( 'X' ) .AND. GetKeyState( VK_CONTROL ) )
            ? ' Multiplas-For Nilson'
	       /*
       CASE nKey==VK_F12
              ? 'F12-For Nilson'
       */
	       CASE ( nKey == VK_F2 .AND. GetKeyState( VK_CONTROL ) )
          ? 'Control+F2-For Nilson'
        // Acao(Action) do seu programa
       CASE ( nKey == VK_F3 .AND. GetKeyState( VK_CONTROL ) )
          ? 'Control+F3-For Nilson'
        // Acao(Action) do seu programa
       CASE ( nKey == VK_F4 .AND. GetKeyState( VK_CONTROL ) )
          ? 'Control+F4-For Nilson'
        // Acao(Action) do seu programa
       CASE ( nKey == VK_F5  .AND. GetKeyState( VK_CONTROL ) )
          ? 'Control+F5-For Nilson'
        // Acao(Action) do seu programa
       CASE ( nKey == VK_F6 .AND. GetKeyState( VK_CONTROL ) )
          ? 'Control+F6-For Nilson'
        // Acao(Action) do seu programa
       CASE ( nKey == VK_F7 .AND. GetKeyState( VK_CONTROL ) )
          ? 'Control+F7-For Nilson'
        // Acao(Action) do seu programa
       CASE ( nKey == VK_F8 .AND. GetKeyState( VK_CONTROL ) )
          ? 'Control+F8-For Nilson'
        // Acao(Action) do seu programa
       CASE ( nKey == VK_F9  .AND. GetKeyState( VK_CONTROL ) )
          ? 'Control+F9-For Nilson'
        // Acao(Action) do seu programa
       //CASE ( nKey == VK_F10 .AND. GetKeyState( VK_CONTROL ) )
       //   ? 'Control+F10-For Nilson'
          // Acao(Action) do seu programa
       CASE ( nKey == VK_F11 .AND. GetKeyState( VK_CONTROL ) )
          ? 'Control+F11-For Nilson'
          // Acao(Action) do seu programa
       CASE ( nKey == VK_F12 .AND. GetKeyState( VK_CONTROL ) )
          ? 'Control+F12-For Nilson'
          // Acao(Action) do seu programa
	    ENDCASE
	Return( .t. )
	// ------------------------------------------------------------------------
	// Para Usar Tecla ALT+Letra. By Ednaldo Rolim
Static Function Teste( nKey, nFlags )
	    local cKey:= CHR( nKey )
	    If  GetKeyState( VK_CONTROL ) .And. ;
        GetKeyState( VK_SHIFT )
	        MsgInfo( " CONTROL + SHIFT + " + cKey )
	        ElseIf GetKeyState( VK_CONTROL )
	        MsgInfo( " ALT + CONTROL + " + cKey )
	        ElseIf GetKeyState( VK_SHIFT )
	        MsgInfo( " ALT + SHIFT + " + cKey )
	        ElseIf GetKeyState( VK_MENU )                    // alt key
	        MsgInfo( " ALT + " + cKey )
	    EndIf
	    // By Ednaldo Rolim - The Best.
    cKey:= Upper( cKey )
	    IF  cKey == "I"            // Alt+I
	        MsgInfo( " INCLUIR" )
	        ELSEIF cKey == "A"    // Alt+A
	        MsgInfo( " ALTERAR" )
	        ELSEIF cKey == "E"    // Alt+E
	        MsgInfo( " EXCLUIR" )
	        ELSEIF cKey == "P"    // Alt+P
	        MsgInfo( " IMPRIMIR" )
	        ELSEIF cKey == "R"    // Alt+R
	        MsgInfo( OemToAnsi( " RELATàRIOS" ) )
	    ENDIF
	Return( nKey )

 

Link to comment
Share on other sites

 

Olá João,

 

Muito obrigado, vou testar aqui.

Eu conversei hoje com o Leonardo Machado de Porto Alegre, a gente combinou de encontrar aí em sp, um dia a ser marcado la pelo mes 03 ou 04, para por o papo em dia e quem sabe dar o ponta pé inicial para o encontro no final do ano que vem.

 

Nárlem

TEM TODO O MEU RÁPOIO!

 

o5ty5bO.jpg

 

Abraços.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...