How Menu Key Can Be Trapped From C?
Posted 08 December 2008 - 06:41 PM
Does anyone know how the menu key can be trapped from C?
It happens using the text editor program that I have created with the SDK that if the user changes to another application while using the editor, he is not warned that he is about to loose all the data because menu key is not trapped by C function GetKey().
Does anyone have an idea how we can overcome this problem?
Posted 08 December 2008 - 07:19 PM
What you should do is install an exit handler. Make a function that asks for user confirmation and lets the user save the file. Register the function with the SetQuitHandler() function. It will be called once the OS has been told to start another program.
edit: Oh, ad by the way - nice program. After a quick look at the source, i think you can save about 10 to 13kB by replacing sprintf() with a custom-made one. You could also replace some sprintf()-calls with strcpy() where you just copy a string, because sprintf() is a slow beast. Thanks for releasing the code.
Edited by Andreas B, 08 December 2008 - 09:37 PM.
Posted 09 December 2008 - 10:49 PM
Thank you for your hint. I implemented an exit handler with the SetQuitHandler() function and it worked fine. I will update soon the text editor in the web with this change. However, it is a pity that this exit handler does not allow to go back to the application, but anyway the user can save the file before loosing it
Thank you also for the remark about sprintf(). I will take this into account.
0 user(s) are reading this topic
0 members, 0 guests, 0 anonymous users