sjshqdlg.cpp

来自「一个通过PCI卡向LED屏发送股票实时行情的系统」· C++ 代码 · 共 1,155 行 · 第 1/3 页

CPP
1,155
字号
				break;
			case IDC_BUTTON3:		//显示字幕
				{
					DlgButtonID=0;
					//刷新提示栏
					int butID=GetCheckedRadioButton(IDC_RADIO1,IDC_GUOZHAI_RADIO);
					if(butID==IDC_RADIO1)
					{
						m_GetDatabase.m_sNewGuAlarm="";
						pedit->SetWindowText("显示公告");
					}
					else if(butID==IDC_RADIO2)
					{
						CString temp;
						m_GetDatabase.m_sNewGuAlarm="";
						pedit->GetWindowText(temp);
						int index=temp.Find(':');
						if(index==-1)
							pedit->SetWindowText("h:/dpm/zm/zmbmp1");
					}
					else
					{
						m_GetDatabase.m_sNewGuAlarm="";
						pedit->SetWindowText("显示国债");
					}
					if(!bchange)
					{
						//起来显示字幕线程
						if(!m_ZMThread)
						{
							m_ZMThread=AfxBeginThread(OnDisplayZM,(LPVOID)this,
								THREAD_PRIORITY_NORMAL,0,0,NULL);
							writeled.ClearAddress();
						}
						bchange=TRUE;
					}
					else
					{
						m_GetDatabase.m_sNewGuAlarm="";
						pedit->SetWindowText("退出显示公告");
						//关闭字幕线程
						if(m_ZMThread)
						{
							::TerminateThread(m_ZMThread->m_hThread,0);
							m_ZMThread=NULL;
						}
						bchange=FALSE;
					}
				}
				break;
			case IDC_BUTTON4:		//显示时间
				{
					//刷新提示栏
					m_GetDatabase.m_sNewGuAlarm="";
					pedit->SetWindowText("显示时间");
					OnButton4();
				}
				break;
			case IDC_BUTTON5:		//显示开市钟
				{
					//刷新提示栏
					m_GetDatabase.m_sNewGuAlarm="";
					pedit->SetWindowText("显示开市钟提示");
					OnButton5();
				}
				break;
			case IDC_BUTTON6:		//显示新股
				{
					//刷新提示栏
					pedit->SetWindowText("显示新股 "+m_GetDatabase.m_sNewGuAlarm);
					OnShowNewStock();
				}
				break;
			case IDC_BUTTON7:		//自动运行
				{
					DlgButtonID=0; 
					if(!bAutoRun)	bAutoRun=1;
					else			
					{//刷新提示栏
						m_GetDatabase.m_sNewGuAlarm="";
						pedit->SetWindowText("退出自动运行!");
						bAutoRun=0;
					}
				}
				break;
		}
		if(bAutoRun)	
			CallAutoRun();	
	}
	CDialog::OnTimer(nIDEvent);
}

void CSjshqDlg::CallAutoRun()
{
	CString str;
	TCHAR buf[256];
	CEdit* pedit=(CEdit*)GetDlgItem(IDC_ZM_BMP_PATH);

	VERIFY(GetTimeFormat(LOCALE_SYSTEM_DEFAULT,0,NULL,"HH:mm:ss",buf,256));
	str=buf;
	if(str>=theApp.Time1&&str<theApp.Time2)			
	{//显示字幕线程
		//刷新提示栏
		int butID=GetCheckedRadioButton(IDC_RADIO1,IDC_GUOZHAI_RADIO);
		if(butID==IDC_RADIO1)
		{
			m_GetDatabase.m_sNewGuAlarm="";
			pedit->SetWindowText("自动运行:显示公告");
		}
		else if(butID==IDC_RADIO2)
		{
			CString temp;
			m_GetDatabase.m_sNewGuAlarm="";
			pedit->GetWindowText(temp);
			int index=temp.Find(':');
			if(index==-1)
				pedit->SetWindowText("h:/dpm/zm/zmbmp1");
		}
		else if(butID==IDC_GUOZHAI_RADIO)
		{
			m_GetDatabase.m_sNewGuAlarm="";
			pedit->SetWindowText("自动运行:显示国债");
		}

		if(!m_ZMThread)
		{
			m_ZMThread=AfxBeginThread(OnDisplayZM,(LPVOID)this,
				THREAD_PRIORITY_NORMAL,0,0,NULL);
			writeled.ClearAddress();
		}
	}
	else
	{
		//关闭字幕线程
		if(m_ZMThread)
		{
			::TerminateThread(m_ZMThread->m_hThread,0);
			m_ZMThread=NULL;
		}
		if(str>=theApp.Time2&&str<theApp.Time3)
		{
			//刷新提示栏
			m_GetDatabase.m_sNewGuAlarm="";
			pedit->SetWindowText("自动运行:显示时间");
			OnButton4();			//显示时间
		}
		else if(str>=theApp.Time3&&str<theApp.Time4)
		{
			//刷新提示栏
			m_GetDatabase.m_sNewGuAlarm="";
			pedit->SetWindowText("自动运行:显示开市钟提示");
			OnButton5();				//显示开市钟
		}
		else if(str>=theApp.Time4&&str<theApp.Time5)	/////////////////
		{//假如无新股或所有设置的新股都不存在直接进入显示行情状态
			static BOOL bIsBack=FALSE;	//状态回逆否
			if((m_GetDatabase.m_nNoExistNewGuCount==m_GetDatabase.m_NewStockNum)||(m_GetDatabase.m_NewStockNum==0))
			{
				pedit->SetWindowText("自动运行:显示行情 "+m_GetDatabase.m_sNewGuAlarm);
				OnRunBtn();				//显示行情
				bIsBack=TRUE;
			}
			else
			{
				if(bIsBack)			{writeled.ClearAddress();	bIsBack=FALSE;}	
				pedit->SetWindowText("自动运行:显示新股 "+m_GetDatabase.m_sNewGuAlarm);
				OnShowNewStock();       //显示新股
			}
		}
		else if((str>=theApp.Time5)||(str<theApp.Time1))				
		{
			pedit->SetWindowText("自动运行:显示行情 "+m_GetDatabase.m_sNewGuAlarm);
			OnRunBtn();					//显示行情
		}
	}

}
void CSjshqDlg::OnBrush_BlueColor()
{
	pDC->FillSolidRect(CRect(0,0,1024,704),RGB(0,0,255));
}

