📄 readtxt.cpp
字号:
m_dc->FillRect(m_oldrect,&m_brush);
bClrScreen=FALSE;
}
if(m_c>0)
{ //部份清屏
CRect m_rc;
CBrush m_brush;
m_brush.CreateSolidBrush(RGB(0,0,0));
if(m_c==1){
// m_rc.SetRect(0,0,m_size.cx,m_demo->maxhight+m_demo->space+m_oldrect.top);
m_rc.SetRect(0,(m_TitleRowNO-1)*(m_demo->maxhight+m_demo->space),m_size.cx,m_TitleRowNO*(m_demo->maxhight+m_demo->space)+m_oldrect.top);
}
else{
m_rc.SetRect(0,m_size.cy-m_oldrect.top-(m_BottomRowNO-1)*(m_demo->maxhight+m_demo->space),m_size.cx,m_oldrect.bottom-(m_BottomRowNO)*(m_demo->maxhight+m_demo->space));
}
m_pmemdc->FillRect(m_rc,&m_brush);
}
m_pmemdc->SetBkColor(RGB(0,0,0));
cur_x=m_x;//+m_showrect.left;
for(jj=0;jj<m_demo->m_showdrawlist.GetCount();jj++)
{
m_strpos=m_demo->m_showdrawlist.FindIndex(jj);
m_demostr=(CShowDraw*)m_demo->m_showdrawlist.GetAt(m_strpos);
if(m_scale==1)
{
lp.lfHeight=m_demostr->m_cy;
lp.lfWidth=m_demostr->m_cx;
}
else
{
lp.lfHeight=(int)((m_demostr->m_cy/((float)m_scale/100)))/2*2;
lp.lfWidth=(int)((m_demostr->m_cx/((float)m_scale/100)))/2*2;
}
lp.lfCharSet=DEFAULT_CHARSET;
if(m_fontlist)
{
m_pos=m_fontlist->FindIndex(m_demostr->m_name);
if(m_pos)
{
m_str=m_fontlist->GetAt(m_pos);
strcpy(lp.lfFaceName,m_str);
}
else
strcpy(lp.lfFaceName,"宋体");
}
else
strcpy(lp.lfFaceName,"宋体");
m_pfont=new CFont;
m_pfont->CreateFontIndirect(&lp);
m_poldfont=m_pmemdc->SelectObject(m_pfont);
color=m_demostr->m_color;
if(m_color==0)
{
if(m_demostr->m_color==1)
m_pmemdc->SetTextColor(RGB(255,0,0));
else if(m_demostr->m_color==2)
m_pmemdc->SetTextColor(RGB(0,255,0));
else
m_pmemdc->SetTextColor(RGB(255,255,0));
}
else
m_pmemdc->SetTextColor(RGB(255,255,255));
cur_pos=m_demostr->m_curx;
if(jj<(m_demo->m_showdrawlist.GetCount()-1))
{
m_strpos=m_demo->m_showdrawlist.FindIndex(jj+1);
m_demostr=(CShowDraw*)m_demo->m_showdrawlist.GetAt(m_strpos);
cur_len=m_demostr->m_curx-cur_pos;
}
else
cur_len=m_demo->m_showstr.GetLength()-cur_pos;
m_str1=m_demo->m_showstr.Left(cur_pos+cur_len);
m_str2=m_str1.Right(cur_len);
if(m_color==0||(m_color==1&&(color==1||color==3))||(m_color==2&&(color==2||color==3)))
{
if(m_scale==1)
m_pmemdc->TextOut(cur_x,m_off+(m_demo->maxhight-lp.lfHeight),m_str2,m_str2.GetLength());
else
{
cur_x=0;
CSize m_size;
for(int jj=0;jj<cur_len+1;jj++)
GetTextExtentPoint32(m_pmemdc->GetSafeHdc(),m_demo->m_showstr,jj,&m_size);
m_pmemdc->TextOut((m_showrect.Width()-m_size.cx)/2,m_off+((int)((m_demo->maxhight/((float)m_scale/100)))/2*2-lp.lfHeight),m_str2,m_str2.GetLength());
//m_pmemdc->TextOut((m_showrect.Width()-cur_len*lp.lfWidth)/2,m_off+((m_demo->maxhight/((float)m_scale/100))/2*2-lp.lfHeight),m_str2,m_str2.GetLength());
}
}
if(m_scale==1)
cur_x+=cur_len*lp.lfWidth/m_scale;
else
cur_x+=cur_len*lp.lfWidth;///((float)m_scale/10);
m_pmemdc->SelectObject(m_poldfont);
m_pfont->DeleteObject();
delete m_pfont;
}
}
void CShowTxt::ZoomInAndOut(BOOL m_run)
{
int ii=0;
CRect m_rc;
CBrush m_brush;
CDC* m_dc;
CDC* m_memdc;
CBitmap* m_bitmap;
CDC* m_redleddc;
CBitmap* m_redledbitmap;
CDC* m_greenleddc;
CBitmap* m_greenledbitmap;
m_dc=m_pshowwnd->GetDC();
m_memdc=new CDC;
m_memdc->CreateCompatibleDC(m_dc);
m_bitmap=new CBitmap;
m_bitmap->CreateCompatibleBitmap(m_dc,m_showrect.Width(),m_showrect.Height());
m_memdc->SelectObject(m_bitmap);
m_redleddc=new CDC;
m_redleddc->CreateCompatibleDC(m_dc);
m_redledbitmap=new CBitmap;
m_redledbitmap->CreateBitmap(m_showrect.Width(),m_showrect.Height(),1,1,NULL);
m_redleddc->SelectObject(m_redledbitmap);
m_greenleddc=new CDC;
m_greenleddc->CreateCompatibleDC(m_dc);
m_greenledbitmap=new CBitmap;
m_greenledbitmap->CreateBitmap(m_showrect.Width(),m_showrect.Height(),1,1,NULL);
m_greenleddc->SelectObject(m_greenledbitmap);
if(m_run)//从大到小
{
for(ii=260;ii>=100;ii-=5)
{
ToMemDC(m_memdc,1,ii,0);
ToMemDC(m_redleddc,1,ii,1);
ToMemDC(m_greenleddc,1,ii,2);
m_dc->BitBlt(m_showrect.left,m_showrect.top,m_showrect.Width(),m_showrect.Height(),m_memdc,0,0,SRCCOPY);
m_led->GetData(m_redledbitmap,1);
m_led->GetData(m_greenledbitmap,2);
m_led->WriteToLed();
Sleep(font_s);
}
}
else //从小到大
{
for(ii=100;ii<260;ii+=5)
{
ToMemDC(m_memdc,1,ii,0);
ToMemDC(m_redleddc,1,ii,1);
ToMemDC(m_greenleddc,1,ii,2);
m_dc->BitBlt(m_showrect.left,m_showrect.top,m_showrect.Width(),m_showrect.Height(),m_memdc,0,0,SRCCOPY);
m_led->GetData(m_redledbitmap,1);
m_led->GetData(m_greenledbitmap,2);
m_led->WriteToLed();
Sleep(font_s);
}
}
Sleep(font_delay*1000);
m_pshowwnd->ReleaseDC(m_dc);
m_memdc->DeleteDC();
m_bitmap->DeleteObject();
delete m_bitmap;
delete m_memdc;
m_redleddc->DeleteDC();
m_redledbitmap->DeleteObject();
delete m_redledbitmap;
delete m_redleddc;
m_greenleddc->DeleteDC();
m_greenledbitmap->DeleteObject();
delete m_greenledbitmap;
delete m_greenleddc;
}
void CShowTxt::CommonShow()
{
CDC* m_dc;
CDC* m_memdc;
CBitmap* m_bitmap;
CDC* m_redleddc;
CBitmap* m_redledbitmap;
CDC* m_greenleddc;
CBitmap* m_greenledbitmap;
CDC* m_redleddc1;
CBitmap* m_redledbitmap1;
CDC* m_greenleddc1;
CBitmap* m_greenledbitmap1;
int ii;
m_dc=m_pshowwnd->GetDC();
m_memdc=new CDC;
m_memdc->CreateCompatibleDC(m_dc);
m_bitmap=new CBitmap;
m_bitmap->CreateCompatibleBitmap(m_dc,m_size.cx,m_size.cy);
m_memdc->SelectObject(m_bitmap);
m_redleddc=new CDC;
m_redleddc->CreateCompatibleDC(m_dc);
m_redledbitmap=new CBitmap;
m_redledbitmap->CreateBitmap(m_size.cx,m_size.cy,1,1,NULL);
m_redleddc->SelectObject(m_redledbitmap);
m_greenleddc=new CDC;
m_greenleddc->CreateCompatibleDC(m_dc);
m_greenledbitmap=new CBitmap;
m_greenledbitmap->CreateBitmap(m_size.cx,m_size.cy,1,1,NULL);
m_greenleddc->SelectObject(m_greenledbitmap);
m_redleddc1=new CDC;
m_redleddc1->CreateCompatibleDC(m_dc);
m_redledbitmap1=new CBitmap;
m_redledbitmap1->CreateBitmap(m_size.cx,m_size.cy,1,1,NULL);
m_redleddc1->SelectObject(m_redledbitmap1);
m_greenleddc1=new CDC;
m_greenleddc1->CreateCompatibleDC(m_dc);
m_greenledbitmap1=new CBitmap;
m_greenledbitmap1->CreateBitmap(m_size.cx,m_size.cy,1,1,NULL);
m_greenleddc1->SelectObject(m_greenledbitmap1);
CBrush m_brush;
CRect m_rc;
m_brush.CreateSolidBrush(RGB(0,0,0));
m_rc.SetRect(0,0,m_size.cx,m_size.cy);
m_redleddc1->FillRect(m_rc,&m_brush);
m_greenleddc1->FillRect(m_rc,&m_brush);
m_memdc->FillRect(m_rc,&m_brush); //Clear the window in screen
ToMemDC(m_memdc,TRUE,1,0);
ToMemDC(m_redleddc,TRUE,1,1);
ToMemDC(m_greenleddc,TRUE,1,2);
/* if(m_ptopdrawtxt)
{
ToOneTxtMemDC(m_dc,m_ptopdrawtxt,m_oldrect.left,m_oldrect.top,0,1,1);
ToOneTxtMemDC(m_redleddc1,m_ptopdrawtxt,m_oldrect.left,m_oldrect.top,1,1,1);
ToOneTxtMemDC(m_greenleddc1,m_ptopdrawtxt,m_oldrect.left,m_oldrect.top,2,1,1);
}
if(m_pbottomdrawtxt)
{
ToOneTxtMemDC(m_dc,m_pbottomdrawtxt,m_oldrect.left,m_size.cy-m_pbottomdrawtxt->maxhight-m_oldrect.top,0,1,2);
ToOneTxtMemDC(m_redleddc1,m_pbottomdrawtxt,m_oldrect.left,m_size.cy-m_pbottomdrawtxt->maxhight-m_oldrect.top,1,1,2);
ToOneTxtMemDC(m_greenleddc1,m_pbottomdrawtxt,m_oldrect.left,m_size.cy-m_pbottomdrawtxt->maxhight-m_oldrect.top,2,1,2);
}
*/
POSITION pos;
for(int iii=m_topdrawtxtList.GetCount()-1;iii>=0;iii--)
{
pos=m_topdrawtxtList.FindIndex(iii);
m_ptopdrawtxt=(CDrawTxt*)m_topdrawtxtList.GetAt(pos);
if(m_ptopdrawtxt)
{
// ToOneTxtMemDC(m_dc,m_ptopdrawtxt,m_oldrect.left,m_oldrect.top,0,1,1);
// ToOneTxtMemDC(m_redleddc1,m_ptopdrawtxt,m_oldrect.left,m_oldrect.top,1,1,1);
// ToOneTxtMemDC(m_greenleddc1,m_ptopdrawtxt,m_oldrect.left,m_oldrect.top,2,1,1);
ToOneTxtMemDC(m_dc,m_ptopdrawtxt,m_oldrect.left,m_oldrect.top+iii*(m_ptopdrawtxt->maxhight+m_ptopdrawtxt->space),0,1,0);
ToOneTxtMemDC(m_redleddc1,m_ptopdrawtxt,m_oldrect.left,m_oldrect.top+iii*(m_ptopdrawtxt->maxhight+m_ptopdrawtxt->space),1,1,0);
ToOneTxtMemDC(m_greenleddc1,m_ptopdrawtxt,m_oldrect.left,m_oldrect.top+iii*(m_ptopdrawtxt->maxhight+m_ptopdrawtxt->space),2,1,0);
}
}
for(iii=m_bottomdrawtxtList.GetCount()-1;iii>=0;iii--)
{
pos=m_bottomdrawtxtList.FindIndex(iii);
m_pbottomdrawtxt=(CDrawTxt*)m_bottomdrawtxtList.GetAt(pos);
if(m_pbottomdrawtxt)
{
ToOneTxtMemDC(m_dc,m_pbottomdrawtxt,m_oldrect.left,m_size.cy-(iii+1)*(m_pbottomdrawtxt->maxhight+m_oldrect.top),0,1,0);//0,1,2);
ToOneTxtMemDC(m_redleddc1,m_pbottomdrawtxt,m_oldrect.left,m_size.cy-(iii+1)*(m_pbottomdrawtxt->maxhight+m_oldrect.top),1,1,0);//1,1,2);
ToOneTxtMemDC(m_greenleddc1,m_pbottomdrawtxt,m_oldrect.left,m_size.cy-(iii+1)*(m_pbottomdrawtxt->maxhight+m_oldrect.top),2,2,0);//2,2,2);
}
}
switch(font_mode)
{
case NORMAL:
/*
m_dc->BitBlt(m_showrect.left,m_showrect.top,m_showrect.Width(),m_showrect.Height(),m_memdc,0,0,SRCCOPY);
m_redleddc1->BitBlt(m_showrect.left,m_showrect.top,m_showrect.Width(),m_showrect.Height(),m_redleddc,0,0,SRCCOPY);
m_greenleddc1->BitBlt(m_showrect.left,m_showrect.top,m_showrect.Width(),m_showrect.Height(),m_greenleddc,0,0,SRCCOPY);
// m_redleddc1->BitBlt(m_showrect.left,m_showrect.top,m_showrect.Width(),m_showrect.Height(),m_memdc,0,0,SRCCOPY);
// m_greenleddc1->BitBlt(m_showrect.left,m_showrect.top,m_showrect.Width(),m_showrect.Height(),m_memdc,0,0,SRCCOPY);
m_led->GetData(m_redledbitmap,1);
m_led->GetData(m_greenledbitmap,2);
m_led->WriteToLed();
*/
// for(ii=0;ii<m_showrect.Width();ii++)
{
m_dc->BitBlt(m_showrect.left,m_showrect.top,m_showrect.Width(),m_showrect.Height(),m_memdc,0,0,SRCCOPY);
m_redleddc1->BitBlt(m_showrect.left,m_showrect.top,m_showrect.Width(),m_showrect.Height(),m_redleddc,0,0,SRCCOPY);
m_greenleddc1->BitBlt(m_showrect.left,m_showrect.top,m_showrect.Width(),m_showrect.Height(),m_greenleddc,0,0,SRCCOPY);
m_led->GetData(m_redledbitmap1,1);
m_led->GetData(m_greenledbitmap1,2);
m_led->WriteToLed();
// Sleep(font_s);
}
break;
case 5:
for(ii=0;ii<m_showrect.Width();ii++)
{
m_dc->BitBlt(m_showrect.left+ii,m_showrect.top,1,m_showrect.Height(),m_memdc,ii,0,SRCCOPY);
m_redleddc1->BitBlt(m_showrect.left+ii,m_showrect.top,1,m_showrect.Height(),m_redleddc,ii,0,SRCCOPY);
m_greenleddc1->BitBlt(m_showrect.left+ii,m_showrect.top,1,m_showrect.Height(),m_greenleddc,ii,0,SRCCOPY);
m_led->GetData(m_redledbitmap1,1);
m_led->GetData(m_greenledbitmap1,2);
m_led->WriteToLed();
Sleep(font_s);
}
break;
case 6:
for(ii=m_showrect.Width()-1;ii>=0;ii--)
{
m_dc->BitBlt(m_showrect.left+ii,m_showrect.top,1,m_showrect.Height(),m_memdc,ii,0,SRCCOPY);
m_redleddc1->BitBlt(m_showrect.left+ii,m_showrect.top,1,m_showrect.Height(),m_redleddc,ii,0,SRCCOPY);
m_greenleddc1->BitBlt(m_showrect.left+ii,m_showrect.top,1,m_showrect.Height(),m_greenleddc,ii,0,SRCCOPY);
m_led->GetData(m_redledbitmap1,1);
m_led->GetData(m_greenledbitmap1,2);
m_led->WriteToLed();
Sleep(font_s);
}
break;
case 7:
for(ii=0;ii<m_showrect.Height();ii++)
{
m_dc->BitBlt(m_showrect.left,m_showrect.top+ii,m_showrect.Width(),1,m_memdc,0,ii,SRCCOPY);
m_redleddc1->BitBlt(m_showrect.left,m_showrect.top+ii,m_showrect.Width(),1,m_redleddc,0,ii,SRCCOPY);
m_greenleddc1->BitBlt(m_showrect.left,m_showrect.top+ii,m_showrect.Width(),1,m_greenleddc,0,ii,SRCCOPY);
m_led->GetData(m_redledbitmap1,1);
m_led->GetData(m_greenledbitmap1,2);
m_led->WriteToLed();
Sleep(font_s);
}
break;
case 8:
for(ii=m_showrect.Height();ii>=0;ii--)
{
m_dc->BitBlt(m_showrect.left,m_showrect.top+ii,m_showrect.Width(),1,m_memdc,0,ii,SRCCOPY);
m_redleddc1->BitBlt(m_showrect.left,m_showrect.top+ii,m_showrect.Width(),1,m_redleddc,0,ii,SRCCOPY);
m_greenleddc1->BitBlt(m_showrect.left,m_showrect.top+ii,m_showrect.Width(),1,m_greenleddc,0,ii,SRCCOPY);
m_led->GetData(m_redledbitmap1,1);
m_led->GetData(m_greenledbitmap1,2);
m_led->WriteToLed();
Sleep(font_s);
}
break;
case 9:
for(ii=0;ii<(m_showrect.Width()/2);ii++)
{
m_dc->BitBlt(m_showrect.left+ii,m_showrect.top,1,m_showrect.Height(),m_memdc,ii,0,SRCCOPY);
m_dc->BitBlt(m_showrect.right-1-ii,m_showrect.top,1,m_showrect.Height(),m_memdc,m_showrect.Width()-1-ii,0,SRCCOPY);
m_redleddc1->BitBlt(m_showrect.left+ii,m_showrect.top,1,m_showrect.Height(),m_redleddc,ii,0,SRCCOPY);
m_redleddc1->BitBlt(m_showrect.right-1-ii,m_showrect.top,1,m_showrect.Height(),m_redleddc,m_showrect.Width()-1-ii,0,SRCCOPY);
m_greenleddc1->BitBlt(m_showrect.left+ii,m_showrect.top,1,m_showrect.Height(),m_greenleddc,ii,0,SRCCOPY);
m_greenleddc1->BitBlt(m_showrect.right-1-ii,m_showrect.top,1,m_showrect.Height(),m_greenleddc,m_showrect.Width()-1-ii,0,SRCCOPY);
m_led->GetData(m_redledbitmap1,1);
m_led->GetData(m_greenledbitmap1,2);
m_led->WriteToLed();
Sleep(font_s);
}
break;
case 10:
for(ii=(m_showrect.Width()/2);ii>=0;ii--)
{
m_dc->BitBlt(m_showrect.left+ii,m_showrect.top,1,m_showrect.Height(),m_memdc,ii,0,SRCCOPY);
m_dc->BitBlt(m_showrect.right-1-ii,m_showrect.top,1,m_showrect.Height(),m_memdc,m_showrect.Width()-1-ii,0,SRCCOPY);
m_redleddc1->BitBlt(m_showrect.left+ii,m_showrect.top,1,m_showrect.Height(),m_redleddc,ii,0,SRCCOPY);
m_redleddc1->BitBlt(m_showrect.right-1-ii,m_showrect.top,1,m_showrect.Height(),m_redleddc,m_showrect.Width()-1-ii,0,SRCCOPY);
m_greenleddc1->BitBlt(m_showrect.left+ii,m_showrect.top,1,m_showrect.Height(),m_greenleddc,ii,0,SRCCOPY);
m_greenleddc1->BitBlt(m_showrect.right-1-ii,m_showrect.top,1,m_showrect.Height(),m_greenleddc,m_showrect.Width()-1-ii,0,SRCCOPY);
m_led->GetData(m_redledbitmap1,1);
m_led->GetData(m_greenledbitmap1,2);
m_led->WriteToLed();
Sleep(font_s);
}
break;
case 11:
for(ii=0;ii<(m_showrect.Height()/2+1);ii++)
{
m_dc->BitBlt(m_showrect.left,m_showrect.top+ii,m_showrect.Width(),1,m_memdc,0,ii,SRCCOPY);
m_dc->BitBlt(m_showrect.left,m_showrect.bottom-1-ii,m_showrect.Width(),1,m_memdc,0,m_showrect.Height()-1-ii,SRCCOPY);
m_redleddc1->BitBlt(m_showrect.left,m_showrect.top+ii,m_showrect.Width(),1,m_redleddc,0,ii,SRCCOPY);
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -