|
VB .NET Helper Newsletter
|
Rod Stephens
|
Jun 05, 2009 12:02 PDT
|
Reminder: If you promised to review my book "Beginning Database Design
Solutions," there's no time like the present!
Learn more about the book at:
http://www.vb-helper.com/db_design.htm
http://www.wiley.com/WileyCDA/WileyTitle/productCd-0470385499.html
http://www.amazon.com/exec/obidos/ASIN/0470385499/vbhelper/
----------
This week's examples show several different ways to display PDF files in
and out of a form in both VB 6 and VB .NET. Once you know how to do it,
it's actually pretty simple (assuming Adobe Reader is installed on your
computer).
----------
Have a great week and thanks for subscribing!
Rod
RodSte-@vb-helper.com
Books To Keep: http://www.BooksToKeep.com
----------
*** Now Available ***
Beginning Database Design Solutions
http://www.amazon.com/exec/obidos/ASIN/0470385499/vbhelper/
Visual Basic 2008 Programmer's Reference
http://www.amazon.com/exec/obidos/ASIN/0470182628/vbhelper/
==========
VB.NET Contents:
1. New HowTo: List system process information similar to the information
provided by Task Manager in Visual Basic .NET
2. New HowTo: Open a PDF file in a WebBrowser control in Visual Basic
.NET
3. New HowTo: Open a PDF file in an external Adobe Reader process in
Visual Basic .NET
4. New HowTo: Open a PDF file in an Adobe Reader control within an
application in Visual Basic .NET
Both Contents:
5. New Links
==========
++++++++++
<VB.NET>
++++++++++
==========
1. New HowTo: List system process information similar to the information
provided by Task Manager in Visual Basic .NET
http://www.vb-helper.com/howto_net_enumerate_processes.html
http://www.vb-helper.com/HowTo/howto_net_enumerate_processes.zip
First, add a reference to System.Management.
When the program loads, it creates a ManagementSearcherObject to execute
the query "SELECT * FROM Win32_process." It loops through the results
saving the returned ManagementObjects and adding their captions to a
list box.
Private m_Results As List(Of ManagementObject)
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load
m_Results = New List(Of ManagementObject)
Dim searcher As New ManagementObjectSearcher("SELECT * FROM
Win32_process")
For Each result As ManagementObject In searcher.Get()
lstCaptions.Items.Add(result.Item("Caption"))
m_Results.Add(result)
Next result
End Sub
When you select an item from the list box, the program call subroutine
ShowDetail. This routine looks up the returned ManagementObject and
displays its textual value in an appropriate format. Use the program's
option buttons to pick the format.
' Show the detail for the selection.
Private Sub ShowDetail()
If lstCaptions.SelectedIndex < 0 Then Exit Sub
Dim result As ManagementObject =
m_Results.Item(lstCaptions.SelectedIndex)
Dim txt As String
If radMof.Checked Then
txt = result.GetText(TextFormat.Mof).ToString()
ElseIf radCimDtd20.Checked Then
txt = result.GetText(TextFormat.CimDtd20).ToString()
Else
txt = result.GetText(TextFormat.WmiDtd20).ToString()
End If
txt = txt.Replace(vbLf, vbCrLf)
txt = txt.Trim()
txtDetails.Text = txt
End Sub
==========
2. New HowTo: Open a PDF file in a WebBrowser control in Visual Basic
.NET
http://www.vb-helper.com/howto_net_open_pdf_browser.html
http://www.vb-helper.com/HowTo/howto_net_open_pdf_browser.zip
Add a WebBrowser control to a form and use its Navigate method to open
the PDF file. It's that easy!
webPdf.Navigate(txtFile.Text)
==========
3. New HowTo: Open a PDF file in an external Adobe Reader process in
Visual Basic .NET
http://www.vb-helper.com/howto_net_open_pdf_externally.html
http://www.vb-helper.com/HowTo/howto_net_open_pdf_externally.zip
Simply call System.Diagnostics.Process.Start to "execute" the file. If
Adobe Reader is installed, it should open the file.
System.Diagnostics.Process.Start(txtFile.Text)
==========
4. New HowTo: Open a PDF file in an Adobe Reader control within an
application in Visual Basic .NET
http://www.vb-helper.com/howto_net_open_pdf_reader.html
http://www.vb-helper.com/HowTo/howto_net_open_pdf_reader.zip
This only works if you have Adobe Reader installed. Then:
1. On the Toolbox, right-click and pick "Choose Items."
2. Click the "COM Components" tab.
3. Select "Adobe PDF Reader" and click OK.
4. Add a PDF reader to the form.
Now you can use the reader control's src property to open the PDF file.
pdfReader.src = txtFile.Text
==========
++++++++++
<Both>
++++++++++
==========
5. New Links
http://www.vb-helper.com/links.html
AcademyX Computer Training
http://www.academyX.com
Hands-on classes in VB6, Excel VBA, Access VBA, Java, and more in San
Francisco, Los Angeles, Sacramento, and San Jose locations.
==========
Archives:
http://www.topica.com/lists/VBHelper
http://www.topica.com/lists/VB6Helper
http://www.topica.com/lists/VBNetHelper
Post questions at:
http://www.topica.com/lists/VBHelperQA
|
|
 |
|