掲示板システム
ホーム
アクセス解析
カテゴリ
ログアウト
ポップアップでEditに文字を書く込むには (ID:30265)
名前
ホームページ(ブログ、Twitterなど)のURL (省略可)
本文
会話のやり取りをみると、入門書を読むところから始めた方がいい気がします。self,Sender等は基本事項ですので入門書を読んで理解してください。 コンポーネントについても標準LabeleEditなんてものは存在しません。 技術系のBBSで会話をするなら正しい用語を使ってくださいね。 厳しいかもしれませんが、ここである程度以上の回答をしている人たちは、例外なく入門書かヘルプを読んでいると思います。 今回の例は上の人たちが言っていることの実現方法の一例です。 書き方しだいで応用範囲はいくらでも広くなります。 unit Unit1; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Menus, StdCtrls; type TForm1 = class(TForm) Label1: TLabel; Label2: TLabel; Label3: TLabel; Label4: TLabel; Label5: TLabel; Label6: TLabel; Label7: TLabel; Label8: TLabel; Label9: TLabel; PopupMenu1: TPopupMenu; test1: TMenuItem; //PopupMenu1の子 procedure FormCreate(Sender: TObject); private { Private 宣言 } procedure LabelContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean); public { Public 宣言 } end; var Form1: TForm1; implementation {$R *.dfm} procedure TForm1.FormCreate(Sender: TObject); var i:Integer; aLabel:TLabel; begin for i:=1 to 9 do begin //オブジェクトインスペクタで貼り付けたラベルを探す aLabel:=TLabel(FindComponent('Label'+IntToStr(i))); //各オブジェクトにパラメータを設定 aLabel.PopupMenu := PopupMenu1; //同じpopupを割り当てる(必ずしも同じ必要は無い) aLabel.Caption:=FloatToStr(Random); //各オブジェクトにイベントを設定 aLabel.OnContextPopup:= LabelContextPopup; end; end; procedure TForm1.LabelContextPopup(Sender: TObject; MousePos: TPoint; var Handled: Boolean); begin //送り主(TLabel)に登録されたPopupMenuの子のcaption = //送り主(TLabel)のCaptionという意味 TLabel(Sender).PopupMenu.Items[0].Caption:=TLabel(Sender).Caption; end; end.
←解決時は質問者本人がここをチェックしてください。
戻る
掲示板システム
Copyright 2021 Takeshi Okamoto All Rights Reserved.