SimApi Timer getSystemTime

From SIMboxWiki
Jump to navigation Jump to search



Icon attributes.pngstatic _SYSTEMTIME SimApi::Timer::getSystemTime(const int i_nSessionPositionInPercentage)

    Description

    Gets a session time on specified percentage of the total session time

    Parameters

    i_nSessionPositionInPercentage - The percentage of the total session time

    Return

    Type: _SYSTEMTIME   Description: Session time on specified percentage of the total session time

    Remarks
    

Gets the session time on specified percentage of the total session time. The time returned in standard SYSTEMTIME structure of Win32 API. For details about SYSTEMTIME structure see its information in MSDN.


    Code Sample
    

//Assume we have an extension slider that was added to the playback Extension collection.
//We would like to have a slider in the toolbar that will set and  display
//the time according to the position of the slider. The slider position is percentage.

void PlaybackSliderExtension::OnSliderPositionChanged(int i_percentage)
{

	//get the time based on the slider position
	SYSTEMTIME st = SimApi::Timer::getSystemTime(i_percentage);
	//seek to a new time in the session playback accroding to the percentage
	SimApi::Timer::seekToTimeByPosition(i_percentage); 
					 
	DisplayTime(st);
}

void PlaybackSliderExtension::DisplayTime(SYSTEMTIME i_time)
{
	//set the values of the time labels on the plugin dialog
	m_hourLabel = SimUtil::Strings::IntToString(st.wHour);
	m_minuteLabel = SimUtil::Strings::IntToString(st.wMinute);
	m_secondLabel = SimUtil::Strings::IntToString(st.wSecond);
}


    See Also

     seekToTimeByPosition

     getPosition

    Related Links

     Recommended: Simulation Time Overview