options: use tabs or not? how to save?

How to save "use tab" settingsin webbrowser?

Page 1 of 1

13 Replies - 2467 Views - Last Post: 25 March 2009 - 12:26 AM Rate Topic: -----

#1 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

options: use tabs or not? how to save?

Posted 18 March 2009 - 03:42 PM

Hello. I got a tabbet webbrowser. i made options for it.. but i cant get the "use tabs" option to work. the idea is that if i check tha checkbox then the "add tab" button will be visible, and the other way around. but this just wont work.. not even if i try it whit the options form open. and is should al least work then.
Here is my code for form_load in form1 ( webbrowser )
		 If Form3.CheckBox1.Checked = True Then ToolStripButton2.Visible = True
		If Form3.CheckBox1.Checked = False Then ToolStripButton2.Visible = False 


and here is my code for the entire form2 ( options)
Public Class Form2

	Private Sub TextBox1_TextChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles TextBox1.TextChanged

	End Sub

	Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		My.Settings.Save()
		My.Settings.HomePageUrl = TextBox1.Text
		TextBox1.Text = My.Settings.HomePageUrl

	End Sub

	Private Sub CheckBox1_CheckedChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles CheckBox1.CheckedChanged

	End Sub

	Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
		My.Settings.Save()


	End Sub

	Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
		Close()
	End Sub

	Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
		TextBox1.Text = My.Settings.HomePageUrl


	End Sub
End Class



anyone got a idea?

Is This A Good Question/Topic? 0
  • +

Replies To: options: use tabs or not? how to save?

#2 myork  Icon User is offline

  • D.I.C Head

Reputation: 41
  • View blog
  • Posts: 129
  • Joined: 04-March 09

Re: options: use tabs or not? how to save?

Posted 18 March 2009 - 06:37 PM

If you're using a setting to save the status of that checkbox (hopefully a boolean :)) then you should use something like the following:
Form_Load()
   checkbox.Checked = My.Settings.CheckedSetting 'CheckedSetting is the hypothetical setting'
   ToolStripButton.Visible = My.Settings.CheckedSetting 'It doesn't really matter whether you use My.Settings.CheckedSetting or checkbox.Checked here because they will be the same boolean value


If this isn't what you were looking for, please specify what each of your forms is doing, because we've got form 2, the checkbox is apparently in Form3, and the load event you're using is form1.
Was This Post Helpful? 0
  • +
  • -

#3 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: options: use tabs or not? how to save?

Posted 19 March 2009 - 08:55 AM

View Postmyork, on 18 Mar, 2009 - 05:37 PM, said:

If you're using a setting to save the status of that checkbox (hopefully a boolean :)) then you should use something like the following:
Form_Load()
   checkbox.Checked = My.Settings.CheckedSetting 'CheckedSetting is the hypothetical setting'
   ToolStripButton.Visible = My.Settings.CheckedSetting 'It doesn't really matter whether you use My.Settings.CheckedSetting or checkbox.Checked here because they will be the same boolean value


If this isn't what you were looking for, please specify what each of your forms is doing, because we've got form 2, the checkbox is apparently in Form3, and the load event you're using is form1.

sorry.. im really new at this.. boolean? i dont understand that one. and the form for the options box ( options opens in a new windows) thats form2. and the webbrowser it self is form1. and form3 is tha "about" box. i dont know that more to say to you.
Was This Post Helpful? 0
  • +
  • -

#4 Arazons  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 1
  • View blog
  • Posts: 79
  • Joined: 18-March 09

Re: options: use tabs or not? how to save?

Posted 19 March 2009 - 06:40 PM

Quote

In computer science, the Boolean datatype, sometimes called the logical datatype, is a primitive datatype having one of two values: true and false. Many systems represent true as non-zero (often 1, or -1) and false as zero. It is the special case of a binary numeric datatype of only one digit, or bit, and can also be represented in any other radix by restricting the range of allowed values for certain operations.

