Page 210 - DCAP408_WEB_PROGRAMMING
P. 210
Windows Programming
Notes TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
The loop verifies the validity of the window handle to the dialog box and only calls the
IsDialogMessage function if the handle is valid. IsDialogMessage only processes the message if
it relates to the dialog box. Or else, it returns FALSE and the loop transmits the message to the
suitable window.
The following statements identify the dialog box procedure.
int iLine; // Receives line number.
BOOL fRelative; // Receives check box status.
BOOL CALLBACK GoToProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM
lParam)
{
BOOL fError;
switch (message)
{
case WM_INITDIALOG:
CheckDlgButton(hwndDlg, ID_ABSREL, fRelative);
return TRUE;
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDOK:
fRelative = IsDlgButtonChecked(hwndDlg, ID_ABSREL);
iLine = GetDlgItemInt(hwndDlg, ID_LINE, &fError,
fRelative);
if (fError)
{
MessageBox(hwndDlg, SZINVALIDNUMBER, SZGOTOERR,
MB_OK);
SendDlgItemMessage(hwndDlg, ID_LINE, EM_SETSEL, 0,
-1L);
}
else
// Notify the owner window to carry out the task.
return TRUE;
204 LOVELY PROFESSIONAL UNIVERSITY