I am a neophyte programmer who was right on the cusp of his answer over here at
Loading a pdf file in Visual Basic Windows form?
Unfortunately I couldn't find a way to get in touch with the person whom I thought gave the best answer, so forgive me if this answer is inapropes...
I would like to add .pdf files to my programme, so that the user can simply read directly upon clicking the menu item.
I have the files "Benutzerhandbuch Info 2 Projekt.pdf" and "Produktbeschreibung Info II Projekt.pdf" ready to go, but don't know where I should save them.
I've already got Adobe installed on my machine and in my toolbox.
GojiraDeMonstah answered with what I think is the best solution (??) but I couldn't ask any further q's as it is against policy and I don't have enough cred 'cause I'm new.
Q* - where should I save the file so that VB can see it?
Q* - once the programming is complete, I will then burn this to CD and give it to Prof as a kind of "Product", but if I link a pdf file saved on my computer, then how will my prof see the file?
Sorry if these questions sound really basic, but I don't even know what to search for besides what I have already done. I really do need a bit of hand-holding here. I wish I could upload pics, because it would make my question easier to understand. Thanks in advance for your help.
Insert a WebBrowser Control in your WinForm, then:
webBrowser1.Navigate("c:\test.pdf")
I ended up using the following:
Public Class Benutzerhandbuch
Private Sub Benutzerhandbuch_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
End Sub
Private Sub AxWebBrowser1_Enter(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles AxWebBrowser1.Enter
AxWebBrowser1.Navigate("C:\FilenamePath\Filename.pdf")
End Sub
End Class
Special thanks to all who contributed.
Logan
Related
I made a nice program while learning and everything was going good until I did something, but I forgot what I did. Now the buttons won't click but they all have the functions.
I know it's something in the properties but I forgot what it was.
vb.net express 2013
Without code provided, we can't really help that much. But what you can do is create another button, then copy whatever the code of your old button was, and paste it to your new button created.
In Visual Studio when you cut and paste any Control instead of simply drag it in a new position it will lost every event handler already added.
In your case simply add Handles clause to your YourButtonName_Click sub:
Private Sub YourButtonName_Click(sender As System.Object, e As System.EventArgs) Handles YourButtonName.Click
I am having a bit problems trying this. I must admit that I am still novice programming. Well, I managed for do this in this way (VB.NET):
Private Sub Timer2_Tick(sender As Object, e As EventArgs) Handles Timer2.Tick
If My.Computer.Keyboard.CtrlKeyDown Then
MORE IRRELEVANT CODE HERE
End If
End Sub
But with this way, even if it work, it dont let me customice the key shortcut (only Control, shift and others).
I did this too for try differents things:
Private Sub Form1_KeyDown(sender As Object, e As KeyEventArgs) Handles MyBase.KeyDown
If e.KeyCode = GlobalVariables.own_key Then
MORE IRRELEVANT CODE HERE
End If
End Sub
I give value to GlobalVariables.own_key from other button. This work perfectly, but only if program have the focus.
So... With the first code program work even if it haven't the focus but only with few keys... And with the second it let me use any key, but don't work if it haven't the focus.
I tryed understand the "keyboard hook" but I must admit that I didn't understad it and couldn't manage for work any of them.
Using VB.net 2012.
Really thanks so much for your help
It may not be an answer you like but it is the answer. In .NET, you cannot get notification of keys when your application does not have focus and you cannot get mouse events outside your applications windows. If you looked into the "Keyboard Hook", you should have read that little important fact regarding VB.
Global hooks are not supported in the .NET Framework
Ok, I'm aware there's a lots of topis about this, but I haven't found anything that works for me.
My program generates a small picture that i would like to keep in a WinForm that's always at the bottom, "with the desktop". Something like the gadgets in windows 7.
How do i tell my form to always stay here, and just can't be visible over any other form/window?
Should'nt this be doable like in the form_load function for this window?
Like this
Private Sub Sticky_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Me.KeepMeAtTheBottomUntillIAmClosed
End Sub
If you create a form that has no border and no controlbox, the user will not be able to resize or move it. Then add your own button to allow it to close, tell it where you want it to be and tada!
You can even add some mouse over functionality to make the tools appear when you are over the form.
I am using the following code to open up a pdf
WebBrowser1.Navigate("file://C:\test.pdf")
However instead of opening up in the browser it just keeps on launching adobe acrobat reader and opening the PDF in that, leaving the webbrowser1 untouched.
This is not what I want; I want my PDF to open up in my web browser
What am I possibly doing wrong?
I just solved this. What you need to do is drag your pdf document to your solution explorer and then open it from there.
Private Sub Form1_Load(sender As System.Object, e As System.EventArgs) Handles MyBase.Load
WebBrowser1.Navigate("c:\users\Fake.Name\documents\visual studio 2010\Projects\SO\SO\test.pdf")
End Sub
I am working on solution 'SO', so I put the pdf into the solution and dragged the pdf to my code where it generated its location.
Also, take a look at this
Hope this helps
The problem with your code is the "file" statment.
Try this
WebBrowser1.Navigate("C:\test.pdf")
And you'll see the file opened into your webbrowser control.
In project properties check "Prefer 32-bit". Of course, that might bring on other problems (as in my case), so it's not a perfect solution.
I have been searching all over for an answer to this, and I'm figuring there is no way to do it, but I thought I'd ask.
I'm looking to make a VB.net app that gets and displays the artist and title of a song playing in Windows Media Player. I'm not looking to embed the player in my app, just pull data from the already existing window.
Most of the stuff I find on how to do this is old or related to embedding WMP. I'm looking to do it in with MWP12. I've also seen references to using AxWindowsMediaPlayer.currentMedia Property, but that doesn't seem to work anymore. I used to be able to pull the data from the Registry, but it seems Microsoft took that away.
I've tried sooooo much other code, but this is currently what I have. I'm at my wits end.
Imports WMPLib
Public Class Form1
Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim wmp As WindowsMediaPlayer = New WindowsMediaPlayer
Dim playlist As IWMPPlaylist = wmp.currentMedia.???????(????).Item(?)
Label1.Text = playlist.getItemInfo("Title")
End Sub
End Class
No idea where to go here, but thanks for any help.