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! 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!
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!
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!
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!
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!
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! > >
This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
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)...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
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...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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
|
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: 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...
|
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,...
|
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,...
|
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...
|
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...
|
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...
| |