On Fri, 26 Sep 2008, Abeb wrote:
> The trick is to trap the keypress of numlock ( or other control key)

And your received correct answer.

Sample code below. It uses two different methods to extract
cotnrol key state. But please remember that not all GTs
can support such functionality.

best regards,
Przemek


#include "inkey.ch"
#include "hbgtinfo.ch"
proc main()
   local cStatus, iStatus, nKey
   clear screen
   while ( nKey := inkey( 0.1 ) ) != K_ESC
      iStatus := hb_gtInfo( HB_GTI_KBDSHIFTS )
      cStatus := ""
      cStatus += iif( HB_BITAND( iStatus, HB_GTI_KBD_SHIFT ) != 0, ;
                     "SHIFT ", "      " )
      cStatus += iif( HB_BITAND( iStatus, HB_GTI_KBD_CTRL ) != 0, ;
                     "CTRL ", "     " )
      cStatus += iif( HB_BITAND( iStatus, HB_GTI_KBD_ALT ) != 0, ;
                     "ALT ", "    " )
      cStatus += iif( HB_BITAND( iStatus, HB_GTI_KBD_SCROLOCK ) != 0, ;
                     "SCRLOCK ", "        " )
      cStatus += iif( HB_BITAND( iStatus, HB_GTI_KBD_NUMLOCK ) != 0, ;
                     "NUMLOCK ", "        " )
      cStatus += iif( HB_BITAND( iStatus, HB_GTI_KBD_CAPSLOCK ) != 0, ;
                     "CAPSLOCK ", "         " )
      cStatus += iif( HB_BITAND( iStatus, HB_GTI_KBD_INSERT ) != 0, ;
                     "INSERT ", "       " )
      @ 1, 0 say cStatus

      cStatus := ""
      cStatus += iif( KSETINS(), "INS ", "    " )
      cStatus += iif( KSETCAPS(), "CAPS ", "     " )
      cStatus += iif( KSETNUM(), "NUM ", "    " )
      cStatus += iif( KSETSCROLL(), "SCROLL ", "       " )
      @ 2, 0 say cStatus
      if nKey==asc("C") .or. nKey==asc("c")
         KSETCAPS(!KSETCAPS())
      elseif nKey==asc("I") .or. nKey==asc("i")
         KSETINS(!KSETINS())
      elseif nKey==asc("N") .or. nKey==asc("n")
         KSETNUM(!KSETNUM())
      elseif nKey==asc("S") .or. nKey==asc("s")
         KSETSCROLL(!KSETSCROLL())
      endif
   enddo
return
_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to