Click here to Skip to main content
15,895,808 members
Home / Discussions / Visual Basic
   

Visual Basic

 
AnswerRe: smpt Mail - Help Needed Pin
Edbert P27-Jun-06 16:10
Edbert P27-Jun-06 16:10 
GeneralRe: smpt Mail - Help Needed Pin
Jats_4ru27-Jun-06 23:47
Jats_4ru27-Jun-06 23:47 
Questionrename treenode at runtime Pin
mini878027-Jun-06 1:20
mini878027-Jun-06 1:20 
AnswerRe: rename treenode at runtime Pin
mini878027-Jun-06 1:44
mini878027-Jun-06 1:44 
QuestionHow to raise event of ITemplate using vb.net, Pls use follwing code Pin
BalasahebK27-Jun-06 0:54
BalasahebK27-Jun-06 0:54 
QuestionSystem Folder Pin
Anil_vvs27-Jun-06 0:33
Anil_vvs27-Jun-06 0:33 
AnswerRe: System Folder Pin
sathish s27-Jun-06 2:10
sathish s27-Jun-06 2:10 
Questioninternet explorer idownloadmanager interface Pin
Qaiser_Iftikhar26-Jun-06 23:54
Qaiser_Iftikhar26-Jun-06 23:54 
Hi there,

I am trying to make this work for the past three days but with no success. I have a windows form application with web browser control integrated into it. What i want is that when ever there is some file download request come along i get the url and download it via System.net classes, if the file is a word,excel or power point document i open them in my other form where i have integrated the word/excel/pp. all the rest of bits are working the only thing left is that i don't know how to intercept file download. I know i have to implement idownloadmanager interface but i can't make it work, my the download method of the interface never get called. the sample code is here


Imports System.Runtime.InteropServices

Public Class Form1
Inherits System.Windows.Forms.Form

#Region " Windows Form Designer generated code "

Public Sub New()
MyBase.New()

'This call is required by the Windows Form Designer.
InitializeComponent()

'Add any initialization after the InitializeComponent() call

End Sub

'Form overrides dispose to clean up the component list.
Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)
If disposing Then
If Not (components Is Nothing) Then
components.Dispose()
End If
End If
MyBase.Dispose(disposing)
End Sub

'Required by the Windows Form Designer
Private components As System.ComponentModel.IContainer

'NOTE: The following procedure is required by the Windows Form Designer
'It can be modified using the Windows Form Designer.
'Do not modify it using the code editor.
Friend WithEvents Browser As AxSHDocVw.AxWebBrowser
<system.diagnostics.debuggerstepthrough()> Private Sub InitializeComponent()
Dim resources As System.Resources.ResourceManager = New System.Resources.ResourceManager(GetType(Form1))
Me.Browser = New AxSHDocVw.AxWebBrowser
CType(Me.Browser, System.ComponentModel.ISupportInitialize).BeginInit()
Me.SuspendLayout()
'
'Browser
'
Me.Browser.Anchor = CType((((System.Windows.Forms.AnchorStyles.Top Or System.Windows.Forms.AnchorStyles.Bottom) _
Or System.Windows.Forms.AnchorStyles.Left) _
Or System.Windows.Forms.AnchorStyles.Right), System.Windows.Forms.AnchorStyles)
Me.Browser.Enabled = True
Me.Browser.Location = New System.Drawing.Point(8, 8)
Me.Browser.OcxState = CType(resources.GetObject("Browser.OcxState"), System.Windows.Forms.AxHost.State)
Me.Browser.Size = New System.Drawing.Size(360, 304)
Me.Browser.TabIndex = 0
'
'Form1
'
Me.AutoScaleBaseSize = New System.Drawing.Size(5, 13)
Me.ClientSize = New System.Drawing.Size(376, 318)
Me.Controls.Add(Me.Browser)
Me.Name = "Form1"
Me.Text = "Form1"
CType(Me.Browser, System.ComponentModel.ISupportInitialize).EndInit()
Me.ResumeLayout(False)

End Sub

#End Region

Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim url As System.Object = "http://my.mindvision.com/~ben/tools/"
Dim o As System.Object = Nothing
Browser.Navigate2(url, o, o, o, o)

SetDownloadManager()

End Sub

Private m_DownloadManagerCookie As System.Int32

Private Sub SetDownloadManager()

Dim ips As COMVB.IProfferService
Dim objBrowser As Object
Dim ispBrowser As COMVB.UCOMIServiceProvider
Dim ip As IntPtr

Try
' Get a handle to the browser ocx
objBrowser = Browser.GetOcx()
ispBrowser = DirectCast(objBrowser, COMVB.UCOMIServiceProvider)

' Query the browser for the IProfferService interface
ip = ispBrowser.QueryService(COMVB.SID_SProfferService, COMVB.IID_IProfferService)
ips = DirectCast(Marshal.GetObjectForIUnknown(ip), COMVB.IProfferService)

' Proffer the new object as the provider of the IHTMLEditHostinterface handler
ips.ProfferService(COMVB.IID_IDownloadManager, New ServiceProvider, m_DownloadManagerCookie)

Catch ex As Exception
MessageBox.Show(ex.Message)

End Try

End Sub


End Class

Class ServiceProvider
Implements COMVB.UCOMIServiceProvider

Public Function QueryService(ByRef guidService As System.Guid, ByRef riid As System.Guid) As IntPtr Implements COMVB.UCOMIServiceProvider.QueryService

