Home > Software engineering >  Turn to VB POPUPMENU
Turn to VB POPUPMENU

Time:09-26

Forms 1 open form 2
Show 1
Form 2 can use right-click menu
In form 1 open the form 2, in forms 2 open form 3
Show 1
Form 3 cannot obtain right-click menu,

The form 2. Show 1

Form 3. Show 1

Even 4-5
3 after all form cannot use right-click menu,

If you don't use show 1 and use the show is going to open the can use,

But at the time of using the software, if use TAB to switch, will know the form 1 to form 2, lead to wrong window order, cause the failure of data transfer or can't pass each other updates,
If use the
The form 2. Show
The form 1. Enabled=False
, then the TAB after switching, lead to form 1, form 2 cover, and, the form 1 cannot operation, think feign death,

Help, how to show 1 mode of obtaining right-click menu?

CodePudding user response:

 
'Form1''add a CommandButton'
'add a menu named mnuPopup, add a menu item mnuHello'
Option Explicit

Private Sub Command1_Click ()
Dim FRM As Form1
The Set FRM=New Form1
FRM. Left=Me. Left + 720
FRM. Top=Me. Top + 720
FRM. Show vbModal, Me
End Sub

Private Sub Form_Load ()
Me. The Caption=Hex (Me. HWnd)
'to distinguish the instance'End Sub

Private Sub Form_MouseDown (Button As an Integer, Shift the As an Integer, As Single X, Y As Single)
If the Button=vbRightButton Then
No matter which of the following pop-up, all no problem '
'PopupMenu Form1. MnuPopup' always pop up the first form of menu '
PopupMenu Me. MnuPopup 'popup the current menu'
End the If
End Sub

Private Sub mnuHello_Click ()
MsgBox "hello @" & amp; Me. The Caption
End Sub

CodePudding user response:

 Private Sub Command1_Click () 
Form2. Show 1
End Sub

Private Sub Form_MouseDown (Button As an Integer, Shift the As an Integer, As Single X, Y As Single)
If the Button=2 Then
PopupMenu pop
End the If
End Sub

'-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Private Sub Command1_Click ()
Form3. Show 1
End Sub

Private Sub Form_MouseDown (Button As an Integer, Shift the As an Integer, As Single X, Y As Single)
If the Button=2 Then
PopupMenu pop
End the If
End Sub

'-- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
Private Sub Form_MouseDown (Button As an Integer, Shift the As an Integer, As Single X, Y As Single)
If the Button=2 Then
PopupMenu pop
End the If
End Sub


Can indeed bring up the POPUPMENU, program may where I went wrong, well, I check again carefully, thank you

CodePudding user response:



Private Sub Grid1_MouseDown (Button As an Integer, Shift the As an Integer, As Single X, Y As Single)
If the Button=vbRightButton Then
PopupMenu Me. AN1
MsgBox Me. AN1. Caption
End the If
End Sub

, as shown in the third form above, Popupmenu didn't run, use a dialog box to confirm, found the right code is executed, but the popup menu directly to ignore the past, expert help

CodePudding user response:

You finally that form on the right is to database control right.
That you should be in the database controls MouseDown operation

CodePudding user response:

Menu just loses focus will automatically shut down,
May be the form controls in the event of an right, you find yourself don't need to display a menu, directly set focus to the self, wrongly, that cause you to PopupMenu directly out of the menu is closed,
As long as you put a PictureBox pop-up right-click menu to make a comparison, can determine whether form controls,
  • Related