VB and Flash problem

Posted on 2001-06-26
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
  • 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?
Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

LVL 10

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 = " - 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 10

Expert Comment

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

Accepted Solution

AzraSound earned 200 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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

860 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