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

Event that is invoked after a form has loaded


Hi All,

The OnLoad() event is invoked automatically when a form is being loaded. Do
we have another event that is invoked automatically after a form has
completed loading?

Thanks.
Nov 15 '05 #1
2 22631
Hi Jeffrey,

Thanks for your reply. How do I trap a Windows's message in C# anyway?
Speaking otherwise, how do I trap the WM_SHOWWINDOW and/or WM_ACTIVATE?

"Jeffrey Tan[MSFT]" <v-*****@online.microsoft.com> wrote in message
news:uY**************@cpmsftngxa06.phx.gbl...

Hi David,

I think the form's OnLoad() event is fire when the WM_CREATE message is
sent.

I use the Spy++ to monitor the messages during the creation of a form.
I found that the form's WM_SHOWWINDOW message was sent after the WM_CREATE. When this message is sent, the form has already been created, so you can
override the form's WndProc method and process WM_SHOWWINDOW message.

In addition, I found that the child controls of the form was created after
the WM_SHOWWINDOW message was sent, so you should process form's
WM_ACTIVATE message to make sure that the child controls are created.

Hope it helps.

Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: " David N" <dq*****@netiq.com>
| Subject: Event that is invoked after a form has loaded
| Date: Tue, 29 Jul 2003 13:56:04 -0700
| Lines: 10
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <#4**************@TK2MSFTNGP10.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: pat-50.bel.netiq.com 65.219.170.50
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:172788 | X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
|
| Hi All,
|
| The OnLoad() event is invoked automatically when a form is being loaded.
Do
| we have another event that is invoked automatically after a form has
| completed loading?
|
| Thanks.
|
|
|

Nov 15 '05 #2

Hi David,
*
Can you tell me why you want to handle the form right after the form’s load?
Maybe I can help you.

To trap Windows’s message in C#, you should override the Form’s WndProc
method.
*
My sample code was listed below:

using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using System.Data;

namespace winformmessage
{
public class Form1 : System.Windows.Forms.Form
{
private const int WM_SHOWWINDOW=0x18;
static bool firsttime=true;
private System.ComponentModel.Container components = null;

public Form1()
{
InitializeComponent();
}

protected override void Dispose( bool disposing )
{
if( disposing )
{
if (components != null)
{
components.Dispose();
}
}
base.Dispose( disposing );
}

#region Windows Form Designer generated code

private void InitializeComponent()
{
this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
this.ClientSize = new System.Drawing.Size(292, 266);
this.Name = "Form1";
this.Text = "Form1";
this.Load += new System.EventHandler(this.Form1_Load);

}
#endregion

[STAThread]
static void Main()
{
Application.Run(new Form1());
}

private void Form1_Load(object sender, System.EventArgs e)
{

}
protected override void WndProc(ref Message m)
{

switch(m.Msg )
{
case WM_SHOWWINDOW:
if(firsttime)
{
MessageBox.Show ("You application run");
}
break;
default:
break;
}
base.WndProc (ref m);
}
}
}
You may use API Text viewer which is shipped with Visual Studio 6.0 to get
the message’s value or reference the following page if you don’t have that
tool available.

http://doc.ddart.net/msdn/header/include/winuser.h.html

Hope this helps.

Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