In some languages the Boolean datatype is defined to represent more than two truth values. For instance the ISO SQL:1999 standard defined a Boolean data type for SQL which could hold three possible values: true, false, unknown (SQL null is treated as equivalent to the unknown truth value, but only for the Boolean data type). This defies the law of excluded middle, though very often useful.

This datatype is used in Boolean and other operations such as and (AND, &, *), or (OR, |, +), exclusive or/not equivalent (xor, NEQV, ^), equal (EQV, =, ==) and not (NOT, ~, !) which correspond to some of the operations of Boolean algebra and arithmetic.

In semiconductor logic hardware, it is usually more efficient[citation needed] to implement all as NAND or NOR, that is NOT-AND and NOT-OR (which is not the same as NOR).


http://en.wikipedia....oolean_datatype
Was This Post Helpful? 0
  • +
  • -

#5 mrmcpott  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 4
  • View blog
  • Posts: 95
  • Joined: 24-November 08

Re: options: use tabs or not? how to save?

Posted 20 March 2009 - 07:15 AM

Hello EndLessMind,

I have read through your code and am going to tell you how I handle settings and apply the changes during run time.

First, create a module to manage your settings, you can call it something like ManageSettings, or something.

This could be the code for your module:

Module ManageSettings


	Public Sub CheckSettings()
		' This will check the settings and apply the changes.

		' Check the options form for the tabbed browser option.
		If Form3.CheckBox1.Checked = True Then
			' The user is going to use tabbed browsing.
			Form1.ToolStripButton2.Visible = True
		ElseIf Form3.CheckBox1.Checked = False Then
			' The user is not going to use tabbed browsing.
			Form1.ToolStripButton2.Visible = False
		End If

		
	End Sub


End Module



Then, under the Form1_Load event all you have to do is place the code:

CheckSettings()



In addition, in form2, under button1_click event, place the code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		My.Settings.Save()
		My.Settings.HomePageUrl = TextBox1.Text
		TextBox1.Text = My.Settings.HomePageUrl
		CheckSettings() ' This will apply the tabbed changes to form1.
End Sub



I hope this helps you!

EDIT:

If you are unsure of how to add a module, here is a screen shot of one way to do it:
Attached Image
Other ways:
Project Menu > Add Module
Or from any "Add new item" dialog box

This post has been edited by mrmcpott: 20 March 2009 - 07:20 AM

Was This Post Helpful? 0
  • +
  • -

#6 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: options: use tabs or not? how to save?

Posted 20 March 2009 - 07:38 AM

View Postmrmcpott, on 20 Mar, 2009 - 06:15 AM, said:

Hello EndLessMind,

I have read through your code and am going to tell you how I handle settings and apply the changes during run time.

First, create a module to manage your settings, you can call it something like ManageSettings, or something.

This could be the code for your module:

Module ManageSettings


	Public Sub CheckSettings()
		' This will check the settings and apply the changes.

		' Check the options form for the tabbed browser option.
		If Form3.CheckBox1.Checked = True Then
			' The user is going to use tabbed browsing.
			Form1.ToolStripButton2.Visible = True
		ElseIf Form3.CheckBox1.Checked = False Then
			' The user is not going to use tabbed browsing.
			Form1.ToolStripButton2.Visible = False
		End If

		
	End Sub


End Module



Then, under the Form1_Load event all you have to do is place the code:

CheckSettings()



In addition, in form2, under button1_click event, place the code:
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
		My.Settings.Save()
		My.Settings.HomePageUrl = TextBox1.Text
		TextBox1.Text = My.Settings.HomePageUrl
		CheckSettings() ' This will apply the tabbed changes to form1.
End Sub



I hope this helps you!

EDIT:

If you are unsure of how to add a module, here is a screen shot of one way to do it:
Attachment attachment
Other ways:
Project Menu > Add Module
Or from any "Add new item" dialog box

thx man. but it didn't work =/
Was This Post Helpful? 0
  • +
  • -

