I have an application that shows the thumbnails of video files.
Then the user can navigate them by keyboard (or simply select one by a mouse click).
Once a thumbnail is selected (whether by keyboard or mouse) the user can press certain keys to do different things.
This is done via the KeyUp method of the picturebox
Aside from that, the user can either right-click on the thumbnail or press the Menu key on the keyboard to bring on a popup menu.
From within that popup menu, there are quite a number of different menu items that the user can select.
Some of those menu items if selected will open other VB6 forms, allowing the user to do additional processes.
Some other menu items in that same popup menu allow the user to play the video by specific video players (as opposed to the main video player that Windows associates with that video type)
Some other menu items do other things.
The management of all of that is done by two methods of the picturebox: The KeyUp method and the MouseUp method.
Here is the code (I have removed a whole lot of unrelated code in here so that we can focus on the main issue):
Code:
Private Sub picFileThumbnail_KeyUp(Index As Integer, KeyCode As Integer, Shift As Integer)
If KeyCode = 27 Then ' Esc key
txtFileName(Index).SetFocus
KeyCode = 0
Shift = 0
ElseIf KeyCode = 32 Then ' Spacebar
txtFileName(Index).SetFocus
KeyCode = 0
Shift = 0
ElseIf (KeyCode = 13) And (Shift = 0) Then ' Enter key
...... ' Playing the video by its Windows associated video player
KeyCode = 0
Shift = 0
ElseIf (KeyCode = 93) And (Shift = 0) Then ' Menu key
Me.PopupMenu mnuVidMain, vbPopupMenuLeftAlign, picFileThumbnail(Index).Left + (picFileThumbnail(Index).Width \ 3), picFileThumbnail(Index).Top + (picFileThumbnail(Index).Height \ 2)
KeyCode = 0
Shift = 0
End If
End Sub
Code:
Private Sub picFileThumbnail_MouseUp(Index As Integer, Button As Integer, Shift As Integer, x As Single, y As Single)
If Button = vbRightButton Then
Me.PopupMenu mnuVidMain
End If
End Sub
The problem is that when the user brings on the popup menu, and then presses Enter to select one of its menu items, the functionality under that menu item (for example opening a new VB6 form) is executed properly, but that "Enter" key pressed on that menu item is ALSO passed to the picFileThumbnail_KeyUp function, resulting in an additional process being fired!
In this case the "Enter" key passed to picFileThumbnail_KeyUp causes the video to be played by its associated video player.
So, when the user intends to open the subsidiary form for some specific process, that subsidiary form opens properly, but the video also starts playing in Windows Media Player.
So, TWO things happen instead of one thing.
Or another example:
The user selects a thumbnail, then presses the menu key to bring on the popup menu, then changes his mind and presses the Escape key to dismiss the popup menu.
In that case the popup menu is properly dismissed as intended, but the Escape key is ALSO passed to the picFileThumbnail_KeyUp function and that causes the functionality for pressing Escape key on the thumbnail itself (within the picFileThumbnail_KeyUp function) be invoked as well.
So, again, TWO things happen instead of one thing.
I have tried everything to fix this, but nothing works.
Please help.
Thanks.