473,402 Members | 2,053 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,402 software developers and data experts.

Preferences Dialog in C#

Hello,

Im creating a Web Browser in Visual C# and I have a preferences dialog. The
current homepage is yahoo.com. The code for the homepage is:

// Go Home - go to the default home page.
WebBrowser thiswebpage = GetCurrentWebBrowser();
thiswebpage.Navigate("http://www.yahoo.com");

On the preferences dialog I have a section to change the homepage. In that
section I have a text box and a button. The Preferences Dialog is a seperate
window. What code should I add to the button so that the homepage changes to
the website I typed in the text box when the button is clicked?

Thank You,

Matt
Nov 16 '05 #1
13 2211
when you create the preferences dialog, pass in a reference to the browser
object where you have the URL property.
WHen the user clicks the button, assign the new URL to this browser object.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Matt" <Ma**@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
Hello,

Im creating a Web Browser in Visual C# and I have a preferences dialog. The current homepage is yahoo.com. The code for the homepage is:

// Go Home - go to the default home page.
WebBrowser thiswebpage = GetCurrentWebBrowser();
thiswebpage.Navigate("http://www.yahoo.com");

On the preferences dialog I have a section to change the homepage. In that
section I have a text box and a button. The Preferences Dialog is a seperate window. What code should I add to the button so that the homepage changes to the website I typed in the text box when the button is clicked?

Thank You,

Matt

Nov 16 '05 #2
Hello,

Thanks for the help but Im just starting and learning to program in Visual
C#. Can you please repeat the instructions in more detail?

Thank You,

Matt

"Nick Malik [Microsoft]" wrote:
when you create the preferences dialog, pass in a reference to the browser
object where you have the URL property.
WHen the user clicks the button, assign the new URL to this browser object.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Matt" <Ma**@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
Hello,

Im creating a Web Browser in Visual C# and I have a preferences dialog.

The
current homepage is yahoo.com. The code for the homepage is:

// Go Home - go to the default home page.
WebBrowser thiswebpage = GetCurrentWebBrowser();
thiswebpage.Navigate("http://www.yahoo.com");

On the preferences dialog I have a section to change the homepage. In that
section I have a text box and a button. The Preferences Dialog is a

seperate
window. What code should I add to the button so that the homepage changes

to
the website I typed in the text box when the button is clicked?

Thank You,

Matt


Nov 16 '05 #3

You can't really do that within the constraints of a VS setup project.
You
could reduct the number of MSI files by combining some of the generic
setups
into one setup, but each web setup is a separate MSI file. There are
other
tools that can what you want (which is what InstallShield, Wise,
ZeroG,
AdvancedInstaller etc do)
Detect FrameWork
http://blogs.msdn.com/astebner/archi...14/229574.aspx
Setup Bootstrapper
http://www.codeproject.com/dotnet/dotNetInstaller.asp
On Wed, 12 Jan 2005 19:37:05 -0800, "Matt"
<Ma**@discussions.microsoft.com> wrote:
Hello,

Thanks for the help but Im just starting and learning to program in Visual
C#. Can you please repeat the instructions in more detail?

Thank You,

Matt

"Nick Malik [Microsoft]" wrote:
when you create the preferences dialog, pass in a reference to the browser
object where you have the URL property.
WHen the user clicks the button, assign the new URL to this browser object.

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Matt" <Ma**@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
> Hello,
>
> Im creating a Web Browser in Visual C# and I have a preferences dialog.

The
> current homepage is yahoo.com. The code for the homepage is:
>
> // Go Home - go to the default home page.
> WebBrowser thiswebpage = GetCurrentWebBrowser();
> thiswebpage.Navigate("http://www.yahoo.com");
>
> On the preferences dialog I have a section to change the homepage. In that
> section I have a text box and a button. The Preferences Dialog is a

seperate
> window. What code should I add to the button so that the homepage changes

to
> the website I typed in the text box when the button is clicked?
>
> Thank You,
>
> Matt



Nov 16 '05 #4
huh?

--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Laurent Liegeois" <zo****@lli.be> wrote in message
news:vp********************************@4ax.com...

You can't really do that within the constraints of a VS setup project.
You
could reduct the number of MSI files by combining some of the generic
setups
into one setup, but each web setup is a separate MSI file. There are
other
tools that can what you want (which is what InstallShield, Wise,
ZeroG,
AdvancedInstaller etc do)
Detect FrameWork
http://blogs.msdn.com/astebner/archi...14/229574.aspx
Setup Bootstrapper
http://www.codeproject.com/dotnet/dotNetInstaller.asp
On Wed, 12 Jan 2005 19:37:05 -0800, "Matt"
<Ma**@discussions.microsoft.com> wrote:
Hello,

