QCW9110006: Error in Editfile and Prntfile Examples

ID Number: Q77852

1.00

WINDOWS

buglist1.00

Summary:

PROBLEM ID: QCW9110006

SYMPTOMS

In Microsoft QuickC for Windows (QC/Win) version 1.0 and in the

Windows Software Development Kit (SDK), unsaved changes made to

the edit buffer in the Editfile and Prntfile examples will be

lost if either New or Open is chosen from the File menu.

CAUSE

The examples use a variable called bChanges to keep track of

whether changes have been made to the edit buffer or not. The value

of bChanges is tested before opening a new file to see whether it

is set to TRUE. If it is TRUE, then the user is asked whether the

changes should be saved. However, in these examples, bChanges is

initialized to be FALSE, but never assigned a value of TRUE.

Therefore, the user will not be queried and changes can be lost.

RESOLUTION

Modify the IDC_EDIT case in the main window procedure to check if

changes have been made and to set bChanges to TRUE if they have.

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 following is the modified IDC_EDIT case. The else-if clause was

added to check if changes have been made. The value of bChanges is set

to TRUE if changes have been made.

case IDC_EDIT:

if (HIWORD (lParam) == EN_ERRSPACE) {

MessageBox (

GetFocus ()

, "Out of memory."

, "EditFile Sample Application"

, MB_ICONHAND | MB_OK

);

}

else if (HIWORD (lParam) == EN_CHANGE) {

bChanges = TRUE;

}

break;

The edit control was given the child control ID IDC_EDIT when it was

created with CreateWindow(). When the child control needs to

communicate with the parent, it sends a WM_COMMAND message with wParam

set to its own ID, IDC_EDIT. Additional information is stored in the

high word of lParam. In these examples, the code processes the case

where lParam is set to EN_ERRSPACE (indicating that additional memory

could not be allocated) and the case where lParam is set to EN_CHANGE

(indicating that the user took an action that may have altered text).

Additional reference words: 1.00