上面的例子有些错位,反正意思就是,abc三个字符我想写成b在a下面,c在b下面,都略向左错半位,我要写很多这样的字,所以不要让我一个字符一个字符的算位置。

解决方案 »

  1.   

    No.1
    procedure TForm1.BitBtn1Click(Sender: TObject);
    begin
      Image1.Picture := nil;
    end;
      

  2.   

    No.2
    procedure TForm1.BitBtn1Click(Sender: TObject);
    var
      S: string;
      I: Integer;
    begin
      S := 'abc';
      for I := 1 to Length(S) do
        Image1.Canvas.TextOut(0, (I - 1) * Image1.Canvas.TextHeight('|'), S[I]);
    end;
      

  3.   

    No.1.2
    procedure TForm1.BitBtn1Click(Sender: TObject);
    begin
      Image1.Canvas.FillRect(Rect(0, 0, Image1.Picture.Bitmap.Width - 1,
        Image1.Picture.Bitmap.Height - 1));
    end;
      

  4.   

    zswang(伴水)(被黑中) 问一下TextHeight('|')得到高度是什么意思?
      

  5.   

    TO: Lion_sj
    指定的Canvas当前字体的文字所占高度,像素数。
      

  6.   

      for I := 1 to Length(S) do
      begin    Image1.Canvas.TextOut(0, (I - 1) * Image1.Canvas.TextHeight('¦'), S[I]);
      end;
      

  7.   

    这样是不是清楚点 
      for I := 1 to Length(S) do
      begin
        x:=0;
        y:=(i-1)*Image1.Canvas.TextHeight('|');
        Image1.Canvas.TextOut(x,y, S[I]);
      end;
      
      

  8.   

    有没有什么好办法呀!
    调api应该调什么呀!!
      

  9.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      S: WideString;
      I: Integer;
    begin
      S := '汉字也可以';
      for I := 1 to Length(S) do
        Image1.Canvas.TextOut(0, (I - 1) * Image1.Canvas.TextHeight('|'), S[I]);
    end;
      

  10.   

    var
      S: WideString;
      I: Integer;
    begin
      S := '你在时时';
      for I := 1 to Length(S) do
        Image1.Canvas.TextOut((I - 1) * Image1.Canvas.TextWidth('|'), (I - 1) * Image1.Canvas.TextHeight('|'), S[I]);
    end;
      

  11.   

    var
      S: WideString;
      I: Integer;
    begin
      S := '你在时时';
      for I := 1 to Length(S) do
        Image1.Canvas.TextOut((I - 1) * Image1.Canvas.TextWidth('无'), (I - 1) * Image1.Canvas.TextHeight('吴'), S[I]);
    end;
      

  12.   

    procedure TForm1.Button1Click(Sender: TObject); 
    var 
      lf : TLogFont; 
      tf : TFont; 
    begin 
      with Form1.Canvas do begin 
        Font.Name := 'Arial'; 
        Font.Size := 24; 
        tf := TFont.Create; 
        tf.Assign(Font); 
        GetObject(tf.Handle, sizeof(lf), @lf); 
        lf.lfEscapement := 450; 
        lf.lfOrientation := 450; 
        tf.Handle := CreateFontIndirect(lf); 
        Font.Assign(tf); 
        tf.Free; 
        TextOut(20, Height div 2, 'Rotated Text!'); 
      end; 
    end; 
    ==================================
    procedure TForm1.FormMouseDown(Sender: TObject; Button: TMouseButton;
    Shift: TShiftState; X, Y: Integer);
    var
    LogFont : TLogFont;
    newFont : TFont;
    begin
    with Form1.Canvas do
    begin
    Font.Name := '黑体'; // 字体
    Font.Size := 32; // 字号
    Font.Color:= $00ffcc; // 颜色
    // 创建新字体
    newFont := TFont.Create;
    newFont.Assign(Font); // 新字体继承窗体字体的属性
    // 为新字体设置旋转属性
    GetObject(newFont.Handle, sizeof(LogFont), @LogFont);
    LogFont.lfEscapement :=600; //角度*10
    LogFont.lfOrientation :=600; //应设为同样的值
    LogFont.lfWidth:=20; //每个字符的大小
    LogFont.lfHeight:=90;
    newFont.Handle := CreateFontIndirect(LogFont);
    Font.Assign(newFont);
    newFont.Free;
    // 在鼠标按下的位置显示文字
    TextOut(X, Y, '旋转文字Demo');
    end;
    end;
      

  13.   

    zswang(伴水)(被黑中):谢谢你,你的方法很好,对我很适合,我会把30分给你但还有一个小问题想问你:你上面的方法是调了一个Font类,这样写出来的是对的,但是写出来的字会有一个矩形的底色,你有没有什么办法使得他象其它Label一样可以设置底色透明。
      

  14.   

    请问TLogFont类是什么类,我在DELPHI的帮助中怎么找不着?
      

  15.   

    //这是我的代码
    //我要看看你的
    procedure TForm1.Button1Click(Sender: TObject);
    var
      lf : TLogFont;
      tf : TFont;
      S: WideString;
      I: Integer;
    begin
      with Image1.Canvas do begin
        Font.Name := '宋体';
        Font.Size := 24;
        tf := TFont.Create;
        tf.Assign(Font);
        GetObject(tf.Handle, sizeof(lf), @lf);
        lf.lfEscapement := 450;
        lf.lfOrientation := 450;
        tf.Handle := CreateFontIndirect(lf);
        Font.Assign(tf);
        tf.Free;
      end;
      S := '汉字也可以';
      for I := 1 to Length(S) do
        Image1.Canvas.TextOut(0, I  * Image1.Canvas.TextHeight('|'), S[I]);
    end;
      

  16.   

    procedure TForm1.Button1Click(Sender: TObject);
    var
      S: WideString;
      I: Integer;
    begin
      Image2.Canvas.FillRect(Rect(0, 0, Image2.Width, Image2.Height));
      S := '汉字也可以';
      for I := 1 to Length(S) do
        Image2.Canvas.TextOut(0, I  * Image2.Canvas.TextHeight('|'), S[I]);
      Image2.Picture.Bitmap.TransParentColor := Image2.Canvas.Font.Color;
      Image2.Transparent := True;
      Image1.Canvas.Draw(1, 1, Image2.Picture.Bitmap);
    end;procedure TForm1.FormCreate(Sender: TObject);
    var
      lf : TLogFont;
      tf : TFont;
    begin
      //Image2//写字
      //Image1//放图
      with Image2.Canvas do begin
        Font.Name := '宋体';
        Font.Size := 24;
        tf := TFont.Create;
        tf.Assign(Font);
        GetObject(tf.Handle, sizeof(lf), @lf);
        lf.lfEscapement := 450;
        lf.lfOrientation := 450;
        tf.Handle := CreateFontIndirect(lf);
        Font.Assign(tf);
        tf.Free;
      end;
    end;
      

  17.   

    zswang(伴水)(被黑中):
    你没有明白我的意思,我想要Label的Transparent属性设为True后的样子
      

  18.   

    zswang(伴水)(被黑中):
    有没有新的答案