Solved

VB and Flash problem

Posted on 2001-06-26
9
173 Views
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.
0
Comment
Question by:NitroBlaze
  • 2
  • 2
  • 2
  • +2
9 Comments
 
LVL 43

Expert Comment

by:TimCottee
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.
0
 
LVL 8

Expert Comment

by:glass_cookie
ID: 6228564
Hi!

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

Author Comment

by:NitroBlaze
ID: 6228729
Glass Cookie:
It's not that easy as Flash doesn't have a MouseDown event.

Tim:
Do you have any sample source codes that prove your theory?
0
 
LVL 10

Expert Comment

by:arana
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()
    Hook
End Sub


Private Sub Command2_Click()
    Unhook
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
    ctl.SetFocus
    If Err Then
        fhWnd = 0
    Else
        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 _
    Long


    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
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 
LVL 10

Expert Comment

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

Accepted Solution

by:
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
0
 
LVL 43

Expert Comment

by:TimCottee
ID: 6230440
Good thought azra!
0
 

Author Comment

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

Expert Comment

by:AzraSound
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  :-)
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
Article by: Martin
Here are a few simple, working, games that you can use as-is or as the basis for your own games. Tic-Tac-Toe This is one of the simplest of all games.   The game allows for a choice of who goes first and keeps track of the number of wins for…
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 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…

705 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

Need Help in Real-Time?

Connect with top rated Experts

21 Experts available now in Live!

Get 1:1 Help Now