473,404 Members | 2,137 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,404 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 1168
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,...
8
by: Dox33 | last post by:
I ran into a very strange behaviour of raw_input(). I hope somebody can tell me how to fix this. (Or is this a problem in the python source?) I will explain the problem by using 3 examples....
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: 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?
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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...

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.