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

📄 dlgalarmerview.cpp

📁 串口收发工具
💻 CPP
📖 第 1 页 / 共 2 页
字号:
		}
	}
	DWORD dwtemp=((GroupStation.Alarm32s_Enable&0xff)<<24)+((GroupStation.Alarm32s_Enable&0xff00)<<8)
			+((GroupStation.Alarm32s_Enable&0xff0000)>>8)+((GroupStation.Alarm32s_Enable&0xff000000)>>24);
	for(i=0;i<32;i++)
	{
		if (dwtemp & 0x01) SetTextColor(hDC,RGB(0,0,255));
		else SetTextColor(hDC,RGB(192,192,192));
		sprintf(temp,"%d",i+1);
		TextOut(hDC,36+(i+1)*nWidth,36,temp,strlen(temp));
		dwtemp >>= 1;
	}
}

void CDlgAlarmerView::FifthGroupDC(HDC hDC)
{
	char temp[100];
	int nWidth = 22 ;
	int nHeight = 24;

	GetClientRect(rect);

	int nX = 30;
	int nY = 30;

	//标题栏的显示
	strcpy(temp,"遥控输出与告警输入对应关系----下");
	TextOut(hDC,nX+300,0,temp,strlen(temp));
	strcpy(temp,"报警输入号→");
	TextOut(hDC,nX,13,temp,strlen(temp));
	strcpy(temp,"遥");
	TextOut(hDC,13,30,temp,strlen(temp));
	strcpy(temp,"控");
	TextOut(hDC,13,45,temp,strlen(temp));
	strcpy(temp,"输");
	TextOut(hDC,13,60,temp,strlen(temp));
	strcpy(temp,"出");
	TextOut(hDC,13,75,temp,strlen(temp));
	strcpy(temp,"号");
	TextOut(hDC,13,90,temp,strlen(temp));
	strcpy(temp,"↓");
	TextOut(hDC,13,105,temp,strlen(temp));
	strcpy(temp,"第5页");
	TextOut(hDC,nX+300,485,temp,strlen(temp));

	// 表格外框架线条的生成
	rect.SetRect(nX,nY,nX+33*nWidth+2,nY+17*nHeight+2);
	DrawRect(hDC,rect,RGB(128,128,128));
	rect.DeflateRect(1,1);
	DrawRect(hDC,rect,RGB(0,0,0));
	rect.DeflateRect(1,1);
	DrawRect(hDC,rect,RGB(192,192,192));

	for(int i=0;i<32;i++)
	{
		DrawLine(hDC,rect.left+(i+1)*nWidth,rect.top,rect.left+(i+1)*nWidth,rect.bottom,RGB(128,128,128));
	}
	for(i=0;i<16;i++)
	{
		DrawLine(hDC,rect.left,rect.top+(i+1)*nHeight,rect.right,rect.top+(i+1)*nHeight,RGB(128,128,128));
	}
	for(i=0;i<16;i++)
	{
		sprintf(temp,"%d",i+17);
		TextOut(hDC,36,36+(i+1)*nHeight,temp,strlen(temp));
	}
	for(int j=0;j<16;j++)
	{
		DWORD dwtemp=((GroupStation.Node_Out[j+16]&0xff)<<24)+((GroupStation.Node_Out[j+16]&0xff00)<<8)
			+((GroupStation.Node_Out[j+16]&0xff0000)>>8)+((GroupStation.Node_Out[j+16]&0xff000000)>>24);
		for(i=0;i<32;i++)
		{
			if (dwtemp & 0x01)
			{
				strcpy(temp,"√");
				TextOut(hDC,36+(i+1)*nWidth,36+(j+1)*nHeight,temp,strlen(temp));
			}
			dwtemp >>= 1;
		}
	}
	DWORD dwtemp=((GroupStation.Alarm32s_Enable&0xff)<<24)+((GroupStation.Alarm32s_Enable&0xff00)<<8)
			+((GroupStation.Alarm32s_Enable&0xff0000)>>8)+((GroupStation.Alarm32s_Enable&0xff000000)>>24);
	for(i=0;i<32;i++)
	{
		if (dwtemp & 0x01) SetTextColor(hDC,RGB(0,0,255));
		else SetTextColor(hDC,RGB(192,192,192));
		sprintf(temp,"%d",i+1);
		TextOut(hDC,36+(i+1)*nWidth,36,temp,strlen(temp));
		dwtemp >>= 1;
	}
}

