for(;;)
{
pMsg=WaitMessage(0);
switch(pMsg->Message)
{
case OSM_TOUCH_SCREEN:
Touch_Position.x=pMsg->WParam&0xffff;
Touch_Position.y=pMsg->WParam>>16;
if(Frame_State==0)//初始化界面
{
if(IsInRect2(pFirst_Button_RECT, pTouch_Position))// 判断进入流程图界面
{
Frame_State=1;
ClearScreen();
DrawButton(pLine_Button);
DrawButton(pCircle_Button);
DrawButton(pCurve_Button);
DrawButton(pClear_Button);
DrawButton(pGreen_Button);
DrawButton(pRed_Button);
DrawButton(pBlue_Button);
DrawButton(pRect_Button);
DrawButton(pTri_Button);
DrawButton(pTwowidth_Button);
DrawButton(pFourwidth_Button);
DrawButton(pBack_Button);
DrawWindow(pDraw_Wnd);
}
else if(IsInRect2(pSecond_Button_RECT, pTouch_Position))//判断进入流程图界面
{
Frame_State=2;
Key_Counter=0;
ClearScreen();
DrawButton(pBack2_Button);
DrawWindow(pDraw_Wnd);
}
else if(IsInRect2(pThird_Button_RECT, pTouch_Position))//判断进入滚动字幕的界面
{
Frame_State=3;
ClearScreen();
DrawButton(pLeftToRight_Button);
DrawButton(pUpToDown_Button);
DrawButton(pBack2_Button);
DrawWindow(pDraw_Wnd);
}
}
else if(Frame_State==1)//电子画板
{
if(IsInRect2(pLine_Button_RECT, pTouch_Position))// line
{
Draw_State=1;
Line_State=0;
}
else if(IsInRect2(pCircle_Button_RECT, pTouch_Position))// circle
{
Draw_State=2;
Circle_State=0;
}
else if(IsInRect2(pCurve_Button_RECT, pTouch_Position))//curve
{
Draw_State=3;
}
else if(IsInRect2(pClear_Button_RECT, pTouch_Position))//clear
{
DrawWindow(pDraw_Wnd);
}
else if(IsInRect2(pRed_Button_RECT,pTouch_Position))//R
{
SetPenColor(pdc,RGB(0,0,255));
}
else if(IsInRect2(pGreen_Button_RECT,pTouch_Position))//G
{
SetPenColor(pdc,RGB(0,255,0));
}
else if(IsInRect2(pBlue_Button_RECT,pTouch_Position))//B
{
SetPenColor(pdc,RGB(255,0,0));
}
else if(IsInRect2(pTwowidth_Button_RECT,pTouch_Position))//2p
{
SetPenWidth(pdc,2);
}
else if(IsInRect2(pFourwidth_Button_RECT,pTouch_Position))//4p
{
SetPenWidth(pdc,4);
}
else if(IsInRect2(pRect_Button_RECT,pTouch_Position))//rect
{
Draw_State=5;
Rect_State=0;
}
else if(IsInRect2(pTri_Button_RECT,pTouch_Position))//tri
{
Draw_State=4;
Triangle_State=0;
}
else if(IsInRect2(pDraw_Wnd_RECT, pTouch_Position))
{
switch(Draw_State)
{
case 1:
if(pMsg->LParam==TCHSCR_ACTION_CLICK) // line
{
if(Line_State==0)
{
MoveTo(pdc, Touch_Position.x, Touch_Position.y);//移动到第一个触摸点
Line_State=1; //将Linestate 置1
}
else
{
LineTo( pdc, Touch_Position.x,Touch_Position.y);
Line_State=0; // 画线结束。
}
}
break;
case 2:
if(pMsg->LParam==TCHSCR_ACTION_CLICK) //circle
{
if(Circle_State==0)
{
x0=Touch_Position.x;
y0=Touch_Position.y; //保存圆心坐标
Circle_State=1;
}
else
{
r=sqrt((x0-Touch_Position.x)*(x0-Touch_Position.x)+(y0-Touch_Position.y)*(y0-Touch_Position.y));
Circle(pdc,x0,y0,r);
Circle_State=0; //画圆结束
}
}
break;
case 3:
switch(pMsg->LParam) //curve
{
case TCHSCR_ACTION_DOWN: //触摸屏按下
MoveTo(pdc, Touch_Position.x, Touch_Position.y);
break;
case TCHSCR_ACTION_MOVE:// 触摸屏移动
LineTo(pdc, Touch_Position.x, Touch_Position.y);
break;
}
break;
case 4:
if(pMsg->LParam==TCHSCR_ACTION_CLICK) // triangle
{
if(Triangle_State==0)
{
MoveTo(pdc, Touch_Position.x, Touch_Position.y);
x0=Touch_Position.x;
y0=Touch_Position.y;//保存第一个触摸点,并将triangle_state置1
Triangle_State=1;
}
else if(Triangle_State==1)
{
Triangle_State=2;
LineTo( pdc, Touch_Position.x,Touch_Position.y);//将第一个点与第二个点连接
MoveTo(pdc, Touch_Position.x, Touch_Position.y);
}
else
{
LineTo( pdc, Touch_Position.x,Touch_Position.y);//将第二个点与第三个点连接
MoveTo(pdc, Touch_Position.x, Touch_Position.y);
LineTo( pdc,x0,y0);//与第一个点连接
Triangle_State=0; //三角形画完结束
}
}
break;
case 5:
if(pMsg->LParam==TCHSCR_ACTION_CLICK) // rectangle
{
if(Rect_State==0)
{
x0=Touch_Position.x;
y0=Touch_Position.y; //保存第一个触摸点
Rect_State=1;
}
else
{
Rect_State=0;
DrawRectFrame(pdc,x0,y0,Touch_Position.x,Touch_Position.y);
}
}
break;
default:
break;
}
}
else if(IsInRect2(pBack_Button_RECT, pTouch_Position)) // 电子画板返回按钮
{
Frame_State = 0;
ClearScreen();
DrawButton(pFirst_Button);
DrawButton(pThird_Button);
DrawButton(pSecond_Button);
DrawWindow(pDraw_Wnd);
ShowBmp(pdc,bmpname,130,20);
TextOut(pdc,200,160,Class_Caption_16,TRUE,FONTSIZE_SMALL);
TextOut(pdc,200,180,Name_Caption_16,TRUE,FONTSIZE_SMALL);
}
}
else if(Frame_State==2)//流程图返回按钮
{
if(IsInRect2(pBack2_Button_RECT, pTouch_Position))
{
Frame_State = 0;
ClearScreen();
DrawButton(pFirst_Button);
DrawButton(pThird_Button);
DrawButton(pSecond_Button);
DrawWindow(pDraw_Wnd);
ShowBmp(pdc,bmpname,130,20);
TextOut(pdc,200,160,Class_Caption_16,TRUE,FONTSIZE_SMALL);
TextOut(pdc,200,180,Name_Caption_16,TRUE,FONTSIZE_SMALL);
}
}
else if(Frame_State==3)//滚动字幕
{
if(IsInRect2(pLeftToRight_Button_RECT, pTouch_Position)) //从左到右滚动字
{
Word_Position=135;//初始化定在left 的135 位置
FillRect2(pdc,pShow_Word2_RECT,GRAPH_MODE_NORMAL,RGB(255,255,255));
do{
OSTimeDly(100);//延时
FillRect2(pdc,pShow_Word_RECT,GRAPH_MODE_NORMAL,RGB(255,255,255));//清除字符串区
//显示字符串
TextOut(pdc,Word_Position,100,Show_Word_Caption_16,TRUE,FONTSIZE_SMALL);
Word_Position+=5;//计算下一个位置
//是否到边界(while)
}while(Word_Position<260);
}
else if(IsInRect2(pUpToDown_Button_RECT,pTouch_Position)) //从上到下滚动字
{
Word_Position=20;//初始化定义在top:20的位置
FillRect2(pdc,pShow_Word_RECT,GRAPH_MODE_NORMAL,RGB(255,255,255));
do{
OSTimeDly(100);//延时
FillRect2(pdc,pShow_Word2_RECT,GRAPH_MODE_NORMAL,RGB(255,255,255));//清除字符串区
//显示字符串
TextOut(pdc,135,Word_Position,Show_Word_Caption_16,TRUE,FONTSIZE_SMALL);
Word_Position+=5;//计算下一个位置
//是否到边界(while)
}while(Word_Position<170);
}
else if(IsInRect2(pBack2_Button_RECT, pTouch_Position)) //滚动字幕的返回主界面按钮
{
Frame_State = 0;
ClearScreen();
DrawButton(pFirst_Button);
DrawButton(pThird_Button);
DrawButton(pSecond_Button);
DrawWindow(pDraw_Wnd);
ShowBmp(pdc,bmpname,130,20);
TextOut(pdc,200,160,Class_Caption_16,TRUE,FONTSIZE_SMALL);
TextOut(pdc,200,180,Name_Caption_16,TRUE,FONTSIZE_SMALL);
}
}
break;
case OSM_KEY://键盘消息
if(Frame_State==2)
{
if(pMsg->WParam==14)//Enter键的键值
{
if(Key_Counter == 0)
{
MoveTo(pdc, 198, 27);
LineTo(pdc, 246, 27);
LineTo(pdc,253,20);
LineTo(pdc,246,13);
LineTo(pdc, 198, 13);
LineTo(pdc,191,20);
LineTo(pdc,198,27);
TextOut(pdc,203,15,Process_Chart_1_Caption_16,TRUE,FONTSIZE_SMALL);//textout "start"
MoveTo(pdc, 221, 27);
LineTo(pdc, 221, 37);
DrawRectFrame(pdc, 168, 37, 273, 55);//left,top,right,bottom
TextOut(pdc, 180, 41, Process_Chart_2_Caption_16,TRUE, FONTSIZE_SMALL); //textout"input a,b,c"
}
else if(Key_Counter == 1)
{
MoveTo(pdc,221, 53);
LineTo(pdc, 221, 59);
LineTo(pdc, 189, 75);
LineTo(pdc, 221, 91);
LineTo(pdc, 253, 75);
LineTo(pdc, 221, 59);
TextOut(pdc, 211, 72, Process_Chart_3_Caption_16, TRUE, FONTSIZE_SMALL);//textout"a>b"
MoveTo(pdc, 189, 75);
LineTo(pdc, 166, 75);
LineTo(pdc, 166, 89);
TextOut(pdc, 178, 62, Process_Chart_4_Caption_16, TRUE, FONTSIZE_SMALL);//textout"T"
MoveTo(pdc, 253, 75);
LineTo(pdc, 267, 75);
LineTo(pdc, 267, 89);
TextOut(pdc, 255, 62, Process_Chart_5_Caption_16, TRUE, FONTSIZE_SMALL);//textout"F"
DrawRectFrame(pdc, 138, 89, 193, 103);
TextOut(pdc, 143, 90, Process_Chart_6_Caption_16, TRUE, FONTSIZE_SMALL);//textout"MAX<-A"
DrawRectFrame(pdc, 239, 89, 294, 103);
TextOut(pdc, 245, 90, Process_Chart_7_Caption_16, TRUE, FONTSIZE_SMALL);//textout"MAX<-B"
}
else if(Key_Counter == 2)
{
MoveTo(pdc, 166, 103);
LineTo(pdc, 166, 112);
MoveTo(pdc, 267, 103);
LineTo(pdc, 267, 112);
LineTo(pdc, 166, 112);
MoveTo(pdc, 221, 112);
LineTo(pdc, 221, 117);
LineTo(pdc, 189, 133);
LineTo(pdc, 221, 149);
LineTo(pdc, 253, 133);
LineTo(pdc, 221, 117);
TextOut(pdc, 205, 129, Process_Chart_8_Caption_16, TRUE, FONTSIZE_SMALL);//textout"C>MAX"
MoveTo(pdc, 189, 133);
LineTo(pdc, 166, 133);
LineTo(pdc, 166, 151);
TextOut(pdc, 178,121, Process_Chart_4_Caption_16, TRUE, FONTSIZE_SMALL);//textout"T"
DrawRectFrame(pdc, 138, 151, 193, 165);
TextOut(pdc, 143, 153, Process_Chart_9_Caption_16, TRUE, FONTSIZE_SMALL);//textout"MAX<-C"
}
else if(Key_Counter == 3)
{
TextOut(pdc, 255, 121, Process_Chart_5_Caption_16, TRUE, FONTSIZE_SMALL);//textout"F"
MoveTo(pdc, 253, 133);
LineTo(pdc, 267, 133);
LineTo(pdc, 267, 173);
MoveTo(pdc, 166, 165);
LineTo(pdc, 166, 173);
LineTo(pdc, 267, 173);
MoveTo(pdc, 216, 173);
LineTo(pdc, 216, 184);
DrawRectFrame(pdc, 164, 184, 269, 200);
TextOut(pdc, 180, 187, Process_Chart_10_Caption_16, TRUE, FONTSIZE_SMALL);//textout"Output Max"
MoveTo(pdc, 216, 200);
LineTo(pdc, 216, 205);
MoveTo(pdc, 193, 219);
LineTo(pdc, 241, 219);
LineTo(pdc,248,212);
LineTo(pdc,241,205);
LineTo(pdc, 193, 205);
LineTo(pdc,186,212);
LineTo(pdc,193,219);
TextOut(pdc,207,207,Process_Chart_11_Caption_16,TRUE,FONTSIZE_SMALL);//textout"End"
}
if(Key_Counter>=3)
{
Key_Counter=0;
}
else
{
Key_Counter++;
}
OSOnSysMessage(pMsg);
}
else
{
OSOnSysMessage(pMsg);
}
}
break;
}
DeleteMessage(pMsg);
OSTimeDly(100);
}
} |