Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

DarkBASIC Professional Discussion / Disable Systemkeys

Author
Message
heartbone
23
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 10th Oct 2003 11:06
My DBPro app gets trashed (similar to an unhandled Minimize Window call) when operating fullscreen, if I press the Windows key without calling the Disable Systemkeys command first.

The program executing in Win98SE correctly ignores the Windows key after the Disable Systemkeys command is called. However my WinXPHome laptop continues to respond to the Windows key, so the program crashes since objects get destroyed without the program being notified of the event.

• Can anyone reproduce this?
•• If so, is this a bug?
••• Is there a workaround?

The more you see, the more you know.
The more you know, the more you see.
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 10th Oct 2003 14:52
Yes - the disable keys command doesn't work with 2000/XP upwards.
It could be made to work if Lee put in a proper keyboard hook..

Theortically the way around it would be :

After returning from a system key press, make sure all graphics and such are deleted and then re-loaded.


Avatar & Logo by Indi. Insert witty comment here...
empty
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 10th Oct 2003 14:52 Edited at: 10th Oct 2003 15:22
for the Disable Systemkeys issue:
• Yes.
•• No. DBpro uses the "screensaver-method", ie. it pretends to be a screensaver which prevents Win98/ME to react on those key presses. However, that doesn't work on NT-based systems.
••• Yes, but it's rather complicated and needs a DLL or TPC. You need to install a "low-level keyboard hook" to examine all keystrokes system-wide and then decide whether to let them through.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 10th Oct 2003 15:07
Could you try the following code, and see if it works :



Get the program running, and then Windows Key/ALT+TAB to another running program, and then go back to this one. It should re-do the cube and continue as usual.


Avatar & Logo by Indi. Insert witty comment here...
empty
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 10th Oct 2003 15:22
That code works for me.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 10th Oct 2003 15:26 Edited at: 10th Oct 2003 15:27
Now we need to see if it works with Heartbone.
The way I described above is the way to go - I've got a routine in the code snippets area that will load graphics from a given filename and number (may need to update it so that it automatically deletes before loading).


Avatar & Logo by Indi. Insert witty comment here...
empty
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 10th Oct 2003 15:32
Right. Although it won't help to solve the Disable Systemkey problem.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 10th Oct 2003 15:52
It will help if you trap for when the program has been switched out and then back in - its the only thing you can do.


Avatar & Logo by Indi. Insert witty comment here...
empty
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 10th Oct 2003 19:48
Here's a little TPC that will hopefully enable/disable system keys on NT-based systems.

http://members.lycos.co.uk/sotmailings/storm/ntsyskeys.htm

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 10th Oct 2003 20:24
There is a windows API command under Win98 which disables systemkeys, this is intended for use with screensavers. However under NT the same command does not exist, hence the program crashes. DISABLE SYSTEMKEYS needs to detect which OS is running and ignore the command under NT or use a different method.

empty
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 10th Oct 2003 20:27
Well that's basically what I posted.
But it doesn't crash, it's just ignored.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
heartbone
23
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 10th Oct 2003 20:36 Edited at: 10th Oct 2003 20:40
TheCodingArea thanks for the suggestion. That method would work if I put that check in (or object exist(N) check) before I accessed each and every object. However that is not practical.

If the screen invalid() check was only made once a loop then the system interrupt to minimize the window could (most likely) happen in the middle of the loop and when the next object manipulation command was executed.... blammo. This is a nasty situation.

empty I'll try your fix. I'll let you know.

The more you see, the more you know.
The more you know, the more you see.
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 10th Oct 2003 21:00
I think you only need to detect whether the screen is invalid once per loop and before a SYNC command - I think it only becomes a problem at the SYNC command, there if you can trap invalid screens before that then you can do all your clearing & reloading before the SYNC command.

Its all theoretical of course...


Avatar & Logo by Indi. Insert witty comment here...
DrakeX
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location:
Posted: 10th Oct 2003 21:17
objects are not lost when switching between programs.

also i've never had DISABLE SYSTEMKEYS work with DBC or DBP in any OS.

stop looking at me!
Rob K
Retired Moderator
23
Years of Service
User Offline
Joined: 10th Sep 2002
Location: Surrey, United Kingdom
Posted: 10th Oct 2003 21:23
Quote: "Well that's basically what I posted."


Oops. Just read the first couple of posts.

OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 10th Oct 2003 23:52
Drake - Objects are lost sometimes, and other times not - it depends (probably) on whether the program's graphics your switching to will fit within the memory of the graphics card. Either way, it must be checked for, and dealt with if needed.


Avatar & Logo by Indi. Insert witty comment here...
heartbone
23
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 11th Oct 2003 01:17 Edited at: 11th Oct 2003 01:17
Thanks for the tmie and effort empty. Unfortunately it did not work as advertised. I built it on 98 and had code like this
If MAJORV = 5 And PLATID = 2 Then Disable NT Systemkeys
The module executed on 98 fine, but when executed on XP it crashed.
So I took off the OS check so it would be called in 98 and it crashed.
So I built it on XP and it still crashed. So I tested it on a small program and it did not crash but it did not block the detection of the Windows key.

