请教有关控件与画图问题?(20)

  • 主题发起人 主题发起人 husion
  • 开始时间 开始时间
H

husion

Unregistered / Unconfirmed
GUEST, unregistred user!
为了更好说明问题,请先看我在百度上传的图片:http://hi.baidu.com/matin01/album/item/85bb787e990cbe2128388adf.html 窗体里面包括: 1.网格(可以显示与隐藏); 2.可以显示坐标值,并且坐标值可以更改; 3.我要在网格上面画图; 自己做过一个失败的例子: 实现网格曾用delphi自带的DrawGriD,但当我在DrawGriD上面加PaintBox画图时,发现上面层还是DrawGriD,明明PaintBox是放在上面的,奇怪?这样导致鼠标捕捉不到PaintBox,无法在上面画图。 还是有其它可以实现在网格上画图,有坐标,而且能在上面画图的方法:)
 
这个问题不好回答吗,高手呢:)
 
DrawGriD本身好像就可以画图吧
 
我要用到PaintBox里面onpaint事件,但DrawGriD没有:)
 
这个没有必要用什么控件,最好的办法是自己定义一个Panel,在添加一个Canvas,要什么自己画上去。或者直接在窗体上画。这里有一段C++Builder的代码,给你参考。//---------------------------------------------------------------------------void __fastcall TFrmMain::DrawGridLine(){ AnsiString StrData = ""; ImgPic->Canvas->Pen->Color = clBlack; ImgPic->Canvas->Pen->Width = 100; for(int i = 0; i < ImgPic->Height / 100 + 2; i++) { ImgPic->Canvas->MoveTo(0, i * 100); ImgPic->Canvas->LineTo(ImgPic->Width, i * 100); } ImgPic->Canvas->Pen->Color = clGreen; ImgPic->Canvas->Pen->Width = 1; for (int i = ImgPic->Height / Intance; i >= 0 ; i--) { ImgPic->Canvas->MoveTo(0, i * Intance); ImgPic->Canvas->LineTo(ImgPic->Width, i * Intance); if(ImgPic->Height / Intance - i != 0) { StrData = IntToStr(ImgPic->Height / Intance - i); if(RightStr(StrData, 1) != "0") { StrData = RightStr(StrData, 1); } ImgV->Canvas->TextOut(0 + 5, i * Intance, StrData); } } for (int i = ImgPic->Width / Intance; i >= 0; i--) { ImgPic->Canvas->MoveTo(i * Intance, 0); ImgPic->Canvas->LineTo(i * Intance, ImgPic->Height); if(i != 0) { StrData = IntToStr(i); if(RightStr(StrData, 1) != "0") { StrData = RightStr(StrData, 1); } ImgH->Canvas->TextOut(i * Intance, 5, StrData); } }}//---------------------------------------------------------------------------void __fastcall TFrmMain::DoDealData(){ int MinValue; randomize(); long MaxValue = ImgPic->Width; if(CanRun) { for(int i = 0; i < MaxValue; i++) ArrayInt = random(MaxValue); } double y, Value; double Pi = 3.1415926535; for(long x = 0; x < MaxValue / 2; x++) { Value = ((double)ArrayInt[x] / (double)MaxValue) * 2 * Pi; y = sin(Value); y = y * (ImgPic->Picture->Bitmap->Height / 2); y += ImgPic->Picture->Bitmap->Height / 2; ImgPic->Picture->Bitmap->Canvas->Brush->Style = bsSolid; ImgPic->Picture->Bitmap->Canvas->Pixels[int(ArrayInt[x])][int(y)] = clYellow; } }//---------------------------------------------------------------------------void __fastcall TFrmMain::DrawGridPos(){ ImgV->Canvas->Pen->Color = clBtnFace; ImgV->Canvas->Pen->Width = 100; ImgH->Canvas->Pen->Color = clBtnFace; ImgH->Canvas->Pen->Width = 100; ImgZero->Canvas->Pen->Color = clBtnFace; ImgZero->Canvas->Pen->Width = 100; for(int i = 0; i < ImgPic->Height / 100 + 2; i++) { ImgV->Canvas->MoveTo(0, i * 100); ImgV->Canvas->LineTo(ImgPic->Width, i * 100); ImgH->Canvas->MoveTo(0, i * 100); ImgH->Canvas->LineTo(ImgPic->Width, i * 100); ImgZero->Canvas->MoveTo(0, i * 100); ImgZero->Canvas->LineTo(ImgPic->Width, i * 100); } ImgZero->Canvas->Brush->Color = clBtnFace; ImgZero->Canvas->TextOut(8, 4, "0"); ImgV->Canvas->Brush->Color = clBtnFace; ImgV->Canvas->Pen->Color = clYellow; ImgH->Canvas->Brush->Color = clBtnFace;}//---------------------------------------------------------------------------void __fastcall TFrmMain::Timer1Timer(TObject *Sender){ DrawGridLine(); DoDealData(); DrawPosLine();}
 
