📄 iconwindow.cpp
字号:
// IconWindow.cpp: implementation of the CIconWindow class.
//
//////////////////////////////////////////////////////////////////////
#include "stdafx.h"
#include "lane_new.h"
#include "IconWindow.h"
#include "DeviceInfo.h"
#ifdef _DEBUG
#undef THIS_FILE
static char THIS_FILE[]=__FILE__;
#define new DEBUG_NEW
#endif
extern CLane_newApp theApp;
//////////////////////////////////////////////////////////////////////
// Construction/Destruction
//////////////////////////////////////////////////////////////////////
CAutoRail::CAutoRail()
{
}
// 绘制开启状态的自动栏杆图标
void CAutoRail::Open()
{
int nScreenX=theApp.nScreenX;
int nScreenY=theApp.nScreenY;
int nLeft=nScreenX*53/64;
int nRight=nScreenX*63/64;
int nTop=nScreenY*4/15;
int nButtom=nScreenY*57/120;
theApp.memDC.Rectangle(CRect(nLeft,nTop,nRight,nButtom)); //绘制手动栏杆窗口外框
CPen Pen2;
if(Pen2.CreatePen(PS_SOLID,nScreenX/640,RGB(255,255,255))==0){
SendMessage(theApp.m_pMainWnd->m_hWnd,WM_ABNORMAL,0,(LPARAM)"产生兼容画笔失败(自动栏杆)\n");
return;
}
theApp.memDC.SelectObject(&Pen2);
CBrush Brush2;
if(Brush2.CreateSolidBrush(RGB(255,255,100))==0){
SendMessage(theApp.m_pMainWnd->m_hWnd,WM_ABNORMAL,0,(LPARAM)"产生兼容画刷失败(自动栏杆座)\n");
return;
}
theApp.memDC.SelectObject(&Brush2);
nLeft=nScreenX*108/128;
nRight=nScreenX*113/128;
nTop=nScreenY*3/8;
nButtom=nScreenY*9/20;
theApp.memDC.Rectangle(CRect(nLeft,nTop,nRight,nButtom)); //绘制手动栏杆座
CBrush Brush3;
if(Brush3.CreateSolidBrush(RGB(255,100,50))==0){
SendMessage(theApp.m_pMainWnd->m_hWnd,WM_ABNORMAL,0,(LPARAM)"产生兼容画刷失败(自动栏杆臂)\n");
return;
}
nLeft=nScreenX*109/128;
nRight=nScreenX*7/8;
nTop=nScreenY*9/32;
nButtom=nScreenY*3/8;
theApp.memDC.SelectObject(&Brush3);
theApp.memDC.Rectangle(CRect(nLeft,nTop,nRight,nButtom));
theApp.m_pMainWnd->Invalidate(FALSE);
theApp.memDC.SelectObject(&theApp.Pen1);
Pen2.DeleteObject();
theApp.memDC.SelectObject(&theApp.Brush1);
Brush2.DeleteObject();
Brush3.DeleteObject();
}
// 绘制关闭状态的自动栏杆图标
void CAutoRail::Close()
{
int nScreenX=theApp.nScreenX;
int nScreenY=theApp.nScreenY;
int nLeft=nScreenX*53/64;
int nRight=nScreenX*63/64;
int nTop=nScreenY*4/15;
int nButtom=nScreenY*57/120;
theApp.memDC.Rectangle(CRect(nLeft,nTop,nRight,nButtom)); //绘制手动栏杆窗口外框
CPen Pen2;
if(Pen2.CreatePen(PS_SOLID,nScreenX/640,RGB(255,255,255))==0){
SendMessage(theApp.m_pMainWnd->m_hWnd,WM_ABNORMAL,0,(LPARAM)"产生兼容画笔失败(自动栏杆)\n");
return;
}
theApp.memDC.SelectObject(&Pen2);
CBrush Brush2;
if(Brush2.CreateSolidBrush(RGB(255,255,100))==0){
SendMessage(theApp.m_pMainWnd->m_hWnd,WM_ABNORMAL,0,(LPARAM)"产生兼容画刷失败(自动栏杆座)\n");
return;
}
theApp.memDC.SelectObject(&Brush2);
nLeft=nScreenX*108/128;
nRight=nScreenX*113/128;
nTop=nScreenY*3/8;
nButtom=nScreenY*9/20;
theApp.memDC.Rectangle(CRect(nLeft,nTop,nRight,nButtom)); //绘制手动栏杆座
CBrush Brush3;
if(Brush3.CreateSolidBrush(RGB(255,100,50))==0){
SendMessage(theApp.m_pMainWnd->m_hWnd,WM_ABNORMAL,0,(LPARAM)"产生兼容画刷失败(自动栏杆臂)\n");
return;
}
nLeft=nScreenX*109/128;
nRight=nScreenX*125/128;
nTop=nScreenY*7/20;
nButtom=nScreenY*3/8;
theApp.memDC.SelectObject(&Brush3);
theApp.memDC.Rectangle(CRect(nLeft,nTop,nRight,nButtom));
theApp.m_pMainWnd->Invalidate(FALSE);
theApp.memDC.SelectObject(&theApp.Pen1);
Pen2.DeleteObject();
theApp.memDC.SelectObject(&theApp.Brush1);
Brush2.DeleteObject();
Brush3.DeleteObject();
}
char * CIndicationLamp::pPictureData=NULL;
HBITMAP CIndicationLamp::hBitmap=0;
DWORD CIndicationLamp::nBmpAddr=0;
CIndicationLamp::CIndicationLamp()
{
}
// 绘制关闭状态的绿色通行指示灯图标
void CIndicationLamp::GreenOff()
{
int nScreenX=theApp.nScreenX;
int nScreenY=theApp.nScreenY;
int nTop=nScreenY/48;
int nButtom=nScreenY*23/100;
int nLeft=nScreenX*125/192;
int nRight=nScreenX*157/192;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nLeft,nButtom);
theApp.memDC.LineTo(nRight,nButtom);
theApp.memDC.LineTo(nRight,nTop);
theApp.memDC.LineTo(nLeft,nTop);
nTop=nScreenY*5/48;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nRight,nTop);
nLeft=nScreenX*141/192;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nLeft,nButtom);
nLeft=nScreenX*125/192;
nRight=nScreenX*141/192;
nTop=nScreenY*5/48;
nButtom=nScreenY*23/100;
theApp.memDC.SelectObject(&theApp.Brush1);
theApp.memDC.Rectangle(CRect(nLeft,nTop,nRight,nButtom));
DrawScreen();
}
// 绘制开启状态的绿色通行指示灯图标
void CIndicationLamp::GreenOn()
{
int nScreenX=theApp.nScreenX;
int nScreenY=theApp.nScreenY;
int nTop=nScreenY/48;
int nButtom=nScreenY*23/100;
int nLeft=nScreenX*125/192;
int nRight=nScreenX*157/192;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nLeft,nButtom);
theApp.memDC.LineTo(nRight,nButtom);
theApp.memDC.LineTo(nRight,nTop);
theApp.memDC.LineTo(nLeft,nTop);
nTop=nScreenY*5/48;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nRight,nTop);
nLeft=nScreenX*141/192;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nLeft,nButtom);
nLeft=nScreenX*125/192;
nRight=nScreenX*141/192;
nTop=nScreenY*5/48;
nButtom=nScreenY*23/100;
theApp.memDC.SelectObject(&theApp.Brush1);
theApp.memDC.Rectangle(CRect(nLeft,nTop,nRight,nButtom));
CPen Pen2;
if(Pen2.CreatePen(PS_SOLID,nScreenX/128,RGB(0,255,0))==0){
SendMessage(theApp.m_pMainWnd->m_hWnd,WM_ABNORMAL,0,(LPARAM)"产生兼容画笔失败(交通绿灯)\n");
return;
}
theApp.memDC.SelectObject(&Pen2);
nLeft=nRight=nScreenX*125/192+nScreenY*5/96;
nTop=nScreenY*58/480;
nButtom=nScreenY*64/300;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nRight,nButtom);
nLeft=nLeft-nScreenX*6/180;
nTop=nScreenY*82/480;
nButtom=nScreenY*64/300;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nRight,nButtom);
nLeft=nRight+nScreenX*6/180;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nRight,nButtom);
theApp.memDC.SelectObject(&theApp.Pen1);
Pen2.DeleteObject();
DrawScreen();
}
// 绘制关闭状态的红色通行指示灯图标
void CIndicationLamp::RedOff()
{
int nScreenX=theApp.nScreenX;
int nScreenY=theApp.nScreenY;
int nTop=nScreenY/48;
int nButtom=nScreenY*23/100;
int nLeft=nScreenX*125/192;
int nRight=nScreenX*157/192;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nLeft,nButtom);
theApp.memDC.LineTo(nRight,nButtom);
theApp.memDC.LineTo(nRight,nTop);
theApp.memDC.LineTo(nLeft,nTop);
nTop=nScreenY*5/48;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nRight,nTop);
nLeft=nScreenX*141/192;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nLeft,nButtom);
nLeft=nScreenX*141/192;
nRight=nScreenX*157/192;
nTop=nScreenY*5/48;
nButtom=nScreenY*23/100;
theApp.memDC.SelectObject(&theApp.Brush1);
theApp.memDC.Rectangle(CRect(nLeft,nTop,nRight,nButtom));
DrawScreen();
}
// 绘制开启状态的红色通行指示灯图标
void CIndicationLamp::RedOn()
{
int nScreenX=theApp.nScreenX;
int nScreenY=theApp.nScreenY;
int nTop=nScreenY/48;
int nButtom=nScreenY*23/100;
int nLeft=nScreenX*125/192;
int nRight=nScreenX*157/192;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nLeft,nButtom);
theApp.memDC.LineTo(nRight,nButtom);
theApp.memDC.LineTo(nRight,nTop);
theApp.memDC.LineTo(nLeft,nTop);
nTop=nScreenY*5/48;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nRight,nTop);
nLeft=nScreenX*141/192;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nLeft,nButtom);
nLeft=nScreenX*141/192;
nRight=nScreenX*157/192;
nTop=nScreenY*5/48;
nButtom=nScreenY*23/100;
theApp.memDC.SelectObject(&theApp.Brush1);
theApp.memDC.Rectangle(CRect(nLeft,nTop,nRight,nButtom));
CPen Pen2;
if(Pen2.CreatePen(PS_SOLID,nScreenX/128,RGB(255,0,0))==0){
SendMessage(theApp.m_pMainWnd->m_hWnd,WM_ABNORMAL,0,(LPARAM)"产生兼容画笔失败(交通红灯)\n");
return;
}
theApp.memDC.SelectObject(&Pen2);
int x=nScreenX/64;
nLeft=nLeft+x;
nRight=nRight-x;
nTop=nTop+x;
nButtom=nButtom-x;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nRight,nButtom);
theApp.memDC.MoveTo(nLeft,nButtom);
theApp.memDC.LineTo(nRight,nTop);
theApp.memDC.SelectObject(&theApp.Pen1);
Pen2.DeleteObject();
DrawScreen();
}
// 绘制关闭状态的报警灯
void CIndicationLamp::AmberOff()
{
int nScreenX=theApp.nScreenX;
int nScreenY=theApp.nScreenY;
int nTop=nScreenY/48;
int nButtom=nScreenY*23/100;
int nLeft=nScreenX*125/192;
int nRight=nScreenX*157/192;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nLeft,nButtom);
theApp.memDC.LineTo(nRight,nButtom);
theApp.memDC.LineTo(nRight,nTop);
theApp.memDC.LineTo(nLeft,nTop);
nTop=nScreenY*5/48;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nRight,nTop);
nLeft=nScreenX*141/192;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nLeft,nButtom);
nLeft=nScreenX*125/192;
nRight=nScreenX*157/192;
nTop=nScreenY/48;
nButtom=nScreenY*5/48;
theApp.memDC.SelectObject(&theApp.Brush1);
theApp.memDC.Rectangle(CRect(nLeft,nTop,nRight,nButtom));
DrawScreen();
}
// 绘制开启状态的报警灯
void CIndicationLamp::AmberOn()
{
int nScreenX=theApp.nScreenX;
int nScreenY=theApp.nScreenY;
int nTop=nScreenY/48;
int nButtom=nScreenY*23/100;
int nLeft=nScreenX*125/192;
int nRight=nScreenX*157/192;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nLeft,nButtom);
theApp.memDC.LineTo(nRight,nButtom);
theApp.memDC.LineTo(nRight,nTop);
theApp.memDC.LineTo(nLeft,nTop);
nTop=nScreenY*5/48;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nRight,nTop);
nLeft=nScreenX*141/192;
theApp.memDC.MoveTo(nLeft,nTop);
theApp.memDC.LineTo(nLeft,nButtom);
// 假如尚未读取图标文件,读取图标文件
if(pPictureData==NULL){
// 获取报警灯图标文件路径
char strFileName[130];
memset(strFileName,0,130);
theApp.GetFullPath(strFileName);
strcat(strFileName,"报警灯.bmp");
FILE *fp1;
if((fp1=fopen(strFileName,"rb"))==NULL) return;
// 首先读取BMP文件头信息,根据文件头信息申请内存
BITMAPFILEHEADER bmpFileHead;
fread(&bmpFileHead,sizeof(BITMAPFILEHEADER),1,fp1);
fclose(fp1);
pPictureData=new char[bmpFileHead.bfSize-sizeof(BITMAPFILEHEADER)];
if(pPictureData==NULL) return;
ReadBitmap(strFileName,pPictureData,hBitmap,nBmpAddr);
}
// 将报警灯的图标绘制到内存DC上
BITMAPINFOHEADER *bmpInfoHeader;
bmpInfoHeader=(BITMAPINFOHEADER *)pPictureData;
::SetDIBitsToDevice(theApp.memDC,nScreenX*141/192-25,nScreenY/48+3,
45,45,0,0,0,bmpInfoHeader->biHeight,
pPictureData+nBmpAddr,
(BITMAPINFO *)pPictureData,DIB_RGB_COLORS);
DrawScreen();
}
// 释放存储报警灯图标信息的内存
void CIndicationLamp::ReleaseMemory()
{
if(pPictureData!=NULL){
delete [] pPictureData;
pPictureData=NULL;
}
}
CPictureLoop::CPictureLoop()
{
}
// 绘制无车压上抓拍线圈
void CPictureLoop::Off()
{
int nScreenX=theApp.nScreenX;
int nScreenY=theApp.nScreenY;
int nLeft=nScreenX*125/192;
int nRight=nScreenX*157/192;
int nTop=nScreenY*4/15;
int nButtom=nScreenY*89/240;
theApp.memDC.Rectangle(CRect(nLeft,nTop,nRight,nButtom));
DrawScreen();
}
// 绘制有车压上抓拍线圈
void CPictureLoop::On()
{
int nScreenX=theApp.nScreenX;
int nScreenY=theApp.nScreenY;
int nLeft=nScreenX*125/192;
int nRight=nScreenX*157/192;
int nTop=nScreenY*4/15;
int nButtom=nScreenY*89/240;
theApp.memDC.Rectangle(CRect(nLeft,nTop,nRight,nButtom));
CBrush Brush2;
if(Brush2.CreateSolidBrush(RGB(255,50,50))==0){
SendMessage(theApp.m_pMainWnd->m_hWnd,WM_ABNORMAL,0,(LPARAM)"产生兼容画刷失败(抓拍线圈)\n");
return;
}
theApp.memDC.SelectObject(&Brush2);
int step=nScreenX/128;
POINT PointArray[8];
PointArray[0].x=nLeft+nScreenX/64;
PointArray[0].y=nButtom-nScreenX/40;
PointArray[1].x=PointArray[0].x+2*step;
PointArray[1].y=PointArray[0].y-3*step;
PointArray[2].x=PointArray[1].x+2*step;
PointArray[2].y=PointArray[1].y;
PointArray[3].x=PointArray[2].x+2*step;
PointArray[3].y=PointArray[2].y-2*step;
PointArray[4].x=PointArray[3].x+5*step;
PointArray[4].y=PointArray[3].y;
PointArray[5].x=PointArray[4].x+2*step;
PointArray[5].y=PointArray[2].y;
PointArray[6].x=PointArray[5].x+2*step;
PointArray[6].y=PointArray[5].y;
PointArray[7].x=PointArray[6].x+2*step;
PointArray[7].y=PointArray[0].y;
theApp.memDC.Polygon(PointArray,8);
theApp.memDC.Ellipse(PointArray[1].x,PointArray[0].y-2*step,PointArray[1].x+4*step,PointArray[0].y+2*step);
theApp.memDC.Ellipse(PointArray[6].x,PointArray[0].y-2*step,PointArray[6].x-4*step,PointArray[0].y+2*step);
theApp.memDC.SelectObject(&theApp.Brush1);
Brush2.DeleteObject();
DrawScreen();
}
CLeaveLoop::CLeaveLoop()
{
}
// 绘制无车压上计数线圈
void CLeaveLoop::Off()
{
int nScreenX=theApp.nScreenX;
int nScreenY=theApp.nScreenY;
int nLeft=nScreenX*125/192;
int nRight=nScreenX*157/192;
int nTop=nScreenY*89/240-2;
int nButtom=nScreenY*57/120;
theApp.memDC.Rectangle(CRect(nLeft,nTop,nRight,nButtom));
DrawScreen();
}
// 绘制有车压上计数线圈
void CLeaveLoop::On()
{
int nScreenX=theApp.nScreenX;
int nScreenY=theApp.nScreenY;
int nLeft=nScreenX*125/192;
int nRight=nScreenX*157/192;
int nTop=nScreenY*89/240-2;
int nButtom=nScreenY*57/120;
theApp.memDC.Rectangle(CRect(nLeft,nTop,nRight,nButtom));
CBrush Brush2;
if(Brush2.CreateSolidBrush(RGB(155,250,50))==0){
SendMessage(theApp.m_pMainWnd->m_hWnd,WM_ABNORMAL,0,(LPARAM)"产生兼容画刷失败(离去线圈)\n");
return;
}
theApp.memDC.SelectObject(&Brush2);
int step=nScreenX/128;
POINT PointArray[8];
PointArray[0].x=nLeft+nScreenX/64;
PointArray[0].y=nButtom-nScreenX/40;
PointArray[1].x=PointArray[0].x+2*step;
PointArray[1].y=PointArray[0].y-3*step;
PointArray[2].x=PointArray[1].x+2*step;
PointArray[2].y=PointArray[1].y;
PointArray[3].x=PointArray[2].x+2*step;
PointArray[3].y=PointArray[2].y-2*step;
PointArray[4].x=PointArray[3].x+5*step;
PointArray[4].y=PointArray[3].y;
PointArray[5].x=PointArray[4].x+2*step;
PointArray[5].y=PointArray[2].y;
PointArray[6].x=PointArray[5].x+2*step;
PointArray[6].y=PointArray[5].y;
PointArray[7].x=PointArray[6].x+2*step;
PointArray[7].y=PointArray[0].y;
theApp.memDC.Polygon(PointArray,8);
theApp.memDC.Ellipse(PointArray[1].x,PointArray[0].y-2*step,PointArray[1].x+4*step,PointArray[0].y+2*step);
theApp.memDC.Ellipse(PointArray[6].x,PointArray[0].y-2*step,PointArray[6].x-4*step,PointArray[0].y+2*step);
theApp.memDC.SelectObject(&theApp.Brush1);
Brush2.DeleteObject();
DrawScreen();
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -