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

Strange Event Behaviour

I posted this last week, so apologies for re-posting but I'm still looking
for a sensible answer, and I'm hoping somone new might be able to cast some
light...
Basically, I have a fairly complicated application which seems to me to be
misbehaving. The following is an attempt to reproduce the error. There are
reasons in the real application why I'm trying to do things the way they are
here, so please no comments on techniques here, UNLESS I'm trying to do
somthing fundamentally wrong (or stupid!)

Anyway, if someone could humour me and try the following:
1) Create a new dotNET project.
2) Add 3 Forms: frmMainForm, frmForm1 and frmForm2. (MainForm is the form
that should load on application startup).
3) Make frmMainForm an MDI Container Form.
4) Add the following code for MainForm:

private void MainForm_Load(object sender, System.EventArgs e)
{
frmForm1 form1 = new frmForm1();
form1.MdiParent = this;
form1.Show();
}

internal void ShowOtherForm()
{
frmForm2 form2 = new frmForm2();
form2.MdiParent = this;
form2.Show();
}

5) Place a button on form1 with the following code:
private void button1_Click(object sender, System.EventArgs e)
{
((frmMainForm)this.MdiParent).ShowOtherForm();
}

6) Place a button and a textBox on form2 with the following code:
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Button Pressed");
this.SendToBack();
}

private void textBox1_KeyUp(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
MessageBox.Show("Enter Pressed");
}

7) Run the program, you should get as a child form inside MainForm
8) Click the button on form1 and you should get an instance of form2.
9) Click the button on form2 and you should get the 'Button Pressed' message
and Form1 comes to the front.
10) CLOSE Form1
11) Make sure focus is in the textBox on Form2 and press ENTER.
12) Please can someone explain what happens next...?

I would really appreciate it if someone could try this out and give me their
thoughts, because it's driving me crazy. I have this project available as a
zip-file if you can't be bothered with all the typing.

Many, many thanks.

ChrisM
Jun 26 '06 #1
7 1423
It displays a message box that says "Enter Pressed", just as expected. What
result are you getting?

/claes

"ChrisM" <ch**************@suedeyahoo.com> wrote in message
news:er**************@TK2MSFTNGP04.phx.gbl...
I posted this last week, so apologies for re-posting but I'm still looking
for a sensible answer, and I'm hoping somone new might be able to cast some
light...
Basically, I have a fairly complicated application which seems to me to be
misbehaving. The following is an attempt to reproduce the error. There are
reasons in the real application why I'm trying to do things the way they
are here, so please no comments on techniques here, UNLESS I'm trying to
do somthing fundamentally wrong (or stupid!)

Anyway, if someone could humour me and try the following:
1) Create a new dotNET project.
2) Add 3 Forms: frmMainForm, frmForm1 and frmForm2. (MainForm is the form
that should load on application startup).
3) Make frmMainForm an MDI Container Form.
4) Add the following code for MainForm:

private void MainForm_Load(object sender, System.EventArgs e)
{
frmForm1 form1 = new frmForm1();
form1.MdiParent = this;
form1.Show();
}

internal void ShowOtherForm()
{
frmForm2 form2 = new frmForm2();
form2.MdiParent = this;
form2.Show();
}

5) Place a button on form1 with the following code:
private void button1_Click(object sender, System.EventArgs e)
{
((frmMainForm)this.MdiParent).ShowOtherForm();
}

6) Place a button and a textBox on form2 with the following code:
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Button Pressed");
this.SendToBack();
}

private void textBox1_KeyUp(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
MessageBox.Show("Enter Pressed");
}

7) Run the program, you should get as a child form inside MainForm
8) Click the button on form1 and you should get an instance of form2.
9) Click the button on form2 and you should get the 'Button Pressed'
message and Form1 comes to the front.
10) CLOSE Form1
11) Make sure focus is in the textBox on Form2 and press ENTER.
12) Please can someone explain what happens next...?

I would really appreciate it if someone could try this out and give me
their thoughts, because it's driving me crazy. I have this project
available as a zip-file if you can't be bothered with all the typing.

Many, many thanks.

ChrisM

Jun 26 '06 #2
That's interesting!!
When I do it, I get 'Button Pressed' which is what was confusing me.
What environment are you using? I have VS2003 and Framework 1.1.

