⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 setdrdatadlg.cpp.svn-base

📁 股票软件源码
💻 SVN-BASE
📖 第 1 页 / 共 2 页
字号:
	StoreDrdata( m_strCurStockCode );
	AfxGetStaticDoc()->UpdateAllViews( NULL, UPDATE_HINT_GRAPHVIEW, NULL );

	return CPropertyPageEx::OnKillActive();
}

void CSetDrdataDlg::OnOK() 
{
	StoreDrdata( m_strCurStockCode );
	AfxGetStaticDoc()->UpdateAllViews( NULL, UPDATE_HINT_GRAPHVIEW, NULL );

	CPropertyPageEx::OnOK();
}

void CSetDrdataDlg::OnCancel() 
{
	StoreDrdata( m_strCurStockCode );
	AfxGetStaticDoc()->UpdateAllViews( NULL, UPDATE_HINT_GRAPHVIEW, NULL );

	CPropertyPageEx::OnOK();
}

void CSetDrdataDlg::OnChangeEditcode() 
{
	// TODO: If this is a RICHEDIT control, the control will not
	// send this notification unless you override the CPropertyPageEx::OnInitDialog()
	// function and call CRichEditCtrl().SetEventMask()
	// with the ENM_CHANGE flag ORed into the mask.
	
	// TODO: Add your control notification handler code here
	CString	strText;
	m_editCode.GetWindowText( strText );
	strText.TrimLeft();
	strText.TrimLeft();
	if( strText.GetLength() > 0 )
	{
		int	nSel	=	m_comboGroupSrc.GetCurSel();
		if( CB_ERR == nSel ||
			CStockContainer::typeAll != (int)(m_comboGroupSrc.GetItemData( nSel )) )
		{
			m_comboGroupSrc.SelectGroupAll( );
			OnSelchangeComboGroupsrc();
		}
	}
	if( !m_listStockSrc.SelectCode( 0, strText ) )
		m_listStockSrc.SelectShortname( 0, strText );
	OnSelchangeListStocksrc( );
}

void CSetDrdataDlg::OnSelchangeComboGroupsrc() 
{
	// TODO: Add your control notification handler code here
	int nType = m_comboGroupSrc.GetCurSelType();
	CString strName = m_comboGroupSrc.GetCurSelName();
	m_listStockSrc.SetCurrentStocks( nType, strName, AfxGetGroupContainer() );
}

BOOL CSetDrdataDlg::PreTranslateMessage(MSG* pMsg) 
{
	// TODO: Add your specialized code here and/or call the base class
	if( WM_KEYDOWN == pMsg->message )
	{
		if( VK_UP == pMsg->wParam )
		{
			if( ::GetFocus() == m_editCode.GetSafeHwnd() )
			{
				m_listStockSrc.SelectUp( );
				OnSelchangeListStocksrc( );
				return TRUE;
			}
		}
		else if( VK_DOWN == pMsg->wParam )
		{
			if( ::GetFocus() == m_editCode.GetSafeHwnd() )
			{
				m_listStockSrc.SelectDown( );
				OnSelchangeListStocksrc( );
				return TRUE;
			}
		}
		else if( VK_PRIOR == pMsg->wParam )
		{
			if( ::GetFocus() == m_editCode.GetSafeHwnd() )
			{
				m_listStockSrc.SelectPrior( );
				OnSelchangeListStocksrc( );
				return TRUE;
			}
		}
		else if( VK_NEXT == pMsg->wParam )
		{
			if( ::GetFocus() == m_editCode.GetSafeHwnd() )
			{
				m_listStockSrc.SelectNext( );
				OnSelchangeListStocksrc( );
				return TRUE;
			}
		}
		else if( VK_RETURN == pMsg->wParam )
		{
			if( ::GetFocus() == m_editCode.GetSafeHwnd() )
			{
				m_editCode.SetWindowText( NULL );
				return TRUE;
			}
		}
	}
	
	return CPropertyPageEx::PreTranslateMessage(pMsg);
}