If guidService.Equals(COMVB.IID_IDownloadManager) Then
If riid.Equals(COMVB.IID_IDownloadManager) Then
Dim idm As COM.Interfaces.IDownloadManager

idm = New DownloadManager
' idm.Download()
Return GetInterface(idm, COMVB.IID_IDownloadManager)
Else
Return Nothing
End If
Else
Return Nothing
End If

End Function

Public Function GetInterface(ByVal obj As Object, ByRef iid As Guid) As IntPtr

Dim pUnk As IntPtr
Dim pInterface As IntPtr
Dim hr As Integer

pUnk = Marshal.GetIUnknownForObject(obj)
hr = Marshal.QueryInterface(pUnk, iid, pInterface)

If hr < 0 Then
Marshal.ThrowExceptionForHR(hr)
End If
' Marshal.GetHINSTANCE()
' Marshal.Release(pUnk)

Return pInterface

End Function

End Class

Class DownloadManager
Implements COM.Interfaces.IDownloadManager

Public Function Download(ByVal pmk As System.Runtime.InteropServices.UCOMIMoniker, ByVal pbc As System.Runtime.InteropServices.UCOMIBindCtx, ByVal dwBindVerb As System.UInt32, ByVal grfBINDF As Integer, ByVal pBindInfo As System.IntPtr, ByVal pszHeaders As String, ByVal pszRedir As String, ByVal uiCP As System.UInt32) As Integer Implements COM.Interfaces.IDownloadManager.Download
MsgBox("file download event")
Return New System.Int32
End Function

End Class

Class COMVB
' IServiceProvider interface
<comvisible(true), comimport(),guid("6d5140c1-7436-11ce-8034-00aa006009fa"),="" _
interfacetypeattribute(cominterfacetype.interfaceisiunknown)=""> _
Public Interface UCOMIServiceProvider
Function QueryService(ByRef guidService As Guid, ByRef riid As Guid) As IntPtr
End Interface


' IProfferService interface
<comvisible(true), comimport(),="" guid("cb728b20-f786-11ce-92ad-00aa00a74cd0"),="" _
="" interfacetypeattribute(cominterfacetype.interfaceisiunknown)=""> _
Public Interface IProfferService
Sub ProfferService(ByRef guidService As Guid, ByVal psp As UCOMIServiceProvider, ByRef cookie As Integer)
Sub RevokeService(ByVal cookie As Integer)
End Interface
Public Shared SID_SProfferService As New Guid("cb728b20-f786-11ce-92ad-00aa00a74cd0")
Public Shared IID_IProfferService As New Guid("cb728b20-f786-11ce-92ad-00aa00a74cd0")
Public Shared SID_SHTMLEditHost As New Guid("3050f6a0-98b5-11cf-bb82-00aa00bdce0b")
Public Shared IID_IDownloadManager As New Guid("988934A4-064B-11D3-BB80-00104B35E7F9")
End Class
QuestionVB.NET and file on Remote IIS Pin
Peace2u26-Jun-06 21:53
Peace2u26-Jun-06 21:53 
Questiondata migration through VB.Net Pin
divyaswati26-Jun-06 19:19
divyaswati26-Jun-06 19:19 
QuestionData Compression(deflate) using VB6 Pin
ksandy4526-Jun-06 18:11
ksandy4526-Jun-06 18:11 
AnswerRe: Data Compression(deflate) using VB6 Pin
Paul Conrad26-Jun-06 18:38
professionalPaul Conrad26-Jun-06 18:38 
GeneralRe: Data Compression(deflate) using VB6 Pin
ksandy4527-Jun-06 2:22
ksandy4527-Jun-06 2:22 
GeneralRe: Data Compression(deflate) using VB6 Pin
Paul Conrad27-Jun-06 5:31
professionalPaul Conrad27-Jun-06 5:31 
GeneralRe: Data Compression(deflate) using VB6 Pin
ksandy4527-Jun-06 21:09
ksandy4527-Jun-06 21:09 
AnswerRe: Data Compression(deflate) using VB6 Pin
Dave Kreskowiak27-Jun-06 1:41
mveDave Kreskowiak27-Jun-06 1:41 
QuestionUsing Visual Basic 6.0 How to Solve the below Pin
Simple programmer26-Jun-06 18:08
Simple programmer26-Jun-06 18:08 
AnswerRe: Using Visual Basic 6.0 How to Solve the below Pin
Dave Kreskowiak27-Jun-06 1:39
mveDave Kreskowiak27-Jun-06 1:39 
GeneralRe: Using Visual Basic 6.0 How to Solve the below Pin
Simple programmer27-Jun-06 14:57
Simple programmer27-Jun-06 14:57 
QuestionHow to show flexgrid control on toolbox? Pin
rushing26-Jun-06 16:24
rushing26-Jun-06 16:24 
AnswerRe: How to show flexgrid control on toolbox? Pin
Dave Kreskowiak26-Jun-06 17:36
mveDave Kreskowiak26-Jun-06 17:36 
QuestionIntegration... Pin
d24k104d26-Jun-06 15:07
d24k104d26-Jun-06 15:07 
AnswerRe: Integration... Pin
Dave Kreskowiak26-Jun-06 17:34
mveDave Kreskowiak26-Jun-06 17:34 
AnswerRe: Integration... Pin
Paul Conrad26-Jun-06 18:40
professionalPaul Conrad26-Jun-06 18:40 
QuestionOpenGL Pin
spelltwister26-Jun-06 11:08
spelltwister26-Jun-06 11:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.