473,386 Members | 1,673 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,386 software developers and data experts.

Application startup events?

hello all, I am wondering how to trap application load event on a windows
forms c# application.

My objective is to instanciate my own windows forms on the fly based on some
registry settings.

where in the visual studio project can I write this code? I need to know
where does the application starts loading...

Thanks,

David Mansilla
Nov 17 '05 #1
2 8195
Application.Run(new Form1()); starts the message loop and the application
effectively starts.
Form.Load event is fired then

You may want to handle the Form's Load event if I understand right
place this code in the class inheriting from Form

this.Load += new EventHandler(Load); //in some initialization routine

private void Load(object sender, EventArgs e)
{
//do what you need to do before the application starts
}

VS.NET allows you to handle load event by double clicking he form in
designer

"David Mansilla" <Da***********@discussions.microsoft.com> wrote in message
news:0C**********************************@microsof t.com...
hello all, I am wondering how to trap application load event on a windows
forms c# application.

My objective is to instanciate my own windows forms on the fly based on some registry settings.

where in the visual studio project can I write this code? I need to know
where does the application starts loading...

Thanks,

David Mansilla

Nov 17 '05 #2
> My objective is to instanciate my own windows forms on the fly based on some
registry settings.
where in the visual studio project can I write this code? I need to know
where does the application starts loading...


In C#, it's the Main method. If you look inside the code for your main
Windows form, you will see that the Designer has created a static
method called Main. (It's probably called something different in VB,
but there will be a corresponding method in VB. There has to be.) If
you examine the code in that method, you will see it calling
Application.Run and passing a constructed instance of the main form
that the Designer created for you when you created the Windows Forms
project.

The way I see it, you have two choices.

1. If you want your application to start up with a different main form
depending upon registry settings, then do the registry lookup in the
Main method, and change the Application.Run() call to pass in an
instance the appropriate form, based on the registry settings.

2. If you want your application to start with the main form that you
created in the designer, but then after that to bring up different
forms based on registry settings, then do the registry lookup wherever
you need to in your main form's code. I doubt this is the case, though,
based on the phrasing of your question.

Nov 17 '05 #3

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

Similar topics

9
by: Mike | last post by:
How do I prevent SQL Server 2000 from posting successful backup completion messages to the Windows 2000 Application Event Log? I have scheduled jobs which backup my transaction logs on 50+...
11
by: Timothy Shih | last post by:
Hi, I am having a freezing issue with my application. My application serves several remotable objects, all of which must be initialized before their use. Furthermore, some of them depend on each...
1
by: RobbieGotNeeds | last post by:
Hi, I am tasked with writing a COM+ application in C# in which the program, when started, will sit and poll for something (not important here), and when that condition occurs, then I publish...
6
by: KS | last post by:
How can I manage my VB.NET-application via the internet ? Some sample code - please ? regards KS, Denmark
1
by: Bob | last post by:
In Vs 2005 you have new applicationsEvents.vb I was testing it in a simple app and found that it was easier to implement unhandled exception management tah it was in Vs2003 (vb.net) You can, if you...
3
by: ApexData | last post by:
Hello I completed an application that worked great until I went to STARTUP and shut off all of the checkboxes. My code uses "Application.CurrentObjectName" to get the current Form name. All my...
2
by: Robert Dufour | last post by:
In my app I was using a sub main as the startup object and this code Curlocale = My.Settings.UserUiLanguage System.Threading.Thread.CurrentThread.CurrentUICulture = New CultureInfo(Curlocale) ...
3
by: lucius | last post by:
I need to know from within my ASP.NET 2.0 Web Service, when the application was started as a DateTime. The service might run on Windows Server 2000, maybe 2003, maybe 2003 R2, maybe XP (in...
4
by: John | last post by:
Hi My app needs to use the MyApplication_Startup and MyApplication_StartupNextInstance events but do not need the start-up form. How can I get rid of the start-up form as I can't select the Sub...
6
by: John Wright | last post by:
During my program startup I need to check for a couple of things. 1. I need to check for network availability 2. I need to check for database connectivity 3. I need to check for access to the...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...

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.