Cheers,

Chris.

PS. You did have exactly the setup I described. Just copied the code and
didn't make any assumptions of corrections? The only way to make it go wrong
is exactly the steps I described. Not accusing you of being unable to follow
simple instructions, but confused as to why it works correctly for you and
not for me. Unless you are using Framework 2.0 which might explain a lot...
:-)

C.

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:uo**************@TK2MSFTNGP04.phx.gbl...
It displays a message box that says "Enter Pressed", just as expected.
What result are you getting?

/claes

"ChrisM" <ch**************@suedeyahoo.com> wrote in message
news:er**************@TK2MSFTNGP04.phx.gbl...
I posted this last week, so apologies for re-posting but I'm still looking
for a sensible answer, and I'm hoping somone new might be able to cast
some light...
Basically, I have a fairly complicated application which seems to me to
be misbehaving. The following is an attempt to reproduce the error. There
are reasons in the real application why I'm trying to do things the way
they are here, so please no comments on techniques here, UNLESS I'm
trying to do somthing fundamentally wrong (or stupid!)

Anyway, if someone could humour me and try the following:
1) Create a new dotNET project.
2) Add 3 Forms: frmMainForm, frmForm1 and frmForm2. (MainForm is the form
that should load on application startup).
3) Make frmMainForm an MDI Container Form.
4) Add the following code for MainForm:

private void MainForm_Load(object sender, System.EventArgs e)
{
frmForm1 form1 = new frmForm1();
form1.MdiParent = this;
form1.Show();
}

internal void ShowOtherForm()
{
frmForm2 form2 = new frmForm2();
form2.MdiParent = this;
form2.Show();
}

5) Place a button on form1 with the following code:
private void button1_Click(object sender, System.EventArgs e)
{
((frmMainForm)this.MdiParent).ShowOtherForm();
}

6) Place a button and a textBox on form2 with the following code:
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Button Pressed");
this.SendToBack();
}

private void textBox1_KeyUp(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
MessageBox.Show("Enter Pressed");
}

7) Run the program, you should get as a child form inside MainForm
8) Click the button on form1 and you should get an instance of form2.
9) Click the button on form2 and you should get the 'Button Pressed'
message and Form1 comes to the front.
10) CLOSE Form1
11) Make sure focus is in the textBox on Form2 and press ENTER.
12) Please can someone explain what happens next...?

I would really appreciate it if someone could try this out and give me
their thoughts, because it's driving me crazy. I have this project
available as a zip-file if you can't be bothered with all the typing.

Many, many thanks.

ChrisM


Jun 26 '06 #3
I used 2.0 for my initial test. Testing it in 1.1 gives the result you're
seeing though. Strange indeed

/claes

"ChrisM" <ch**************@suedeyahoo.com> wrote in message
news:eK**************@TK2MSFTNGP03.phx.gbl...
That's interesting!!
When I do it, I get 'Button Pressed' which is what was confusing me.
What environment are you using? I have VS2003 and Framework 1.1.

Cheers,

Chris.

PS. You did have exactly the setup I described. Just copied the code and
didn't make any assumptions of corrections? The only way to make it go
wrong is exactly the steps I described. Not accusing you of being unable
to follow simple instructions, but confused as to why it works correctly
for you and not for me. Unless you are using Framework 2.0 which might
explain a lot... :-)

C.

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:uo**************@TK2MSFTNGP04.phx.gbl...
It displays a message box that says "Enter Pressed", just as expected.
What result are you getting?

/claes

"ChrisM" <ch**************@suedeyahoo.com> wrote in message
news:er**************@TK2MSFTNGP04.phx.gbl...
I posted this last week, so apologies for re-posting but I'm still
looking for a sensible answer, and I'm hoping somone new might be able to
cast some light...
Basically, I have a fairly complicated application which seems to me to
be misbehaving. The following is an attempt to reproduce the error.
There are reasons in the real application why I'm trying to do things
the way they are here, so please no comments on techniques here, UNLESS
I'm trying to do somthing fundamentally wrong (or stupid!)

Anyway, if someone could humour me and try the following:
1) Create a new dotNET project.
2) Add 3 Forms: frmMainForm, frmForm1 and frmForm2. (MainForm is the
form that should load on application startup).
3) Make frmMainForm an MDI Container Form.
4) Add the following code for MainForm:

