During a sub execution I'd like to ignore any keys that are pressed or mouse clicks, etc. At the end of the sub if I could clear all pending keyboard activity or mouse activity, that would be great!
I'm not sure the best way to do it. Any help would be awesome. I'm hoping there is a simple way.
I am using Android Mini PC and use key presses to activate video and image manipulation. A child or impatient user will press many keys in an attempt to manipulate an image presentation (panning, rotation, zooming, etc.) or simply "play" with the system. These key presses build up, as keys can be pressed faster than the images can be loaded and displayed until the app exits, probably due to some memory issue.
I was looking for an "easy" fix. Short of that, I was thinking I could re-direct the key press activity to somewhere else while images are being loaded. A different view?
It would appear that calling ProgressDialogShow does sort of eat the keyboard presses - unfortunately, I don't want the screen dimmed or to show a spinning icon. I'll probably look into a different view to send the activities while the sub is working...
I've not had the greatest experience using DoEvents. Since I'm trying to use as much cache memory as possible to hold as many images in memory as I can, I don't have a lot left over to use for different tasks. Somehow DoEvents impacts memory and leads to an untimely application exit in some cases.
Why don't you simply ignore the keys when a flag is raised? I mean: when you start your task, you set a flag to true. While this flag is set, you ignore all key strokes (you only return true in the event handler). When the task ends, you set the flag to false to reenable the key handling.
Why don't you simply ignore the keys when a flag is raised? I mean: when you start your task, you set a flag to true. While this flag is set, you ignore all key strokes (you only return true in the event handler). When the task ends, you set the flag to false to reenable the key handling.
That's the way I thought it would work (I do return true in the event handler). But, evidently the keys that are pressed during the sub stay in the cue and try to get processed after the sub completes, causing the sub to get triggered over and over until something happens with memory and the app exits.
Do you mean that your task is blocking the app while it runs (thus, no event can be processed in the meanwhile)? In this case, you should really use DoEvents to handle the waiting messages. I can't see why DoEvents would eat memory. You should trace what subs you enter to be sure that you run only what's needed. The memory loss comes from somewhere in your code.
Do you mean that your task is blocking the app while it runs (thus, no event can be processed in the meanwhile)? In this case, you should really use DoEvents to handle the waiting messages. I can't see why DoEvents would eat memory. You should trace what subs you enter to be sure that you run only what's needed. The memory loss comes from somewhere in your code.
Yes, I don't want anything else to happen during the sub processing and DoEvents seems like a way to eat the keyboard presses - I'll do some testing, this makes sense. Thanks!
I used a Timer Sub to increment a Global variable (i+1) each time the timer sub fires and I set a starting timer value (timerval=i+1000) at the beginning of the Sub Activity_Keypress. At the end of the Sub Activity_Keypress I set the timerval to 1 and within a timer sub I checked to see if the timerval was less than i. If that condition was true then I set a variable to process Keypresses again. Works great.
By the way, I did learn that if you send too many DoEvents to quickly that the program exits.