Click here to Skip to main content
15,892,746 members
Home / Discussions / Visual Basic
   

Visual Basic

 
Questionhow to use compare function Pin
zhiyuan166-Sep-10 19:37
zhiyuan166-Sep-10 19:37 
AnswerRe: how to use compare function Pin
Dave Kreskowiak7-Sep-10 1:50
mveDave Kreskowiak7-Sep-10 1:50 
AnswerRe: how to use compare function Pin
Luc Pattyn7-Sep-10 2:05
sitebuilderLuc Pattyn7-Sep-10 2:05 
QuestionHow to store a string in Byte array in hex form Pin
jainiraj4-Sep-10 23:49
jainiraj4-Sep-10 23:49 
AnswerRe: How to store a string in Byte array in hex form Pin
Dave Kreskowiak5-Sep-10 3:17
mveDave Kreskowiak5-Sep-10 3:17 
QuestionREgarding sending data when using socket winsock Pin
jainiraj4-Sep-10 20:38
jainiraj4-Sep-10 20:38 
AnswerRe: REgarding sending data when using socket winsock Pin
Dave Kreskowiak5-Sep-10 3:13
mveDave Kreskowiak5-Sep-10 3:13 
QuestionHow to interact a Context Menu with a web browser... Pin
thebiostyle4-Sep-10 11:31
thebiostyle4-Sep-10 11:31 
Here is what I have so far...
Private WithEvents CurrentDocument As HtmlDocument
   Dim MousePoint As Point
   Dim Ele As HtmlElement

   Private Sub OpenLinkInNewWindowToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenLinkInNewWindowToolStripMenuItem.Click
       Dim FirstForm As New Form1
       FirstForm.Show()
   End Sub

   Private Sub OpenLinkInNewTabToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles OpenLinkInNewTabToolStripMenuItem.Click
       Dim Browser As New WebBrowser
       Clipboard.SetText(Ele.GetAttribute("href"))
       TabControl1.TabPages.Add("New Tab")
       TabControl1.SelectTab(Int)
       Browser.Name = "Web Browser"
       Browser.Dock = DockStyle.Fill
       TabControl1.SelectedTab.Controls.Add(Browser)
       AddHandler Browser.ProgressChanged, AddressOf Loading
       AddHandler Browser.DocumentCompleted, AddressOf Done
       Int = Int + 1
       Browser.IsWebBrowserContextMenuEnabled = False
       Browser.ContextMenuStrip = CMenuMain
       Me.TabControl1.SelectedTab.Controls.Add(Browser)
       CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(Clipboard.GetText)
   End Sub

   Private Sub CopyLinkLocationToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyLinkLocationToolStripMenuItem.Click
       Clipboard.SetText(Ele.GetAttribute("href"))
   End Sub

   Private Sub ViewImageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles ViewImageToolStripMenuItem.Click
       Dim Browser As New WebBrowser
       Clipboard.SetText(Ele.GetAttribute("src"))
       TabControl1.TabPages.Add("New Tab")
       TabControl1.SelectTab(Int)
       Browser.Name = "Web Browser"
       Browser.Dock = DockStyle.Fill
       TabControl1.SelectedTab.Controls.Add(Browser)
       AddHandler Browser.ProgressChanged, AddressOf Loading
       AddHandler Browser.DocumentCompleted, AddressOf Done
       Int = Int + 1
       Browser.IsWebBrowserContextMenuEnabled = False
       Browser.ContextMenuStrip = CMenuMain
       Me.TabControl1.SelectedTab.Controls.Add(Browser)
       CType(TabControl1.SelectedTab.Controls.Item(0), WebBrowser).Navigate(Clipboard.GetText)
   End Sub

   Private Sub CopyImageLocationToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CopyImageLocationToolStripMenuItem.Click
       Clipboard.SetText(Ele.GetAttribute("src"))
   End Sub

   Private Sub SaveImageToolStripMenuItem_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles SaveImageToolStripMenuItem.Click
       SaveFileDialog2.ShowDialog()
   End Sub


I am working on getting the Open Link in New Window, Open Link in New Tab, Copy Link Location, View Image, and Copy Image Location options. How Would I change my code to get them to work?

I used this page to get some of the code Advanced Web Browser Context Menu Tutorial. I did not add certain parts, because they too would not work. They included these...

-------------------------------------------
Now double click your webbrowser, and go to the Navigated event of the webbrowser. Add this code:
CurrentDocument = Browser.Document