private void MainForm_Load(object sender, System.EventArgs e)
{
frmForm1 form1 = new frmForm1();
form1.MdiParent = this;
form1.Show();
}

internal void ShowOtherForm()
{
frmForm2 form2 = new frmForm2();
form2.MdiParent = this;
form2.Show();
}

5) Place a button on form1 with the following code:
private void button1_Click(object sender, System.EventArgs e)
{
((frmMainForm)this.MdiParent).ShowOtherForm();
}

6) Place a button and a textBox on form2 with the following code:
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Button Pressed");
this.SendToBack();
}

private void textBox1_KeyUp(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
MessageBox.Show("Enter Pressed");
}

7) Run the program, you should get as a child form inside MainForm
8) Click the button on form1 and you should get an instance of form2.
9) Click the button on form2 and you should get the 'Button Pressed'
message and Form1 comes to the front.
10) CLOSE Form1
11) Make sure focus is in the textBox on Form2 and press ENTER.
12) Please can someone explain what happens next...?

I would really appreciate it if someone could try this out and give me
their thoughts, because it's driving me crazy. I have this project
available as a zip-file if you can't be bothered with all the typing.

Many, many thanks.

ChrisM



Jun 26 '06 #4
Glad to hear that you can now see the same problem. I thought for a while I
was going mad...
Any idea what might be going wrong? More importantly, any idea how to stop
it from happening???

;-)

Thanks,

Chris.

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:O2**************@TK2MSFTNGP03.phx.gbl...
I used 2.0 for my initial test. Testing it in 1.1 gives the result you're
seeing though. Strange indeed

/claes

"ChrisM" <ch**************@suedeyahoo.com> wrote in message
news:eK**************@TK2MSFTNGP03.phx.gbl...
That's interesting!!
When I do it, I get 'Button Pressed' which is what was confusing me.
What environment are you using? I have VS2003 and Framework 1.1.

Cheers,

Chris.

PS. You did have exactly the setup I described. Just copied the code and
didn't make any assumptions of corrections? The only way to make it go
wrong is exactly the steps I described. Not accusing you of being unable
to follow simple instructions, but confused as to why it works correctly
for you and not for me. Unless you are using Framework 2.0 which might
explain a lot... :-)

C.

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:uo**************@TK2MSFTNGP04.phx.gbl...
It displays a message box that says "Enter Pressed", just as expected.
What result are you getting?

/claes

"ChrisM" <ch**************@suedeyahoo.com> wrote in message
news:er**************@TK2MSFTNGP04.phx.gbl...
I posted this last week, so apologies for re-posting but I'm still
looking for a sensible answer, and I'm hoping somone new might be able
to cast some light...
Basically, I have a fairly complicated application which seems to me to
be misbehaving. The following is an attempt to reproduce the error.
There are reasons in the real application why I'm trying to do things
the way they are here, so please no comments on techniques here, UNLESS
I'm trying to do somthing fundamentally wrong (or stupid!)

Anyway, if someone could humour me and try the following:
1) Create a new dotNET project.
2) Add 3 Forms: frmMainForm, frmForm1 and frmForm2. (MainForm is the
form that should load on application startup).
3) Make frmMainForm an MDI Container Form.
4) Add the following code for MainForm:

private void MainForm_Load(object sender, System.EventArgs e)
{
frmForm1 form1 = new frmForm1();
form1.MdiParent = this;
form1.Show();
}

internal void ShowOtherForm()
{
frmForm2 form2 = new frmForm2();
form2.MdiParent = this;
form2.Show();
}

5) Place a button on form1 with the following code:
private void button1_Click(object sender, System.EventArgs e)
{
((frmMainForm)this.MdiParent).ShowOtherForm();
}

6) Place a button and a textBox on form2 with the following code:
private void button1_Click(object sender, System.EventArgs e)
{
MessageBox.Show("Button Pressed");
this.SendToBack();
}

private void textBox1_KeyUp(object sender,
System.Windows.Forms.KeyEventArgs e)
{
if(e.KeyCode == Keys.Enter)
MessageBox.Show("Enter Pressed");
}

