神啊,那位大哥帮我写一段代码,要求在form上或者image上画出格子图,并能根据自己的要求在不同的格子中填充不同的颜色,please,急用~,要多少分您开个价!谢谢了

解决方案 »

  1.   

    unit Unit1;interfaceuses
      Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
      Dialogs, ColorGrd, ExtCtrls, StdCtrls;type
      TForm1 = class(TForm)
        Shape1: TShape;
        Shape2: TShape;
        Shape3: TShape;
        ColorGrid1: TColorGrid;
        Shape4: TShape;
        Shape5: TShape;
        Shape6: TShape;
        Shape7: TShape;
        Shape8: TShape;
        Shape9: TShape;
        procedure ColorGrid1Change(Sender: TObject);
        procedure Shape1MouseDown(Sender: TObject; Button: TMouseButton;
          Shift: TShiftState; X, Y: Integer);
      private
        InColor:TColor;
        { Private declarations }
      public
        { Public declarations }
      end;var
      Form1: TForm1;implementation{$R *.dfm}procedure TForm1.ColorGrid1Change(Sender: TObject);
    begin
      InColor:=ColorGrid1.ForegroundColor;
    end;procedure TForm1.Shape1MouseDown(Sender: TObject; Button: TMouseButton;
      Shift: TShiftState; X, Y: Integer);
    begin
      Tshape(sender).Brush.Color:=InColor;
    end;end.
    保存为unit1.pas 你可以动态生成shape,演示还够用
      

  2.   

    首先你要能画出格子,如果能达到这个功能,那填充颜色还有何难,画每个格子都有他的Rect,然后上色就行了Canvas.Brush.Color
      

  3.   

    TCanvas.Rectangle
    TCanvas.Brush.Color
    TCanvas.Pen.Color
    TCanvas.Pen.Width
      

  4.   

    procedure TForm1.btn1Click(Sender: TObject);
    var
      rec: TRect;
      i,j: Integer;
    begin
      rec.Left := img1.Left;
      rec.Top := img1.Top;
      rec.Right := rec.Left + img1.Width;
      rec.Bottom := rec.top + img1.Height;  i := rec.Left;
      while i < rec.Right do
      begin
        j := rec.Top;
        while j < rec.Bottom do
        begin
          Canvas.Brush.Color := 你要的色;
          Canvas.Rectangle(i,j,i+10,j+10);
          Inc(j,10);
        end;
        Inc(i,10);
      end;
    end;测试通过.将img1分成若干的小格子,并按你的要求填色
    这样都还写不来,你就没搞了