掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
エラーをなくすには? (ID:21454)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
以下のプログラムを起動して、ボタンを押すとエラーが発生します。 どうしてでしょうか? エラーは[EOutOfResource]です。 ---------------------------------------------------------------------- unit MessageMain; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, StdCtrls, MessagePanel; type TForm1 = class(TForm) Button1: TButton; procedure Button1Click(Sender: TObject); private MessagePanel: TMessagePanel; public end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.Button1Click(Sender: TObject); begin MessagePanel := TMessagePanel.Create(Self, 'テスト'); end; end. ---------------------------------------------------------------------- unit MessagePanel; interface Uses Windows, ExtCtrls, Graphics, Classes, Controls, Forms, StdCtrls, Math, SysUtils, Dialogs; type TMessagePanel = class(TPaintBox) private MessageStr: String; WorkBmp: TBitmap; procedure DrawMessage(Sender: TObject); public constructor Create(AOwner: TComponent; Str: String); reintroduce; destructor Destroy; override; end; implementation Uses MachineStatusBoardMain; constructor TMessagePanel.Create(AOwner: TComponent; Str: String); begin inherited Create(AOwner); Parent := TWinControl(AOwner); WorkBmp := TBitmap.Create; WorkBmp.Canvas.Font.Assign(TForm(Owner).Font); OnPaint := DrawMessage; MessageStr := Str; end; destructor TMessagePanel.Destroy; begin WorkBmp.Free; inherited Destroy; end; procedure TMessagePanel.DrawMessage(Sender: TObject); begin WorkBmp.Width := WorkBmp.Canvas.TextWidth(MessageStr); WorkBmp.Height := Font.Height; end; end. ----------------------------------------------------------------------
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2020 Takeshi Okamoto All Rights Reserved.