#7 mrmcpott  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 4
  • View blog
  • Posts: 95
  • Joined: 24-November 08

Re: options: use tabs or not? how to save?

Posted 20 March 2009 - 08:06 AM

That is strange, I will work out an example that works. I'll post back in about 10 minutes.
Was This Post Helpful? 0
  • +
  • -

#8 mrmcpott  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 4
  • View blog
  • Posts: 95
  • Joined: 24-November 08

Re: options: use tabs or not? how to save?

Posted 20 March 2009 - 09:04 AM

Okay, it was more than 10 minutes, I'm sorry. I just went ahead and built a web browser real fast.

Allright, so I added a user setting with the following properties:

Name: TabbedBrowsing
Type: Boolean
Scope: User
Value: True

I set the value to"True" so tabbed browsing is enabled by default.

I then created two forms: 1) The browser window 2) the prefrences dialog (options box)

Lets start with the options dialog first. I added a checkbox named "chkTabbedBrowsing." I also added two buttons, "Apply" and "Cancel." The Apply button applies the user's changes, the Cancel button simply closes the options dialog without changes.

The Options Dialog:
--------------------------------------------------------------------
The code for my Apply button is as follows:
' This is checking to see if the user has selected to use tabbed browsing, if so then the setting is changed accordingly.
  If chkTabbedBrowsing.Checked = True Then
			My.Settings.TabbedBrowsing = True
		Else
			My.Settings.TabbedBrowsing = False
		End If
		My.Settings.Save()
' The following comes from the module method I mentioned earlier (I'll explain this later).
		CheckSettings()



Okay, so you might wonder how to check the chkTabbedBrowsing checkbox according to the users choices when you load the options dialog again. So, under the Form_Load() event of the options dialog I added the following:

' If TabbedBrowsing is enabled then check the box, if not do not check the box.
 If My.Settings.TabbedBrowsing = True Then
			chkTabbedBrowsing.Checked = True
		Else
			chkTabbedBrowsing.Checked = False
		End If



Keep in mind this code is written for my interface and can easily be adjusted to meet your needs.

Thats pretty much it for the options dialog. Moving on...

The ManageSettings Module:
--------------------------------------------------------------------
My interface is probably much different then yours, so I am going to rewrite my code to fit what you described earlier.

The first step is to make the module, just follow the steps I showed you earlier. The second step is to create a Public Sub, I named mine "CheckSettings()."

So far our module looks like this:
Module ManageSettings

Public Sub CheckSettings()

End Sub

End Module



