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
  • 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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

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.

Question has a verified solution.

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

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

840 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