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

what is going on in Close()

It might be basics for many but I never gave attention on this before.

Steps:

Add 2 forms (Form1/Form2) in application.
Create a object in Form1 for Form2.

Form2 f2 = new Form2(); //line 1
//f2.Show(); // line 2
f2.Close(); // line 3
f2.Show(); // works just fine // line 4

Give attn on line 2 as it is marked out. In line 4 it shows form. But when I
uncomment line 2 it gives error on line 4. I hope to get this behavior even
when line 2 is commented out.

1- why dispose is not called when I call Close when line 2 is commented?
2- what is happening in Close() when line 2 is commented?
3- why it is working when I create form object, call close on it, and then
show it?
4- what is happening when I do Show(), Close(), and then Show() ?

In my understanding object is in hidden state after creation. Show only
makes Visible property of form to true. Now I am sure there is something
more to it than just making the form visible.

Thanks a lot,

Ashish
Nov 16 '05 #1
6 1780
hi ashish,

Basically Close and dispose are not same.
When u call close on an object, it just closes it.
For example the close call on a SQL connection closes the connection to the
SQL server.
This means that the same object can be and will be used again with a call to
the open connection command.

Dispose in this case disposes off the object itself, so that it cannot be
used again, u need to create a new object to use the object.

The case u have specified is similar to the webform,
U cannot close a form unless it is showing up.....

Hope it helped u get a basic idea about close and dispose,
Regds,
Kannan.V

"Ashish" wrote:
It might be basics for many but I never gave attention on this before.

Steps:

Add 2 forms (Form1/Form2) in application.
Create a object in Form1 for Form2.

Form2 f2 = new Form2(); //line 1
//f2.Show(); // line 2
f2.Close(); // line 3
f2.Show(); // works just fine // line 4

Give attn on line 2 as it is marked out. In line 4 it shows form. But when I
uncomment line 2 it gives error on line 4. I hope to get this behavior even
when line 2 is commented out.

1- why dispose is not called when I call Close when line 2 is commented?
2- what is happening in Close() when line 2 is commented?
3- why it is working when I create form object, call close on it, and then
show it?
4- what is happening when I do Show(), Close(), and then Show() ?

In my understanding object is in hidden state after creation. Show only
makes Visible property of form to true. Now I am sure there is something
more to it than just making the form visible.

Thanks a lot,

Ashish

Nov 16 '05 #2
Hi Kannan,

Actually I know what you told me. Condition is little different then just
calling Dispose() or Close() on the form. Dispose(bool) will be called from
Close() when we do a Show() before calling Close() (stack trace). I was
looking for something deeper in this problem. But thanks for the reply.

"Kannan.V [MCAD.net]" <Ka************@discussions.microsoft.com> wrote in
message news:C6**********************************@microsof t.com...
hi ashish,

Basically Close and dispose are not same.
When u call close on an object, it just closes it.
For example the close call on a SQL connection closes the connection to
the
SQL server.
This means that the same object can be and will be used again with a call
to
the open connection command.

Dispose in this case disposes off the object itself, so that it cannot be
used again, u need to create a new object to use the object.

The case u have specified is similar to the webform,
U cannot close a form unless it is showing up.....

Hope it helped u get a basic idea about close and dispose,
Regds,
Kannan.V

"Ashish" wrote:
It might be basics for many but I never gave attention on this before.

Steps:

Add 2 forms (Form1/Form2) in application.
Create a object in Form1 for Form2.

Form2 f2 = new Form2(); //line 1
//f2.Show(); // line 2
f2.Close(); // line 3
f2.Show(); // works just fine // line 4

Give attn on line 2 as it is marked out. In line 4 it shows form. But
when I
uncomment line 2 it gives error on line 4. I hope to get this behavior
even
when line 2 is commented out.

1- why dispose is not called when I call Close when line 2 is commented?
2- what is happening in Close() when line 2 is commented?
3- why it is working when I create form object, call close on it, and
then
show it?
4- what is happening when I do Show(), Close(), and then Show() ?