--------------------
| From: " David N" <dq*****@netiq.com>
| References: <#4**************@TK2MSFTNGP10.phx.gbl>
<uY**************@cpmsftngxa06.phx.gbl>
| Subject: Re: Event that is invoked after a form has loaded
| Date: Wed, 30 Jul 2003 09:21:14 -0700
| Lines: 62
| X-Priority: 3
| X-MSMail-Priority: Normal
| X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| Message-ID: <Oa**************@TK2MSFTNGP11.phx.gbl>
| Newsgroups: microsoft.public.dotnet.languages.csharp
| NNTP-Posting-Host: pat-50.bel.netiq.com 65.219.170.50
| Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP11.phx.gbl
| Xref: cpmsftngxa06.phx.gbl microsoft.public.dotnet.languages.csharp:173009
| X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
|
| Hi Jeffrey,
|
| Thanks for your reply. How do I trap a Windows's message in C# anyway?
| Speaking otherwise, how do I trap the WM_SHOWWINDOW and/or WM_ACTIVATE?
|
| "Jeffrey Tan[MSFT]" <v-*****@online.microsoft.com> wrote in message
| news:uY**************@cpmsftngxa06.phx.gbl...
| >
| > Hi David,
| >
| > I think the form's OnLoad() event is fire when the WM_CREATE message is
| > sent.
| >
| > I use the Spy++ to monitor the messages during the creation of a form.
| > I found that the form's WM_SHOWWINDOW message was sent after the
| WM_CREATE.
| > When this message is sent, the form has already been created, so you can
| > override the form's WndProc method and process WM_SHOWWINDOW message.
| >
| > In addition, I found that the child controls of the form was created
after
| > the WM_SHOWWINDOW message was sent, so you should process form's
| > WM_ACTIVATE message to make sure that the child controls are created.
| >
| > Hope it helps.
| >
| > Jeffrey Tan
| > Microsoft Online Partner Support
| > Get Secure! - www.microsoft.com/security
| > This posting is provided "as is" with no warranties and confers no
rights.
| >
| > --------------------
| > | From: " David N" <dq*****@netiq.com>
| > | Subject: Event that is invoked after a form has loaded
| > | Date: Tue, 29 Jul 2003 13:56:04 -0700
| > | Lines: 10
| > | X-Priority: 3
| > | X-MSMail-Priority: Normal
| > | X-Newsreader: Microsoft Outlook Express 6.00.2800.1158
| > | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1165
| > | Message-ID: <#4**************@TK2MSFTNGP10.phx.gbl>
| > | Newsgroups: microsoft.public.dotnet.languages.csharp
| > | NNTP-Posting-Host: pat-50.bel.netiq.com 65.219.170.50
| > | Path: cpmsftngxa06.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTN GP10.phx.gbl
| > | Xref: cpmsftngxa06.phx.gbl
| microsoft.public.dotnet.languages.csharp:172788
| > | X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
| > |
| > |
| > | Hi All,
| > |
| > | The OnLoad() event is invoked automatically when a form is being
loaded.
| > Do
| > | we have another event that is invoked automatically after a form has
| > | completed loading?
| > |
| > | Thanks.
| > |
| > |
| > |
| >
|
|
|

Nov 15 '05 #3

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

Similar topics

11
by: Sharon | last post by:
I'm writing a new control derived from UserControl. I need to get an event when the control is done resizing. I tried the Resize, SizeChanged, Move and the Layout events and I also tried to...
7
by: Tim T | last post by:
Hi, I have the need to use dynamically loaded user controls in a webform page. I have the controls loading dynamically, and that part works fine. this is the code used in a webform to dynamically...
8
by: Donald Xie | last post by:
Hi, I noticed an interesting effect when working with controls that are dynamically loaded. For instance, on a web form with a PlaceHolder control named ImageHolder, I dynamically add an image...
4
by: Antonio Carpentieri | last post by:
Hi all, in my previous post I've wrong typed some tems.. this is the corrected post. in a aspx page I have a repeater like this: <asp:repeater id=repeaterResults runat="server"...
4
by: EvelynAnd Ethan | last post by:
Hi, ItemCommand event not firing from a dynamic user control ,WHERE A DATAGRID HAS BUTTON,when i click on the linkbutton first time the itemcommand event doesnt fire,second time event fires up ...
4
by: C M Shaw | last post by:
I have a form which I want to show modally; it's a fairly old form that's been ported up several versions of VB, and I'd like to keep its rewriting to a minimum. Basically, it is used in this...
1
by: John F | last post by:
Hello, I'm dynamically loading a child form saved in a DLL. I have this code working and it's pretty straightforward. What I'd like to do is pass an object type to an invoked method in the...
1
by: superjacent | last post by:
Hope someone can point me in the right direction. When opening a form the 'click' event of the ListBox is invoked (run). I thought the 'click' event of the ListBox is only invoked when clicking...
19
by: zacks | last post by:
I have a .NET 2.0 MDI application where the child form has a Tab Control. Each of the Tab in the Tab Control has a Validating event to handle what it should do when the user changes tabs. But...
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: 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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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
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...

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.