In our application, when you go to "Menu > Help...", it opens our help files in Internet Explorer, which is the desirable effect. However, we have the shortcut key "F1" set to open the help files as well. It still opens the help in Internet Explorer... but it also opens them up at the same time in the user's default web browser!
Here is the code in the event method that opens the web browser:
Private Sub menuHelpHelp_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles menuHelpHelp.Click
Dim temp As String = String.Format("{0}\Internet Explorer\iexplore.exe", Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles))
Dim temp2 As String = String.Format("{0}", Globals.HelpFilePath)
If Not System.IO.File.Exists(temp2)
MessageBox.Show(String.Format("Could not find index.html, run ""help_zip.exe"" inside the Doc folder as an Administrator to restore the help system (make sure to overwrite all files when asked!)"))
Else
System.Diagnostics.Process.Start(temp, temp2)
End If
End Sub
If I step through the code after clicking the Help menu item, IE opens as intended when I hit the "System.Diagnostics.Process.Start(temp, temp2)" line. However, when I do the same thing after pressing F1, it opens first in the user's default browser, and then in IE second. Any ideas? The code in this part of the application is written in VB.NET, and the application is a .NET 3.5 app.
Out of curiosity, have you tried binding the action to another button to see if the problem still exists? Switch it from F1 to F2, see if it still happens. Almost certainly will, unless there's some code in your program which you forgot about that's causing problems.
EDIT
You appear to be setting a global variable for your help path.. which means the default F1 Help would likely load the correct file. So I'd go with the "F1 is still bound to the default Help action." You'll need to unbind it.
Related
Recently try to use a webbrowser component.
when I click button, it will navigate to facebook.com. after I login on first time and stop the program. and then when I run the program second time I don't need to fill the email and password. why I don't need to fill an email and password textbox ? thanks
Here's the code
Public Class Form1
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
WebBrowser1.Navigate("m.facebook.com")
End Sub
End Class
Note: I will delete this post, because it doesn't help the community. Just my curiosity. Thanks
how do i need to re-type the email password again when 2nd starting the program
You have two options:
The first is to save the CookieContainer associated with the WebBrowser to disk and reload it when you restart your program. There is no straightforward way to serialize cookies to disk or other storage method - that is up to you.
Instruct the WebBrowser object to make use of the user's Windows profile Internet Explorer cookie collection which is shared with Internet Explorer and other programs that also opt-in to sharing state (I do not know if this also applies to the Edge browser, I suspect it does not). See here for instructions on how to do this: Use cookies from CookieContainer in WebBrowser
I am trying to display a pdf file in an Access form, but my code only works once. When I close the Access application and reopen it Acropdf doesn't display the pdf, it just gets stuck on this screen:
Private Sub Command1_Click()
Dim strPdfDoc As String
'Below is my source
strPdfDoc = "F:\Grifols\files\Unified Region TemplateV1_0_Budget.pdf"
'Here I am loading the pdf file with Acropdf
AcroPDF0.loadFile strPdfDoc
End Sub
I get no errors when debugging the code, but the pdf never shows.
I struggled with this issue for a long time, it was only happening when the EXE was run as Administrator.
My fix was the following:
Set EXE compile to x86 CPU
Change PDF output path to ProgramData: "C:\ProgramData(Client)(Project)"
Update code to first call "AxAcroPDF1.LoadFile(PDFfilepath)" then call "AxAcroPDF1.src = PDFfilepath"
Important: If you need to run the application on Windows Server for some reason, then the 32bit version of Crystal Runtime needs to be installed
Check that your version of Adobe Reader is up to date and replace your code with this. I was able to load the file several times, close and reopen and load again.
Private Sub Command1_Click()
Dim pdf As AcroPDF
Set pdf = Me.AcroPDF0.Object
pdf.LoadFile "F:\Grifols\files\Unified Region TemplateV1_0_Budget.pdf"
End Sub
I had Acrobat Reader DC installed, I Downgraded to 11 from this link
https://helpx.adobe.com/acrobat/kb/install-reader-x-windows.html
And changed the following registry setting to get this to work
To disable the Enable Protected Mode at startup configuration, navigate to the following registry key:
HKEY_CURRENT_USER\Software\Adobe\Acrobat Reader\DC\Privledged
… then modify the bProtectedMode REG_DWORD value to 0 to disable and 1 to enable:
found it at this link
http://terenceluk.blogspot.co.uk/2016/01/disabling-enable-protected-mode-at.html
I found a solution, that work for me, at this link:
To solve initializing screen for Acrobat Reader XI, just disable "Enable Protected Mode At Startup"
I have a website stored 100 users ....now i want to create a VB form with 100 buttons ....while i click button1, it will open IE then log in users1 automatic and when i click button2 , it will open IE then log in as user2 automatic. user3 until user100 the same ....click from button on vb form.
Note : i am already done to set open IE and log in as different users in each windows but now i am finding how to set auto log in with different users in the same website when i click each button in form.
i have something more about form....i will use ( 100 button click = 100 users = 100 IE window ....)
it depend on user click on button that he need to log in......because we don't know that what button/users/time will he want to click .....
I really need your help urgently...
Thank in advanced.
here is some code of Button_Click
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Using p As New Process
p.StartInfo.FileName = "C:\Program Files\Internet Explorer\iexplore.exe"
p.StartInfo.Arguments = "http://test.com"
p.Start()
End Using
This is the only way I can come up with on how to solve this.
My guess is that your login is using POST variables, it's pretty much standard.
To make this work you would have to allow the username and password to be supplied with GET. That is, sending them in the url like this:
http://test.com/login.php/asp?username=username&password=password
Since you haven't specified whether you use PHP or ASP.NET I will add info on how to get the value for both:
ASP.NET
Request.Querystring("username")
PHP
$_GET["username"];
EDIT based on comment
You are correct it is not possible to isolate separate webbrowser controls.
I would suggest you look into either WaTin to control separate IE instances, or Awsomium .NET, which i believe allows separate sessions in 1.7, though i haven't tested it.
Also be aware that since IE8 session cookies are shared across instanced by default, so you would need to run them with the -nomerge flag. WaTin supports this.
Based on the fact that you have not mentioned this in your question, i am presuming you are using IE7. If that is the case, and this application is not intended to be used on other machines, it should be possible to create a separate application with an embeded webbrowser control, then launch multiple insatances of that application from the main one, so you can add your own communication mechanism, but WaTin is probably a far better idea
OLD ANSWER:
It is very hard to work out what you want to do, but im guessing you want to create a winforms app, that lets you to choose a user account, and then open a browser and login to a website with that account.
Based on that assumption, my suggestion would be to have one button, and some way of selecting the account, say a comboBox, and a webbrowser control:
http://img198.imageshack.us/img198/888/66649645.jpg
Rather than 1 button per user account and trying to manipulate an external browser.
If this is indeed what you want to do, comment and i will edit my answer as required, and provide starting code if you need, but i cant do that without really undertanding what you need to do.
I have setup a userform1 to browse an intranet using web browser controls in VBA/Excel. The problem I am having is that when the user initiates a popup through the web browser control, that popup runs in IE by default, outside of the scope of the web browser control, and therefore doesnt contain the correct session data in the popup. This popup initiates from a dropdown box, onchange command and then inserts the input from the popup back into a web form on the page. The code below intercepts the popup event and lets you handle it, by transferring it to say, userform2
Private Sub WebBrowser1_NewWindow2(ppDisp As Object, Cancel As Boolean)
Dim frm As UserForm2
'Dim ppDisp As Object
Set frm = New UserForm2
Set ppDisp = frm.WebBrowser1.Application
frm.Show
End Sub
Problem is, it gets stuck right now on frm.show, when I pause, and doesnt seem to be actively transferring over the web page correctly into userform2. I'm not sure where my logic is wrong here, any advice would be helpful. Most guides have shown:
Set ppDisp = frm.WebBrowser1.object
But I cant find that in the object browser anywhere, and doing .object bombs out, as error 438: object doesnt support this property or method. But everything I could find on this so far shows using .object.
for anyone reading this, VBA wont support this method as the above says. It works perfectly in .net and I would assume then, vb6
I am programming in Windows Mobile SDK 6 using Visual Basic, i would like to know how to make a button open the smartphone browser with a specific website path (make a link)
I got to the next piece of code so far:
Public Class GuitarHelperPage
Public link As New WebBrowser
Public adress As Uri
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
adress = New Uri("https://www.google.com")
Try
link.Navigate(adress)
'link.Focus()
Catch ex As System.UriFormatException
Return
End Try
End Sub
(the commented 'link.Focus()' its just something i tryed out, but i got the same output)
I simply want to click the button and open the browser at google homepage. But when I click it, the warning "This page contains both secure and nonsecure items. Do you want to continue?" appears and when I click "yes", nothing else hapens.
I've been researching and found this on MSDN help pages:
"The WebBrowser class can only be used in threads set to single thread apartment (STA) mode. To use this class, ensure that your Main method is marked with the STAThreadAttribute attribute"
SO i added this my main method:
<STAThread()> _
Shared Sub Main()
But still i get this error : "Type STAThread is not defined." And can't find a away around, I tried to add this same attribute to a Windows Desktop VB project and it works, maybe there is another way to do it in Mobile?
I am using .Net Framework 3.5 and windows mobile sdk 6.0 for this project
Please help, thank you.
If you want to open the default browser, you don't need a WebBrowser control. Just use the Process class, specifically the Start overload that takes in a ProcessStartInfo. Set the UseShellExecute property of the ProcessStartInfo to true so that it will open the default browser (e.g. if the user installed Opera Mobile, it will use that, not just always force IE).