Example #1
0
LRESULT CProgressDlg::OnCancel(WORD /*wNotifyCode*/, WORD /*wID*/, HWND /*hWndCtl*/, BOOL& /*bHandled*/)
{ 
	// This method is called when user clicks the "Cancel" button
	// on the dialog.

    if(m_ActionOnCancel==CLOSE_MYSELF_AND_PARENT)
    {
        // Hide this window smoothly
        AnimateWindow(m_hWnd, 200, AW_HIDE|AW_BLEND); 

        // Request parent window to close
        HWND hWndParent = ::GetParent(m_hWnd);
        ::PostMessage(hWndParent, WM_CLOSE, 0, 0);
        return 0;
    }
    else if(m_ActionOnCancel==CLOSE_MYSELF)
    {
        // Hide this window smoothly
        AnimateWindow(m_hWnd, 200, AW_HIDE|AW_BLEND); 	  
        return 0;
    }

    // Start cancelling the worker thread
	CErrorReportSender* pSender = CErrorReportSender::GetInstance();
    pSender->Cancel();  

    // Disable Cancel button
    m_btnCancel.EnableWindow(0);

    return 0;
}