7) Run the program, you should get as a child form inside MainForm
8) Click the button on form1 and you should get an instance of form2.
9) Click the button on form2 and you should get the 'Button Pressed'
message and Form1 comes to the front.
10) CLOSE Form1
11) Make sure focus is in the textBox on Form2 and press ENTER.
12) Please can someone explain what happens next...?

I would really appreciate it if someone could try this out and give me
their thoughts, because it's driving me crazy. I have this project
available as a zip-file if you can't be bothered with all the typing.

Many, many thanks.

ChrisM



Jun 26 '06 #5
It behaves as if the AccepButton property of the form is set to the button,
but it clearly isn't so not sure why that happens. I noticed that it's only
the enter key that triggers the button click event. All other keys gets
routed to the keypress event handler as expected. Looking at the call stack
I noticed that the Form's PropDefaultButton is set and this is what causes
the button click event handler to be invoked (use Reflector and take a look
in the Form.ProcessDialogKey method). Can't tell you why or where it gets
set though, but that might be worth tracking down.

If you don't already have Reflector you should download it. It's a great
tool to see the code in the framework. You can find it at
http://www.aisto.com/roeder/dotnet/

/claes

"ChrisM" <ch**************@suedeyahoo.com> wrote in message
news:eY*************@TK2MSFTNGP05.phx.gbl...
Glad to hear that you can now see the same problem. I thought for a while
I was going mad...
Any idea what might be going wrong? More importantly, any idea how to stop
it from happening???

;-)

Thanks,

Chris.

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:O2**************@TK2MSFTNGP03.phx.gbl...
I used 2.0 for my initial test. Testing it in 1.1 gives the result you're
seeing though. Strange indeed

/claes

"ChrisM" <ch**************@suedeyahoo.com> wrote in message
news:eK**************@TK2MSFTNGP03.phx.gbl...
That's interesting!!
When I do it, I get 'Button Pressed' which is what was confusing me.
What environment are you using? I have VS2003 and Framework 1.1.

Cheers,

Chris.

PS. You did have exactly the setup I described. Just copied the code and
didn't make any assumptions of corrections? The only way to make it go
wrong is exactly the steps I described. Not accusing you of being unable
to follow simple instructions, but confused as to why it works correctly
for you and not for me. Unless you are using Framework 2.0 which might
explain a lot... :-)

C.

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:uo**************@TK2MSFTNGP04.phx.gbl...
It displays a message box that says "Enter Pressed", just as expected.
What result are you getting?

/claes

"ChrisM" <ch**************@suedeyahoo.com> wrote in message
news:er**************@TK2MSFTNGP04.phx.gbl...
>I posted this last week, so apologies for re-posting but I'm still
>looking for a sensible answer, and I'm hoping somone new might be able
>to cast some light...
>
>
> Basically, I have a fairly complicated application which seems to me
> to be misbehaving. The following is an attempt to reproduce the error.
> There are reasons in the real application why I'm trying to do things
> the way they are here, so please no comments on techniques here,
> UNLESS I'm trying to do somthing fundamentally wrong (or stupid!)
>
> Anyway, if someone could humour me and try the following:
> 1) Create a new dotNET project.
> 2) Add 3 Forms: frmMainForm, frmForm1 and frmForm2. (MainForm is the
> form that should load on application startup).
> 3) Make frmMainForm an MDI Container Form.
> 4) Add the following code for MainForm:
>
> private void MainForm_Load(object sender, System.EventArgs e)
> {
> frmForm1 form1 = new frmForm1();
> form1.MdiParent = this;
> form1.Show();
> }
>
> internal void ShowOtherForm()
> {
> frmForm2 form2 = new frmForm2();
> form2.MdiParent = this;
> form2.Show();
> }
>
> 5) Place a button on form1 with the following code:
> private void button1_Click(object sender, System.EventArgs e)
> {
> ((frmMainForm)this.MdiParent).ShowOtherForm();
> }
>
> 6) Place a button and a textBox on form2 with the following code:
> private void button1_Click(object sender, System.EventArgs e)
> {
> MessageBox.Show("Button Pressed");
> this.SendToBack();
> }
>
> private void textBox1_KeyUp(object sender,
> System.Windows.Forms.KeyEventArgs e)
> {
> if(e.KeyCode == Keys.Enter)
> MessageBox.Show("Enter Pressed");
> }
>
> 7) Run the program, you should get as a child form inside MainForm
> 8) Click the button on form1 and you should get an instance of form2.
> 9) Click the button on form2 and you should get the 'Button Pressed'
> message and Form1 comes to the front.
> 10) CLOSE Form1
> 11) Make sure focus is in the textBox on Form2 and press ENTER.
> 12) Please can someone explain what happens next...?
>
> I would really appreciate it if someone could try this out and give me
> their thoughts, because it's driving me crazy. I have this project
> available as a zip-file if you can't be bothered with all the typing.
>
> Many, many thanks.
>
> ChrisM
>



