HWND hwndProgress = NULL; if (!IsWindow(hwndProgress)) { hwndProgress = CreateDialog(hInst, MAKEINTRESOURCE(IDD_PROGRESS), NULL, (DLGPROC)TestProc); ShowWindow(hwndProgress, SW_SHOW); }You provide a callback function with the correct signature to process messages for both external events (SendMessage) and internal events such as a Cancel button being clicked.
LRESULT CALLBACK TestProc(HWND hwndDlg, UINT message, WPARAM wParam, LPARAM lParam) { switch (message) { case WM_INITDIALOG: return TRUE; case WM_COMMAND: switch (LOWORD(wParam)) { case IDOK: return TRUE; case IDCANCEL: DestroyWindow(hwndDlg); hwndProgress = NULL; return TRUE; case CUSTOMMSG: // Perform custom processing like updating child controls. return TRUE; } } return FALSE; }Once you have your HWND you can register custom external messages using the RegisterWindowMessage function and send them to the dialog, this in turn is catered for in the dialog callback function.
... case APP_UPDATEEXENAME: SetDlgItemText(hwndDlg, IDD_EXEFILENAME, lpstrNewEXEFileName); return TRUE; ...HTH