I know the module was built correctly as it went up in size about 16K adn the compiler did not complain.

One odd thing is that on my 98 install the new commands don't highlight in the IDE.
On my XP install where no keywords ever highlight, now (only) the new commands highlight. More to investigate I guess.

The more you see, the more you know.
The more you know, the more you see.
empty
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 11th Oct 2003 05:19 Edited at: 11th Oct 2003 05:19
Thanks for the info.
I don't have constant access to XP at the moment.
Yet I was able to prevent the popup menus that appear when you press the "windows" keys.
Also when pressing alt+tab, the task switcher doesn't show, but (and that's BUT) the window minimises nonetheless, which renders the whole process useless.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
DrakeX
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location:
Posted: 11th Oct 2003 05:45
"Objects are lost sometimes"

oh my that's a scary thought.

stop looking at me!
heartbone
23
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 11th Oct 2003 08:52
Drake, anytime that one uses
Set Window On from off and vice versa or
Minimize Window commands,
the objects, bitmaps and images are invalidated and must be reloaded.
I am surprised that you hadn't discovered this.

And Disable Systemkeys works with DBPro Patch 4 under Windows 98 as it applies to the Windows keys. No it does not stop Al+F4 but it does have an effect, so it does work (somewhat).
--------------------------------------------------------------
OFF TOPIC
35 years ago right now!


The Jimi Hendrix Experience
October 10, 11, & 12, 1968
The Winterland, San Francisco

This ones for you Jimi.


The more you see, the more you know.
The more you know, the more you see.
heartbone
23
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 11th Oct 2003 09:00
TheCodingArea: I think you only need to detect whether the screen is invalid once per loop and before a SYNC command - I think it only becomes a problem at the SYNC command, there if you can trap invalid screens before that then you can do all your clearing & reloading before the SYNC command.

Its all theoretical of course...


What I am typing is NOT theoretical.

That Windows key generates an interrupt to the DarkBASIC process immediately. You get NO chance to catch the event in DarkBASIC Pro. When the process execution resumes, the very next command encountered that requires an existing image or object will cause the program to abend. Sync has nothing to do with it.

The more you see, the more you know.
The more you know, the more you see.
Powersoft
22
Years of Service
User Offline
Joined: 1st Aug 2003
Location: United Kingdom
Posted: 11th Oct 2003 11:22
my simplitic approach is


Im not an ALIEN
OSX Using Happy Dude
22
Years of Service
User Offline
Joined: 21st Aug 2003
Location: At home
Posted: 11th Oct 2003 12:51
Quote: "oh my that's a scary thought."

Blame Microsoft...

Quote: "That Windows key generates an interrupt to the DarkBASIC process immediately"

Therefore always check to see if the object is availiable, until you can detect whether the screen is invalid (or detect the first object and if its not present reload the lot).

There's nothing much you can do to stop task switching on XP - and why should you ? I'm usually doing other things whilst playing, and I get annoyed at programs that dont handle that process properly (SpyHunter is an example - task switch and then go back to it, and it brings up a message staying its exiting).


Avatar & Logo by Indi. Insert witty comment here...
empty
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 11th Oct 2003 13:53
Quote: "Also when pressing alt+tab, the task switcher doesn't show, but (and that's BUT) the window minimises nonetheless, which renders the whole process useless."

Forgot to mention that this only happens in fullscreen exlusive mode. With windowed apps it works perfectly.

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
empty
23
Years of Service
User Offline
Joined: 26th Aug 2002
Location: 3 boats down from the candy
Posted: 11th Oct 2003 16:16 Edited at: 11th Oct 2003 16:17
So finally had some more time to test it on an XP system.
Unfortunately there are some issues with DBpro. While the new version (dl below) works principally, it stops working as soon as a DBpro mouse or keyboard command/function is involved. Why is this? Well, my guess:
The DLL sets a new low-level keyboard hook to one of its own functions.
Ie. all system keys messages are sent to this hook function instead to the application (or actually to the active window). It seems that DBpro sets its own hook functions to process user inputs and thus overrides the current one.
So while this code works (here at least with patch 5):



this doesn't:




http://members.lycos.co.uk/sotmailings/storm/ntsyskeys.htm

I awoke in a fever. The bedclothes were all soaked in sweat.
She said "You've been having a nightmare and it's not over yet"
heartbone
23
Years of Service
User Offline
Joined: 9th Nov 2002
Location:
Posted: 11th Oct 2003 18:21
TheCodingArea there is no way to make absolutely sure as the interrupt could occur just after a check and before use of the object or image. AND processing would be slowed horribly. I use 118 objects and 434 images. I don't want to stop task switching, but I do need to stop destructive interrupts. If your app is in the windows mode and a user uses the minimize window gadget, everything is handled properly. If your code uses the Minimize Window command to minimize the window there's data destruction. So I don't use the Minimize window command. Likewise I'd like to prevent the Window key command from happening in full screen. If possible.


empty thanks again. Unfortunately users of my app will use both keyboard and mouse.

The more you see, the more you know.
The more you know, the more you see.

Login to post a reply

Server time is: 2026-07-26 05:02:47
Your offset time is: 2026-07-26 05:02:47