你可以用graphic32画我做的一款软件就是的
 
to fang_csc: 你的什么软件,不明白你说什么哦
 
你可以去www.iconcool.com上一款图标软件就是我做的就有网格是用graphic32画的
 
to fang_csc: 有没有源码,能不能发我一份:yxdz126@126.com
 
源码肯定有的但不能发给你是公司的产品我可以给你一个思路就是用graphic32的TPositionedLayer建一个层 GridLayer := TPositionedLayer.create(self.Layers); GridLayer.Tag :=8; GridLayer.Location := GR32.FloatRect(0, 0, self.width, self.height); GridLayer.Scaled := true; GridLayer.MouseEvents := true; GridLayer.OnPaint :=PaintSimpleDrawingHandler;在上面画网格再把这层放上顶层你在graphic32上画图就可以了画网格的代码如下 procedure PaintSimpleDrawingHandler(Sender: TObject; Buffer: TBitmap32);var Cx,Cy,i: Integer; W2,H2: Integer; XX,YY: Integer; user_w: Boolean;beginuser_w := false; with TPositionedLayer(Sender).GetAdjustedLocation do begin W2 := 0; H2 := 0; Cx := FCompartmentWidth * FGridWidth; Cy := FCompartmentWidth * FGridHeight; buffer.PenColor := clRed32; //---------------------------------------------------//下面代码用于画出一个钜形框的x线 if FCompartmentWidth < 5 then begin user_w := true; Cx := FCompartmentWidth * FGridWidth div 5; Cy := FCompartmentWidth * FGridHeight div 5; end else begin Cx := FCompartmentWidth * FGridWidth div FCompartmentWidth; Cy := FCompartmentWidth * FGridHeight div FCompartmentWidth; end; for xx := 1 to Cy do begin if user_w then i := xx * 5 else i := xx * FCompartmentWidth; //----------------------- if (xx mod FCompartmentLineNumber)=0 then buffer.PenColor := FCompartmentColor else buffer.PenColor := FGridLineColor; //------------------------ buffer.MoveTof(1, i); buffer.LineTofs(FCompartmentWidth * FGridWidth - 1, i); end; for yy := 1 to Cx do begin xx := yy; if user_w then i := xx * 5 else i := xx * FCompartmentWidth; //----------------------- if (yy mod FCompartmentLineNumber)=0 then buffer.PenColor := FCompartmentColor else buffer.PenColor := FGridLineColor; //------------------------ buffer.MoveTof(i, 1); buffer.LineTofs(i, FCompartmentWidth * FGridHeight - 1); end; buffer.PenColor := FEdgeColor; buffer.MoveTof(0, 0); buffer.LineTofs(0, FGridHeight); buffer.MoveTof(0, 0); buffer.LineTofs(FGridWidth - 1, 0); buffer.MoveTof(FGridWidth - 1, 0); buffer.LineTofs(FGridWidth - 1, FGridHeight - 1); buffer.MoveTof(0, FGridHeight - 1); buffer.LineTofs(FGridWidth, FGridHeight - 1); end;end;
 
to fang_csc: 你说的那个网址是哪个软件,把链接发给我,我下载看看
 
IconCool Studio你下吧
 
to fang_csc: 软件下载了,也安装了,提示好像要下载新版本,请问哪个才是新的,试了几个都不行
 
你QQ是多少加我吧345966848
 
我加你了446170752
 
多人接受答案了。
 
后退
顶部