|
Post by dw817 on Sept 1, 2006 14:23:50 GMT -5
Hey coders:
* I would like to catch the [ESC] keystroke and, instead of it exiting Basic4GL is read in as a keystroke. This would undoubtedly mean that some other keystroke (like CTRL-Q) would need to be assigned to exiting.
Is this possible ?
/)avid
|
|
|
Post by STT on Sept 1, 2006 17:10:04 GMT -5
Yup.
Use the following program to find the in key:
while 1 cls print inscankey() sleep(50) wend
You'll have to save this to an EXE and uncheck the "ESC quits the program" box type thing.
Doing this will tell you that "27" is the keycode for ESC (ALT+F4 will also give you this).
To use it, use
if inscankey(27) 'Yadda endif if scankeydown(vk_control) and keydown("Q") end endif
|
|
|
Post by dw817 on Sept 2, 2006 7:52:52 GMT -5
Hi STT: * Excellent answer. Just what I was looking for, and less than a hundred lines of code to boot ! Thank You ! * One more question. How do I catch when the CLOSEBOX is pressed with the mouse, or if ALT-F4 which is similar ? Are you saying then that if you hit ALT-F4 or try the CloseBox that character #27 will be sent ? The CLOSEBOX/ALT-F4 must be a read as a signal, not an immediate reaction. That is, their World file is saved first before in my coding it truly exits. I have [ESC] planned for bringing up the main options menu wherever you are in the map editor, now that I can track it. I already know the other important keys: k$=inkey$():shiftkey=0:ctrlkey=0:keyup=0:keydn=0:keylf=0:keyrt=0 if scankeydown(16)then shiftkey=1endif if scankeydown(17)then ctrlkey=1endif if scankeydown(vk_up)then keyup=keyup+1else keyup=0endif if scankeydown(vk_down)then keydn=keydn+1else keydn=0endif if scankeydown(vk_left)then keylf=keylf+1else keylf=0endif if scankeydown(vk_right)then keyrt=keyrt+1else keyrt=0endif
* Also, is there a way to determine if the Basic4GL window is in focus, that is, it is the active window, and a way to determine if it is NOT active, that is, you are inside the task of a different window like volume control, or notepad ? /)avid
|
|
|
Post by davy on Sept 2, 2006 15:40:38 GMT -5
"is there a way to determine if the Basic4GL window is in focus" Not natively, but maybe someone is able to write a dll for it... *shrug* I dont know enough about win32 programming yet to say.
Also, about the close button... Maybe you should make the window without a border and draw your own titlebar + close button... I guess the only problem then would be that you cant move the window around.
|
|
|
Post by dw817 on Sept 3, 2006 7:24:24 GMT -5
Morning Davy: * OK Good. I'm running Basic4GL without a frame anyways in the center at 640x480 so no problems there. GFABasic can determine if it is the active window. I'll have GFABasic IXTO Basic4GL to become active then when it isn't. /)avid
|
|