QCW9112008: Incorrect Code Generated for OK and CANCEL Buttons

ID Number: Q79156

1.00

WINDOWS

buglist1.00

Summary:

PROBLEM ID: QCW9112008

SYMPTOMS

When using the Microsoft QuickC for Windows Development Environment

(QC/Win) version 1.0, buttons in a dialog box may have incorrect

code generated in QCase:W. In particular, the button names "OK" and

"Cancel" always generate cases for "IDOK" and "IDCANCEL",

respectively, even if they are assigned different symbol names.

RESOLUTION

The only work around is to edit the source file and change the

duplicate case statements to correspond to the symbol names used.

Since the Dialog Editor creates the correct header file for these

symbols, the source code generated by QCase:W is the only place

where a change is necessary.

STATUS

Microsoft has confirmed this to be a problem in QC/Win version 1.0.

We are researching this problem and will post new information here

as it becomes available.

More Information:

The sample code below is the dialog WM_COMMAND switch created by

QCase:W for a dialog box containing four buttons. Two buttons are

assigned the symbols IDOK and IDCANCEL and two are assigned the

numbers 103 and 104.

The "Test OK" and OK buttons both generate the case IDOK, and "Test

Cancel" and Cancel both generate the case IDCANCEL even though

different symbols are assigned in each situation.

To view this code:

1. Create a dialog box by using the Dialog Editor.

2. Place four buttons in the dialog box and name them Test OK, Test

Cancel, OK, and Cancel.

3. Assign Test OK the symbol IDOK, and assign Test Cancel the symbol

IDCANCEL.

4. Use the default values for the other two symbols (they will be ID

numbers such as 103 and 104).

5. Save the dialog box and enter QCase:W.

6. Create a top-level menu for the application by selecting the menu

symbol ( <<>> ) on the prototype window's menu bar.

7. Enter a name and link the menu to a dialog box by choosing the

"Link to" combo box and clicking Dialog Box.

8. Choose the Configure Link button and enter the filename for the

dialog box created earlier.

9. Choose OK on this and the next dialog box.

10. Save the file and choose Generate from the Build menu to generate

the code.

11. Open QC/Win and the sample code below will correspond to the code

generated in the message procedure for the dialog box.

Sample Code

-----------

// This code was generated by QuickCase:W

// The generated comments were deleted.

case WM_COMMAND:

switch(wParam)

{

case IDOK:

EndDialog(hWndDlg, TRUE);

break;

case IDCANCEL:

EndDialog(hWndDlg, FALSE);

break;

/* The following two cases should be changed to match

the ID numbers requested in the dialog editor. */

case IDOK: /* Change to case 103: */

EndDialog(hWndDlg, TRUE);

break;

case IDCANCEL: /* Change to case 104: */

EndDialog(hWndDlg, FALSE);

break;

}

break; /* End of WM_COMMAND */

Additional reference words: 1.00 QuickCase:W