In my understanding object is in hidden state after creation. Show only
makes Visible property of form to true. Now I am sure there is something
more to it than just making the form visible.

Thanks a lot,

Ashish

Nov 16 '05 #3
Hi Ashish,

Provided that the window handle has been created, Form.Close sends a
WM_CLOSE message to the window. It is up to the Form's message handling
routine to take it from there. If the window handle has not been created
yet, Form.Close does nothing. The window handle of a form is not created
when the form is created. The window handle does get created when the form
is made visible (there may be other things that would cause the window
handle to be created before the form is made visible).

Regards,
Daniel

"Ashish" <no*****@thisaddress.com> wrote in message
news:OJ**************@tk2msftngp13.phx.gbl...
It might be basics for many but I never gave attention on this before.

Steps:

Add 2 forms (Form1/Form2) in application.
Create a object in Form1 for Form2.

Form2 f2 = new Form2(); //line 1
//f2.Show(); // line 2
f2.Close(); // line 3
f2.Show(); // works just fine // line 4

Give attn on line 2 as it is marked out. In line 4 it shows form. But when I uncomment line 2 it gives error on line 4. I hope to get this behavior even when line 2 is commented out.

1- why dispose is not called when I call Close when line 2 is commented?
2- what is happening in Close() when line 2 is commented?
3- why it is working when I create form object, call close on it, and then
show it?
4- what is happening when I do Show(), Close(), and then Show() ?

In my understanding object is in hidden state after creation. Show only
makes Visible property of form to true. Now I am sure there is something
more to it than just making the form visible.

Thanks a lot,

Ashish

Nov 16 '05 #4
Hi Ashish,

Provided that the window handle has been created, Form.Close sends a
WM_CLOSE message to the window. It is up to the Form's message handling
routine to take it from there. If the window handle has not been created
yet, Form.Close does nothing. The window handle of a form is not created
when the form is created. The window handle does get created when the form
is made visible (there may be other things that would cause the window
handle to be created before the form is made visible).

Regards,
Daniel

"Ashish" <no*****@thisaddress.com> wrote in message
news:OJ**************@tk2msftngp13.phx.gbl...
It might be basics for many but I never gave attention on this before.

Steps:

Add 2 forms (Form1/Form2) in application.
Create a object in Form1 for Form2.

Form2 f2 = new Form2(); //line 1
//f2.Show(); // line 2
f2.Close(); // line 3
f2.Show(); // works just fine // line 4

Give attn on line 2 as it is marked out. In line 4 it shows form. But when I uncomment line 2 it gives error on line 4. I hope to get this behavior even when line 2 is commented out.

1- why dispose is not called when I call Close when line 2 is commented?
2- what is happening in Close() when line 2 is commented?
3- why it is working when I create form object, call close on it, and then
show it?
4- what is happening when I do Show(), Close(), and then Show() ?

In my understanding object is in hidden state after creation. Show only
makes Visible property of form to true. Now I am sure there is something
more to it than just making the form visible.

Thanks a lot,

Ashish

Nov 16 '05 #5
Thanks Daniel, that is what I was looking for.
"Daniel Pratt" <ko******************@hotmail.com> wrote in message
news:Oz**************@TK2MSFTNGP12.phx.gbl...
Hi Ashish,

Provided that the window handle has been created, Form.Close sends a
WM_CLOSE message to the window. It is up to the Form's message handling
routine to take it from there. If the window handle has not been created
yet, Form.Close does nothing. The window handle of a form is not created
when the form is created. The window handle does get created when the form
is made visible (there may be other things that would cause the window
handle to be created before the form is made visible).

Regards,
Daniel

"Ashish" <no*****@thisaddress.com> wrote in message
news:OJ**************@tk2msftngp13.phx.gbl...
It might be basics for many but I never gave attention on this before.

Steps:

Add 2 forms (Form1/Form2) in application.
Create a object in Form1 for Form2.

Form2 f2 = new Form2(); //line 1
//f2.Show(); // line 2
f2.Close(); // line 3
f2.Show(); // works just fine // line 4

