|
Hello Dean,
Thank you for that code. It does work except it gives me the text of the item name as the navigating address which does not work. You have helped me though to realize that I must find a way to open the url file referrenced by that ListItem name in order to read it and then send the "http://" text within that file to the WebBrowser.Navigate. If you or anyone else can help me out to do this or maybe direct me in the right dirrection to figure it out, that would be great.
Thanks again for your help.
|
|
|
|
|
So what exactly is in the listview? Is it at list of URLS like this:
http://www.codeproject.com
http://www.msn.com
http://www.google.com
.
.
.
etc?
Or does the list contain the name of each website like this:
CodeProject
MSN
Google
.
.
.
etc?
Thanks,
Dean
|
|
|
|
|
It gets the name of the url files like this.
1sitename.url
2sitename.url
|
|
|
|
|
In that case, what I would do is put the actual URL navigation text in another hidden column of your listview and reference that text for the Navigate command.
So where the users see:
1sitename.url
2sitename.url
...listed in the first column of the listview, in the second column (with a column width of zero) would be the URL navigation text:
http://www.1sitename.com
http://www.2sitename.com
Then in the SelectedIndexChanged event you could do your navigate:
Me.WebBrowser1.Navigate(Me.lvwLeft.SelectedItems(0).SubItems(1).Text)
Dean
|
|
|
|
|
so each file in the directory I look through to populate the ListView I would need to open/read it and then put it's http address text in a hidden column in the Listview. That's what you mean right?
Question: If so, wouldn't that make things lag quite a bit if a person has many folders with possible 100's of links in it?
Thanks
-- modified at 17:56 Friday 24th February, 2006
|
|
|
|
|
Hey Dean,
I did what you suggested and it works very nicely and it doesn't lag at all. At least not with my Favorites folder and I have quite a few links in there. The only problem I have now is that I have only been able to read the complete url file text and there is too much garbage text to send it as a http: address. I have to find a way to extract only the url text and put that in the hidden column. Any ideas? Thanks
The text I get from the StreamReader is simular to this for every url file it reads, just the actual http:// text changes.
"[default]baseurl=http://www.adenak.com/[InternetShortcut]URL=http://www.adenak.com/Modified=1067F49A2E3BC50134"
Private Sub tvwExplorer_AfterSelect(ByVal sender As System.Object, ByVal e As System.Windows.Forms.TreeViewEventArgs) Handles tvwExplorer.AfterSelect<br />
'Get reference to the selected node<br />
Dim dirInfo As DirectoryInfo = New DirectoryInfo(e.Node.FullPath)<br />
'Clear all the items in the listview<br />
lvwExplorer.Items.Clear()<br />
'Check if the Directory exist or not<br />
If (dirInfo.Exists) Then<br />
'Get reference to all the files<br />
Dim fileInfos As FileInfo() = dirInfo.GetFiles()<br />
'Add all the files to the ListView one by one<br />
Dim info As FileInfo<br />
For Each info In fileInfos<br />
'First check the extension, make sure it's a url file<br />
If info.Extension = ".url" Then<br />
Try<br />
'Open the file and read it<br />
'Convert the file path into a string for the StreamReader<br />
Dim infoPath As String = info.FullName<br />
' Create an instance of StreamReader to read from each file.<br />
Dim sr As StreamReader = New StreamReader(infoPath)<br />
'Read the complete url file text<br />
Dim url As String<br />
url = sr.ReadToEnd()<br />
'Extract only the url text<br />
<big>This is where I need to extract the http text</big><br />
<br />
Dim item As ListViewItem = New ListViewItem<br />
item = lvwExplorer.Items.Add(info.Name)<br />
' Link the ImageList object<br />
item.ImageIndex = 2<br />
'Add the items<br />
item.SubItems.Add(url.ToString())<br />
item.SubItems.Add(info.LastAccessTime.ToString())<br />
sr.Close()<br />
Catch ex As Exception<br />
'Ignor Exception<br />
Return<br />
End Try<br />
End If<br />
Next<br />
End If<br />
End Sub
-- modified at 19:43 Friday 24th February, 2006
|
|
|
|
|
Hey Dean,
I got it to work! Sorry but the Newbie is excited!!! lol I figured it out. I was reading the text wrong. I was reading the whole thing in one shot instead of reading it line by line and the 4th line I had to read it in two shots. This is the reading code I did and it all works just fine now. For anyone (Newbies) that need to know how to do this here's the extra code to finish it up. Change everything between the "Dim url As String" and the beginning of the listview code to this below.
'Read the url file and get the url text<br />
Dim c(3) As Char<br />
Dim url As String<br />
url = sr.ReadLine()<br />
url = sr.ReadLine()<br />
url = sr.ReadLine()<br />
url = sr.Read(c, 0, c.Length)<br />
url = sr.ReadLine()
Thanks again for all of your help Dean.
|
|
|
|
|
I have created a new instance of a form from a thread that responds to incoming UDP packets from another computer. This form shows up in the screen but the user cannot use it’s command buttons. Other threads cannot manipulate it’s variables or cause a paint event on it’s picture box.
How does one accomplish these things?
Thanks.
RCarey
|
|
|
|
|
Forms are not thread safe.
Because of this, I highly recommend that you display all of your forms on the same thread. If you need a separate thread to manipulate a form's contents, then look into using the BeginInvoke() method. See the below link for more details.
http://www.codeproject.com/csharp/begininvoke.asp[^]
|
|
|
|
|
I'm quite a vb.net beginner and I lost my library-card so I have to wait a month before I can get a book about this: How do I load a dll file into my vb.net program??
(I'm only 15 so I'm not very good at vb.net)
|
|
|
|
|
It depends what that dll file is! not all .dll files are the same thing, confusing I know!
So, if it is another dll written in .NET, then you just add a reference to the dll (are you using Visual Studio?)
If it is a COM dll, then you can still add a reference, and if using Visual Studio it will do the "hard work" for you.
If it is a windows dll then you often have to call them using pinvoke... this is a little complex if you are a beginner.... i hope its one of the above!
Hope that helps buddy, 15 is a good age to start learning to program!
|
|
|
|
|
Here is the link: http://r2.d2.hu/snf/sound_tools/freeware_gpl/free_bladeenc_encoder_player_editor_wav_mp3_ogg_rip_convert_encode_tracker.html
I only know how to use variables, load files, save files and some other basics :P
|
|
|
|
|
OK, so it looks like a COM dll to me, are you using Visual Studio to write your program?
|
|
|
|
|
nope visual express(it's .net by the way)
|
|
|
|
|
|
that's a great help
sorry but not really, none of the codes works
-- modified at 16:34 Thursday 23rd February, 2006
|
|
|
|
|
teuneboon,
What do you mean by it doesn't work?
I works in my vb.net...
Declare Auto Function MyMessageBox Lib "user32.dll" Alias _
"MessageBox" (ByVal hWnd As Integer, ByVal msg As String, _
ByVal Caption As String, ByVal Tpe As Integer) As Integer
Private Sub Button1_Click(ByVal sender As System.Object, _
ByVal e As System.EventArgs) Handles Button1.Click
MyMessageBox(0, "Hello World !!!", "Project Title", 0)
End Sub
progload
|
|
|
|
|
|
teuneboon,
hmmm... I guess i won't be able to help, It works here on mine just fine.
sorry,
progload
|
|
|
|
|
I now know how it works (I inserted the code in a form :S) but the call fuction doesn't work in my form when I want to call the class1 file
|
|
|
|
|
teuneboon,
If you want to put the Delcare Auto Function... in Class1 and then Call it from Form1, do this:
Change the line in your Form1 Button1_Click that reads:
MyMessageBox(0, "Hello World !!!", "Project Title", 0)
Change it to this:
Call Class1.MyMessageBox(0, "Hello World !!!", "Project Title", 0)
progload
|
|
|
|
|
ok now I know alot more about class and dll, thanks all
|
|
|
|
|
If you are talking about a Win32 API DLL, you do it like this:
Declare Function (or Sub) (FunctionName) Lib (Dllname) Alias (Function Name in DLL) then the arguments.
for instance:
Declare Function MsgBox Lib "user32.dll" _
Alias "MessageBox" (ByVal hWnd As Integer, _
ByVal txt As String, ByVal caption As String, _
ByVal Type As Integer) As Integer
Then you could call it like any other function.
There is more info about this here: http://kpdweb.cjb.net/
|
|
|
|
|
If you're using PInvoke, you probably want to check out www.pinvoke.net, they may have done the hard yards for you already.
I was 13 when I started coding. *sigh* That was in 1982.
Christian Graus - Microsoft MVP - C++
|
|
|
|
|
The early 80s were a good time to start coding.
It brings back the memories. My dad borrowed a Commodore Pet from work when I was 6. A friend had a Sinclair ZX81 and then my dad bought a ZX Spectrum in 1983.
ColinMackay.net
Scottish Developers are looking for speakers for user group sessions over the next few months. Do you want to know more?
|
|
|
|