如果使用重音符号,可以使用奇怪的字符输出 - 拉撒路

时间:2016-03-12 07:50:31

标签: winapi lazarus freepascal

我正在将一个Marquee组件从Delphi转换为Lazarus。

我的textout问题。

如果我的字符没有重音一切都很好,但如果我使用重音字符,我会得到这段代码奇怪的字符

{ Output the Text to the memory bitmap }
FScrollText:='não bastão'; ->I set it in my code  only to test
TextOut(FMemoryBitmap.Canvas.Handle,FScrollScreenPos,0,PChar(FScrollPartString),Length(FScrollPartString));  --> Error I get weird chars on Screen
//Here I have strange chars on screen

这是我的完整程序:

procedure TScrolling.DoScrolling(Restarting: Boolean);
var
  ARect : TRect;
  OutY  : Integer;
begin
  { Set colors }
  Canvas.Brush.Color := Color;
  FMemoryBitmap.Canvas.Brush.Color := Color;

  { When restarting, set default values }
  if Restarting then begin
    Canvas.FillRect(ClientRect);
    FScrollScreenPos   := ClientWidth;
    FScrollCurrentChar := 1;
    FScrollPartString  := '';
  end;

  try
    { Clear the bitmap }
    ARect := Rect(0,0,FMemoryBitmap.Width,FMemoryBitmap.Height);
    FMemoryBitmap.Canvas.FillRect(ARect);

    { Exit if there is no text to scroll }
    if Length(FScrollText) > 0 then begin
      { Decrease the current output position }
      Dec(FScrollScreenPos,FScrollAmount);

      { Remove text from the beginning until the scrolling position is around 0 }
      if (FScrollScreenPos < 0) then begin
        if Length(FScrollPartString) > 0 then while (FScrollScreenPos+TextWidth(FScrollPartString[1]) < 0) do begin
          Inc(FScrollScreenPos,TextWidth(FScrollPartString[1]));
          Delete(FScrollPartString,1,1);
        end;
      end;

      { Fill up text at the end until PartString is wider than the client rectangle }
      while FScrollScreenPos+TextWidth(FScrollPartString) < ClientWidth do begin
        FScrollPartString := FScrollPartString+FScrollText[FScrollCurrentChar];
        Inc(FScrollCurrentChar);
        if FScrollCurrentChar > Length(FScrollText) then FScrollCurrentChar := 1;
      end;

      { Output the Text to the memory bitmap }
      FScrollText:='não bastão';  --> Only to test
      TextOut(FMemoryBitmap.Canvas.Handle,FScrollScreenPos,0,PChar(FScrollPartString),Length(FScrollPartString));  --> Error I get weird chars on Screen

      { Now draw the memory bitmap }
      OutY := 0;
      if FAutoCenter then OutY := (ClientHeight-FMemoryBitmap.Height) div 2;
      BitBlt(Canvas.Handle,0,OutY,ClientWidth,FMemoryBitmap.Height,FMemoryBitmap.Canvas.Handle,0,0,SRCCOPY);
    end;
  except
  end;
end;

0 个答案:

没有答案