MyICQ
MyICQ

Reputation: 1158

GDIPLUS in Delphi - string from TTnTEdit

I am trying to draw a rotated text in Arab to a paintbox, using Delphi 6. Tried different tools like GR32 and now GDIPLUS.

GDIPLUS Samples work fine, I can draw the "Hello":

  graphics := TGPGraphics.Create(PaintBox.Canvas.Handle);
  fontFamily:= TGPFontFamily.Create('Times New Roman');
  font := TGPFont.Create(fontFamily, 24, FontStyleRegular, UnitPixel);
  pointF := MakePoint(30.0, 10.0);
  solidBrush:= TGPSolidBrush.Create(MakeColor(255, 0, 0, 255));
  r :=  graphics.DrawString('Hello', -1, font, pointF, solidBrush);
  showmessage( GetEnumName(
        typeinfo(Tstatus), ord(r)  )
     );
  fontFamily.Free;
  font.Free;
  solidBrush.Free;
  graphics.Free;

When run, I get my "Hello" drawn in the Paintbox as expected, and an "OK" status back.

Now I change the string in DrawString (which IS a widestring parameter) to accept input from a TTnTEdit I placed on canvas.

  thestring := TNTEdt1.Text;   
  r :=  graphics.DrawString(thestring , -1, font, pointF, solidBrush);

Now I get NOTHING printed, and still OK returned.

I would expect a TTnTEdit to actually return a widestring ?

EDIT: I should point out that it does not matter what content the TNTEdit has, even if I put "Hello".

Upvotes: 0

Views: 727

Answers (1)

AmigoJack
AmigoJack

Reputation: 6099

If you use Tnt Delphi Unicode Controls already you could also use TntGraphics.pas for Widestring output on a TCanvas, simply by issuing:

TntGraphics.WideCanvasTextOut( MyPaintBox.Canvas, x, y, MyTntEdit.Text );

Since your question mentioned rotating the text but your code nowhere tries so have a look at this answer's method DrawTextRotatedB() and use that one. Of course: change String to Widestring and ACanvas.TextOut(X, Y, AText) into my example code line. Successfully tried this using D7 and I'm pretty sure it will also work with D6:

rotated text: Arabian, Katakana, Kanji

Upvotes: 1

Related Questions