Esempio n. 1
0
void CRoundSliderCtrl::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	const int nMin = GetRangeMin();
	const int nMax = GetRangeMax()+1;

	switch(nChar)
	{
	case VK_LEFT:
	case VK_UP:
		{
			int nNewPos = GetPos()-GetLineSize();
			while(nNewPos < nMin) nNewPos += (nMax - nMin);
			SetPos(nNewPos);
			RedrawWindow();
			PostMessageToParent(TB_LINEUP);
		}
		break;
	
	case VK_RIGHT:
	case VK_DOWN:
		{
			int nNewPos = GetPos()+GetLineSize();
			while(nNewPos >= nMax) nNewPos -= (nMax - nMin);
			SetPos(nNewPos);
			RedrawWindow();
			PostMessageToParent(TB_LINEDOWN);
		}
		break;

	case VK_PRIOR:
		{
			int nNewPos = GetPos()-GetPageSize();
			while(nNewPos < nMin) nNewPos += (nMax - nMin);
			SetPos(nNewPos);
			RedrawWindow();
			PostMessageToParent(TB_PAGEUP);
		}
		break;

	case VK_NEXT:
		{
			int nNewPos = GetPos()+GetPageSize();
			while(nNewPos >= nMax) nNewPos -= (nMax - nMin);
			SetPos(nNewPos);
			RedrawWindow();
			PostMessageToParent(TB_PAGEDOWN);
		}
		break;

	case VK_HOME:
	case VK_END:
		// Do nothing (ignore keystroke)
		break;

	default:
		CSliderCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
	}
}
Esempio n. 2
0
void CInstall::OnInstallStatus(WPARAM wParam, LPARAM lParam)
{
	// Declare variables
	CString sTemp;
	int iFileProgress, iTotalProgress;
	
	// Calculate action count every time to be as precise as possible
	m_iActionCount = m_pInstallFiles->GetActionCount();
	m_iActionCount += m_pInstallIni->GetActionCount();
	m_iActionCount += m_pInstallRegistry->GetActionCount();

	// Get status information
	InstallStatus * pInstallStatus = (InstallStatus *)wParam;

	// Get name
	lstrcpy(m_szFilename, pInstallStatus->sTitle);

	// Check if there is a positive difference between previous and current action count
	if (pInstallStatus->iTotalActionsPerformed - m_iPreviousActionsPerformed > 0)
	{
		// Update the difference
		m_iTotalActionsPerformed += pInstallStatus->iTotalActionsPerformed - m_iPreviousActionsPerformed;
	}

	// Save current action count so we can compare
	m_iPreviousActionsPerformed = pInstallStatus->iTotalActionsPerformed;

	// Calculate % of file
	if (pInstallStatus->iFileActions != 0)
	{
		iFileProgress = (pInstallStatus->iFileActionsPerformed * 100) / pInstallStatus->iFileActions;
	}
	else
	{
		iFileProgress = 0;
	}
	
	// Calculate % of total progress
	if (m_iActionCount != 0)
	{
		iTotalProgress = (m_iTotalActionsPerformed * 100) / m_iActionCount;
	}
	else
	{
		iTotalProgress = 0;
	}

	// Should we send information to parent?
	if (m_iFileProgress != iFileProgress)
		PostMessageToParent(WMU_UPDATE_GUI_FILEPROGRESS, iFileProgress, (LPARAM)m_szFilename);
	if (m_iTotalProgress != iTotalProgress)
		PostMessageToParent(WMU_UPDATE_GUI_TOTALPROGRESS, iTotalProgress, 0);

	// Update information
	m_iFileProgress = iFileProgress;
	m_iTotalProgress = iTotalProgress;
}
Esempio n. 3
0
void CRoundSliderCtrl::OnLButtonDown(UINT nFlags, CPoint point) 
{
	if(m_bDragByKnobOnly)
	{
		CPoint pt = m_ptKnobCenter - point;
		if((pt.x*pt.x + pt.y*pt.y) > m_nKnobRadius*m_nKnobRadius) return; // Ignore it...
	}

	if(!m_bDragging)
	{
		m_bDragging = true;
		m_bDragChanged = false;
		SetCapture();
		SetFocus();
		if(SetKnob(point))
		{
			m_bDragChanged = true;
			PostMessageToParent(TB_THUMBTRACK);
		}
		RedrawWindow();
	}
	else
	{
		CSliderCtrl::OnLButtonDown(nFlags, point);
	}
}
Esempio n. 4
0
void CInstall::OnQuestionAnswer(WPARAM wParam, LPARAM lParam)
{
	// Check which question we are dealing with
	if (wParam == QUESTION_CLOSEAPPLICATION)
	{
		// Handle ourself
		if (lParam == QUESTIONRESULT_YES)
		{
			if (m_pUpdateInfo->GetCloseApplication() != CLOSE_USER)
			{
				// Close application
				if (!m_pFunctions->CloseApplication(m_pSettings->GetAppName(), m_pSettings->GetAppLocation()))
				{
					// Send error message
					PostMessageToParent(WMU_ERROR, ERROR_CLOSEAPP, (LPARAM)(LPCTSTR)m_pSettings->GetAppName());
					PostThreadMessage(WM_QUIT, 0, 0);
					return;
				}

				// Start installing first part
				InstallPart(INSTALL_FILES);
			}
			else
			{
				PostThreadMessage(WMU_THREADMESSAGE, THREAD_START, 0);
			}
		}
		else
		{
			// Send error message
			PostMessageToParent(WMU_ERROR, ERROR_CLOSEAPP, (LPARAM)(LPCTSTR)m_pSettings->GetAppName());
			PostThreadMessage(WM_QUIT, 0, 0);
			return;
		}
	}
	else
	{
		// Send this result message immediatly to childs
		m_pInstallFiles->PostThreadMessage(WMU_QUESTION_ANSWER, wParam, lParam);
		m_pInstallIni->PostThreadMessage(WMU_QUESTION_ANSWER, wParam, lParam);
		m_pInstallRegistry->PostThreadMessage(WMU_QUESTION_ANSWER, wParam, lParam);
	}
}
Esempio n. 5
0
void CInstall::InstallNextPart()
{
	// Suspend current thread
	switch (m_iCurrentPart)
	{
	case INSTALL_FILES:
		m_pInstallFiles->PostThreadMessage(WM_QUIT, 0, 0);
		//m_pInstallFiles->SuspendThread();
		break;
		
	case INSTALL_INI:
		m_pInstallIni->PostThreadMessage(WM_QUIT, 0, 0);
		//m_pInstallIni->SuspendThread();
		break;
		
	case INSTALL_REGISTRY:
		m_pInstallRegistry->PostThreadMessage(WM_QUIT, 0, 0);
		//m_pInstallRegistry->SuspendThread();
		break;
	}

	// Update the part
	m_iCurrentPart++;

	// Are there still parts left?
	if (m_iCurrentPart < INSTALL_MAX)
	{
		// Install next part
		InstallPart(m_iCurrentPart);
	}
	else
	{
		// We are ready, progress MUST be 100%
		PostMessageToParent(WMU_UPDATE_GUI_FILEPROGRESS, 100, (LPARAM)m_szFilename);
		PostMessageToParent(WMU_UPDATE_GUI_TOTALPROGRESS, 100, 0);

		// Send message to parent that we are ready
		PostMessageToParent(WMU_TASK_COMPLETE, TASK_INSTALL, 0);
		
		// Exit the thread
		PostThreadMessage(WM_QUIT, 0, 0);
	}
}
Esempio n. 6
0
void CInstall::OnThreadMessage(WPARAM wParam, LPARAM lParam)
{
	// Declare variables
	int iThreadAction = (int)wParam;
	
	// Check what task to perform for thread
	switch (iThreadAction)
	{
	case THREAD_START:
		// Are we already started?
		if (!m_bStarted)
		{
			// Check if app should be closed
			if (m_pUpdateInfo->GetCloseApplication() != CLOSE_FALSE)
			{
				// Is application running?
				if (m_pFunctions->ApplicationRunning(m_pSettings->GetAppLocation()))
				{
					// Ask user
					PostMessageToParent(WMU_QUESTION, QUESTION_CLOSEAPPLICATION, 
						(LPARAM)(LPCTSTR)m_pSettings->GetAppName());

					// Now wait for an answer
					return;
				}
			}

			// Application should be closed now, start installing first part
			InstallPart(INSTALL_FILES);
		}
		break;
		
	case THREAD_PAUSE:
		// Pause thread
		SuspendThread();
		break;
		
	case THREAD_RESUME:
		// Resume thread
		ResumeThread();
		break;
		
	case THREAD_CANCEL:
		// Exit thread
		PostThreadMessage(WM_QUIT, 0, 0);
		break;
		
	case THREAD_FINISH:
		// Exit thread
		PostThreadMessage(WM_QUIT, 0, 0);
		break;
	}
}
Esempio n. 7
0
void CRoundSliderCtrl::OnLButtonUp(UINT nFlags, CPoint point) 
{
	if(m_bDragging)
	{
		m_bDragging = false;
		::ReleaseCapture();
		if(SetKnob(point))
		{
			PostMessageToParent(TB_THUMBTRACK);
			m_bDragChanged = true;
		}
		if(m_bDragChanged)
		{
			PostMessageToParent(TB_THUMBPOSITION);
			m_bDragChanged = false;
		}
		RedrawWindow();
	}
	else
	{
		CSliderCtrl::OnLButtonUp(nFlags, point);
	}
}
Esempio n. 8
0
void CRoundSliderCtrl::OnMouseMove(UINT nFlags, CPoint point) 
{
	if(m_bDragging)
	{
		if(SetKnob(point))
		{
			m_bDragChanged = true;
			PostMessageToParent(TB_THUMBTRACK);
			RedrawWindow();
		}
	}
	else
	{
		CSliderCtrl::OnMouseMove(nFlags, point);
	}
}
Esempio n. 9
0
void CRoundSliderCtrl::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags) 
{
	switch(nChar)
	{
	case VK_LEFT:
	case VK_UP:
	case VK_RIGHT:
	case VK_DOWN:
	case VK_PRIOR:
	case VK_NEXT:
		PostMessageToParent(TB_ENDTRACK);
		break;

	case VK_HOME:
	case VK_END:
		// Do nothing
		break;

	default:
		CSliderCtrl::OnKeyUp(nChar, nRepCnt, nFlags);
	}
}
Esempio n. 10
0
void CRoundSliderCtrl::SetPosition(int nNewPos)
{
	SetPos(nNewPos);
	PostMessageToParent(TB_THUMBTRACK);
	RedrawWindow();
}
Esempio n. 11
0
void CInstall::OnQuestion(WPARAM wParam, LPARAM lParam)
{
	// Send this question immediatly to parent
	PostMessageToParent(WMU_QUESTION, wParam, lParam);
}
Esempio n. 12
0
void CInstall::OnWarning(WPARAM wParam, LPARAM lParam)
{
	// Send this warning immediatly to parent
	PostMessageToParent(WMU_WARNING, wParam, (LPARAM)m_szFilename);
}
Esempio n. 13
0
void CInstall::OnError(WPARAM wParam, LPARAM lParam)
{
	// Send this error immediatly to parent
	PostMessageToParent(WMU_ERROR, wParam, (LPARAM)m_szFilename);
}
Esempio n. 14
0
BOOL CUpdaterThread::InitInstance()
{
	CUnregThreadAssist	uta(m_nThreadID);

	ULONG lResult = 0;

	PROCESS_INFORMATION piProcInfo; 
	STARTUPINFO siStartInfo = {sizeof(STARTUPINFO)};

	CString strFilename = thePrefs.GetMuleDirectory(EMULE_EXECUTEABLEDIR);

	CFileFind ff;

	strFilename.Append(_T("updater.exe"));

	if(!ff.FindFile(strFilename))
	{
		PostThreadMessage(WM_QUIT, 0, 0);
	}

	WCHAR sz[1024] = {0};
	_tcsncpy(sz,_T("updater.exe -checkforupdates"),1024);

#ifdef _DEBUG
	_tcsncpy(sz,_T("updater.exe -checkforupdates -debug"),1024);
#endif

#ifdef _BETA
	#ifndef _VCALPHA
		_tcsncpy(sz,_T("updater.exe -checkforupdates -beta"),1024);
	#endif
#endif

#ifdef _RELEASE
		_tcsncpy(sz,_T("updater.exe -checkforupdates -release"),1024);
#endif

#ifdef _VCALPHA
	_tcsncpy(sz,_T("updater.exe -checkforupdates -alpha"),1024);
#endif

#ifdef _CRACK_VC
	_tcsncpy(sz,_T("updater.exe -checkforupdates -crack"),1024);
#endif

#ifdef _FOREIGN_VERSION
	_tcsncpy(sz,_T("updater.exe -checkforupdates -english"),1024);
#endif

	if(!CreateProcess(strFilename, sz, NULL, NULL, FALSE, NULL, NULL, NULL, &siStartInfo, &piProcInfo))
	{
		PostThreadMessage(WM_QUIT, 0, 0);
	}

	if (!CGlobalVariable::IsRunning())
	{
		TerminateProcess(piProcInfo.hProcess,0);
		PostThreadMessage(WM_QUIT, 0, 0);
		return FALSE;
	}

	WaitForSingleObject(piProcInfo.hProcess, INFINITE);

	if(GetExitCodeProcess(piProcInfo.hProcess, &lResult) && CGlobalVariable::IsRunning())
	{
		switch(lResult)
		{
		case RESULT_NEWVERSION:
			AddLogLine(TRUE, _T("Start Emule VeryCD P2P Update."));
			PostMessageToParent(UM_STARTED2KUPDATE, 0, 0);
			break;
		case ERROR_NONEWVERSION:
			AddLogLine(TRUE,GetResString(IDS_LATEST_VERSION));
			PostMessageToParent(UM_EASYMULECHECKUPDATEFINISHED, 1, ERROR_NONEWVERSION);
			break;
		case ERROR_NOCONNECTION:
			AddLogLine(false, GetResString(IDS_NOCONNECT));
			break;
		case ERROR_SERVER:
			AddLogLine(false, GetResString(IDS_NOCONNECT_SERVER));
			break;
		case ERROR_CHECKFAIL:
			AddLogLine(false, GetResString(IDS_CHECKOUT_FAILED));
			break;
		case ERROR_MEMNOTCREATE:
			AddLogLine(false, GetResString(IDS_CREATEMEMORY_FAILED));
			break;
		case ERROR_MEMNOTOPEN:
			AddLogLine(false, GetResString(IDS_OPENMEMORY_FAILED));
			break;
		case ERROR_MEMNOTMAP:
			AddLogLine(false, GetResString(IDS_MAP_FAILED));
			break;
		case ERROR_WRITEMEM:
			AddLogLine(false, GetResString(IDS_READIN_FAILED));
			break;
		case ERROR_LOADFAIL:
			AddLogLine(false,GetResString(IDS_LOAD_FAILED));
			break;
		default:
			AddLogLine(false, GetResString(IDS_UNKNOWN_ERROR));
		}
	}

	return FALSE;
}