473,396 Members | 2,011 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.

create deactivated form

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!
Nov 16 '05 #1
6 5815
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.

"Ekim" <th************@gmx.net> wrote in message
news:2p************@uni-berlin.de...
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!

Nov 16 '05 #2
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) ;-(
"Mark Broadbent" <no************@no-spam-please.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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.

"Ekim" <th************@gmx.net> wrote in message
news:2p************@uni-berlin.de...
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!


Nov 16 '05 #3
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!

"Ekim" <th************@gmx.net> wrote in message
news:2p************@uni-berlin.de...
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) ;-(
"Mark Broadbent" <no************@no-spam-please.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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.

"Ekim" <th************@gmx.net> wrote in message
news:2p************@uni-berlin.de...
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!



Nov 16 '05 #4
In the second form you could call something like :

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

Steph.

__________________________________________________ ____________

Stephane Orban
IT Manager
EOLE-UNICLAM
EMail : in**********@uniclam.com
Web : www.uniclam.com
Tel : +32 (0) 2 227 54 98
Fax : +32(0) 2 218 74 60

"Ekim" <th************@gmx.net> wrote in message
news:2p************@uni-berlin.de...
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) ;-(
"Mark Broadbent" <no************@no-spam-please.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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.

"Ekim" <th************@gmx.net> wrote in message
news:2p************@uni-berlin.de...
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!



Nov 16 '05 #5
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!
"Ekim" <th************@gmx.net> wrote in message
news:2p************@uni-berlin.de...
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) ;-(
"Mark Broadbent" <no************@no-spam-please.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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.

"Ekim" <th************@gmx.net> wrote in message
news:2p************@uni-berlin.de...
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!



Nov 16 '05 #6
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.

"Ekim" <th************@gmx.net> wrote in message
news:2p************@uni-berlin.de...
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!
"Ekim" <th************@gmx.net> wrote in message
news:2p************@uni-berlin.de...
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) ;-(
"Mark Broadbent" <no************@no-spam-please.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
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.

"Ekim" <th************@gmx.net> wrote in message
news:2p************@uni-berlin.de...
> 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!
>
>



Nov 16 '05 #7

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

Similar topics

7
by: Bil Muh | last post by:
Esteemede Developers, I would like to Thank All of You in advance for your sincere guidances. I am developing a software using Visual C++ .NET Standard Edition with Windows Form (.NET)...
5
by: me | last post by:
I have a Class Library that contains a Form and several helper classes. A thread gets created that performs processing of data behind the scenes and the Form never gets displayed (it is for debug...
1
by: Bevo | last post by:
I instantiate form B from form A and makes A the owner of B. At a certain user action I hide B (tried both .Hide and .Visible = false), then I show it again at another action. When I do it refuses to...
2
by: Roberto Rocco | last post by:
Whenever I try to create a new ASP Web Page I get this message : "Visual Studio cannot create or open the application because the Web server on this computer is not running. Start the Web server...
16
by: Simon Jefferies | last post by:
Hello, I am getting a First-chance exception "The activation context being deactivated is not the most recently activated one." followed by another exception straight afterwards "An unhandled...
1
by: dwilliamjoe | last post by:
VB.net, launch procedure, close form, the whole APP is deactivated. When I say deactivated, other applications (Wind Explorer, My computer, Ect...) come to the foreground and my app goes to the...
2
by: mike | last post by:
i'm building an desktop windows app in C#. the main menu for the application will be different depending on the admin rights of the user. i've built the entire app. in delphi and i simply activated...
2
by: Melisa | last post by:
Hi, How can i create bitmap of a window form with all its child controls without showing this form? 1. I am trying to create bitmap image of a window form. 2. I am creating a new instance of...
27
by: max | last post by:
Hello, I am a newbye, and I'm trying to write a simple application. I have five tables with three columns; all tables are identical; I need to change some data in the first table and let VB...
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: 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
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...

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.