Give attn on line 2 as it is marked out. In line 4 it shows form. But
when

I
uncomment line 2 it gives error on line 4. I hope to get this behavior

even
when line 2 is commented out.

1- why dispose is not called when I call Close when line 2 is commented?
2- what is happening in Close() when line 2 is commented?
3- why it is working when I create form object, call close on it, and
then
show it?
4- what is happening when I do Show(), Close(), and then Show() ?

In my understanding object is in hidden state after creation. Show only
makes Visible property of form to true. Now I am sure there is something
more to it than just making the form visible.

Thanks a lot,

Ashish


Nov 16 '05 #6
Thanks Daniel, that is what I was looking for.
"Daniel Pratt" <ko******************@hotmail.com> wrote in message
news:Oz**************@TK2MSFTNGP12.phx.gbl...
Hi Ashish,

Provided that the window handle has been created, Form.Close sends a
WM_CLOSE message to the window. It is up to the Form's message handling
routine to take it from there. If the window handle has not been created
yet, Form.Close does nothing. The window handle of a form is not created
when the form is created. The window handle does get created when the form
is made visible (there may be other things that would cause the window
handle to be created before the form is made visible).

Regards,
Daniel

"Ashish" <no*****@thisaddress.com> wrote in message
news:OJ**************@tk2msftngp13.phx.gbl...
It might be basics for many but I never gave attention on this before.

Steps:

Add 2 forms (Form1/Form2) in application.
Create a object in Form1 for Form2.

Form2 f2 = new Form2(); //line 1
//f2.Show(); // line 2
f2.Close(); // line 3
f2.Show(); // works just fine // line 4

Give attn on line 2 as it is marked out. In line 4 it shows form. But
when

I
uncomment line 2 it gives error on line 4. I hope to get this behavior

even
when line 2 is commented out.

1- why dispose is not called when I call Close when line 2 is commented?
2- what is happening in Close() when line 2 is commented?
3- why it is working when I create form object, call close on it, and
then
show it?
4- what is happening when I do Show(), Close(), and then Show() ?

In my understanding object is in hidden state after creation. Show only
makes Visible property of form to true. Now I am sure there is something
more to it than just making the form visible.

Thanks a lot,

Ashish


Nov 16 '05 #7

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

Similar topics

6
by: Rtritell | last post by:
Please can you find out what's wrong, fix the script and tell me what was wrong. Im just beginning <html> <head> <title>Random Mad Lib!</title> <script language="JavaScript"> <!-- Hide
9
by: andrew | last post by:
Hi, I posted this message recently, but received no response, so I figured I'd try again. I can't find anybody who can tell me what's going on here. I'm having a problem with fieldsets in IE...
1
by: Tim Marshall | last post by:
In using DAO methods, I close recordsets and set them to nothing. When a DAO.database is dimmed, I set it to nothing. I have an application in which a user clicks on a control on a form and a...
3
by: subnet | last post by:
I'm trying to write a very simple program that uses a signal-based synchronization between two processes. Here's it: ----------------------------------------------- /* The world's simplest...
9
by: Jay | last post by:
Everywhere I go (read/browse) I see these parameters.... ByVal sender As Object, ByVal e As System.EventArgs Yet I never see them used within the function/method. Could someone tell me what they...
0
by: dbuchanan | last post by:
Hello, Why can't my application recognize or find the data layer. These are the design-time and runtime errors I receive. \\ "One or more errors encountered while loading the designer. The...
669
by: Xah Lee | last post by:
in March, i posted a essay “What is Expressiveness in a Computer Language”, archived at: http://xahlee.org/perl-python/what_is_expresiveness.html I was informed then that there is a academic...
1
by: tomcarr1 | last post by:
What event is triggered in ASP.Net when you close the browser ? What event is normally used to trigger clean up stuff when going from one form to another or leaving the project?
1
by: woollymammoth | last post by:
I can't assign a MS SQL Server table record value to a simple VB variable, should be a really easy thing. Sample SQL Server table has the data in the record as a char(30) string, the column for that...
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
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:
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

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.