Now lets add some logic to our CheckSettings() sub. First we want to check if TabbedBrowsing is enabled (that is, the setting's value is set to True). And if it is True, you want your ToolStripButton2 on form1 to be visible. So let's do that.

Module ManageSettings

Public Sub CheckSettings()
	If My.Settings.TabbedBrowsing = True Then
			' Show everything that is needed for tabbed browsing.
		   Form1.ToolStripButton2.Visible = True
		Else
			' Hide anything that isn't needed if tabbed browsing is not enabled.
		   Form1.ToolStripButton2.Visible = False
		End If
End Sub

End Module



Okay, so that is pretty much it for the module. If you add more things that are needed for tabbed browsing, or not needed just add them to the appropriate area in the If statement. For example, if you had another ToolStripButton that you needed for tabbed browsing, say ToolStripButton3, then you would add it just like this:

Module ManageSettings

Public Sub CheckSettings()
	If My.Settings.TabbedBrowsing = True Then
			' Show everything that is needed for tabbed browsing.
		   Form1.ToolStripButton2.Visible = True
			' Additional things you might add...
		   Form1.ToolStripButton3.Visible = True
		Else
			' Hide anything that isn't needed if tabbed browsing is not enabled.
		   Form1.ToolStripButton2.Visible = False
			' Additional things you might add...
		   Form1.ToolStripButton3.Visible = False
		End If
End Sub

End Module



Simple enough when explained.

Now, the Web Browser (Form1)
-------------------------------------------------------------------
Okay, now on the Form1_Load event simply place the following code:

CheckSettings()



And Finally!
-------------------------------------------------------------------

I really, really, really hope this helped you. I have added a screenshot of the sample test browser I made when developing this response.

Attached Image

Again, I hope this helps you out in some way, shape or form.

Good luck with your web browser (I like making them too),
John.
Was This Post Helpful? 0
  • +
  • -

#9 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: options: use tabs or not? how to save?

Posted 20 March 2009 - 11:06 AM

oh thx.. i got it to work :D might you help me with some other stuff to? fist i want to know how you got the tabs to nice O.o mine is tiny and looks like win98 O.o next i need help with this: the progress bar,status bar and the "webpage name in tab" functions only work if i add the line of code for each tabpage..becuase when i open a new tabpage then it creatse a new webbrowser. so if i just put in the code for webbrowser1 then the progress bar,status bar and the "webpage name in tab" functions will only work in that tab.

my code for form_load1 when i add tab is
		Dim myWebBrowser As New WebBrowser
		TabControl1.SelectTab(1 - 1)
		TabControl1.SelectedTab.Controls.Add(myWebBrowser)
		i = i + 1


and for the add button
		Dim web As New WebBrowser()
		Dim tab As New TabPage("ja")
		'do what you want to with the webbrowser'
		'do what you want to with the tabpage'
		tab.Controls.Add(web)
		TabControl1.TabPages.Add(tab)
		web.Dock = DockStyle.Fill[/coce]

and i need help with one more thing. i got a downloader with progress bar. i want it to open when i right click and then click on "save target as" i cant get that to work. and its done so you must put in the specific adress to the file you want to download. and ofc i want to make the adress "type it self" if you know that i mean. can you help me with that? :) the code for the WebFileDownloader ( the downloader is named that) is [code]'2006 kleinma MSMVP
'www.vbforums.com

Imports System.Net
Imports System.IO

Public Class WebFileDownloader
	Public Event AmountDownloadedChanged(ByVal iNewProgress As Long)
	Public Event FileDownloadSizeObtained(ByVal iFileSize As Long)
	Public Event FileDownloadComplete()
	Public Event FileDownloadFailed(ByVal ex As Exception)

	Private mCurrentFile As String = String.Empty

	Public ReadOnly Property CurrentFile() As String
		Get
			Return mCurrentFile
		End Get
	End Property
	Public Function DownloadFile(ByVal URL As String, ByVal Location As String) As Boolean
		Try
			mCurrentFile = GetFileName(URL)
			Dim WC As New WebClient
			WC.DownloadFile(URL, Location)
			RaiseEvent FileDownloadComplete()
			Return True
		Catch ex As Exception
			RaiseEvent FileDownloadFailed(ex)
			Return False
		End Try
	End Function

	Private Function GetFileName(ByVal URL As String) As String
		Try
			Return URL.Substring(URL.LastIndexOf("/") + 1)
		Catch ex As Exception
			Return URL
		End Try
	End Function
	Public Function DownloadFileWithProgress(ByVal URL As String, ByVal Location As String) As Boolean
		Dim FS As FileStream
		Try
			mCurrentFile = GetFileName(URL)
			Dim wRemote As WebRequest
			Dim bBuffer As Byte()
			ReDim bBuffer(256)
			Dim iBytesRead As Integer
			Dim iTotalBytesRead As Integer

			FS = New FileStream(Location, FileMode.Create, FileAccess.Write)
			wRemote = WebRequest.Create(URL)
			Dim myWebResponse As WebResponse = wRemote.GetResponse
			RaiseEvent FileDownloadSizeObtained(myWebResponse.ContentLength)
			Dim sChunks As Stream = myWebResponse.GetResponseStream
			Do
				iBytesRead = sChunks.Read(bBuffer, 0, 256)
				FS.Write(bBuffer, 0, iBytesRead)
				iTotalBytesRead += iBytesRead
				If myWebResponse.ContentLength < iTotalBytesRead Then
					RaiseEvent AmountDownloadedChanged(myWebResponse.ContentLength)
				Else
					RaiseEvent AmountDownloadedChanged(iTotalBytesRead)
				End If
			Loop While Not iBytesRead = 0
			sChunks.Close()
			FS.Close()
			RaiseEvent FileDownloadComplete()
			Return True
		Catch ex As Exception
			If Not (FS Is Nothing) Then
				FS.Close()
				FS = Nothing
			End If
			RaiseEvent FileDownloadFailed(ex)
			Return False
		End Try
	End Function

	Public Shared Function FormatFileSize(ByVal Size As Long) As String
		Try
			Dim KB As Integer = 1024
			Dim MB As Integer = KB * KB
			' Return size of file in kilobytes.
			If Size < KB Then
				Return (Size.ToString("D") & " bytes")
			Else
				Select Case Size / KB
					'Case Is < 1000
					'	Return (Size / KB).ToString("N") & "KB"
					Case Is < 1000000
						Return (Size / MB).ToString("N") & "MB"
					Case Is < 10000000
						Return (Size / MB / KB).ToString("N") & "GB"
				End Select
			End If
		Catch ex As Exception
			Return Size.ToString
		End Try
	End Function