Jun 27 '06 #6
Thanks for your input, Claes, it is much appreciated.

What IS (Prop)DefaultButton?? I know what AcceptButton, and CancelButton are
for, but from what I can tell, DefaultButton is an ASP.Net thing, not a
Windows Forms thing?? What could be setting it?

Cheers,

Chris.

PS I didn't have 'Reflector' before, but I do now, and it looks like it
might be useful...

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
It behaves as if the AccepButton property of the form is set to the
button, but it clearly isn't so not sure why that happens. I noticed that
it's only the enter key that triggers the button click event. All other
keys gets routed to the keypress event handler as expected. Looking at the
call stack I noticed that the Form's PropDefaultButton is set and this is
what causes the button click event handler to be invoked (use Reflector
and take a look in the Form.ProcessDialogKey method). Can't tell you why
or where it gets set though, but that might be worth tracking down.

If you don't already have Reflector you should download it. It's a great
tool to see the code in the framework. You can find it at
http://www.aisto.com/roeder/dotnet/

/claes

"ChrisM" <ch**************@suedeyahoo.com> wrote in message
news:eY*************@TK2MSFTNGP05.phx.gbl...
Glad to hear that you can now see the same problem. I thought for a while
I was going mad...
Any idea what might be going wrong? More importantly, any idea how to
stop it from happening???

;-)

Thanks,

Chris.

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:O2**************@TK2MSFTNGP03.phx.gbl...
I used 2.0 for my initial test. Testing it in 1.1 gives the result you're
seeing though. Strange indeed

/claes

"ChrisM" <ch**************@suedeyahoo.com> wrote in message
news:eK**************@TK2MSFTNGP03.phx.gbl...
That's interesting!!
When I do it, I get 'Button Pressed' which is what was confusing me.
What environment are you using? I have VS2003 and Framework 1.1.

Cheers,

Chris.

PS. You did have exactly the setup I described. Just copied the code
and didn't make any assumptions of corrections? The only way to make it
go wrong is exactly the steps I described. Not accusing you of being
unable to follow simple instructions, but confused as to why it works
correctly for you and not for me. Unless you are using Framework 2.0
which might explain a lot... :-)

C.

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:uo**************@TK2MSFTNGP04.phx.gbl...
> It displays a message box that says "Enter Pressed", just as expected.
> What result are you getting?
>
> /claes
>
> "ChrisM" <ch**************@suedeyahoo.com> wrote in message
> news:er**************@TK2MSFTNGP04.phx.gbl...
>>I posted this last week, so apologies for re-posting but I'm still
>>looking for a sensible answer, and I'm hoping somone new might be able
>>to cast some light...
>>
>>
>> Basically, I have a fairly complicated application which seems to me
>> to be misbehaving. The following is an attempt to reproduce the
>> error. There are reasons in the real application why I'm trying to do
>> things the way they are here, so please no comments on techniques
>> here, UNLESS I'm trying to do somthing fundamentally wrong (or
>> stupid!)
>>
>> Anyway, if someone could humour me and try the following:
>> 1) Create a new dotNET project.
>> 2) Add 3 Forms: frmMainForm, frmForm1 and frmForm2. (MainForm is the
>> form that should load on application startup).
>> 3) Make frmMainForm an MDI Container Form.
>> 4) Add the following code for MainForm:
>>
>> private void MainForm_Load(object sender, System.EventArgs e)
>> {
>> frmForm1 form1 = new frmForm1();
>> form1.MdiParent = this;
>> form1.Show();
>> }
>>
>> internal void ShowOtherForm()
>> {
>> frmForm2 form2 = new frmForm2();
>> form2.MdiParent = this;
>> form2.Show();
>> }
>>
>> 5) Place a button on form1 with the following code:
>> private void button1_Click(object sender, System.EventArgs e)
>> {
>> ((frmMainForm)this.MdiParent).ShowOtherForm();
>> }
>>
>> 6) Place a button and a textBox on form2 with the following code:
>> private void button1_Click(object sender, System.EventArgs e)
>> {
>> MessageBox.Show("Button Pressed");
>> this.SendToBack();
>> }
>>
>> private void textBox1_KeyUp(object sender,
>> System.Windows.Forms.KeyEventArgs e)
>> {
>> if(e.KeyCode == Keys.Enter)
>> MessageBox.Show("Enter Pressed");
>> }
>>
>> 7) Run the program, you should get as a child form inside MainForm
>> 8) Click the button on form1 and you should get an instance of form2.
>> 9) Click the button on form2 and you should get the 'Button Pressed'
>> message and Form1 comes to the front.
>> 10) CLOSE Form1
>> 11) Make sure focus is in the textBox on Form2 and press ENTER.
>> 12) Please can someone explain what happens next...?
>>
>> I would really appreciate it if someone could try this out and give
>> me their thoughts, because it's driving me crazy. I have this project
>> available as a zip-file if you can't be bothered with all the typing.
>>
>> Many, many thanks.
>>
>> ChrisM
>>
>
>



