掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
TEditorで文字列が欠損しないように文字列を描画するには (ID:48424)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
いろいろと試行錯誤していた結果、以下のようなサンプルコードを作成できました。 Editor1のフォントを10ポイントのMSゴシックにして、文字列を3行程度設定して以下のコードを実行すると、 画像のような問題を再現できます。ここで、コメントの部分を修正すると、いろいろ と文字間のピッチを修正できるようですが、もともとColWidthは固定の数値であるた め、なぜこのような問題が起こったのか、特定できておりません。 procedure TForm1.Editor1DrawLine(Sender: TObject; LineStr: String; X, Y, Index: Integer; ARect: TRect; Selected: Boolean); var R: TRect; i: Integer; A: array [0..1000] of Integer; begin R := ARect; Editor1.Canvas.Font.Name := 'MS ゴシック'; Editor1.Canvas.Font.Size := 10; Editor1.Canvas.Font.Color := clRed; Editor1.Canvas.Brush.Color := clYellow; // ↓ここを直すとピッチが修正できる様子だが、直し方が分からない。 for i := 0 to 1000 do A[i] := Editor1.ColWidth; if Index = 0 then begin Editor1.Canvas.Font.Style := [fsBold]; Windows.ExtTextOut(Editor1.Canvas.Handle, X, Y, ETO_CLIPPED, @R, PChar('begin '), 6, PInteger(@A)); end; if Index = 1 then begin Canvas.Font.Style := []; Windows.ExtTextOut(Editor1.Canvas.Handle, X, Y, ETO_CLIPPED, @R, PChar('begine'), 6, PInteger(@A)); end; end;
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.