单选题
设已经在菜单编辑器中设计了弹出式菜单mnuStyle,要求程序运行时,当用户在文本框Textl上单击鼠标右键时,能够弹出该菜单,则应使用的事件过程是( )。
A、
Private Sub Text1_MouseDown(Button As Integer,Shift As Integer,X As Single,Y As Single) If Button=2 Then PopupMenu mnuStyle End If End Sub
B、
Private Sub Textl_MouseDown(Button As Integer,Shift As Integer,X As Single,Y As Single) If Button=1 Then PopupMenu mnuStyle End If End Sub
C、
Private Sub Textl—MouseDown(Button As Integer,Shift As Integer,X As Single,Y As Single) If Button=2 Then mnuStyle.Show End If End Sub
D、
Private Sub Text1_MouseDown(Button As Integer,Shift As Integer,X As Single,Y As Single) If Button=1 Then mnuStyle.Popup End If End Sub
【正确答案】
A
【答案解析】
解析:为了显示弹出式菜单,通常把PopupMenu方法放在MouseDown事件中,该事件响应所有的鼠标单击操作。按照惯例,一般通过单击鼠标右键显示弹出式菜单,这可以用Button参数来实现。对于鼠标来说,左键的Button参数值为l,右键的Button参数设置为2,因此,可以使用“If Button=2 Then P叩upMenu菜单名”语句可以通过单击鼠标右键来响应MouseDown事件、显示弹出式菜单,故本题A选项正确。本题选择A选项。
提交答案
关闭