'Examine the characterInput Function
'NOMAINWIN
PRINT "Press Any Key(s)..."
OPEN "Examine Character Input" for GRAPHICS as #graph
PRINT #graph, "when characterInput [keyPressed]"
PRINT #graph, "trapclose [quit]"
[loopHere]
'make sure #graph has input focus
PRINT #graph, "setfocus"
TIMER 3000, [SkipLine]
WAIT
[SkipLine]
TIMER 0
#graph "cls"
GraphTextY = 20
PRINT "-----"
WAIT
[keyPressed]
key$ = Inkey$
TIMER 0
SELECT CASE LEN(key$)
CASE 1
TempWord$ = key$
CASE 2
GOSUB [FindVirtualKeys]
CASE ELSE
TempWord$ = "Inkey$ contains " + STR$(len(key$)) + " characters!"
END SELECT
PRINT TempWord$
#graph "place 5 "; GraphTextY; ";|"; TempWord$
GraphTextY = GraphTextY + 20
GOTO [loopHere]
[FindVirtualKeys]
SELECT CASE ASC(RIGHT$(key$, 1))
CASE _VK_F1
TempWord$ = "FunctionKey 1 = _VK_F1"
CASE _VK_F2
TempWord$ = "FunctionKey 2 = _VK_F2"
CASE _VK_F3
TempWord$ = "FunctionKey 3 = _VK_F3"
CASE _VK_F4
TempWord$ = "FunctionKey 4 = _VK_F4"
CASE _VK_F5
TempWord$ = "FunctionKey 5 = _VK_F5"
CASE _VK_F6
TempWord$ = "FunctionKey 6 = _VK_F6"
CASE _VK_F7
TempWord$ = "FunctionKey 7 = _VK_F7"
CASE _VK_F8
TempWord$ = "FunctionKey 8 = _VK_F8"
CASE _VK_F9
TempWord$ = "FunctionKey 9 = _VK_F9"
CASE _VK_F10
TempWord$ = "FunctionKey 10 = _VK_F10"
CASE _VK_F11
TempWord$ = "FunctionKey 11 = _VK_F11"
CASE _VK_F12
TempWord$ = "FunctionKey 12 = _VK_F12"
CASE _VK_F13
TempWord$ = "FunctionKey 13 = _VK_F13"
CASE _VK_F14
TempWord$ = "FunctionKey 14 = _VK_F14"
CASE _VK_F15
TempWord$ = "FunctionKey 15 = _VK_F15"
CASE _VK_F16
TempWord$ = "FunctionKey 16 = _VK_F16"
CASE _VK_MENU
TempWord$ = "ALT = _VK_MENU"
CASE _VK_SHIFT
TempWord$ = "SHIFT = _VK_SHIFT"
CASE _VK_HOME
TempWord$ = "HOME = _VK_HOME"
CASE _VK_END
TempWord$ = "END = _VK_END"
CASE _VK_INSERT
TempWord$ = "INSERT = _VK_INSERT"
CASE _VK_DELETE
TempWord$ = "DELETE = _VK_DELETE"
CASE _VK_NUMLOCK
TempWord$ = "NUMLOCK = _VK_NUMLOCK"
CASE _VK_UP
TempWord$ = "Arrow UP = _VK_UP"
CASE _VK_DOWN
TempWord$ = "Arrow DOWN = _VK_DOWN"
CASE _VK_LEFT
TempWord$ = "Arrow LEFT = _VK_LEFT"
CASE _VK_RIGHT
TempWord$ = "Arrow RIGHT = _VK_RIGHT"
CASE _VK_NUMPAD0
TempWord$ = "NumPad 0 = _VK_NUMPAD0"
CASE _VK_NUMPAD1
TempWord$ = "NumPad 1 = _VK_NUMPAD1"
CASE _VK_NUMPAD2
TempWord$ = "NumPad 2 = _VK_NUMPAD2"
CASE _VK_NUMPAD3
TempWord$ = "NumPad 3 = _VK_NUMPAD3"
CASE _VK_NUMPAD4
TempWord$ = "NumPad 4 = _VK_NUMPAD4"
CASE _VK_NUMPAD5
TempWord$ = "NumPad 5 = _VK_NUMPAD5"
CASE _VK_NUMPAD6
TempWord$ = "NumPad 6 = _VK_NUMPAD6"
CASE _VK_NUMPAD7
TempWord$ = "NumPad 7 = _VK_NUMPAD7"
CASE _VK_NUMPAD8
TempWord$ = "NumPad 8 = _VK_NUMPAD8"
CASE _VK_NUMPAD9
TempWord$ = "NumPad 9 = _VK_NUMPAD9"
CASE ELSE
TempWord$ = UPPER$(RIGHT$(key$, 1)) + " = CHR$(" + STR$(ASC(RIGHT$(key$, 1))) + ")"
END SELECT
IF ASC(key$) AND 16 THEN TempWord$ = "ALT + " + TempWord$
IF ASC(key$) AND 8 THEN TempWord$ = "CTRL + " + TempWord$
IF ASC(key$) AND 4 THEN TempWord$ = "SHIFT + " + TempWord$
IF ASC(key$) AND 2 THEN TempWord$ = "Unknown2 + " + TempWord$
IF ASC(key$) AND 1 THEN TempWord$ = "Unknown1 + " + TempWord$
IF ASC(key$) = 0 THEN TempWord$ = "NULL + " + TempWord$
RETURN
[quit]
PRINT "Quitting"
CLOSE #graph
END
I have a program that reacts differently depending on whether 1, 2 or 3 of these buttons are pressed, irregardless of which ones they are. It can detect when 1 or 2 of them are pressed, but not all 3. 'resize.bas
'Rewritten for Just BASIC, by Brent D. Thorn, 4/2005
'This is an example of a program which resizes several
'controls in a window depending on how the user changes
'the size of the window.
nomainwin
WindowWidth = 550
WindowHeight = 410
resizer.lbox1.Width = 256: resizer.lbox1.Height = 186
listbox #resizer.lbox1, array$(), [lbox1DClick], 0, 0, resizer.lbox1.Width, resizer.lbox1.Height
resizer.lbox2.Left = 257: resizer.lbox2.Width = 284: resizer.lbox2.Height = 164
listbox #resizer.lbox2, array$(), [lbox2DClick], resizer.lbox2.Left, 0, resizer.lbox2.Width, resizer.lbox2.Height
resizer.cbox3.Left = 257: resizer.cbox3.Top = 164: resizer.cbox3.Width = 283
combobox #resizer.cbox3, array$(), [cbox3DoubleClick], resizer.cbox3.Left, resizer.cbox3.Top, resizer.cbox3.Width, 150
resizer.tedit4.Top = 186: resizer.tedit4.Width = 540: resizer.tedit4.Height = 195
texteditor #resizer.tedit4, 1, resizer.tedit4.Top, resizer.tedit4.Width, resizer.tedit4.Height
open "Resizing example" for window as #resizer
print #resizer, "trapclose [quit]"
print #resizer, "resizehandler [resized]"
[loop]
wait
goto [loop]
[resized]
wWid = WindowWidth
wHig = WindowHeight
upperVert = int(256/550*wWid) 'upper middle vertical edge
midHoriz = int(186/410*wHig) 'middle horizontal edge
urWid = upperVert - wWid
resizer.lbox1.Width = upperVert
resizer.lbox1.Height = int(186/410*wHig)
resizer.lbox2.Left = upperVert
resizer.lbox2.Width = wWid-upperVert
resizer.lbox2.Height = int(186/410*wHig)-23
resizer.cbox3.Left = upperVert
resizer.cbox3.Top = midHoriz-23
resizer.cbox3.Width = wWid - upperVert
resizer.tedit4.Top = midHoriz
resizer.tedit4.Width = wWid
resizer.tedit4.Height = wHig-midHoriz
print #resizer, "refresh"
goto [loop]
[quit] 'quit the program
close #resizer
end
This no longer works... but then again, I suppose that's why it's openly referred to as 'resize.bas
'This is an example of a program which resizes several
'controls in a window depending on how the user changes
'the size of the window.
nomainwin
WindowWidth = 550
WindowHeight = 410
listbox #resizer.lbox1, array$(), [lbox1DClick], 1, 0, 256, 186
listbox #resizer.lbox2, array$(), [lbox2DClick], 257, 0, 284, 164
combobox #resizer.cbox3, array$(), [cbox3DoubleClick], 257, 164, 283, 150
texteditor #resizer.tedit4, 1, 186, 540, 195
open "Resizing example" for window as #resizer
print #resizer, "trapclose [quit]"
[loop]
print #resizer, "resizehandler [resized]"
input r$
goto [loop]
[resized]
wWid = WindowWidth
wHig = WindowHeight
upperVert = int(256/550*wWid) 'upper middle vertical edge
midHoriz = int(186/410*wHig) 'middle horizontal edge
urWid = upperVert - wWid
print #resizer.lbox1, "locate 0 0 "; upperVert; " "; int(186/410*wHig)
print #resizer.lbox2, "locate "; upperVert; " 0 "; wWid-upperVert; " "; int(186/410*wHig)-23
print #resizer.cbox3, "locate "; upperVert; " "; midHoriz-23; " "; wWid - upperVert; " "; 100
print #resizer.tedit4, "!locate 0 "; midHoriz; " "; wWid; " "; wHig-midHoriz;
print #resizer, "refresh"
goto [loop]
[quit] 'quit the program
close #resizer
end