Пример #1
0
LRESULT CAutoComplete::WindowProc(UINT msg, WPARAM wp, LPARAM lp)

{
	
	if ((msg==WM_COMMAND && LOWORD(wp)==m_idMyControl) &&
		
		((m_iType==Edit && HIWORD(wp)==EN_CHANGE) ||
		
		(m_iType==ComboBox && HIWORD(wp)==CBN_EDITCHANGE))) {
		
		// 因为我要改变控制的内容,它将触发更多的EN_CHANGE消息,
		
		// 当我获得控制时使用 m_bIgnoreChangeMsg 结束处理.
		
		if (!m_bIgnoreChangeMsg++) {
			
			CString s;
			
			CWnd* pWnd = CWnd::FromHandle((HWND)lp);
			
			pWnd->GetWindowText(s);
			
			OnComplete(pWnd, s);
			
		}
		
		m_bIgnoreChangeMsg--;
		
	}
	
	return CSubclassWnd::WindowProc(msg, wp, lp);
	
}
Пример #2
0
void CProgressBar::SetProgress (float progress)
{
	m_fProgress = progress;
	if( m_fProgress >= 100 )
	{
		m_fProgress = 0;
		OnComplete();
	}

}
Пример #3
0
LRESULT CThreadProcessor::OnCompleteHandler(WPARAM,LPARAM)
{
	try
	{
		if(state==st_stopping||!thrd)return 0;
		errors_t vals_messages;
		
		{
			lkt lk(mtx);

			std::swap(messages,vals_messages);
		}
		if(vals_messages.empty())OnComplete();
		else OnErrors(vals_messages);
	}
	catch(...)
	{
	}

	return 0;
}
Пример #4
0
bool CSingleAction::Run(CPathAction &DesiredAction)
{
        
    m_Notifications.push_back(CMOOSMsg(MOOS_NOTIFY,m_sVarName,m_sValue,MOOSTime()));
    return OnComplete();
}
Пример #5
0
void *wxDownloadThread::Entry()
{
    wxInputStream *in = m_url.GetInputStream();

    // check the stream
    if (in == NULL)
    {
        // something is wrong with the input URL...
        OnAbort();
        return NULL;
    }
    if (!in->IsOk())
    {
        delete in;

        // something is wrong with the input URL...
        OnAbort();
        return NULL;
    }

    // we successfully connected with the server
    OnConnect();

    // we are starting the download of a file; update our datetime field
    wxLogDebug(_("wxDownloadThread::Entry - downloading [%s]"),
               m_url.GetURL().c_str());
    m_dtStart = wxDateTime::UNow();

    wxASSERT(m_output->IsOk());

    // get size of download, if available
    size_t sz = in->GetSize();
    m_nFinalSize = (sz == (size_t)-1) ? wxInvalidSize : sz;

    // begin the download
    char buf[wxDT_BUF_TEMP_SIZE];
    bool paused = false;
    while (!TestDestroy())
    {
        if (GetFlag() == wxDTF_ABORT)
        {
            wxLogDebug(wxS("wxDownloadThread::Entry - user-aborting"));
            delete in;
            OnUserAbort();
            return NULL;
        }
        else if (GetFlag() == wxDTF_PAUSE)
        {
            wxLogDebug(wxS("wxDownloadThread::Entry - sleeping"));

            // did we warn our event handler that the download was paused?
            if (!paused)
            {
                paused = true;
                OnPause();
            }

            // sleep 100 msec and then test again our flag to see
            // if it has changed to wxDTF_CONTINUE or to wxDTF_ABORT
            wxMilliSleep(100);
            continue;
        }

        paused = false;

        // write the downloaded stuff in the output file
        // without using the
        //      out.Write(*in);
        // command; that would be easier but would not allow
        // the program to stop this thread while downloading
        // the file since the TestDestroy() function would not
        // be called in that way...
        size_t bytes_read = in->Read(buf, WXSIZEOF(buf)).LastRead();
        if ( !bytes_read )
            break;      // no more data to read

        if ( m_output->Write(buf, bytes_read).LastWrite() != bytes_read )
        {
            // something wrong with saving downloaded data!
            OnAbort();
            return NULL;
        }

        // update our downloaded bytes var
        m_nCurrentSize = m_output->GetSize();

        // notify our even handler that we made progress
        OnUpdate();
    }

    // we don't need the INPUT stream anymore...
    delete in;

    wxASSERT_MSG(m_nCurrentSize == m_nFinalSize || m_nFinalSize == wxInvalidSize,
                 wxS("All errors should have already been catched!"));

    wxLogDebug(_("wxDownloadThread::Entry - completed download of %lu bytes"),
               m_nCurrentSize.ToULong());

    // download is complete
    OnComplete();
    wxLogDebug(wxS("sent complete event"));
    return NULL;
}
Пример #6
0
void ZTask::Complete()
{
	OnComplete();
}
Пример #7
0
// This function is executed in the main thread
void StorageAsyncGet::ExecuteAsyncGet()
{
    StorageFileChunk*   fileChunk;

    if (itChunk == NULL)
        goto complete;
    
    fileChunk = (StorageFileChunk*) (*itChunk);
    if (stage == BLOOM_PAGE)
    {
        if (lastLoadedPage != NULL)
        {
            ASSERT(fileChunk->bloomPage == NULL);
            fileChunk->bloomPage = (StorageBloomPage*) lastLoadedPage;
            fileChunk->isBloomPageLoading = false;
        }
    }
    else if (stage == INDEX_PAGE)
    {
        if (lastLoadedPage != NULL)
        {
            ASSERT(fileChunk->indexPage == NULL);
            fileChunk->indexPage = (StorageIndexPage*) lastLoadedPage;
            fileChunk->AllocateDataPageArray();
            fileChunk->isIndexPageLoading = false;
        }
    }
    else if (stage == DATA_PAGE)
    {
        if (lastLoadedPage != NULL)
        {
            // TODO: FIXME:
//            ASSERT(fileChunk->dataPages[index] == NULL);
            if (fileChunk->dataPages[index] == NULL)
            {
                fileChunk->dataPages[index] = (StorageDataPage*) lastLoadedPage;
                StoragePageCache::AddPage(lastLoadedPage);
                lastLoadedPage = NULL;
            }
            else
            {
                delete lastLoadedPage;
                lastLoadedPage = NULL;
            }
        }
    }

    if (lastLoadedPage)
    {
        StoragePageCache::AddPage(lastLoadedPage);
        lastLoadedPage = NULL;
    }
    
    stage = START;
    while (itChunk != NULL)
    {
        completed = false;
        (*itChunk)->AsyncGet(this);
        if (completed && ret)
            break;  // found

        if (!completed)
            return; // needs async loading

        itChunk = shard->GetChunks().Prev(itChunk);
    }

complete:
    if (itChunk == NULL)
        completed = true;

    if (completed)
        OnComplete();

    // don't put code here, because OnComplete deletes the object
}