よしと申します。お世話になります。
クラスモジュールでの処理にて、
ラベルを右クリックすると
ポップアップメニューは表示されますが
そのメニューをクリックした時の
イベント取得ができません。
ご教授宜しくお願いします。
フォーム側 (Form1.frm)
Private Popclass As Class1
Private Sub Form_Load()
Set Popclass = New Class1
Popclass.Label = Label1
End Sub
---------------------------------------------------
クラス側 (Class1.cls)
Private WithEvents Label1 As Label
Public Property Let Label(ByVal ctlLabel As Label)
Set Label1 = ctlLabel
End Property
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button And vbRightButton) <> 0 Then
Form1.PopupMenu Form1.menu1, , , Form1.menu2
End If
End Sub
Private Sub menu2_Click()
MsgBox "メニュークリックされました" <--- 効きません
End Sub
自己解決いたしました。
クラス側 (Class1.cls)
Private WithEvents Label1 As Label
Public Property Let Label(ByVal ctlLabel As Label)
Set Label1 = ctlLabel
End Property
Private Sub Label1_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If (Button And vbRightButton) <> 0 Then
Form1.PopupMenu Form1.menu1, , , Form1.menu2
Set Ctrl = Label1 '<- 追加
End If
End Sub
Private Property Set Ctrl(Data As Control) '<- 変更
MsgBox "メニュークリックされました"
End Property
メニューをクリックすると反応いたしました。
ツイート | ![]() |