28.10.2006, 18:22 | #1 |
Участник
|
Axapta Lessons: Trapping keystrokes in a Form
Источник: http://axapta-lessons-learned.blogsp...s-in-form.html
============== How can we catch keystrokes in a Form? When we want to catch the key pressed in a form we need to make some adjustments to the Form. These modifications consist of a few steps: 1. Add a macro that contains the values for the virtual keys. 2. Modify the ClassDeclaration of the Form. 3. Create a new method overruleFKeys on the Form to overrule the virtual keys. 4. Create a new method checkKeyPressed on the Form to capture the key pressed. 5. Override the Task method on the Form. 6. Override the Close method on the Form. 7. Override the Init method on the Form. Let us have a look at an example hereafter. The Form we are going to create will just get two activeX controls, a clock and calendar. The final Form defition will look as follows± 1. Add a macro that contains the values for the virtual keys. 2. Modify the ClassDeclaration of the Form. 3. Create a new method overruleFKeys on the Form to overrule the virtual keys. Overruling the virtual keys will result in no standard handling for the virtual keys anymore; this means that for instance pressing F1 will no longer lead to the help-functionality of Axapta, unless you implement it yourself again. 4. Create a new method checkKeyPressed on the Form to capture the key pressed. We are going to use the Windows DLL 'USER32' and it's function 'GetAsyncKeyState'. The function needs the value of the virtual key to be passed as a binary parameter, like for instance 0x72 for F3. When the key is pressed the function will return a value different from 0. We can find the hexadecimal values for the keys here Virtual Key Codes . 5. Override the Task method on the Form. In the task-method we are going to catch taskId 520. When doing so, we will have to loop over all virtual keys to see if one of them was pressed. There is no other way to find out which one was pressed (if any) then to check them all. Since there are only a few of them, this won't lead to any performance problems. We are going to achieve this by calling the method checkKeyPressed. 6. Override the Close method on the Form. 7. Override the Init method on the Form. To be continued with detail explanation of the different steps.?* ============== Источник: http://axapta-lessons-learned.blogsp...s-in-form.html |
|
|
За это сообщение автора поблагодарили: kashperuk (5). |
|
Опции темы | Поиск в этой теме |
Опции просмотра | |
|