Fills contiguous bytes with a specified value.
procedure FillChar(var X; Count: Integer; Value: Byte);
FillChar( X, int Count, Byte Value);
In Delphi, FillChar fills Count contiguous bytes (referenced by X) with the value specified by Value (Value can be type Byte or Char).
Note that if X is a UnicodeString, this may not work as expected because FillChar expects a byte count, which not be the same as the character count.
In addition, the fill character is a single byte character. Therefore, when Buf is a UnicodeString, the code FillChar(Buf, Length(Buf), #9); fills Buf with the code point $0909, not $09. For such cases, you probably want to use the function StringOfChar.
Delphi Examples:
{ This example creates a rotated font and displays it on the form by assigning the handle of the rotated to the Form’s Canvas Font via the Font’s Handle property. Rotating fonts is a straightforward process, so long as the Windows Font Mapper can supply a rotated font based on the font you request. If you are using a TrueType font there is virtually no reason for failure. } procedure TForm1.Button1Click(Sender: TObject); var lf: LOGFONT; // Windows native font structure begin Canvas.Brush.Style := bsClear; // set the brush style to transparent FillChar(lf, SizeOf(lf), Byte(0)); lf.lfHeight := 20; lf.lfEscapement := 10 * 45; // degrees to rotate lf.lfOrientation := 10 * 45; lf.lfCharSet := DEFAULT_CHARSET; StrCopy(lf.lfFaceName, 'Tahoma'); Canvas.Font.Handle := CreateFontIndirect(lf); Canvas.TextOut(10, 100, 'Rotated text'); // output the rotated font end;
Copyright(C) 2009 Embarcadero Technologies, Inc. All Rights Reserved.
|
What do you think about this topic? Send feedback!
|