Quantcast
Channel: VBForums - CodeBank - Visual Basic 6 and earlier
Viewing all articles
Browse latest Browse all 1450

vb6 Gif Ocx/Png OCX,Show Movie by DirectShow,WebBrowser,AniGif.OCX

$
0
0
Name:  ShowGif_byWebbrowser.jpg
Views: 14
Size:  30.0 KB
Usercontrol.ctl about Webbrowser GIF(PNG ,JPG),Support Url,Localdisk File
[gif ocx,Png ocx] activex control

Code:

Dim WithEvents M_Dom As MSHTML.HTMLDocument
Public Event ImgClick()
Private Url As String
'Usercontrol Name:WebImgOcx

Private Sub UserControl_Initialize()
'add Webbrowser to Usercontrol
UserControl.ScaleMode = 3
WebBrowser1.Visible = False
End Sub

Public Property Get ImgUrl() As String
    ImgUrl = Url
End Property

Public Property Let ImgUrl(ByVal vNewValue As String)
Url = vNewValue
If Url <> "" Then
    WebBrowser1.Visible = True
    SetImg Url
Else
    WebBrowser1.Visible = False
End If
End Property
 

Private Sub UserControl_ReadProperties(PropBag As PropertyBag)
  ImgUrl = PropBag.ReadProperty("ImgUrl", "")
End Sub
 

Private Sub UserControl_WriteProperties(PropBag As PropertyBag)
 PropBag.WriteProperty "ImgUrl", ImgUrl
End Sub
 

Sub SetImg(UrlA As String)
    Url = UrlA
    WebBrowser1.Navigate Url
End Sub
Private Function M_Dom_onclick() As Boolean
    RaiseEvent ImgClick
End Function

Private Sub WebBrowser1_DocumentComplete(ByVal pDisp As Object, Url As Variant)
If Url = "" Then Exit Sub
    Dim body As Object
    Set M_Dom = WebBrowser1.Document
    Set body = WebBrowser1.Document.body
   
    body.Scroll = "no"
    body.Style.border = "none"
    body.leftMargin = 0
    body.topMargin = 0
   
       
    WebBrowser1.Width = body.All(0).clientWidth
    WebBrowser1.Height = body.All(0).clientHeight
    UserControl.Width = WebBrowser1.Width * Screen.TwipsPerPixelX
    UserControl.Height = WebBrowser1.Height * Screen.TwipsPerPixelY
   
   
    Call WebBrowser1.Document.parentWindow.execScript("document.body.ondragstart=function(){return false}", "javascript") 'good
    Call WebBrowser1.Document.parentWindow.execScript("document.body.oncontextmenu=function(){return false}", "javascript") 'good '禁止右键
End Sub

CALL Usercontrol OCX IN FORM1
Code:

WebImgOcx2.Imgurl="http://www.a.com/123.gif"

Private Sub WebImgOcx2_ImgClick()
 MsgBox WebImgOcx2.ImgUrl
End Sub

Attached Images
 
Attached Files

Viewing all articles
Browse latest Browse all 1450

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>