start_draw.cpp

来自「开发虚拟的被控对象及虚拟的PLC,模似PLC的工作过程进行实验。用户可根据具体的」· C++ 代码 · 共 87 行

CPP
87
字号
//初始界面
#include "stdafx.h"
#include "PLC_DEMO.h"
#include "PLC_DEMODoc.h"
#include "PLC_DEMOView.h"

extern CPLC_DEMOView *fordraw;

void initializedraw()
{
	CDC *thisDC;
	thisDC=fordraw->GetDC();
	CBrush brushred(RGB(255,0,0));
	CPoint x1(50,110);
	CRect r1(x1,x1);
	r1.InflateRect(30,95);
	thisDC->FrameRect(&r1,&brushred);

	CPoint x4(150,110);
	CRect r4(x4,x4);
	r4.InflateRect(20,95);
	thisDC->FrameRect(&r4,&brushred);

	CBrush brushblue(RGB(0,0,255));
	CPoint x2(50,384);
	CRect r2(x2,x2);
	r2.InflateRect(30,115);
	thisDC->FrameRect(&r2,&brushblue);

  	CPoint x3(150,384);
	CRect r3(x3,x3);
	r3.InflateRect(20,115);
	thisDC->FrameRect(&r3,&brushblue);
   
	CPen blackpen(PS_SOLID,2,RGB(0,0,0));
	CPen *old=thisDC->SelectObject(&blackpen);
	
	thisDC->MoveTo(162,33);//线段
	thisDC->LineTo(200,33);
	thisDC->MoveTo(162,60);
	thisDC->LineTo(200,60);
	thisDC->MoveTo(162,87);
	thisDC->LineTo(200,87);
	thisDC->MoveTo(162,111);
	thisDC->LineTo(200,111);
	thisDC->MoveTo(162,137);
	thisDC->LineTo(200,137);
	thisDC->MoveTo(162,162);
	thisDC->LineTo(200,162);
	thisDC->MoveTo(162,189);
	thisDC->LineTo(200,189);

	thisDC->MoveTo(162,290);
	thisDC->LineTo(200,290);
	thisDC->MoveTo(162,314);
	thisDC->LineTo(200,314);
	thisDC->MoveTo(162,336);
	thisDC->LineTo(200,336);
	thisDC->MoveTo(162,360);
	thisDC->LineTo(200,360);
	thisDC->MoveTo(162,383);
	thisDC->LineTo(200,383);
	thisDC->MoveTo(162,407);
	thisDC->LineTo(200,407);
	thisDC->MoveTo(162,431);
	thisDC->LineTo(200,431);
	thisDC->MoveTo(162,454);
	thisDC->LineTo(200,454);
	thisDC->MoveTo(162,478);
	thisDC->LineTo(200,478);

	thisDC->MoveTo(50,205);//PLC
	thisDC->LineTo(50,216);
	thisDC->MoveTo(30,216);
	thisDC->LineTo(70,216);
	thisDC->LineTo(70,256);
	thisDC->LineTo(30,256);
	thisDC->LineTo(30,216);
	thisDC->MoveTo(50,256);
	thisDC->LineTo(50,269);	

	thisDC->MoveTo(280,20);
	thisDC->LineTo(280,510);//界线
     
	thisDC->SelectObject(old);
	fordraw->ReleaseDC(thisDC);	
}

⌨️ 快捷键说明

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