VB and Flash problem

Suppose I've placed a flash component into a Visual Basic form. I've disabled the menus property that displays a list of commands that manipulate the flash file when right clicking on it.

Eventhough the main menu selections are removed, the "about Macromedia Flash" menu is still visible when you right click on the flash movie. My question is, is there a way to completely disable the right-click function on the movie during runtime?

Disabling the mouse would not be a good option as the mouse is needed during the program's runtime.
Who is Participating?
AzraSoundConnect With a Mentor Commented:
place the swflash control inside of a picturebox control and set the picturebox control's enabled property to false
Nitroblaze, I don't think that you can do this easily. You could possibly subclass the window and handle the mouse messages sent to the control. This way you could discard the right-click messages and not allow the flash control to respond. It does seem a bit of overkill but maybe you really do need this.

My comment is only applicable if there's a mousedown event for your flash object.

If there's a mousedown event for the flash object (I don't know about flash - don't have it), you may want to pop up some msgbox with your greetings or whatever to remove the menus.

On the other hand, I tried this code with textboxes.  You may want to replace Text2 with the name of your flash object and try it out:

Create a timer called Timer1, interval set to 1000.  Create also textboxes Text1 and Text2.  Test the right-clicking ONLY on Text2.

Private Sub Text2_MouseDown(Button As Integer, Shift As Integer, X As Single, Y As Single)
If Button = 2 Then
Text2.Enabled = False
End If
Timer1.Enabled = True
End Sub

Private Sub Timer1_Timer()
Text2.Enabled = True
Timer1.Enabled = False
End Sub

You may want to reduce the interval of Timer1, but lower values of timer1 may cause the menu to appear as it's too fast.

That's it!

glass cookie : )
Train for your Pen Testing Engineer Certification

Enroll today in this bundle of courses to gain experience in the logistics of pen testing, Linux fundamentals, vulnerability assessments, detecting live systems, and more! This series, valued at $3,000, is free for Premium members, Team Accounts, and Qualified Experts.

NitroBlazeAuthor Commented:
Glass Cookie:
It's not that easy as Flash doesn't have a MouseDown event.

Do you have any sample source codes that prove your theory?
this worked for me, i just
tried this and worked just fine,

note: some of this code i got from PSC and some are regular API CALLS, (just need to put it all together)

this is just about getting the flash handle (that flash ocx does not give by default), and hooking it.

'*************begin form1
Option Explicit
'form1 has only command1,command2,text1 and shockwaveflash1
Private Sub Command1_Click()
End Sub

Private Sub Command2_Click()
End Sub
'**************end form1

'***********begin module

Option Explicit

Public Declare Function FlashWindow Lib "user32" (ByVal hwnd As Long, ByVal Invert As Long) As Long

Public Declare Function CallWindowProc Lib "user32" Alias "CallWindowProcA" (ByVal lpPrevWndFunc As Long, ByVal hwnd As Long, ByVal Msg As Long, ByVal wParam As Long, ByVal lParam As Long) As Long

Public Declare Function SetWindowLong Lib "user32" Alias "SetWindowLongA" (ByVal hwnd As Long, ByVal nIndex As Long, ByVal dwNewLong As Long) As Long
'********* Code Start *************
Private Declare Function apiGetFocus Lib "user32" _
        Alias "GetFocus" _
         () As Long
    Public Const GWL_WNDPROC = -4
    Global lpPrevWndProc As Long
Function fhWnd(ctl As Control) As Long
    On Error Resume Next
    If Err Then
        fhWnd = 0
        fhWnd = apiGetFocus
    End If
    On Error GoTo 0
End Function
'*********** Code End *************
Function WindowProcedure(ByVal hw As Long, ByVal uMsg As _
    Long, ByVal wParam As Long, ByVal lParam As Long) As _

    Select Case uMsg
        ' Cases comes from WinSPY
        Case 513: Form1.Text1.Text = "WWW.Planet-Source-Code.com - for al your code"
        Case 516: Form1.Text1.Text = "This example is from PLANET SOURCE CODE"
        WindowProcedure = -1 ' = If you click Then WindowProcedure gets the command and Not the Textbox
        Exit Function
        Case Else
    End Select

WindowProcedure = CallWindowProc(lpPrevWndProc, hw, _
uMsg, wParam, lParam)
End Function

Public Sub Hook()
'    lpPrevWndProc = SetWindowLong(Form1.Text1.hwnd, GWL_WNDPROC, AddressOf WindowProcedure)
lpPrevWndProc = SetWindowLong(fhWnd(Form1.ShockwaveFlash1), GWL_WNDPROC, AddressOf WindowProcedure)
End Sub

Public Sub Unhook()
    Dim temp As Long
    temp = SetWindowLong(fhWnd(Form1.ShockwaveFlash1), GWL_WNDPROC, lpPrevWndProc)
End Sub
'********end module1
oh dont forget to UNHOOK before stopping your app as your app may crash!
Good thought azra!
NitroBlazeAuthor Commented:
Simply put and gets the job done... perfect.
generally if an answer 100% successfully solves your problem, you offer an 'A' grade.  food for thought in the future (since i know you are new here)

glad i could help  :-)
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.