void CSetDrdataDlg::OnSelchangeListStocksrc() 
{
	// TODO: Add your control notification handler code here
	HWND hWndFocus = ::GetFocus( );
	int	nSel	=	m_listStockSrc.GetCurSel( );

	StoreDrdata( m_strCurStockCode );

	if( LB_ERR != nSel )
	{
		CString	rString, strStockCode;
		m_listStockSrc.GetText(nSel,rString);
		int	nIndex	=	rString.Find( '(' );
		if( -1 != nIndex )
			strStockCode	=	rString.Left( nIndex );

		m_staticStock.SetWindowText( rString );

		m_strCurStockCode	=	strStockCode;
		LoadDrdata( m_strCurStockCode );
	}
	else
	{
		m_Grid.DeleteNonFixedRows();
		m_Grid.Invalidate( );

		CString	strNoStock;
		strNoStock.LoadString( IDS_SETDRDATA_NOSTOCK );
		m_staticStock.SetWindowText( strNoStock );
		m_strCurStockCode.Empty();
	}

	m_btnInsert.EnableWindow( m_strCurStockCode.GetLength() > 0 );
	m_btnDelete.EnableWindow( m_strCurStockCode.GetLength() > 0 );
	::SetFocus( hWndFocus );
}

void CSetDrdataDlg::OnInsert() 
{
	// TODO: Add your control notification handler code here
	UpdateData( );

	CString	strNewDate	=	FormatDate( m_tmDrdata );
	if( m_strCurStockCode.GetLength() > 0 )
	{
		CStringArray	astr;
		astr.SetSize( SETDR_COLUMN_COUNT );
		astr.ElementAt(0)	=	strNewDate;
		astr.ElementAt(1).Format( "%.3f", 0. );
		astr.ElementAt(2).Format( "%.2f", 0. );
		astr.ElementAt(3).Format( "%.2f", 0. );
		astr.ElementAt(4).Format( "%.3f", 0. );
		
		int nRow = m_Grid.InsertRow( strNewDate );
		for( int nCol=1; nCol<SETDR_COLUMN_COUNT; nCol++ )
		{
			GV_ITEM item;
			item.mask = GVIF_TEXT|GVIF_FORMAT;
			item.nFormat = DT_CENTER|DT_VCENTER|DT_SINGLELINE;
			item.row = nRow;
			item.col = nCol;
			item.szText	=	astr[nCol];
			m_Grid.SetItem(&item);
		}
	}
	m_Grid.Invalidate( );
}

void CSetDrdataDlg::OnDelete() 
{
	// TODO: Add your control notification handler code here

	for( int nRow=m_Grid.GetRowCount()-1; nRow >=1; nRow -- )
	{
		for( int nCol=0; nCol<m_Grid.GetColumnCount(); nCol ++ )
		{
			if( m_Grid.GetItemState(nRow,nCol) & GVIS_SELECTED )
			{
				m_Grid.DeleteRow( nRow );
				int	nRowNext	=	-1;
				if( nRow < m_Grid.GetRowCount() )
					nRowNext	=	nRow;
				else if( nRow-1 >= 1 && nRow-1 < m_Grid.GetRowCount() )
					nRowNext	=	nRow -1;
				if( nRowNext != -1 )
				{
					for( int nColTemp=0; nColTemp<m_Grid.GetColumnCount(); nColTemp ++ )
						m_Grid.SetItemState(nRowNext,nColTemp,m_Grid.GetItemState(nRowNext,nColTemp) | GVIS_SELECTED);
				}
				m_Grid.Invalidate( );
				return;
			}
		}
	}
}

BOOL CALLBACK ImportDRCallback(DWORD dwCode, DWORD dwProgress,
							LPCTSTR lpszMsg, void *cookie)
{
	HWND	hMainWnd	=	(HWND)cookie;

	if( PROG_PROGRESS == dwCode && ::IsWindow(hMainWnd) )
	{
		::SendMessage( hMainWnd, WM_USER_WAITPROGRESS, dwProgress, (LPARAM)lpszMsg );
	}

	return TRUE;
}

