|
高手你好,由于工作需要,做一个阵面监测的程序,
我在窗口上画的矩形没有任何显示,为什么?程序如下
int MyDetectWin::MyDraw(int left,int top,int width,int height) { ZafRegionStruct drawRegion ; //BeginDraw(); ZafDisplay *display = Display(); display->SetCoordinateType(ZAF_PIXEL); BeginDraw(); drawRegion.left = 10; drawRegion.top = 10; drawRegion.right = drawRegion.left + 100; drawRegion.bottom = drawRegion.top + 100;
display->SetBackground(ZAF_CLR_RED); display->Rectangle(drawRegion,1,true); //display->DestroyColor(color); ZafPrompt *lable=new ZafPrompt(drawRegion.left,drawRegion.top,40, ZAF_ITEXT("prompt"));//prompt在界面上可以看到,说明执行了。 lable->SetCoordinateType(ZAF_PIXEL); Add(lable); EndDraw(); return 1; }
但是用鼠标消息画的矩形却有显示:
ZafEventType MyDetectWin::Event(const ZafEventStruct &event) { ZafEventType ccode = LogicalEvent(event); char buf[50]; ZafDisplay *replay = Display(); switch (ccode) { case L_BEGIN_SELECT: { ccode = ZafWindow::Event(event);
//WindowManager()->SetMouseEventRoute(this);//这一句会导致任何鼠标事件都发给她处理,破坏了 origin = event.position; //原来的路由方式. replay->SetCoordinateType(ZAF_PIXEL); origin_PIXEL = origin.Position(ZAF_PIXEL); sprintf(buf,"%d",origin_PIXEL.column); rowstring->SetText(ZAF_ITEXT(buf)); sprintf(buf,"%d",origin_PIXEL.line); linestring->SetText(ZAF_ITEXT(buf)); BeginDraw(); ZafRegionStruct redrawRegion ; redrawRegion.left = origin_PIXEL.column; redrawRegion.top = origin_PIXEL.line; redrawRegion.right = redrawRegion.left + CELLWIDTH; redrawRegion.bottom = redrawRegion.top + CELLHEIGHT; replay->SetBackground(ZAF_CLR_RED); replay->Rectangle(redrawRegion,1,true); EndDraw(); } break; default: ccode = ZafWindow::Event(event); }
return (ccode); }
怎么办?
我需要画几十个矩形呢!!对了MyDetectWin是加在notebook上的。
MyTabBook::MyTabBook(int left ,int top,int width,int height) :ZafNotebook(left, top, width, height) { SetCoordinateType(ZAF_PIXEL);
ZafWindow *page1 = new MyDetectWin(left,top,width,height); page1->Add(new ZafTitle("Array Detect"));
Add(page1);
tableft = left; tabtop = top; tabwidth = width; tabheight = height; }
我感觉是画了,但是又被重画刷新了,怎么改? |