visual studio 2010 MFC在进行数据处理时,弹出进度条,
用鼠标点击进度条上端的可拖动位置,按住左键不动时,或来回拖动时,
进度条停滞不动,松开鼠标左键,才恢复运行。求教,鼠标拖动操作不影响进度条进行的方法。

解决方案 »

  1.   

    下面是进度条部分的代码BOOL CProgressWnd::Create(CWnd* pParent, LPCTSTR pszTitle, BOOL bSmooth )
    {
        BOOL bSuccess;    // Register window class
        CString csClassName = AfxRegisterWndClass(CS_OWNDC|CS_HREDRAW|CS_VREDRAW,
                                                  ::LoadCursor(NULL, IDC_APPSTARTING),
                                                  CBrush(::GetSysColor(COLOR_BTNFACE)));    // Get the system window message font for use in the cancel button and text area
        NONCLIENTMETRICS ncm;
        ncm.cbSize = sizeof(NONCLIENTMETRICS);
        VERIFY(SystemParametersInfo(SPI_GETNONCLIENTMETRICS, sizeof(NONCLIENTMETRICS), &ncm, 0));
        m_font.CreateFontIndirect(&(ncm.lfMessageFont));     // If no parent supplied then try and get a pointer to it anyway
        if (!pParent)
            pParent = AfxGetMainWnd();

        // Create popup window
        bSuccess = CreateEx(WS_EX_DLGMODALFRAME|WS_EX_TOPMOST, // Extended style
                            csClassName,                       // Classname
                            pszTitle,                          // Title
                            WS_POPUP|WS_BORDER|WS_CAPTION,     // style
                            0,0,                               // position - updated soon.
                            390,130,                           // Size - updated soon
                            pParent->GetSafeHwnd(),            // handle to parent
                            0,                                 // No menu
                            NULL);    
        if (!bSuccess) return FALSE;    // Now create the controls
        CRect TempRect(0,0,10,10);    bSuccess = m_Text.Create(_T(""), WS_CHILD|WS_VISIBLE|SS_NOPREFIX|SS_LEFTNOWORDWRAP,
                                 TempRect, this, IDC_TEXT);
        if (!bSuccess)return FALSE;    DWORD dwProgressStyle = WS_CHILD|WS_VISIBLE;
    #ifdef PBS_SMOOTH    
        if (bSmooth)dwProgressStyle |= PBS_SMOOTH;
    #endif
        bSuccess = m_wndProgress.Create(dwProgressStyle, TempRect, this, IDC_PROGRESS);
        if (!bSuccess) return FALSE;    bSuccess = m_CancelButton.Create(m_strCancelLabel, 
                                         WS_CHILD|WS_VISIBLE|WS_TABSTOP| BS_PUSHBUTTON, 
                                         TempRect, this, IDC_CANCEL);
        if (!bSuccess) return FALSE;    m_CancelButton.SetFont(&m_font, TRUE);
        m_Text.SetFont(&m_font, TRUE);    // Resize the whole thing according to the number of text lines, desired window
        // width and current font.
        SetWindowSize(m_nNumTextLines, 390);    // Center and show window
        if (m_bPersistantPosition)
            GetPreviousSettings();
        else
            CenterWindow();    Show();

        return TRUE;
    }