How to get the URL off the Gecko loaded page - vb.net

EDIT (Important!): This question din't make sense before, and even though I have the answer from a loong time ago I decided to update it with some acual code. Probably all comments will be irrelevant because the old post contained code that had nothing to do with the question.
I'm trying to get the URL off the current loading/loaded page in GeckoWebBrowser. I only have one idea on how I can get it:
Private Sub Browser_Navigated(ByVal sender As Object, ByVal e As System.Windows.Forms.WebBrowserNavigatedEventArgs) Handles Browser.Navigated
someLabel.Text = GeckoWebBrowser.DocumentTitle
End Sub
The error I am getting is that it is not updating.

Related

How do you launch an .exe in a VB.net application who's directory varies amongst users?

I am creating an application for an Arma 3 server that directly launches the game and connects the user to a specific server. The problem that I am encountering, being the relatively new VB coder that I am, is that the Arma3battleye.exe directory (the .exe used to launch the game) may be installed in different directories depending on where the user originally installed it. I've developed the code to connect the user to the server if they've installed Arma in the normal location:
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Process.Start("C:\Program Files (x86)\Steam\steamapps\common\Arma 3\arma3battleye.exe", "2 1 -noSplash -skipIntro -useBE -noPause -world=empty -connect=192.99.36.80 -port=2505 -mod=#Exile;#AlRayak;#AllInArmaTerrainPack;#CUP Units;#CUP Vehicles;#CUP Weapons;#CBA_A3;#TRYK's Multi-Play Unifrom's pack")
End Sub
However, after researching for many hours, I cannot determine how to have the program automatically determine the install directory of the arma3batteye.exe and then execute it with all of the correct start parameters included. Any solutions or pointers to help solve this problem would be greatly appreciate.
TLDR: What is the easiest way to program an application to automatically find the install directory of a given .exe and then execute it with the given parameters as I've done above?
Edit: Another thread similar to mine asks a similar question (how to view/get to the steam folder without hard coding it. They arrive at the conclusion that if you do (for winx32):
Dim strSteamInstallPath as String = My.Computer.Registry.GetValue(
"HKEY_LOCAL_MACHINE\SOFTWARE\Valve\Steam", "InstallPath", Nothing)
Or using this registry location for winx64:
HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Valve\Steam
and then were to create a button using Process.Start that it would allow you to ultimately view the directory. At this point I haven't discovered a way for that to translate into being able to execute the battleyearma3.exe from within that steam directory with the proper parameters. While it seems this code may be useful in arriving at the solution I'm looking for, I can only get the program to view the general steam directory at this time.
edit: Solution posted at bottom. Thanks to #VisualVincent who was really the one that allowed me to complete this. It really should be you having posted the correct answer, not me.
I would use the registry...
You add a key like HKEY_LOCAL_MACHINE\Software\Arma3\ServerPath = "..." when you install the server.
And whenever you need to start the client, you check up the path from that registry key.
So with the comments and tips you gave me (especially #VisualVincent) I managed to piece enough stuff together to solve my issue. Thanks to everyone for the help:
First I declared 2 variables. The first one (BattleyePath) goes into the registry as far as I can get it to dig. Executing this variable on its own will open the users steam directory. I then declared a second variable (BattleyePath2) which uses IO.Path.Combine get to the directory the users Arma3.exe is installed in:
Dim BattleyePath As String = My.Computer.Registry.GetValue("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\Valve\Steam", "InstallPath", Nothing)
Dim BattleyePath2 As String = IO.Path.Combine(BattleyePath, "SteamApps", "common", "Arma 3", "arma3battleye.exe")
I added a couple buttons to close the program and mute the sound:
`Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
Me.Close()
End Sub
Private Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click
My.Computer.Audio.Stop()
End Sub`
Finally I created the button that actually launches the game:
`Private Sub Button4_Click_1(sender As Object, e As EventArgs) Handles Button4.Click
Process.Start(BattleyePath2, "2 1 -noSplash -skipIntro -useBE -noPause -world=empty -connect=192.99.36.80 -port=2505 -mod=#Exile;#AlRayak;#AllInArmaTerrainPack;#CUP Units;#CUP Vehicles;#CUP Weapons;#CBA_A3;#TRYK's Multi-Play Unifrom's pack")
End Sub`

vb.net connects to database access

im really new to this language so this is so simple please answer
Me.InfoBindingSource.RemoveCurrent()
i only have id t on my delete button do i have to adsome codes? knows anyone?
i've searched some sites and it is the only code they say. i connected it and actually worked on add. but with delete it dont.
Do i need to move something.. like files?
i've tried everything this is my last hope. thanks for the answer :)
here is the whole code
Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Me.InfoBindingSource.RemoveCurrent()
End Sub
That RemoveCurrent method will mark the current row in the bound DataTable as Deleted. Just like when adding or editing rows though, you still have to call Update on your data adapter or table adapter to save that change back to the database.

GeckoFX DocumentTitle return previous title rather than current

I am having trouble getting the Document Title for a Gecko web browser (1.9.1.2) in Visual Studio 2015 (VB.Net), this is my code, I can get the URL, but the Document Title returns the title of the previous page, not the current one...
Private Sub NavFinished(ByVal sender As Object, ByVal g As GeckoNavigatedEventArgs) Handles GeckoWebBrowser.Navigated
alabel.Text = GeckoWebBrowser.DocumentTitle
anotherlabel.Text = GeckoWebBrowser.Url.ToString
End sub
any ideas what is wrong?
I found a work around, using GeckoWebBrowser.DocumentTitleChanged - still confused as to why it wouldn't work via navigated tho, if anyone can shed some light on it, that would be great!

Getting a stack overflow exception when calling OpenFileDialog1.ShowDialog() [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
Attempted to read or write protected memory. When I call showDialog method of openfileDialog
Not sure why. It was originally working just fine, then I made some changes to the code that should have had no effect on this.
The changes I made where to just change some properties of a checkbox when the file is selected:
Private Sub OpenFileDialog1_FileOk(ByVal sender As System.Object, ByVal e As System.ComponentModel.CancelEventArgs)
attachmentLabel.Text = OpenFileDialog1.FileName.ToString()
attachmentCheckBox.Visible = True
attachmentCheckBox.Checked = True
End Sub
Here's the event handler that calls OpenFileDialog1.ShowDialog()
Private Sub Button2_Click(sender As System.Object, e As System.EventArgs) Handles Button2.Click
OpenFileDialog1.Title = "Please Select a File"
OpenFileDialog1.InitialDirectory = "C:temp"
OpenFileDialog1.ShowDialog()
End Sub
Any help would be appreciated.
When the exception occurs, the values for e and sender say "unable to evaluate expression".
(This is really a comment, but it is too big.)
It is due to:
some of your code not shown here,
some filesystem or networking issue specific to your machine, or
a transient problem with VisualStudio (or the VB.NET compiler).
To rule out (3), (and (2) if the problem is transient) reboot your machine and rebuild your application (either clean and then build or at least just rebuild).
To confirm (2), try running your program on a different machine.
To help locate the issue if it is (1), search your code for references to OpenFileDialog1. If it appears anywhere other than in designer generated code and the two events you have shown in your question, include them in your question.
If the problem does still occur, confirm if it occurs with both Debug and Release builds or not, and include the designer generated code in the question as well.

Focused row not working - Gridview

I am using Dev Express to develop a form in which i have a GridControl with a View inside a View.
It looks like this:
I am then trying to use the event ValidatingEditor to validate the user input.
I tried to do that by doing:
Private Sub grvObsAM_Artigos_ValidatingEditor(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs) Handles grvObsAM_Artigos.ValidatingEditor
Dim row As Integer = Me.grvObsAM_Artigos.FocusedRowHandle
This, however always returns me something like -99999..
I poked around and tried this other solution using the sender from the event:
Private Sub grvObsAM_Artigos_ValidatingEditor(ByVal sender As Object, ByVal e As DevExpress.XtraEditors.Controls.BaseContainerValidateEditorEventArgs) Handles grvObsAM_Artigos.ValidatingEditor
Dim grv As DevExpress.XtraGrid.Views.Grid.GridView = CType(sender, DevExpress.XtraGrid.Views.Grid.GridView)
Dim row As Integer = grv.FocusedRowHandle
And using this second solution i managed to get the focused row handle. Even though this worked this time (because the event was triggered by the view itself and i had access to the sender) this doesn't solve my problem as there are other events where the sender is not the view and the problem persists.
Usign Me.grvObsAM_Artigos."insert anything here" doesn't seem to work properly.
Does anyone have any idea on why this is happening? Am i missing something?
Regards,
I think your issue is actually that you have several of the grvObsAM_Artigos gridviews. One for each row that has the details. So you need to use the view above ti to access the proper one. Using:
Dim grv as XtraGrid.Views.Grid.GridView = grvObsAM.GetDetailView(RowHandle, 0)
That should give you the right instance of the gridView you want. Everytime a master row is expanded and collapsed, the child is created and destroyed respectively.
This should give you a bit more background.
http://documentation.devexpress.com/#WindowsForms/DevExpressXtraGridViewsGridGridView_GetDetailViewtopic