Page 1 of 1

keyboard led status & LED demo

Posted: Fri Nov 26, 2010 3:45 pm
by Bob Hays
2 questions:
1) how can I get the status of the keybord leds? :-?
          I want to display the Num  ans Caps state on the status
          bar of my application
2)How can I get the LED demo to work with the new compiler. :-?
          I would like to use the LED routine on the status bar also

keyboard led status & LED demo

Posted: Mon Nov 29, 2010 12:50 am
by Bob Hays
I figured out the keyboard status routine figured out - just cannot get initial status` to show up when the application is started. ????

I seams that record does not support complex variables such as:
record led as image
end record
"expecting as but got image"

or

record led
  dim led as image
end record

"expecting simple variable but got image"

record led
  dim led as integer

  sub paint()

keyboard led status & LED demo

Posted: Mon Nov 29, 2010 2:56 pm
by fred
Did not look into it yet but two remarks:
Image is a windows object, not a (real) data type as integer.
Using a record name and the same var name is not allowed?

keyboard led status & LED demo

Posted: Mon Nov 29, 2010 4:26 pm
by Marco
Hi, there is no type statement within the new fnxbasic yet.
The old example will not work.
record is only for nummeric and string types.

best regards

keyboard led status & LED demo

Posted: Mon Nov 29, 2010 8:53 pm
by Bob Hays
:( I guess i`ll sit and twiddle my thumbs.

keyboard led status & LED demo

Posted: Wed Dec 01, 2010 10:35 pm
by Marco
part one :)


Const VK_Capital = &H14
Const VK_Numlock = &H90
Const VK_Scroll = &H91

declare ledstate as "GetKeyState" of "user32"
  vkkey as integer
  result as integer
end declare

function getstate(key as integer) as boolean
  ledstate.vkkey=key
  ledstate.execute
  result=ledstate.result
end function

if getstate(vk_capital)=true then print "capslock is activated"
if getstate(vk_numlock)=true then print "numlock is activated"
if getstate(vk_scroll)=true then print "scrollock is activated"
showmessage "check consolescreen"

i hope this will help a bit
best regards

keyboard led status & LED demo

Posted: Thu Dec 02, 2010 12:48 am
by Bob Hays
That solution looks a bit simpler than the one i wrote. Thanks.  :)

Now if I could JUST figure out how to draw an "LED" on the status bar for those states! :-?

keyboard led status & LED demo

Posted: Sat Dec 04, 2010 4:21 pm
by Marco
here is a little program that produces leds:

`=====MAIN LED ROUTINES==============
`=COLORS: RED GREEN AND BLUE        =   
`=METHODS: LEDON(IMAGE.CANVAS,COLOR)= 
`=         LEDOFF(IMAGE.CANVAS)     =
`====================================

const blue=rgb(0,0,255)
const green=rgb(0,200,0)
const red=rgb(255,0,0)

sub led
  dim bmp as bitmap
  dim effect as integer
  dim c as integer,size as byte
  dim on as boolean
  size=8
  if on=false then effect=rgb(120,120,120)
  bmp.width=size*2
  bmp.height=size*2
  bmp.transparentcolor=&hffffff
  bmp.transparent=true
  bmp.canvas.circle(size,size,size,0)
  bmp.canvas.fill(size,size,effect,0)
  for c=size-4 to size
    bmp.canvas.line(c/2,c,c,c/2,&hffffff)
  next c
end sub

sub ledon(s as canvas,effect as integer)
  led.effect=effect
  led.on=true
  led
  s.draw(0,0,led.bmp)
end sub

sub ledoff(s as canvas)
  led.on=false
  led
  s.draw(0,0,led.bmp)
end sub


`=======Example prograM======
object myform as form
  object led1 as image
    left=10
    top=10
    transparent=true
  end object
  object led2 as image
    left=10
    top=30
    transparent=true
  end object 
end object

ledon(led1.canvas,red)
ledoff(led2.canvas)
myform.showmodal


best regards marco
















keyboard led status & LED demo

Posted: Tue Dec 07, 2010 1:34 am
by Bob Hays
Thanks - This routine helped me understand how it works.