This code tells the CurrentDocument HtmlDocument which we just declared to always be the same as the Webbrowser document.

Next go to the Currentdocument.MouseMove event. Add this code:
MousePoint = New Point(e.MousePosition.X, e.MousePosition.Y)


This tells the program to change the record where the mouse is on the document (so it knows where to get the element that the contextmenu has been shown over).

Now, go to the CMenuMain.Opening event, and add this code:
ele = Currentdocument.GetElementFromPoint(MousePoint)
    If ele.TagName = "A" Then  
OpenLinkInNewWindowToolStripMenuItem.Visible = True
OpenLinkInNewTabToolStripMenuItem.Visible = True
CopyLinkLocationToolStripMenuItem.Visible = True
ToolStripMenuItem29.Visible = True
    Else    
OpenLinkInNewWindowToolStripMenuItem.Visible = False
OpenLinkInNewTabToolStripMenuItem.Visible = False
CopyLinkLocationToolStripMenuItem.Visible = False
ToolStripMenuItem29.Visible = False
    End If
    If ele.TagName = "IMG" Then
ViewImageToolStripMenuItem.Visible = True
CopyImageLocationToolStripMenuItem.Visible = True
SaveImageToolStripMenuItem.Visible = True
ToolStripSeparator19.Visible = True
    Else
ViewImageToolStripMenuItem.Visible = False
CopyImageLocationToolStripMenuItem.Visible = False
SaveImageToolStripMenuItem.Visible = False
ToolStripSeparator19.Visible = False
    End If


This is where ele and MousePoint come into action. This code makes ele (the HtmlElement, say an image, a link or a button) whatever HtmlElement the mouse is over on the webbrowser, because we made MousePoint wherever the mouse was on the document when it moved.

-------------------------------------------

I'd like to implement that code into the project as well, thanks in advance!! Wink | ;)
AnswerRe: How to interact a Context Menu with a web browser... Pin
Mycroft Holmes5-Sep-10 13:06
professionalMycroft Holmes5-Sep-10 13:06 
GeneralRe: How to interact a Context Menu with a web browser... Pin
thebiostyle5-Sep-10 13:34
thebiostyle5-Sep-10 13:34 
QuestionRegarding long data type .. Pin
jainiraj4-Sep-10 2:43
jainiraj4-Sep-10 2:43 
AnswerRe: Regarding long data type .. Pin
DaveAuld4-Sep-10 4:15
professionalDaveAuld4-Sep-10 4:15 
AnswerRe: Regarding long data type .. Pin
Luc Pattyn4-Sep-10 4:29
sitebuilderLuc Pattyn4-Sep-10 4:29 
GeneralRe: Regarding long data type .. Pin
jainiraj4-Sep-10 20:21
jainiraj4-Sep-10 20:21 
GeneralRe: Regarding long data type .. Pin
Dave Kreskowiak5-Sep-10 3:11
mveDave Kreskowiak5-Sep-10 3:11 
GeneralRe: Regarding long data type .. Pin
jainiraj6-Sep-10 0:33
jainiraj6-Sep-10 0:33 
AnswerRe: Regarding long data type .. Pin
Luc Pattyn6-Sep-10 3:19
sitebuilderLuc Pattyn6-Sep-10 3:19 
GeneralRe: Regarding long data type .. Pin
Dave Kreskowiak6-Sep-10 3:49
mveDave Kreskowiak6-Sep-10 3:49 
QuestionRead Table of Content from PDF using PDFBOX library Pin
Nilesh Araligidad3-Sep-10 3:57
Nilesh Araligidad3-Sep-10 3:57 
AnswerIgnore - Crosspost Pin
Dave Kreskowiak3-Sep-10 4:55
mveDave Kreskowiak3-Sep-10 4:55 
QuestionProblem in UDP socket connection. [modified] Pin
jainiraj3-Sep-10 1:39
jainiraj3-Sep-10 1:39 
AnswerRe: Problem in UDP socket connection. Pin
Dave Kreskowiak3-Sep-10 2:14
mveDave Kreskowiak3-Sep-10 2:14 
GeneralMessage Removed Pin
3-Sep-10 2:53
jainiraj3-Sep-10 2:53 
GeneralRe: Problem in UDP socket connection. Pin
LloydA1114-Sep-10 3:40
LloydA1114-Sep-10 3:40 
GeneralRe: Problem in UDP socket connection. Pin
Expert Coming4-Sep-10 22:29
Expert Coming4-Sep-10 22:29 

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.