Jun 27 '06 #7
Hi Claes,

With your invaluable help, I've managed to bodge my way round this problem,
(I hope).
Since, as you pointed out, the problem is stemming from the
'ProcessDialogKey' code, I've stuck the following code into the Form that is
causing the problem:

protected override bool ProcessDialogKey(Keys keyData)
{
if (keyData == Keys.Enter && this.ActiveControl == textBox1)
return true;
else
return base.ProcessDialogKey (keyData);
}

In other-words, if you've pressed Enter, and you are in the textBox then
don't carry out the usual ProcessDialogKey code. If you are in any other
control, or pressed any other key then carry on as normal, and pass the call
on up the stack.
Certainly works in my little test App, I'm going to try it in my proper one
now, and see what happens...

Will report back (probably tomorrow)

Thanks once again,

Chris.

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:%2****************@TK2MSFTNGP04.phx.gbl...
It behaves as if the AccepButton property of the form is set to the
button, but it clearly isn't so not sure why that happens. I noticed that
it's only the enter key that triggers the button click event. All other
keys gets routed to the keypress event handler as expected. Looking at the
call stack I noticed that the Form's PropDefaultButton is set and this is
what causes the button click event handler to be invoked (use Reflector
and take a look in the Form.ProcessDialogKey method). Can't tell you why
or where it gets set though, but that might be worth tracking down.

If you don't already have Reflector you should download it. It's a great
tool to see the code in the framework. You can find it at
http://www.aisto.com/roeder/dotnet/

/claes

"ChrisM" <ch**************@suedeyahoo.com> wrote in message
news:eY*************@TK2MSFTNGP05.phx.gbl...
Glad to hear that you can now see the same problem. I thought for a while
I was going mad...
Any idea what might be going wrong? More importantly, any idea how to
stop it from happening???

;-)

Thanks,

Chris.

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:O2**************@TK2MSFTNGP03.phx.gbl...
I used 2.0 for my initial test. Testing it in 1.1 gives the result you're
seeing though. Strange indeed

/claes

"ChrisM" <ch**************@suedeyahoo.com> wrote in message
news:eK**************@TK2MSFTNGP03.phx.gbl...
That's interesting!!
When I do it, I get 'Button Pressed' which is what was confusing me.
What environment are you using? I have VS2003 and Framework 1.1.

Cheers,

Chris.

PS. You did have exactly the setup I described. Just copied the code
and didn't make any assumptions of corrections? The only way to make it
go wrong is exactly the steps I described. Not accusing you of being
unable to follow simple instructions, but confused as to why it works
correctly for you and not for me. Unless you are using Framework 2.0
which might explain a lot... :-)

C.