void CSjshqDlg::OnCreate_AllKindsOfFonts()
{
    int		FontWidth;
	LOGFONT lp;
	lp.lfCharSet=DEFAULT_CHARSET;
	lp.lfEscapement=0;
	lp.lfUnderline=0;
	lp.lfItalic=0;
	lp.lfStrikeOut=0;

	FontWidth=80;
	lp.lfHeight=FontWidth-4;
	lp.lfWidth=FontWidth/2;
	lp.lfWeight=500;
	strcpy(lp.lfFaceName,"黑体");
	mTxtTitleFnt=new CFont;
	mTxtTitleFnt->CreateFontIndirect(&lp);

	FontWidth=78;
	lp.lfHeight=FontWidth-4;
	lp.lfWidth=FontWidth/2;
	lp.lfWeight=500;
	strcpy(lp.lfFaceName,"宋体");
	mTxt1Fnt=new CFont;
	mTxt1Fnt->CreateFontIndirect(&lp);//mTxt1Fnt

	FontWidth=56;
	lp.lfHeight=FontWidth-4;
	lp.lfWidth=FontWidth/2;
	strcpy(lp.lfFaceName,"宋体");
	mTxt2Fnt=new CFont;
	mTxt2Fnt->CreateFontIndirect(&lp);//mTxt2Fnt

	FontWidth=36;
	lp.lfHeight=FontWidth;
	lp.lfWidth=FontWidth/2;
	strcpy(lp.lfFaceName,"宋体");
	mTxt3Fnt=new CFont;
	mTxt3Fnt->CreateFontIndirect(&lp);//mTxt3Fnt

	FontWidth=48;
	lp.lfHeight=FontWidth;
	lp.lfWidth=FontWidth/2;
	strcpy(lp.lfFaceName,"楷体_GB2312");
	mhq_TitleFnt=new CFont;
	mhq_TitleFnt->CreateFontIndirect(&lp);

	FontWidth=32;
	lp.lfHeight=FontWidth;
	lp.lfWidth=FontWidth/2;
	strcpy(lp.lfFaceName,"黑体");
	mhq_ABFnt=new CFont;
	mhq_ABFnt->CreateFontIndirect(&lp);

//	FontWidth=32;
	lp.lfHeight=FontWidth;
	lp.lfWidth=FontWidth/2;
	strcpy(lp.lfFaceName,"黑体");
	mhq_GNameFnt=new CFont;
	mhq_GNameFnt->CreateFontIndirect(&lp);

	FontWidth=24;
 	lp.lfHeight=FontWidth;
	lp.lfWidth=FontWidth/2;
	strcpy(lp.lfFaceName,"黑体");
	mhq_TimeFnt=new CFont;
	mhq_TimeFnt->CreateFontIndirect(&lp);

//	FontWidth=24;
 	lp.lfHeight=FontWidth;
	lp.lfWidth=FontWidth/2;
	strcpy(lp.lfFaceName,"楷体_GB2312");
	mhq_ExpFnt=new CFont;
	mhq_ExpFnt->CreateFontIndirect(&lp);

	FontWidth=180;
	lp.lfHeight=FontWidth;
	lp.lfWidth=FontWidth/2;
	strcpy(lp.lfFaceName,"楷体_GB2312");
	mBellFnt=new CFont;
	mBellFnt->CreateFontIndirect(&lp);

	FontWidth=88;
	lp.lfHeight=FontWidth;
	lp.lfWidth=FontWidth/2;
	strcpy(lp.lfFaceName,"楷体_GB2312");
	mNewStockFnt=new CFont;
	mNewStockFnt->CreateFontIndirect(&lp);
	
	FontWidth=88;
	lp.lfHeight=FontWidth;
	lp.lfWidth=FontWidth/2;
	strcpy(lp.lfFaceName,"黑体");
	mNewStockTitleFnt=new CFont;
	mNewStockTitleFnt->CreateFontIndirect(&lp);
}

