3.4.2 具体实现(9)
- }
- else
- {
- ColorVal = atoi(tempStr2);
- tempStr2.Empty();
- }
- //获得一个值
- //改变前景颜色,这个颜色可以按照一定的规则自定义
- if (ColorVal>29 && ColorVal<38)
- //cTextColor = RGB(0,0,255);
- //设置背景颜色
- if (ColorVal>39 && ColorVal<48)
- //cBackgroundColor = RGB(0,255,ColorVal);
- //恢复基本设置
- if (ColorVal==0)
- {
- //cBackgroundColor = RGB(0,0,0);
- //cTextColor = RGB(255,255,255);
- }
- //如果为1,则设置前景色
- //if ColorVal==1
- //表示要反色
- //if ColorVal==7
- }
- }
- //如果为字符K,表示要画一条背景色的矩形区域
- if (pText[loop] == 'K')
- {
- int x, y;
- CString myStr;
- //保持原来的坐标
- //画出矩形区域,因为以背景色画,所以相当于移动光标
- //将坐标变量改变到目前的位置
- x = CurrentXX;
- y = CurrentYY;
- for (int l=CurrentXX; l<80; l++)
- {
- cText[l][CurrentYY] = ' ';
- myStr += ' ';
- }
- pDC->TextOut(x*dtX, y*dtY, myStr);
- CurrentXX = x;
- CurrentYY = y;
- }
- //如果字符为C,表示要改变当前的横坐标
- if (pText[loop] == 'C')
- {
- //获得横坐标的改变量
- if (tempStr2.Find(";") != -1)
- {
- ColorVal = atoi(tempStr2.Mid(0, tempStr2.Find(";")));
- tempStr2tempStr2 = tempStr2.Mid(tempStr2.Find(";") + 1);
- }
- else
- {
- ColorVal = atoi(tempStr2);
- tempStr2.Empty();
- }
- //然后增建坐标值,注意这里要加上字符宽度
- CurrentXXCurrentXX = CurrentXX + ColorVal;
- }
- //如果字符为H,表示重新设置横坐标和纵坐标
- if (pText[loop] == 'H')
- {
- //获得纵坐标值,在服务器发送的过程中,先发送纵坐标值
- TRACE0("H");
- int tX=0, tY=0;
- //char buffer3[20];
- tY = atoi(tempStr2.Mid(0, tempStr2.Find(";")));
- tempStr2tempStr2 = tempStr2.Mid(tempStr2.Find(";") + 1);
- //获得横坐标值,注意这里获得的值是没有加字符宽度的
- tX = atoi(tempStr2);
- if (tX>0 && tY>0)
- {
- CurrentYY = tY - 1;
- CurrentXX = tX - 1;
- }
- }
- //如果为字符J,表示要清除整个屏幕
- if (pText[loop] == 'J')
- {
- ClearWindows(pDC);
- }
- }
- loop++;
- IfOutput = false;
- break;
-
- case 0:
- loop++;
-
- case 10: //换行
- {
- CurrentYYCurrentYY = CurrentYY + 1;
- if (CurrentYY >= bufferLines)
- {
- for(int row=0; row<bufferLines; row++)
- {
- for(int col=0; col<80; col++)
- {
- cText[col][row] = cText[col][row+1];
- }
- }
- for(int col=0; col<80; col++)