"Claes Bergefall" <lo*****@nospam.nospam> wrote in message
news:uo**************@TK2MSFTNGP04.phx.gbl...
> It displays a message box that says "Enter Pressed", just as expected.
> What result are you getting?
>
> /claes
>
> "ChrisM" <ch**************@suedeyahoo.com> wrote in message
> news:er**************@TK2MSFTNGP04.phx.gbl...
>>I posted this last week, so apologies for re-posting but I'm still
>>looking for a sensible answer, and I'm hoping somone new might be able
>>to cast some light...
>>
>>
>> Basically, I have a fairly complicated application which seems to me
>> to be misbehaving. The following is an attempt to reproduce the
>> error. There are reasons in the real application why I'm trying to do
>> things the way they are here, so please no comments on techniques
>> here, UNLESS I'm trying to do somthing fundamentally wrong (or
>> stupid!)
>>
>> Anyway, if someone could humour me and try the following:
>> 1) Create a new dotNET project.
>> 2) Add 3 Forms: frmMainForm, frmForm1 and frmForm2. (MainForm is the
>> form that should load on application startup).
>> 3) Make frmMainForm an MDI Container Form.
>> 4) Add the following code for MainForm:
>>
>> private void MainForm_Load(object sender, System.EventArgs e)
>> {
>> frmForm1 form1 = new frmForm1();
>> form1.MdiParent = this;
>> form1.Show();
>> }
>>
>> internal void ShowOtherForm()
>> {
>> frmForm2 form2 = new frmForm2();
>> form2.MdiParent = this;
>> form2.Show();
>> }
>>
>> 5) Place a button on form1 with the following code:
>> private void button1_Click(object sender, System.EventArgs e)
>> {
>> ((frmMainForm)this.MdiParent).ShowOtherForm();
>> }
>>
>> 6) Place a button and a textBox on form2 with the following code:
>> private void button1_Click(object sender, System.EventArgs e)
>> {
>> MessageBox.Show("Button Pressed");
>> this.SendToBack();
>> }
>>
>> private void textBox1_KeyUp(object sender,
>> System.Windows.Forms.KeyEventArgs e)
>> {
>> if(e.KeyCode == Keys.Enter)
>> MessageBox.Show("Enter Pressed");
>> }
>>
>> 7) Run the program, you should get as a child form inside MainForm
>> 8) Click the button on form1 and you should get an instance of form2.
>> 9) Click the button on form2 and you should get the 'Button Pressed'
>> message and Form1 comes to the front.
>> 10) CLOSE Form1
>> 11) Make sure focus is in the textBox on Form2 and press ENTER.
>> 12) Please can someone explain what happens next...?
>>
>> I would really appreciate it if someone could try this out and give
>> me their thoughts, because it's driving me crazy. I have this project
>> available as a zip-file if you can't be bothered with all the typing.
>>
>> Many, many thanks.
>>
>> ChrisM
>>
>
>



Jun 27 '06 #8

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

Similar topics

0
by: Daniel O'Brien | last post by:
Hi - any help with this would be greatly appreicated - it has already had me confused for a good few hours! I am using Visual Studio 2003 and the .NET framework 1.1. I have a C# Windows...
3
by: Sebastian C. | last post by:
Hello everybody Since I upgraded my Office XP Professional to SP3 I got strange behaviour. Pieces of code which works for 3 years now are suddenly stop to work properly. I have Office XP...
1
by: Ian | last post by:
Hi, I have noticed some strange behaviour when loading my database. I load a menu form on startup; this form contains a linked image to display. If the project is not then signed, the menu form...
0
by: theintrepidfox | last post by:
Dear Group I came accross a very annoying behaviour of Visual Studio, giving me six hours of headache till I found the solution. This post is mainly for fellow developers for reference as it...
7
by: ChrisM | last post by:
I posted this last week, so apologies for re-posting but I'm still looking for a sensible answer, and I'm hoping somone new might be able to cast some light... Basically, I have a fairly...
5
by: Ian | last post by:
Hi everyone, I have found some bizarre (to me...!) behaviour of the Form_Activate function. I have a form which has a button control used to close the form and a subform with a datasheet view...
1
by: Asko Telinen | last post by:
Hi all. I ran into quite strange problem concerning the event raising inside FileSystemWatcher Delete event. First, i would like to describe a bit my environment. I have main GUI...
5
by: =?Utf-8?B?Y2FsZGVyYXJh?= | last post by:
Dear all, I have a strange behaviour on the use of delagate. I will try to explain. I have an assembly (Lets call it AssmDB) which contains database function operation like Insert, Delete,...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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: 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...

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.