void CDlgAlarmerView::SixthGroupDC(HDC hDC)
{

	char temp[100];
	int nWidth = 22 ;
	int nHeight = 24;

	GetClientRect(rect);

	int nX = 30;
	int nY = 30;
	//标题栏的显示
	strcpy(temp,"1~32路报警输入的报警使能、取反系数、布撤防状态一览");
	TextOut(hDC,nX+200,5,temp,strlen(temp));
	strcpy(temp,"报警输入号→");
	TextOut(hDC,nX,13,temp,strlen(temp));
	strcpy(temp,"使能");
	TextOut(hDC,nX-30,60,temp,strlen(temp));
	strcpy(temp,"取反");
	TextOut(hDC,nX-30,85,temp,strlen(temp));
	strcpy(temp,"状态");
	TextOut(hDC,nX-30,110,temp,strlen(temp));
	strcpy(temp,"第1页");
	TextOut(hDC,nX+300,485,temp,strlen(temp));

	strcpy(temp,"1~32防区的布撤防控制号一览");
	TextOut(hDC,nX+300,200,temp,strlen(temp));
	strcpy(temp,"防区号");
	TextOut(hDC,nX+2,235,temp,strlen(temp));
	TextOut(hDC,nX+2,235+2*nHeight,temp,strlen(temp));
	strcpy(temp,"控制号");
	TextOut(hDC,nX+2,235+nHeight,temp,strlen(temp));
	TextOut(hDC,nX+2,235+3*nHeight,temp,strlen(temp));
	
	WORD wtemp=GroupStation.Alarm_Ring_Delay;
	wtemp = (LOBYTE(wtemp)<<8)+HIBYTE(wtemp);
	sprintf(temp,"报警响铃延时时间:%d秒",wtemp);
	TextOut(hDC,56,135,temp,strlen(temp));
	// 表格外框架线条的生成
	rect.SetRect(nX,nY,nX+32*nWidth+2,nY+4*nHeight+2);
	DrawRect(hDC,rect,RGB(128,128,128));
	rect.DeflateRect(1,1);
	DrawRect(hDC,rect,RGB(0,0,0));
	rect.DeflateRect(1,1);
	DrawRect(hDC,rect,RGB(192,192,192));

	//1 frame	
	for(int i=0;i<32;i++)
	{
		DrawLine(hDC,rect.left+(i+1)*nWidth,rect.top,rect.left+(i+1)*nWidth,rect.bottom,RGB(128,128,128));
	}
	for(i=0;i<3;i++)
	{
		DrawLine(hDC,rect.left,rect.top+(i+1)*nHeight,rect.right,rect.top+(i+1)*nHeight,RGB(128,128,128));
	}
		//第2个表
	rect.SetRect(nX,nY+200,nX+34*nWidth+2,nY+200+4*nHeight);
	DrawRect(hDC,rect,RGB(128,128,128));
	rect.DeflateRect(1,1);
	DrawRect(hDC,rect,RGB(0,0,0));
	rect.DeflateRect(1,1);
	DrawRect(hDC,rect,RGB(192,192,192));
	for(i=0;i<16;i++)
	{
		DrawLine(hDC,rect.left+(i+1)*nWidth*2,rect.top,rect.left+(i+1)*nWidth*2,rect.bottom,RGB(128,128,128));
	}
	for(i=0;i<3;i++)
	{
		DrawLine(hDC,rect.left,rect.top+(i+1)*nHeight,rect.right,rect.top+(i+1)*nHeight,RGB(128,128,128));
	}


   //1 frame
	for(i=0;i<32;i++)
	{
		sprintf(temp,"%d",i+1);
		TextOut(hDC,36+i*nWidth,36,temp,strlen(temp));
	}
	//2 frame
	for(i=0;i<16;i++)
	{
		sprintf(temp,"%d",i+1);
	//	crTextPre = SetTextColor(hDC,(bPowerDCYX[0] & 0x02)?RGB(255,0,0):RGB(192,192,192));
		TextOut(hDC,40+(i+1)*nWidth*2,235,temp,strlen(temp));
	
	}

	for(i=0;i<16;i++)
	{
		sprintf(temp,"%d",i+17);
		TextOut(hDC,40+(i+1)*nWidth*2,235+2*nHeight,temp,strlen(temp));
	}
	SetTextColor(hDC,RGB(0,0,255));
	DWORD dwtemp=((GroupStation.Alarm32s_Enable&0xff)<<24)+((GroupStation.Alarm32s_Enable&0xff00)<<8)
			+((GroupStation.Alarm32s_Enable&0xff0000)>>8)+((GroupStation.Alarm32s_Enable&0xff000000)>>24);
	for(i=0;i<32;i++)
	{
		if (dwtemp & 0x01)
		{
			strcpy(temp,"√");
			TextOut(hDC,36+i*nWidth,36+nHeight,temp,strlen(temp));
		}
		dwtemp >>= 1;
	}

	dwtemp=(GroupStation.YxNotD<<24)+(GroupStation.YxNotC<<16)
			+(GroupStation.YxNotB<<8)+GroupStation.YxNotA;
	for(i=0;i<32;i++)
	{
		if (dwtemp & 0x01)
		{
			strcpy(temp,"√");
			TextOut(hDC,36+i*nWidth,36+2*nHeight,temp,strlen(temp));
		}
		dwtemp >>= 1;
	}
	dwtemp=((GroupStation.ALarm_Status&0xff)<<24)+((GroupStation.ALarm_Status&0xff00)<<8)
			+((GroupStation.ALarm_Status&0xff0000)>>8)+((GroupStation.ALarm_Status&0xff000000)>>24);
	//dwtemp=GroupStation.ALarm_Status;
	for(i=0;i<32;i++)
	{
		if (dwtemp & 0x01)
		{
			strcpy(temp,"√");
			TextOut(hDC,36+i*nWidth,36+3*nHeight,temp,strlen(temp));
		}
		dwtemp >>= 1;
	}
	//frame 2
	for(i=0;i<16;i++)
	{
	
		sprintf(temp,"%d",GroupStation.FangQu_BCHControl_ID[i]);
		TextOut(hDC,40+(i+1)*nWidth*2,235+nHeight,temp,strlen(temp));
		//第2行
		sprintf(temp,"%d",GroupStation.FangQu_BCHControl_ID[i+16]);
		TextOut(hDC,40+(i+1)*nWidth*2,235+3*nHeight,temp,strlen(temp));
	}

}

