void CDateComboBox::SetCurrentWindowText( )
{
	if( !::IsWindow(m_hWnd) )
		return;

	DWORD	dwDate = -1;
	AfxGetSListStockContainer().GetCurrentType(NULL,NULL,&dwDate);
	CSPTime	sptime;
	if( DWORD(-2) == dwDate )
	{
		CString	strItem;
		strItem.LoadString( IDS_DATECOMBOBOX_MORE );
		SelectString( 0, strItem );
	}
	else if( DWORD(-1) == dwDate )
	{
		CString	strItem;
		strItem.LoadString( IDS_DATECOMBOBOX_NOW );
		SelectString( 0, strItem );
	}
	else if( sptime.FromStockTimeDay( dwDate ) )
	{
		CString	strItem	=	AfxGetTimeString( sptime.GetTime(), szDateComboBoxTimeFormat, TRUE );
		SelectString( 0, strItem );
	}
	else
	{
		CString	strItem;
		strItem.LoadString( IDS_DATECOMBOBOX_NOW );
		SelectString( 0, strItem );
	}
}
BOOL CDateComboBox::InitDates( )
{
	ResetContent( );

	// Add Date ComboBox Members
	CSPDWordArray dwArray;
	AfxGetStockContainer().GetTechDateArray( dwArray );

	InitStorage( dwArray.GetSize()+2, 32 );

	CString strMore;
	strMore.LoadString( IDS_DATECOMBOBOX_MORE );
	int nIndex = AddString( strMore );
	SetItemData( nIndex, -2 );

	/*int	nMaxDaysCalculate	=	AfxGetProfile().GetMaxDaysCalculate( );*/
	// for( int nCount=dwArray.GetSize()-1; nCount >= 0/*nCount > nMaxDaysCalculate*/; nCount -- )
	for( int nCount=0; nCount < dwArray.GetSize(); nCount ++ )
	{
		CSPTime	sptime;
		if( sptime.FromStockTimeDay( dwArray[nCount] ) )
		{
			CSPTime	time( sptime.GetTime() );
			CString	strItem	=	AfxGetTimeString( time.GetTime(), szDateComboBoxTimeFormat, TRUE );
			if( strItem.GetLength() > 0 )
			{
				int nIndex = AddString( strItem );
				SetItemData( nIndex, dwArray[nCount] );
			}
		}
	}

	CString strNow;
	strNow.LoadString( IDS_DATECOMBOBOX_NOW );
	nIndex = AddString( strNow );
	SetItemData( nIndex, -1 );
	SetCurSel( nIndex );

	return TRUE;
}
Example #3
0
BOOL CDownloadDlg::OnInitDialog() 
{
	CXFDialog::OnInitDialog();
	
	// TODO: Add extra initialization here
	m_staticRefreshServer.SetWindowPos( NULL, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_HIDEWINDOW);
	m_staticStatus.SetWindowPos( NULL, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_HIDEWINDOW);
	m_ctrlProgress.SetWindowPos( NULL, 0,0,0,0, SWP_NOSIZE|SWP_NOMOVE|SWP_NOZORDER|SWP_HIDEWINDOW);

	m_btnStopRefresh.EnableWindow( FALSE );
	m_btnStop.EnableWindow( FALSE );

	InitComboServers();

	m_ctrlProgress.SetRange( 0, STKLIB_MAX_PROGRESS );
	m_ctrlProgress.SetPos( 0 );
	m_btnCheckReport.SetCheck( AfxGetStkReceiver().NetEngineIsWorking() );
	m_btnCheckReport.EnableWindow( AfxGetStkReceiver().NetEngineIsWorking() );
	m_btnCheckDay.SetCheck( TRUE );

	// Set Time
	CSPTime	tmCurrent	=	CSPTime::GetCurrentTime();
	if( tmCurrent.GetHour() < 15 )
		tmCurrent	-=	CSPTimeSpan(1,0,0,0);

	if( tmCurrent.GetMonth() == 1 && tmCurrent.GetDay() == 1 )
		tmCurrent	-=	CSPTimeSpan(1,0,0,0);
	if( tmCurrent.GetMonth() == 5 && tmCurrent.GetDay() == 1 )
		tmCurrent	-=	CSPTimeSpan(1,0,0,0);
	if( tmCurrent.GetMonth() == 10 && tmCurrent.GetDay() == 1 )
		tmCurrent	-=	CSPTimeSpan(1,0,0,0);
	if( tmCurrent.GetDayOfWeek() == 1 )
		tmCurrent	-=	CSPTimeSpan(2,0,0,0);
	if( tmCurrent.GetDayOfWeek() == 7 )
		tmCurrent	-=	CSPTimeSpan(1,0,0,0);
	
	m_tmDayFrom		=	m_netdb.GetTimeInitial().GetTime();
	m_tmDayTo		=	tmCurrent;
	m_tmMin5From	=	m_tmMin5To	=	tmCurrent;

	CSPTime	tmLatest;
	if( m_netdb.SetRootPath( AfxGetProfile().GetSelfDBPath(), IStStore::dbtypeSelfDB )
		&& m_netdb.GetTimeLocalRange( &tmLatest, NULL, NULL ) )
	{
		CString	strTimeLatest	=	(LPCTSTR)AfxGetTimeString( tmLatest.GetTime(), "%Y-%m-%d", TRUE ); //tmLatest.Format( "%Y-%m-%d,%A" );
		m_staticLatest.SetWindowText( strTimeLatest );

		m_tmDayFrom	=	CSPTime(tmLatest.GetTime()) + CSPTimeSpan(1,0,0,0 );

		if( m_tmDayFrom.GetMonth() == 1 && m_tmDayFrom.GetDay() == 1 )
			m_tmDayFrom	+=	CSPTimeSpan(1,0,0,0);
		if( m_tmDayFrom.GetMonth() == 5 && m_tmDayFrom.GetDay() == 1 )
			m_tmDayFrom	+=	CSPTimeSpan(1,0,0,0);
		if( m_tmDayFrom.GetMonth() == 10 && m_tmDayFrom.GetDay() == 1 )
			m_tmDayFrom	+=	CSPTimeSpan(1,0,0,0);
		if( m_tmDayFrom.GetDayOfWeek() == 1 )
			m_tmDayFrom	+=	CSPTimeSpan(1,0,0,0);
		if( m_tmDayFrom.GetDayOfWeek() == 7 )
			m_tmDayFrom	+=	CSPTimeSpan(2,0,0,0);
		
		if( m_tmDayFrom > m_tmDayTo )
			m_tmDayTo	=	m_tmDayFrom;
	}

	// Initial Download
	if( m_bInitDownloadTime )
	{
		m_tmDayFrom	=	m_tmDLBegin;
		m_tmDayTo	=	m_tmDLEnd;
	}

	UpdateData( FALSE );

	if( m_bAutoRun )
	{
		UpdateWindow( );
		ShowWindow( SW_SHOW );
		OnOK( );
	}
	
	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}