void CSjshqDlg::OnDelete_AllKindsOfFonts()
{
	mTxtTitleFnt->DeleteObject();
	delete mTxtTitleFnt;
	mTxt1Fnt->DeleteObject();
	delete mTxt1Fnt;
	mTxt2Fnt->DeleteObject();
	delete mTxt2Fnt;
	mTxt3Fnt->DeleteObject();
	delete mTxt3Fnt;

	mhq_TitleFnt->DeleteObject();
	delete mhq_TitleFnt;
	mhq_ABFnt->DeleteObject();
	delete mhq_ABFnt;
	mhq_GNameFnt->DeleteObject();
	delete mhq_GNameFnt;
	mhq_TimeFnt->DeleteObject();
	delete mhq_TimeFnt;
	mhq_ExpFnt->DeleteObject();
	delete mhq_ExpFnt;
	mBellFnt->DeleteObject();
	delete mBellFnt;
	mNewStockFnt->DeleteObject();
	delete mNewStockFnt;
	mNewStockTitleFnt->DeleteObject();
	delete mNewStockTitleFnt;
}

void CSjshqDlg::OnShowNewStock() 
{
	int m_pos,m_pos1;
	CString  m_str1=" 证券名称 最近价 升跌幅  ";
    LPCTSTR  lpszSQL="SELECT * FROM sjshq";	
    m_GetDatabase.GetNewStock(lpszSQL);//读数据库

	int      temp_int=m_GetDatabase.m_NewStockNum-m_GetDatabase.m_nNoExistNewGuCount;
	m_FntOld=pDC->SelectObject(mNewStockTitleFnt);
	m_pos=(704-(m_GetDatabase.m_NewStockNum-m_GetDatabase.m_nNoExistNewGuCount+1)*88)/2;

	pDC->FillSolidRect(CRect(0,0,1024,m_pos*3/4),RGB(0,0,255));
	pDC->FillSolidRect(CRect(0,m_pos*3/4+88,1024,m_pos+88),RGB(0,0,255));
	pDC->FillSolidRect(CRect(0,(temp_int+1)*88+m_pos,1024,710),RGB(0,0,255));

	pDC->SetBkColor(RGB(0,0,255));
 	pDC->SetTextColor(RGB(255,255,0));
	pDC->TextOut(-20,m_pos*3/4,m_str1);//标题

	pDC->SelectObject(mNewStockFnt);
	pDC->SetTextColor(RGB(255,0,0));
    for(int i=0;i<temp_int;i++)
	{
		m_pos1=m_pos+(i+1)*88;
		pDC->TextOut(-20,m_pos1," "+m_GetDatabase.m_NewStockStr[i]+" ");/////////
	}
 	pDC->SelectObject(m_FntOld);
}



HBRUSH CSjshqDlg::OnCtlColor(CDC* pDC, CWnd* pWnd, UINT nCtlColor) 
{
	HBRUSH hbr = CDialog::OnCtlColor(pDC, pWnd, nCtlColor);
	
	// TODO: Change any attributes of the DC here
	if((pWnd->GetDlgCtrlID()==IDC_ZM_BMP_PATH)&&(!m_GetDatabase.m_sNewGuAlarm.IsEmpty()))
	{
		pDC->SetBkMode(TRANSPARENT);
//		pDC->SetBkColor(RGB(0,0,255));
		pDC->SetTextColor(RGB(255,0,0));
//		return (HBRUSH)m_brush.GetSafeHandle();
	}
//	else
	
	// TODO: Return a different brush if the default is not desired
	return hbr;
}

void CSjshqDlg::OnGuozhaiRadio() 
{
	// TODO: Add your control notification handler code here
	CEdit* pedit=(CEdit*)GetDlgItem(IDC_ZM_BMP_PATH);
	//刷新提示栏
	m_GetDatabase.m_sNewGuAlarm="";
	pedit->SetWindowText("显示国债");
	
}

void CSjshqDlg::OnRadio1() 
{
	// TODO: Add your control notification handler code here
	CEdit* pedit=(CEdit*)GetDlgItem(IDC_ZM_BMP_PATH);
	//刷新提示栏
	m_GetDatabase.m_sNewGuAlarm="";
	pedit->SetWindowText("显示公告");	
}

void CSjshqDlg::OnRadio2() 
{
	// TODO: Add your control notification handler code here
	CEdit* pedit=(CEdit*)GetDlgItem(IDC_ZM_BMP_PATH);
	//刷新提示栏
	m_GetDatabase.m_sNewGuAlarm="";
	pedit->SetWindowText("h:/dpm/zm/zmbmp1");	
}

⌨️ 快捷键说明

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