////////////////////////////////////////////////////////////////////////////
// 画出一条直线

void CDlgAlarmerView::DrawLine(HDC hDC,int x0,int y0,int x1,int y1,COLORREF crLine)
{
	HPEN hPen = CreatePen(PS_SOLID,1,crLine);
	HPEN hOldPen = (HPEN)SelectObject(hDC,hPen);
	MoveToEx(hDC,x0,y0,NULL);
	LineTo(hDC,x1,y1);
	SelectObject(hDC,hOldPen);
	DeleteObject(hPen);
}

/////////////////////////////////////////////////////////////////////////////
// 画出一个空心的矩形

void CDlgAlarmerView::DrawRect(HDC hDC,LPRECT lpRect,COLORREF crRect)
{
	HBRUSH hBrush = (HBRUSH)GetStockObject(NULL_BRUSH);
	HBRUSH hOldBrush = (HBRUSH)SelectObject(hDC,hBrush);
	HPEN hPen = CreatePen(PS_SOLID,1,crRect);
	HPEN hOldPen = (HPEN)SelectObject(hDC,hPen);
	Rectangle(hDC,lpRect->left,lpRect->top,lpRect->right,lpRect->bottom);
	SelectObject(hDC,hOldPen);
	DeleteObject(hPen);
	SelectObject(hDC,hOldBrush);
//	DeleteObject(hBrush);
}
void CDlgAlarmerView::TransBuf(BYTE *buf,int len)
{
	CPaintDC dc(this); // device context for painting
	HDC hDC = dc.GetSafeHdc();
	query_flag=2;
	memcpy(bDataBuf,buf,len);
	memcpy(&GroupStation,bDataBuf,sizeof(GROUPSTATION));
	RedrawWindow();//去掉老的显示
//	SecondGroupDC(hDC);

}

void CDlgAlarmerView::OnAlarmerVQU() 
{
	query_flag=1;
	((CMainFrame*)AfxGetMainWnd())->CallAlarmer(); 
	RedrawWindow();//去掉老的显示
}

int CDlgAlarmerView::OnCreate(LPCREATESTRUCT lpCreateStruct) 
{
	if (CFrameWnd::OnCreate(lpCreateStruct) == -1)
		return -1;
	int nX = 30;
	int nY = 30;
	CPaintDC dc(this); // device context for painting
	HDC hDC = dc.GetSafeHdc();
	ZeroMemory(&GroupStation,sizeof(GroupStation));
	query_flag=1;
	((CMainFrame*)AfxGetMainWnd())->CallAlarmer(); 
	RedrawWindow();//去掉老的显示
	return 0;
}

void CDlgAlarmerView::OnAlarmerVP1() 
{
	m_fGroupFirstPage =	1;	
	RedrawWindow();//去掉老的显示
}

void CDlgAlarmerView::OnAlarmerVP2() 
{
	m_fGroupFirstPage =	2;	
	RedrawWindow();//去掉老的显示
}

void CDlgAlarmerView::OnAlarmerVP3() 
{
	m_fGroupFirstPage =	3;
	RedrawWindow();//去掉老的显示
}

void CDlgAlarmerView::OnAlarmerVP4() 
{
	m_fGroupFirstPage =	4;
	RedrawWindow();//去掉老的显示
	
}

void CDlgAlarmerView::OnAlarmerVP5() 
{
	m_fGroupFirstPage =	5;
	RedrawWindow();//去掉老的显示
	
}

⌨️ 快捷键说明

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