Thanks for the help but Im just starting and learning to program in VisualC#. Can you please repeat the instructions in more detail?

Thank You,

Matt

"Nick Malik [Microsoft]" wrote:
when you create the preferences dialog, pass in a reference to the browser object where you have the URL property.
WHen the user clicks the button, assign the new URL to this browser object.
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Matt" <Ma**@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
> Hello,
>
> Im creating a Web Browser in Visual C# and I have a preferences dialog. The
> current homepage is yahoo.com. The code for the homepage is:
>
> // Go Home - go to the default home page.
> WebBrowser thiswebpage = GetCurrentWebBrowser();
> thiswebpage.Navigate("http://www.yahoo.com");
>
> On the preferences dialog I have a section to change the homepage. In that > section I have a text box and a button. The Preferences Dialog is a
seperate
> window. What code should I add to the button so that the homepage changes to
> the website I typed in the text box when the button is clicked?
>
> Thank You,
>
> Matt

Nov 16 '05 #5
Matt,

I think you are after this piece of code

AxWebBrowser.Navigate("about:<html><body
onload=javascript:window.external.addFavorite('" + textbox1.Text +
"')></body></html>")

I hope this helps?

Cor
Nov 16 '05 #6
Hi Cor,

No, it's not that. Visual C# underlines many parts of the code red. And it
doesn't work.

Thanks anyways,

Matt

"Cor Ligthert" wrote:
Matt,

I think you are after this piece of code

AxWebBrowser.Navigate("about:<html><body
onload=javascript:window.external.addFavorite('" + textbox1.Text +
"')></body></html>")

I hope this helps?

Cor

Nov 16 '05 #7
OK.

In your main form, create a public method. The idea is that any other part
of the system can call your main form and provide a URL, and your main form
will respond by bringing up that URL in the window.

Also, I've included the code needed to pass the reference to the preferences
form.

public class MainForm : System.Windows.Forms.Form
{
private Form m_preferences = null;

public void SetURL(string myURL)
{
// put code here to cause your browser app to visit the URL and
render

}

public void DisplayPreferencesDialog()
{
m_preferences = new frmPreferences(); // create the preferences
object
m_preferences.BrowserWindow = this;
m_preferences.Show();

}

}

Your preferences window gets one new property and a new method.

public class frmPreferences : System.Windows.Forms.Form
{
private MainForm _browserwindow = null;

public MainForm BrowserWindow
{
set { _browserwindow = value; }
}

// now, call this little method from within your form code to set the
URL on the browser window
private void SetBrowserWindowURL(string URL)
{
_browserwindow.SetURL(URL);
}
}

I hope this helps.
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Matt" <Ma**@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
Hello,

Thanks for the help but Im just starting and learning to program in Visual
C#. Can you please repeat the instructions in more detail?

Thank You,

Matt

"Nick Malik [Microsoft]" wrote:
when you create the preferences dialog, pass in a reference to the browser object where you have the URL property.
WHen the user clicks the button, assign the new URL to this browser object.
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Matt" <Ma**@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
Hello,

Im creating a Web Browser in Visual C# and I have a preferences dialog.
The
current homepage is yahoo.com. The code for the homepage is:

// Go Home - go to the default home page.
WebBrowser thiswebpage = GetCurrentWebBrowser();
thiswebpage.Navigate("http://www.yahoo.com");

On the preferences dialog I have a section to change the homepage. In
that section I have a text box and a button. The Preferences Dialog is a

seperate
window. What code should I add to the button so that the homepage

changes to
the website I typed in the text box when the button is clicked?

Thank You,

Matt


Nov 16 '05 #8
Matt,

A little bit copied to fast from VBNet
this.axWebBrowser1.Navigate(@"about:<html><body
onload=javascript:window.external.addFavorite('htt p://www.Google.com')></body></html>");

I this goes better?

Cor
Nov 16 '05 #9
Hi Cor,

Thanks, but just on problem:

Now C# only underlines: axWebBrowser1 with the color blue.

When I build it the error output says:

'WEB.Preferences' does not contain a definition for 'axWebBrowser1'
C:\Documents and Settings\Administrator\Desktop\Web Browser\Preferences.cs.

We're getting closer :)

Thanks,

Matt

"Cor Ligthert" wrote:
Matt,

A little bit copied to fast from VBNet
this.axWebBrowser1.Navigate(@"about:<html><body
onload=javascript:window.external.addFavorite('htt p://www.Google.com')></body></html>");

I this goes better?

Cor

Nov 16 '05 #10
Hi Cor,

Thanks, but just on problem:

Now C# only underlines: axWebBrowser1 with the color blue.

When I build it the error output says:

Error 1 'WEB.Preferences' does not contain a definition for 'axWebBrowser1'
C:\Documents and Settings\Administrator\Desktop\Web Browser\Preferences.cs.

We're getting closer :)

Thanks,

Matt

"Nick Malik [Microsoft]" wrote:
OK.

In your main form, create a public method. The idea is that any other part
of the system can call your main form and provide a URL, and your main form
will respond by bringing up that URL in the window.

Also, I've included the code needed to pass the reference to the preferences
form.

public class MainForm : System.Windows.Forms.Form
{
private Form m_preferences = null;

public void SetURL(string myURL)
{
// put code here to cause your browser app to visit the URL and
render

}

public void DisplayPreferencesDialog()
{
m_preferences = new frmPreferences(); // create the preferences
object
m_preferences.BrowserWindow = this;
m_preferences.Show();

}

}

Your preferences window gets one new property and a new method.

public class frmPreferences : System.Windows.Forms.Form
{
private MainForm _browserwindow = null;

public MainForm BrowserWindow
{
set { _browserwindow = value; }
}

// now, call this little method from within your form code to set the
URL on the browser window
private void SetBrowserWindowURL(string URL)
{
_browserwindow.SetURL(URL);
}
}

I hope this helps.
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Matt" <Ma**@discussions.microsoft.com> wrote in message
news:97**********************************@microsof t.com...
Hello,

Thanks for the help but Im just starting and learning to program in Visual
C#. Can you please repeat the instructions in more detail?

Thank You,

Matt

"Nick Malik [Microsoft]" wrote:
when you create the preferences dialog, pass in a reference to the browser object where you have the URL property.
WHen the user clicks the button, assign the new URL to this browser object.
--
--- Nick Malik [Microsoft]
MCSD, CFPS, Certified Scrummaster
http://blogs.msdn.com/nickmalik

Disclaimer: Opinions expressed in this forum are my own, and not
representative of my employer.
I do not answer questions on behalf of my employer. I'm just a
programmer helping programmers.
--
"Matt" <Ma**@discussions.microsoft.com> wrote in message
news:61**********************************@microsof t.com...
> Hello,
>
> Im creating a Web Browser in Visual C# and I have a preferences dialog. The
> current homepage is yahoo.com. The code for the homepage is:
>
> // Go Home - go to the default home page.
> WebBrowser thiswebpage = GetCurrentWebBrowser();
> thiswebpage.Navigate("http://www.yahoo.com");
>
> On the preferences dialog I have a section to change the homepage. In that > section I have a text box and a button. The Preferences Dialog is a
seperate
> window. What code should I add to the button so that the homepage changes to
> the website I typed in the text box when the button is clicked?
>
> Thank You,
>
> Matt


Nov 16 '05 #11
thiswebpage.
Nov 16 '05 #12
Same Error???

"Cor Ligthert" wrote:
thiswebpage.

Nov 16 '05 #13
Matt,

I thought it was a solution, however this is about the favorite window in
IE. So before we are looking for a solution too get it working. Is that what
you are after? I could not find what was the preferences dialog so I thought
it was this one.

Cor
Nov 16 '05 #14

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Adam J. Schaff | last post by:
OK, there are billions of posts on dotnet newsgroups about this, and I have read half of them, but I'm still a little confused. First I'll say what I think I've learned and anyone can correct me if...
3
by: Jonathan | last post by:
Hi, Here's an interesting challenge for anyone who's up to it. :-) When I edit preferences for Netscape or Mozilla, there's an option that says "block unrequested popup windows." Next to this is...
0
by: Just Me | last post by:
If I look at the properties of a printer I can find two things: Printing Preferences and Printing Defaults. I believe the preferences apply to my apps and the defaults apply to all users. In...
3
by: clintonG | last post by:
I'm messing around with the Request.UserLanguages and the Request.ServerVariables("HTTP_ACCEPT_LANGUAGE"); to see how similar or dissimilar they may be. I observe and conclude that both get...
0
by: Tom | last post by:
I am planning on adding a Preferences form to my application and using the Property Grid to display the preferences to the user. What do you think would be the best way to save these preferences...
11
by: Tom | last post by:
I am planning on adding a Preferences form to my application and using the Property Grid to display the preferences to the user. What do you think would be the best way to save these preferences...
1
by: Tom | last post by:
I have a large application; lots of forms, multiple dynamic DLLs, etc. I also have, in the appliation, a general 'Preferences' class object (which is in itself a separate DLL, and I just include a...
0
by: H. Williams | last post by:
I am trying to programmatically change printing preferences (not printer settings). For example, preferences specific to a printer like watermark or pages per sheet. I have tried using the...
1
by: =?Utf-8?B?T21lZ2FTcXVhcmVk?= | last post by:
have customized PageSetup and Print dialogs that emulate the standard dialogs. I would like to be able to open the "Printer Preferences" dialog by clicking a button (just like can be done on the...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.