Exemple #1
0
BOOL CFilterInfoDlg::OnInitDialog() 
{
	CXFDialog::OnInitDialog();

	DWORD	dwDate	=	0;
	if( AfxGetStockContainer().GetCurrentType( NULL, NULL, &dwDate )
		&& (-1 != dwDate || AfxGetStockContainer().GetLatestTechDate(&dwDate)) )
	{
		CSPTime	sptime;
		if( -1 != dwDate && sptime.FromStockTimeDay( dwDate ) )
		{
			CString	string	=	sptime.Format( "%Y-%m-%d" );
			m_staticTime.SetWindowText( string );
		}
	}
	
	InitListInfo( );
	OnSelchangeListinfo();

	CheckRadioButton( IDC_RADIOAND, IDC_RADIOOR, IDC_RADIOAND );

	m_btnAll.SetCheck( 1 );
	OnAll( );

	m_btnAddToGroup.EnableWindow( FALSE );

	m_ctrlProgress.ShowWindow( SW_HIDE );

	return TRUE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
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 );
	}
}
Exemple #3
0
int CKData::DayToMonth( CKData &kdday, CKData &kdmonth )
{
	// convert day k line to month k line
	SP_ASSERT( ktypeDay == kdday.GetKType() );
	SP_ASSERT( ktypeMonth == kdmonth.GetKType() );

	kdmonth.SetSize( 0, kdday.GetSize() / 20 + 5 );
	
	int nStart		=	kdday.GetSize() % 3;
	int	nCount		=	0;
	KDATA	dataDest;
	memset( &dataDest, 0, sizeof(dataDest) );
	int	nYearCur = 0, nMonthCur = 0 ;
	for( int pos=nStart; pos<kdday.GetSize(); pos++ )
	{
		KDATA & dataSrc = kdday.ElementAt( pos );

		CSPTime	tm;
		if( !tm.FromStockTimeDay(dataSrc.m_date) )
			continue;
		int nYear	=	tm.GetYear();
		int nMonth	=	tm.GetMonth();

		if( nYear != nYearCur || nMonth != nMonthCur )	// a new month
		{
			if( 0 != pos )
				kdmonth.Add( dataDest );				// add a month

			memcpy( &dataDest, &dataSrc, sizeof(dataDest) );	// begin a new month
			nYearCur	=	nYear;
			nMonthCur	=	nMonth;
		}
		else
		{
			dataDest.m_fAmount		+=	dataSrc.m_fAmount;
			if( dataDest.m_fHigh < dataSrc.m_fHigh )	dataDest.m_fHigh	=	dataSrc.m_fHigh;
			if( dataDest.m_fLow > dataSrc.m_fLow )		dataDest.m_fLow		=	dataSrc.m_fLow;
			dataDest.m_fVolume		+=	dataSrc.m_fVolume;
			dataDest.m_fClose		=	dataSrc.m_fClose;
		}

		if( pos == kdday.GetSize()-1 )	// the latest one
			kdmonth.Add( dataDest );
	}

	return kdmonth.GetSize();
}
Exemple #4
0
int CKData::DayToWeek( CKData &kdday, CKData &kdweek )
{
	// convert day k line to week k line
	SP_ASSERT( ktypeDay == kdday.GetKType() );
	SP_ASSERT( ktypeWeek == kdweek.GetKType() );

	kdweek.SetSize( 0, kdday.GetSize() / 5 + 5 );
	
	int nStart		=	kdday.GetSize() % 3;
	int	nCount		=	0;
	KDATA	dataDest;
	memset( &dataDest, 0, sizeof(dataDest) );
	for( int pos=nStart; pos<kdday.GetSize(); pos++ )
	{
		KDATA & dataSrc = kdday.ElementAt( pos );

		CSPTime	tm;
		if( !tm.FromStockTimeDay(dataSrc.m_date) )
			continue;

		if( tm.GetDayOfWeek() == 2 )	// a new week
		{
			if( 0 != pos )
				kdweek.Add( dataDest );				// add a week

			memcpy( &dataDest, &dataSrc, sizeof(dataDest) );	// begin a new week
		}
		else
		{
			dataDest.m_fAmount		+=	dataSrc.m_fAmount;
			if( dataDest.m_fHigh < dataSrc.m_fHigh )	dataDest.m_fHigh	=	dataSrc.m_fHigh;
			if( dataDest.m_fLow > dataSrc.m_fLow )		dataDest.m_fLow		=	dataSrc.m_fLow;
			dataDest.m_fVolume		+=	dataSrc.m_fVolume;
			dataDest.m_fClose		=	dataSrc.m_fClose;
		}

		if( pos == kdday.GetSize()-1 )	// the latest one
			kdweek.Add( dataDest );
	}

	return kdweek.GetSize();
}
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;
}
Exemple #6
0
void CSListView::ExportList( CListExportDlg * pDlg )
{
	ASSERT( pDlg );
	if( NULL == pDlg )
		return;

	int	nColumnCount	=	m_Grid.GetColumnCount();
	ASSERT( nColumnCount > 0 );
	if( nColumnCount <= 0 )
		return;

	CStockContainer & container = AfxGetSListStockContainer();

	// Get Current StockList Time
	DWORD	dwDate;
	CSPTime	sptime;
	CSPTime	time;
	if( container.GetCurrentType( NULL, NULL, &dwDate )
		&& (-1 != dwDate || container.GetLatestTechDate(&dwDate))
		&& sptime.FromStockTimeDay( dwDate ) )
		time	=	CSPTime( sptime.GetTime() );

	// Set Column
	CStringArray	astrColumn;
	CUIntArray		anWidth;
	CUIntArray		anParams;
	for(int nCol = 0; nCol < nColumnCount; nCol ++ )
	{
		astrColumn.Add( m_Grid.GetItemText(0,nCol) );
		anWidth.Add( m_Grid.GetColumnWidth(nCol) );
		anParams.Add( m_Grid.GetItemData(0,nCol) );
	}
	if( ! pDlg->ExportBegin( astrColumn, anWidth, TRUE )
		|| ! pDlg->ExportOpenTable( time, TRUE ) )
		return;

	container.Lock();

	// set Item
	int	nCount = 0, nTotalCount = 0;
	if( pDlg->m_bItemAll )
	{
		nTotalCount	=	m_Grid.GetRowCount()-1;
		pDlg->SetProgressRange( 0, nTotalCount );
		for( int nRow=1; nRow<m_Grid.GetRowCount(); nRow++ )
		{
			CStringArray	astrItemText;
			astrItemText.SetSize( 0, nColumnCount+1 );
			LPARAM	id	=	m_Grid.GetItemData(nRow,0);
			CStockInfo & info	=	container.GetStockInfoByID(id);
			for(nCol=0; nCol<anParams.GetSize(); nCol++ )
			{
				astrItemText.Add( m_Grid.GetItemText( nRow, nCol ) );
			}
			pDlg->ExportAddItem( astrItemText );

			nCount	++;
			pDlg->SetProgress( nCount );
		}
	}
	else if( pDlg->m_bItemSelected )
	{
		nTotalCount	=	m_Grid.GetSelectedCount();
		pDlg->SetProgressRange( 0, nTotalCount );
		for( int nRow=1; nRow<m_Grid.GetRowCount(); nRow++ )
		{
			BOOL	bSelected	=	FALSE;
			for( nCol=0; nCol<m_Grid.GetColumnCount(); nCol ++ )
				bSelected	|=	( m_Grid.GetItemState(nRow,nCol) & GVIS_SELECTED );
			if( !bSelected )
				continue;

			CStringArray	astrItemText;
			astrItemText.SetSize( 0, nColumnCount+1 );
			LPARAM	id	=	m_Grid.GetItemData(nRow,0);
			CStockInfo & info	=	container.GetStockInfoByID(id);
			for(nCol=0; nCol<anParams.GetSize(); nCol++ )
			{
				astrItemText.Add( m_Grid.GetItemText( nRow, nCol ) );
			}
			pDlg->ExportAddItem( astrItemText );

			nCount	++;
			pDlg->SetProgress( nCount );
		}
	}
	else if( pDlg->m_bItemDefine )
	{
		nTotalCount	=	min(m_Grid.GetRowCount()-1,pDlg->m_nItemEnd) - max(1,pDlg->m_nItemBegin) + 1;
		pDlg->SetProgressRange( 0, nTotalCount );
		for( int nRow=max(1,pDlg->m_nItemBegin); nRow<=min(m_Grid.GetRowCount()-1,pDlg->m_nItemEnd); nRow++ )
		{
			CStringArray	astrItemText;
			astrItemText.SetSize( 0, nColumnCount+1 );
			LPARAM	id	=	m_Grid.GetItemData(nRow,0);
			CStockInfo & info	=	container.GetStockInfoByID(id);
			for(nCol=0; nCol<anParams.GetSize(); nCol++ )
			{
				astrItemText.Add( m_Grid.GetItemText( nRow, nCol ) );
			}
			pDlg->ExportAddItem( astrItemText );

			nCount	++;
			pDlg->SetProgress( nCount );
		}
	}

	container.UnLock();

	pDlg->ExportFinish( );
}
Exemple #7
0
void CMultiSort::DrawMultiSort( CDC * pDC, CSPDWordArray &adwSortID, CRect rect, UINT nSLH, int nSelectPos )
{
	DECLARE_COLOR_DEFINATION

	int	x	=	rect.left+8;
	int	x2	=	(int)( rect.left+0.56*rect.Width() );
	int	x3	=	rect.right-8;
	int	y	=	rect.top+20;
	int	yStep	=	(rect.Height()-23) / 6 ;
	if( yStep <= 0 )
		return;
	
	CFont	* pOldFont	=	AfxSelectDCFont( pDC, 14 );
	pDC->SetBkColor( clrBK );

	for( int i=0; i<adwSortID.GetSize(); i++ )
	{
		if( (int)adwSortID[i] < 0 || (int)adwSortID[i] >= AfxGetStockContainer().GetSize() )
			continue;

		CStockInfo	& info	=	AfxGetStockContainer().ElementAt(adwSortID[i]);

		pDC->SetTextColor( clrText );
//#ifdef	CLKLAN_ENGLISH_US
//		pDC->TextOut( x, y, info.GetStockCode() );
//#else
		pDC->TextOut( x, y, info.GetStockName() );
//#endif

		UINT nOldAlign = pDC->SetTextAlign( TA_RIGHT | TA_TOP );
		pDC->SetTextColor( AfxGetVariantColor(SLH_CLOSE,info) );
		pDC->TextOut( x2, y, (LPCTSTR)AfxGetVariantDispString(SLH_CLOSE,info,NULL) );

		pDC->SetTextColor( AfxGetVariantColor(nSLH,info) );
		if( SLH_RATIO_VOLUME == nSLH )
		{
			double	dVolRatio	=	1;
			CSPTime	tTrade;
			if( AfxGetVariantValue(nSLH,info,&dVolRatio,NULL)
				&& tTrade.FromStockTimeDay( info.m_datetech ) )
				dVolRatio = dVolRatio / CSPTime::GetTimeTradeRatioOfOneDay( tTrade, CSPTime::GetCurrentTime() );

			CString	strTemp;
			strTemp.Format( "%.2f", dVolRatio );
			pDC->TextOut( x3, y, strTemp );
		}
		else
		{
			pDC->TextOut( x3, y, (LPCTSTR)AfxGetVariantDispString(nSLH,info,NULL) );
		}

		y	+=	yStep;
		pDC->SetTextAlign( nOldAlign );

		// 选中股票
		if( nSelectPos == i )
		{
			int	ySel = y-yStep+16;
			if( ySel > rect.top && ySel < rect.bottom )
				DrawLine( pDC, 2, clrBorder, rect.left+5, ySel, rect.right-5, ySel );
		}
	}

	// 补足股票排名
	for( i=adwSortID.GetSize(); i<6; i++ )
	{
		pDC->SetTextColor( clrText );
		pDC->TextOut( x, y, "-" );

		UINT nOldAlign = pDC->SetTextAlign( TA_RIGHT | TA_TOP );
		pDC->TextOut( x2, y, "-" );

		pDC->TextOut( x3, y, "-" );

		y	+=	yStep;
		pDC->SetTextAlign( nOldAlign );
	}

	pDC->SelectObject( pOldFont );
}
DWORD CSPTime::GetStockTimeNext( DWORD dwDate, int ktype, DWORD dwYear )
{
	CSPTime	sptime;
	if( ktype == ktypeDay )
	{
		if( !sptime.FromStockTimeDay( dwDate ) )
			return -1;
		if( 6 == sptime.GetDayOfWeek() )	//	Friday
			sptime	+=	CSPTimeSpan(3,0,0,0);
		else
			sptime	+=	CSPTimeSpan(1,0,0,0);
		return sptime.ToStockTimeDay();
	}
	else if( ktype == ktypeWeek )
	{
		if( !sptime.FromStockTimeDay( dwDate ) )
			return -1;
		sptime	+=	CSPTimeSpan(7,0,0,0);
		return sptime.ToStockTimeDay();
	}
	else if( ktype == ktypeMonth )
	{
		if( !sptime.FromStockTimeDay( dwDate ) )
			return -1;
		int	nYearNew	=	sptime.GetYear();
		int nMonthNew	=	sptime.GetMonth();
		nYearNew	=	( nMonthNew >= 12 ? nYearNew+1 : nYearNew );
		nMonthNew	=	( nMonthNew >= 12 ? 1 : nMonthNew+1 );
		CSPTime	sptime2( nYearNew, nMonthNew, sptime.GetDay(), sptime.GetHour(),sptime.GetMinute(), sptime.GetSecond() );

		if( 6 == sptime2.GetDayOfWeek() )	//	Friday
			sptime2	+=	CSPTimeSpan(3,0,0,0);
		else
			sptime2	+=	CSPTimeSpan(1,0,0,0);
		return sptime2.ToStockTimeDay();
	}
	else if( ktype == ktypeMin5 )
	{
		if( !sptime.FromStockTimeMin( dwDate ) )
			return -1;
		if( sptime.GetHour() == 11 && sptime.GetMinute() >= 25 )
			sptime	+=	CSPTimeSpan(0,1,35,0);
		else if( sptime.GetHour() == 14 && sptime.GetMinute() >= 55 )
			sptime	+=	CSPTimeSpan(0,18,35,0);
		else
			sptime	+=	CSPTimeSpan(0,0,5,0);
		return sptime.ToStockTimeMin();
	}
	else if( ktype == ktypeMin15 )
	{
		if( !sptime.FromStockTimeMin( dwDate ) )
			return -1;
		if( sptime.GetHour() == 11 && sptime.GetMinute() >= 15 )
			sptime	+=	CSPTimeSpan(0,1,45,0);
		else if( sptime.GetHour() == 14 && sptime.GetMinute() >= 45 )
			sptime	+=	CSPTimeSpan(0,18,45,0);
		else
			sptime	+=	CSPTimeSpan(0,0,15,0);
		return sptime.ToStockTimeMin();
	}
	else if( ktype == ktypeMin30 )
	{
		if( !sptime.FromStockTimeMin( dwDate ) )
			return -1;
		if( sptime.GetHour() == 11 && sptime.GetMinute() >= 0 )
			sptime	+=	CSPTimeSpan(0,2,0,0);
		else if( sptime.GetHour() == 14 && sptime.GetMinute() >= 30 )
			sptime	+=	CSPTimeSpan(0,19,0,0);
		else
			sptime	+=	CSPTimeSpan(0,0,30,0);
		return sptime.ToStockTimeMin();
	}
	else if( ktype == ktypeMin60 )
	{
		if( !sptime.FromStockTimeMin( dwDate ) )
			return -1;
		if( (sptime.GetHour() == 10 && sptime.GetMinute() >= 30) || sptime.GetHour() == 11 )
			sptime	+=	CSPTimeSpan(0,2,30,0);
		else if( sptime.GetHour() == 14 && sptime.GetMinute() >= 0 )
			sptime	+=	CSPTimeSpan(0,19,30,0);
		else
			sptime	+=	CSPTimeSpan(0,1,0,0);
		return sptime.ToStockTimeMin();
	}
	else
	{
		ASSERT( FALSE );
		return -1;
	}
}