create deactivated form

  • Thread starter Thread starter Mark Broadbent
  • Start date Start date
M

Mark Broadbent

If the form is not a dialog, why dont you re-activate the original form once
you have created the new one?
private void button1_Click(object sender, System.EventArgs e)

{

Form2 myform = new Form2();

myform.Show();

this.Activate();

}

Br,

Mark.
 
Ah, I see. Im sure I've seen this thing come up before in the ngs and I'm
not sure there is a good answer, however hopefully one of the gurus will
come to your assistance.
Good Luck!
 
In the second form you could call something like :

(this.parent as Form).Activate();
.....

Steph.

______________________________________________________________

Stephane Orban
IT Manager
EOLE-UNICLAM
EMail : (e-mail address removed)
Web : www.uniclam.com
Tel : +32 (0) 2 227 54 98
Fax : +32(0) 2 218 74 60
 
Great. I would have suggested Stephs method too but it wasn't strictly what
you were asking for.
I don't even think it is possible in Winforms to start form deactivated, but
would love to hear from a GUI expert to confirm this. (Im sure this question
keeps cropping up over and over)

Br,

Mark.
 
hy,

I've got a quite simple application: one windows form that consists of a
button, and as soon as the user hits the button a second form shall appear.
The difficult thing about it is that I want the new form to be created as
"deactivated" - that means that the second form has an editbox in it, and
this must NOT have the focus - instead, the calling form shall keep its
focus.

One simple way would be to immediately set focus back after the second form
got it, but this won't work in the future for me when I will extend my app.
So I'm looking for a way to immediately create a window that doesn't have
focus.
I've already tried overriding the CreateParams-method like this (the
WS_EX_NOACTIVATE style here is the one from CreateWindowEx in win32-sdk):


protected override CreateParams CreateParams
{
get
{
const int WS_EX_NOACTIVATE = 0x08000000;
CreateParams myParams = base.CreateParams;
myParams.ExStyle = myParams.ExStyle | WS_EX_NOACTIVATE;
return myParams;
}
}


Or do I have to override a method like myForm.Show(), or myForm.Activated()
(because the new window gets focus as soon as I call myForm.Show())

I really appreciate any hints that could lead to a solution,
thx in advance,
ekim!
 
thanks for your answer - this would of course work if the case would be as
simple as I had described it.
but in fact I don't call the second form to be created from within this
..NET-project, but call it from a c++-win32-client via com-interop (com
callable wrappers). more detailled, I create the .NET-form as soon as the
user makes some keystrokes into an editbox of my win32-toolbar (and
therefore I MUST NOT lose focus, so that the user can keep on entering keys
into my editbox) ;-(
 
thx for your efforts,

indeed I've solved the problem in the meantime - although I found no
possibility to deactivate the .net-form at startup, I made some changes to
my win32-program...it's about setting the focus to the current window again
just in the right moment...however, it works, thx!
 
Back
Top