** 1 page regular, HBASIC 5 tutorial / 736 words ** When is a dialog not a dialog? Paul Jones looks to find the answer... Click goes the mouse! last issue we looked at the basic structure of PDO explaining how the program works. This time let's think of some ways it could be improved: ** BL on ** * Keyboard shortcuts: These are a useful addition to most programs. * An information dialog, like the one we created back in AC#5! * A registration dialog to remind people to pay for software they use. ** BL off The PDO structure makes it easy to add new features and you should remember this when programming your own projects. First we have to make a modification to the main loop: ** PROG1.GIF here ** Now, instead of simply waiting for messages, we can also get input from the keyboard! If we get a keyboard input now, our program will jump to a subroutine called do_keybd with the key pressed as a parameter. If you're not sure of parameters, subroutines or functions, re-read AC#6. ** PROG2.GIF here ** Whenever a button is pressed, the value is displayed in an alert box. Using this method you can press the desired key combinations and write down their values for use in the program. Here's what I got for the following combinations: ** BL on ** * [Alternate]+O 6144 * [Alternate]+L 9728 * [Alternate]+S 7936 * [Alternate]+V 12032 * [Alternate]+P 6400 * [Alternate]+Q 4096 * [Alternate]+A 7680 ** BL off ** Now, we can edit the subroutine so these values are used to go to the required item in ProcessUserMenus. ** PROG3.GIF here ** We get a value in, find which item it belongs to and jump to the processing menu. For example, if we get 12032 in, we know this value is unique to [Alternate]+V and can proceed as if the "View file" option had been selected by the user via the drop down menus. Oh no, more dialog boxes!... If you compile and run this modified version you'll encounter a problem. If you press a combination key, followed by a key without a combination key, for example, if you press [Alternate]+O then, after the alert box has been displayed, you press D, the same alert which came up for the keyboard shortcut combination will be displayed again for an invalid key! We do some object checking to find out if the currently pressed button is a valid key, then jump to that menu item in ProcessUserMenus... ** PROG4.GIF here ** At the start of the routine the variable id is set to 0. If any of the shortcuts have been selected then id is set to 1 and the routine will jump to ProcessUserMenus. If an invalid shortcut has been selected it will be ignored because id is not set to 1. Next we need to change two lines in ProcessUserMenus: ** PROG5.GIF here ** Both these will display a dialog box from the RSC file. If the About option is selected (via the menu option or new shortcut routine) the info dialog is displayed and this is also the case for the register dialog. The "regcode" in the register dialog is the name of the default edit field, which we'll look at in more detail next issue. The current PDO source code is on the Reader Disk. ** Boxout 1 ** Shareware delays Shareware delay can take various guises. One of the most common is a dialog box on screen which reminds the user of their obligations. These often incorporate a time delay of some sort, for example, a progress bar which prevents the user from dismissing or bypassing the dialog immediately. Happily these are easy to implement. Take a look at the PDO source in the dialog subroutine you will see the line: ** NP on ** junk=FNobjc_draw(tree&,0,10,x,y,w,h) ** NP off ** This simply just draws the dialog on screen, another command ** NP on ** form_do ** NP off ** enables the user to interact with the dialog. If we simply display the dialog then wait in a loop, we have effectively created a shareware delay! As for the progression bar, we can have an object in the box which via another GEM command we can change the size of. A variation of the shareware delay is included in GEMBench which displays "Register" in a flashing colour and you can also add this to your own programs - I'll be covering this next time around. ** End boxout 1 **