End Class




thx in advance
Was This Post Helpful? 0
  • +
  • -

#10 mrmcpott  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 4
  • View blog
  • Posts: 95
  • Joined: 24-November 08

Re: options: use tabs or not? how to save?

Posted 20 March 2009 - 11:30 AM

Hello again,

I'm glad that worked out for you. As for most of the other things you requested, there is a tutorial on this website:

http://www.dreaminco...wtopic70491.htm

I just read through this tutorial; it should help you out a lot in creating your web browser. And as for my web browser, it is actually a Mdi Application. And the tabs are a control called MdiTabStrip. I might post a tutorial on a really slick method of creating Mdi Applications using the MdiTabStrip.

Any other questions feal free to ask!

Also, what developing environment are you using? (Microsoft Visual Studio 2003, 05, 08, etc, or some other?) And what is your operating system? Could you post a screen shot of your browser?
Was This Post Helpful? 0
  • +
  • -

#11 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: options: use tabs or not? how to save?

Posted 20 March 2009 - 11:39 AM

i have gone my webbrowser form that topic.. so that nothing new.. and im useings visual basic express 2008.. and windows 7
Was This Post Helpful? 0
  • +
  • -

#12 mrmcpott  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 4
  • View blog
  • Posts: 95
  • Joined: 24-November 08

Re: options: use tabs or not? how to save?

Posted 20 March 2009 - 11:43 AM

Perhaps on Monday I will sit down and work on an example to help you out with all of that stuff. I am wound up in my own project at the moment and work this weekend. If I have time between classes on monday I'll figure something out for you :D
Was This Post Helpful? 0
  • +
  • -

#13 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: options: use tabs or not? how to save?

Posted 20 March 2009 - 12:01 PM

View Postmrmcpott, on 20 Mar, 2009 - 10:43 AM, said:

Perhaps on Monday I will sit down and work on an example to help you out with all of that stuff. I am wound up in my own project at the moment and work this weekend. If I have time between classes on monday I'll figure something out for you :D

that would be great.. ^^ you see.. im only 16 ^^ but im doing this because if want to learn vb.net and how to make programs :P and i think that im doing well..even then i stated last week ^^ and here comes a print screen of my browser :D

Attached image(s)

  • Attached Image

Was This Post Helpful? 0
  • +
  • -

#14 EndLessMind  Icon User is offline

  • These are the droids you're looking for
  • member icon

Reputation: 194
  • View blog
  • Posts: 1,099
  • Joined: 13-March 09

Re: options: use tabs or not? how to save?

Posted 25 March 2009 - 12:26 AM

Anyone? Help maybe?
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1