Defining Menu Commands

You must define each prototyped command, either by having QuickCase:W link in an include file that defines the command or by adding the relevant code to the generated .C file.

QuickCase:W gives each command its own internal name in the .C file. It bases the internal name on the prefix “IDM_” plus the menu name plus the command name. It then places all the commands in a switch statement that serves as the main event-handling loop.

Under the case statement for each command is a comment indicating where to insert the code for that command. You can either insert the code directly in the case statement or call a function that performs the desired action.

The following example shows the C code generated by QuickCase:W for a menu system with one menu, named “File,” and two commands, named “New” and “Open.” During the prototyping phase the Open command was linked to a text file called LNKTXT.INC.

switch (Message)

{

case WM_COMMAND:

/* The Windows messages for action bar and pulldown menu items */

/* are processed here. */

switch (wParam)

{

case IDM_F_NEW:

/* Place User Code to respond to the */

/* Menu Item Named "&New" here. */

break;

case IDM_F_OPEN:

/* Place User Code to respond to the */

/* Menu Item Named "&Open" here. */

#include "c:\qcwin\include\lnktxt.inc"

break;

default:

return DefWindowProc(hWnd, Message, wParam, lParam);

break;

}

break; /* End of WM_COMMAND */

In this example, the New command still needs a definition; the Open command may or may not need any further code, depending on the completeness of the LNKTXT.INC include file.