VB and Flash problem

Posted on 2001-06-26
Medium Priority
Last Modified: 2010-05-02
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.
Question by:NitroBlaze
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
  • 2
  • +2
LVL 43

Expert Comment

ID: 6227555
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.

Expert Comment

ID: 6228564

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 : )

Author Comment

ID: 6228729
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?
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

LVL 11

Expert Comment

ID: 6228997
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
LVL 11

Expert Comment

ID: 6229002
oh dont forget to UNHOOK before stopping your app as your app may crash!
LVL 28

Accepted Solution

AzraSound earned 600 total points
ID: 6229549
place the swflash control inside of a picturebox control and set the picturebox control's enabled property to false
LVL 43

Expert Comment

ID: 6230440
Good thought azra!

Author Comment

ID: 6230548
Simply put and gets the job done... perfect.
LVL 28

Expert Comment

ID: 6231395
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  :-)

Featured Post


Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…
Suggested Courses

649 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question