sjshqdlg.cpp
来自「一个通过PCI卡向LED屏发送股票实时行情的系统」· C++ 代码 · 共 1,155 行 · 第 1/3 页
CPP
1,155 行
CString m_str3="深圳证券交易所实时行情";
CString m_str4="";
CString m_str5="A股行情";
CString m_str6="B股、基金行情";
int length;
CTime tm;
LPCTSTR lpszSQL="SELECT * FROM sjshq";
tm=tm.GetCurrentTime();
m_str4.Format(_T("%4d年%2d月%2d日 %02d:%02d:%02d"),tm.GetYear(),tm.GetMonth(),tm.GetDay(),tm.GetHour(),tm.GetMinute(),tm.GetSecond());
////////////////////////处理大屏汉字到m_pMemDC中
m_FntOld=m_pMemDC->SelectObject(mhq_TitleFnt);
m_pMemDC->SetBkColor(RGB(0,0,0));
m_pMemDC->SetTextColor(RGB(255,255,0));
m_pMemDC->SetTextCharacterExtra(6);
m_pMemDC->TextOut(472,10,m_str3);
m_pMemDC->SetTextCharacterExtra(0);
m_pMemDC->SelectObject(m_FntOld);
////////////////////////处理时间到m_pMemDC中
m_FntOld=(CFont*)m_pMemDC->SelectObject(mhq_TimeFnt);
m_pMemDC->SetBkColor(RGB(0,0,0));
m_pMemDC->SetTextColor(RGB(255,255,0));
length=m_str4.GetLength();
length=(1536-length*12)/2;
m_pMemDC->TextOut(length,64,m_str4);
m_pMemDC->SelectObject(m_FntOld);
////////////////////////处理指数到m_pMemDC中
m_GetDatabase.GetDataCjl(lpszSQL);;
m_GetDatabase.GetHotStock(lpszSQL);;
m_FntOld=(CFont*)m_pMemDC->SelectObject(mhq_ExpFnt);
m_pMemDC->SetBkColor(RGB(0,0,0));
m_pMemDC->SetTextColor(RGB(255,255,0));
CString temp;
m_pMemDC->FillSolidRect(CRect(454,370,440+640,370+24),RGB(0,0,0));////////////////////
m_pMemDC->FillSolidRect(CRect(454,674,440+640,674+24),RGB(0,0,0));////////////////////
temp.Format(_T("成份指数: 成交金额:%7.2f亿元"),(m_GetDatabase.AGu_cjl1+m_GetDatabase.AGu_cjl2)/10000.0);
length=temp.GetLength();
length=(640-length*12)/2+448;
m_pMemDC->TextOut(length,370,temp);
if(m_GetDatabase.m_CFExp_Color==1)
m_pMemDC->SetTextColor(RGB(255,0,0));
else if(m_GetDatabase.m_CFExp_Color==2)
m_pMemDC->SetTextColor(RGB(0,255,0));
else
m_pMemDC->SetTextColor(RGB(255,255,0));
m_pMemDC->TextOut(length+110,370,m_GetDatabase.m_CFExp);
m_pMemDC->SetTextColor(RGB(255,255,0));
temp.Format(_T("B股成指: 成交金额:%7.2f亿元"),m_GetDatabase.BGu_cjl/10000.0);
length=temp.GetLength();
length=(640-length*12)/2+448;
m_pMemDC->TextOut(length,674,temp);
if(m_GetDatabase.m_BGExp_Color==1)
m_pMemDC->SetTextColor(RGB(255,0,0));
else if(m_GetDatabase.m_BGExp_Color==2)
m_pMemDC->SetTextColor(RGB(0,255,0));
else
m_pMemDC->SetTextColor(RGB(255,255,0));
m_pMemDC->TextOut(length+110,674,m_GetDatabase.m_BGExp);
m_pMemDC->SelectObject(m_FntOld);
//////////////Show title
m_FntOld=(CFont*)m_pMemDC->SelectObject(mhq_ABFnt);
m_pMemDC->SetBkColor(RGB(0,0,0));
m_pMemDC->SetTextColor(RGB(255,255,0));
m_pMemDC->TextOut(0,90,m_str1);
m_pMemDC->TextOut(1088,90,m_str2);
length=(448-m_str5.GetLength()*16)/2+32;
m_pMemDC->TextOut(length,44,m_str5);
length=(448-m_str5.GetLength()*16)/2;
m_pMemDC->TextOut(length+1056,44,m_str6);
m_pMemDC->SetTextColor(RGB(255,0,0));
m_pMemDC->SelectObject(m_FntOld);
}
void CSjshqDlg::OnDestroy()
{
CDialog::OnDestroy();
KillTimer(1);
//关闭线程
if(m_ZMThread)
{
::TerminateThread(m_ZMThread->m_hThread,0);
m_ZMThread=NULL;
}
m_GetDatabase.Close();
// m_pWnd->ReleaseDC(pDC);
m_pMemDC->DeleteDC();
if(m_pMemDC)
delete m_pMemDC;
if(m_pWnd)
delete m_pWnd;
//保存新股代码
OnSaveNewStockToFile();
//删除各种字体
OnDelete_AllKindsOfFonts();
}
void CSjshqDlg::OnSaveNewStockToFile()
{
static char *szProFile="C:\\WINDOWS\\sjshq.ini";
char cTemp[10];
strcpy(cTemp, "NewGu");
for(int i=0;i<m_GetDatabase.m_NewStockNum;i++)
{
itoa(i+1,&cTemp[5],10);
WritePrivateProfileString("NEW_STOCK",cTemp,m_GetDatabase.m_NewStock[i].m_NewStockCode, szProFile);
}
itoa(m_GetDatabase.m_NewStockNum,cTemp,10);
WritePrivateProfileString("NEW_STOCK","NewGuNumber",cTemp, szProFile);
}
void CSjshqDlg::OnButton5()
{
CString m_str1="请敲开市钟!";
CString m_str2=" ";
CTime tm;
m_FntOld=pDC->SelectObject(mBellFnt);
pDC->SetBkColor(RGB(0,0,255));
OnBrush_BlueColor();
pDC->SetTextColor(RGB(255,0,0));
pDC->TextOut(20,250,m_str1);
Sleep(500);
pDC->TextOut(20,250,m_str2);
pDC->SelectObject(m_FntOld);
}
void CSjshqDlg::OnButton4()
{
CString m_str1=" 当前时间 ";
CString m_str2;
CTime tm;
pDC->FillSolidRect(CRect(0,340,1024,390),RGB(0,0,255));//宽481,高7
m_FntOld=pDC->SelectObject(mBellFnt);
pDC->SetBkColor(RGB(0,0,255));
pDC->SetTextColor(RGB(255,255,0));
pDC->TextOut(0,160,m_str1);
pDC->TextOut(0,-20," ");
pDC->TextOut(0,540," ");
tm=tm.GetCurrentTime();
m_str2.Format(_T(" %02d:%02d:%02d "),tm.GetHour(),tm.GetMinute(),tm.GetSecond());
pDC->TextOut(0,380,m_str2);
pDC->SelectObject(m_FntOld);
}
void CSjshqDlg::OnButton1()
{
// TODO: Add your control notification handler code here m_NewStock[kk].m_NewStockCode
CAddNewStock dlg;
dlg.m_NewStockNum=m_GetDatabase.m_NewStockNum;
for(int i=0;i<m_GetDatabase.m_NewStockNum;i++)
strcpy(dlg.m_NewStockCode[i],m_GetDatabase.m_NewStock[i].m_NewStockCode);
if(dlg.DoModal()==IDOK)
{
m_GetDatabase.m_NewStockNum=dlg.m_NewStockNum;
if(m_GetDatabase.m_NewStockNum>7)
m_GetDatabase.m_NewStockNum=7;
for(int i=0;i<m_GetDatabase.m_NewStockNum;i++)
{
strcpy(m_GetDatabase.m_NewStock[i].m_NewStockCode,dlg.m_NewStockCode[i]);
m_GetDatabase.m_NewStock[i].m_bExist=FALSE;
}
}
OnBrush_BlueColor();
}
void CSjshqDlg::GetHangQingToBuf()
{
///////////////////////处理行情部分到redbuf & greenbuf
COLORREF color;
BYTE m_RValue;
BYTE m_GValue;
BYTE m_Temp;
BYTE m_RTemp;
BYTE m_GTemp;
for(int i=7;i<704;i++)
{
for(int j=0;j<32;j++)
{
m_RTemp=0;
m_GTemp=0;
for(int k=0;k<8;k++)
{
m_Temp=0;
color=m_pMemDC->GetPixel(j*8+k,i);
m_RValue=GetRValue(color);
if(m_RValue<=255&&m_RValue>=128)
m_Temp=1;
else
m_Temp=0;
m_RTemp=m_RTemp<<1;
m_RTemp=m_RTemp|m_Temp;
m_GValue=GetGValue(color);
m_Temp=0;
if(m_GValue<=255&&m_GValue>=128)
m_Temp=1;
else
m_Temp=0;
m_GTemp=m_GTemp<<1;
m_GTemp=m_GTemp|m_Temp;
}
writeled.m_redbuf[(i-7)*32+j]=m_RTemp;
writeled.m_greenbuf[(i-7)*32+j]=m_GTemp;
}
for(j=0;j<32;j++)
{
m_RTemp=0;
m_GTemp=0;
for(int k=0;k<8;k++)
{
m_Temp=0;
color=m_pMemDC->GetPixel(j*8+k+1280,i);
m_RValue=GetRValue(color);
if(m_RValue<=255&&m_RValue>=128)
m_Temp=1;
else
m_Temp=0;
m_RTemp=m_RTemp<<1;
m_RTemp=m_RTemp|m_Temp;
m_GValue=GetGValue(color);
m_Temp=0;
if(m_GValue<=255&&m_GValue>=128)
m_Temp=1;
else
m_Temp=0;
m_GTemp=m_GTemp<<1;
m_GTemp=m_GTemp|m_Temp;
}
writeled.m_redbuf1[(i-7)*32+j]=m_RTemp;
writeled.m_greenbuf1[(i-7)*32+j]=m_GTemp;
}
}
}
///////////////////////////////////////////////////////////////////////////////
UINT OnDisplayZM(LPVOID pParam) //显示字幕
{
// TODO: Add your control notification handler code here
CSjshqDlg* pDlg=(CSjshqDlg*)pParam;
CFont* pOldfont;
CRect dRect1=CRect(0,704-468-32,1024,704-32);
CRect dRect2=CRect(0,200+28,1024,704);
CRect dRect3=CRect(0,200-36,1024,704);
CRect dRect4=CRect(0,180,1024,704);
CString Titlestr1="深圳证券市场概况";
CString Titlestr2="港台及海外主要证券市场指数";
CString Titlestr3="深圳证券交易所公告";
CStdioFile timeFile;
CString timestr="";
pOldfont=pDlg->pDC->SelectObject(pDlg->mNewStockTitleFnt);
pDlg->pDC->SetBkColor(RGB(0,0,0));
pDlg->pDC->SetTextColor(RGB(255,0,0));
while(1)
{
int butID=pDlg->GetCheckedRadioButton(IDC_RADIO1,IDC_GUOZHAI_RADIO);
if(butID==IDC_RADIO1)
{
//得到时间字串
if (!timeFile.Open(theApp.ZM_txt3File,CFile::modeRead|CFile::typeText|CFile::shareDenyNone))
return 0;
else
{
timeFile.ReadString(timestr);
timestr.TrimRight();
timeFile.Close();
}
//播放文本////////////
pDlg->pDC->SelectObject(pDlg->mNewStockTitleFnt);
pDlg->pDC->FillSolidRect(CRect(0,0,1024,704),RGB(0,0,0));
CSize strSize=pDlg->pDC->GetTextExtent(Titlestr1); //标题
pDlg->pDC->TextOut((1024-strSize.cx)/2,50,Titlestr1);
pDlg->pDC->SelectObject(pDlg->mTxt2Fnt);
strSize=pDlg->pDC->GetTextExtent(timestr);//时间
pDlg->pDC->TextOut((1024-strSize.cx)/2,50+92,timestr);
BOOL bS=pDlg->m_ShowBmpFile.Open_DrawTxt(pDlg->m_pWnd,pDlg->pDC,dRect1.left,dRect1.top,dRect1.Width(),dRect1.Height(),
theApp.ZM_txt1File,1,pDlg->mTxt1Fnt);
if(bS)
Sleep(theApp.TxtPauseTime*1000);
pDlg->pDC->FillSolidRect(CRect(0,0,1024,704),RGB(0,0,0));
pDlg->pDC->SelectObject(pDlg->mTxtTitleFnt);
strSize=pDlg->pDC->GetTextExtent(Titlestr2);
pDlg->pDC->TextOut((1024-strSize.cx)/2,50,Titlestr2);
pDlg->pDC->SelectObject(pDlg->mTxt2Fnt);
strSize=pDlg->pDC->GetTextExtent(timestr);//时间
pDlg->pDC->TextOut((1024-strSize.cx)/2,50+88,timestr);
pDlg->m_ShowBmpFile.Open_DrawTxt(pDlg->m_pWnd,pDlg->pDC,dRect2.left,dRect2.top,dRect2.Width(),dRect2.Height(),
theApp.ZM_txt2File,1,pDlg->mTxt2Fnt);//mTxt1Fnt
if(bS)
Sleep(theApp.TxtPauseTime*1000);
pDlg->pDC->FillSolidRect(CRect(0,0,1024,704),RGB(0,0,0));
pDlg->pDC->SelectObject(pDlg->mNewStockTitleFnt);
strSize=pDlg->pDC->GetTextExtent(Titlestr3);
pDlg->pDC->TextOut((1024-strSize.cx)/2,42,Titlestr3);
pDlg->m_ShowBmpFile.Open_DrawTxt3(pDlg->m_pWnd,pDlg->pDC,dRect3.left,dRect3.top,dRect3.Width(),dRect3.Height(),
theApp.ZM_txt4File,1,pDlg->mTxt3Fnt);//mTxt1Fnt
// if(bS)
// Sleep(theApp.TxtPauseTime*1000);
}
else if(butID==IDC_RADIO2) //欢迎
{
//开始循环播放所有的位图文件
pDlg->pDC->FillSolidRect(CRect(0,0,1024,704),RGB(0,0,0));
CString PlayFile,str;
char temp_char[10];
CRect sRect=CRect(0,0,1024,704);
CRect dRect=CRect(0,0,1024,704);
for(int FIndex=0;FIndex<MAX_FILENUMBER;FIndex++)
{
PlayFile=pDlg->m_sZMBmpFilePath+"/aaa";
itoa(FIndex,temp_char,10);
str=temp_char;
PlayFile+=str+".bmp";
BOOL bS=pDlg->m_ShowBmpFile.Open_DrawBmp(pDlg->m_pWnd,pDlg->pDC,dRect.left,dRect.top,dRect.Width(),dRect.Height(),
PlayFile,theApp.ZM_bmpFile[FIndex-1].DisplayMode,2,
sRect.left,sRect.top,sRect.Width(),sRect.Height());
if(bS)
Sleep((theApp.ZM_bmpFile[FIndex-1].PauseTime)*1000);
}
}
else //国债
{
pDlg->m_ShowBmpFile.Open_DrawTxt0812(pDlg->m_pWnd,pDlg->pDC,dRect4.left,dRect4.top,
dRect4.Width(),dRect4.Height(),theApp.Txt_0812,pDlg->mTxt1Fnt,pDlg->mTxtTitleFnt);
Sleep(60000);
// Sleep(2000);
}
}
pDlg->pDC->SelectObject(pOldfont);
}
void CSjshqDlg::OnTimer(UINT nIDEvent)
{
// TODO: Add your message handler code here and/or call default
CEdit* pedit=(CEdit*)GetDlgItem(IDC_ZM_BMP_PATH);
UpdateData();
static BOOL bchange=FALSE;
if(nIDEvent==1)
{
if((DlgButtonID!=IDC_BUTTON3)&&(DlgButtonID!=0))
{//关闭字幕线程
if(m_ZMThread)
{
::TerminateThread(m_ZMThread->m_hThread,0);
m_ZMThread=NULL;
}
bchange=FALSE;
}
switch(DlgButtonID)
{
case IDC_BUTTON1: //设置新股
{
DlgButtonID=0;
//刷新提示栏
m_GetDatabase.m_sNewGuAlarm="";
pedit->SetWindowText("设置新股");
OnButton1();
}
break;
case IDC_BUTTON2: //显示行情
{
//刷新提示栏
pedit->SetWindowText("显示行情 "+m_GetDatabase.m_sNewGuAlarm);
OnRunBtn();
}
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?