void CSetDrdataDlg::OnImport() 
{
	CNetDatabase	netdb;
	if( !netdb.SetRootPath( AfxGetProfile().GetSelfDBPath(), IStStore::dbtypeSelfDB ) )
	{
		AfxMessageBox( IDS_ROOTPATH_ERROR, MB_OK | MB_ICONINFORMATION );
		return;
	}

	CKSFileDialog dlg (TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_ENABLESIZING,
		"XDR Data files (*.zip,*.dat)|*.zip;*.dat|All files (*.*)|*.*||", NULL);
	if( IDOK == dlg.DoModal() )
	{
		CString	sFileName	=	dlg.GetPathName();
		if( sFileName.GetLength() <= 0 || 0 != access(sFileName,0) )
		{
			AfxMessageBox( IDS_SETDRDATA_FILENOTEXISTS, MB_OK|MB_ICONINFORMATION );
			return;
		}
		
		CWaitDlg	waitdlg( NULL, FALSE );
		waitdlg.SetProgressRange( 0, STKLIB_MAX_PROGRESS );

		CPackage	pac;
		pac.m_nType		=	CPackage::packageDR;
		pac.m_bIsZipped	=	( sFileName.GetLength() > 4 && 0 == sFileName.Right(4).CompareNoCase(".zip") );
		pac.m_strDescript	=	sFileName;
		if( netdb.InstallPackageEx( pac, sFileName, ImportDRCallback, waitdlg.GetSafeHwnd() ) )
			AfxMessageBox( IDS_SETDRDATA_INSTALLOK, MB_OK|MB_ICONINFORMATION );
		else
			AfxMessageBox( IDS_SETDRDATA_INSTALLFAIL, MB_OK|MB_ICONINFORMATION );

		AfxGetStaticDoc()->UpdateAllViews( NULL, UPDATE_HINT_GRAPHVIEW, NULL );
	}
}

void CSetDrdataDlg::OnImportfxj() 
{
	CNetDatabase	netdb;
	if( !netdb.SetRootPath( AfxGetProfile().GetSelfDBPath(), IStStore::dbtypeSelfDB ) )
	{
		AfxMessageBox( IDS_ROOTPATH_ERROR, MB_OK | MB_ICONINFORMATION );
		return;
	}

	CKSFileDialog dlg (TRUE, NULL, NULL, OFN_HIDEREADONLY | OFN_FILEMUSTEXIST | OFN_EXPLORER | OFN_ENABLESIZING,
		"Fxj Power files (*.zip,*.pwr)|*.zip;*.pwr|All files (*.*)|*.*||", NULL);
	if( IDOK == dlg.DoModal() )
	{
		CString	sFileName	=	dlg.GetPathName();
		if( sFileName.GetLength() <= 0 || 0 != access(sFileName,0) )
		{
			AfxMessageBox( IDS_SETDRDATA_FILENOTEXISTS, MB_OK|MB_ICONINFORMATION );
			return;
		}
		
		CPackage	pac;
		pac.m_nType		=	CPackage::packageDR;
		pac.m_bIsZipped	=	( sFileName.GetLength() > 4 && 0 == sFileName.Right(4).CompareNoCase(".zip") );
		pac.m_strDescript	=	sFileName;
		if( netdb.InstallPackageEx( pac, sFileName, NULL, NULL ) )
			AfxMessageBox( IDS_SETDRDATA_INSTALLOK, MB_OK|MB_ICONINFORMATION );
		else
			AfxMessageBox( IDS_SETDRDATA_INSTALLFAIL, MB_OK|MB_ICONINFORMATION );

		AfxGetStaticDoc()->UpdateAllViews( NULL, UPDATE_HINT_GRAPHVIEW, NULL );
	}
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -