473,729 Members | 2,335 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Preventing new form from stealing focus

Hi,

I need to create a popup form what will not steal focus. I've searched
the net and I managed to put some code together.

Below is the result of my code, but I have a single question .... how
can I prevent form2 to show in taskbar? I've tried to set the
ShowInTaskBar to false, but then an exception is thrown.

Here's my code:

Form1 (master form):

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As_
System.EventArg s) Handles Button1.Click
Dim frm2 As New Form2
frm2.Show()
End Sub

Form2 (popup form):

Protected Overrides ReadOnly Property CreateParams() As_
System.Windows. Forms.CreatePar ams
Get
Dim cp As CreateParams = MyBase.CreatePa rams
cp.Style = cp.Style Or &H56000000
Return cp
End Get
End Property

How can I prevent the form to be shown in the taskbar?

Thank you in advance!!

M O J O

Nov 20 '05 #1
13 3607
Set it to minimized.

Regards - OHM#

==============
M O J O wrote:
Hi,

I need to create a popup form what will not steal focus. I've searched
the net and I managed to put some code together.

Below is the result of my code, but I have a single question .... how
can I prevent form2 to show in taskbar? I've tried to set the
ShowInTaskBar to false, but then an exception is thrown.

Here's my code:

Form1 (master form):

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As_
System.EventArg s) Handles Button1.Click
Dim frm2 As New Form2
frm2.Show()
End Sub

Form2 (popup form):

Protected Overrides ReadOnly Property CreateParams() As_
System.Windows. Forms.CreatePar ams
Get
Dim cp As CreateParams = MyBase.CreatePa rams
cp.Style = cp.Style Or &H56000000
Return cp
End Get
End Property

How can I prevent the form to be shown in the taskbar?

Thank you in advance!!

M O J O


Best Regards - OHMBest Regards - OHM On**********@BT Internet.Com
Nov 20 '05 #2
I do not understand how setting my form to minimized should prevent it
from taken focus nor showing in the task bar.

Please explain.

Thank you in advance.

M O J O

One Handed Man [ OHM ] wrote:
Set it to minimized.

Regards - OHM#

==============
M O J O wrote:
Hi,

I need to create a popup form what will not steal focus. I've searched
the net and I managed to put some code together.

Below is the result of my code, but I have a single question .... how
can I prevent form2 to show in taskbar? I've tried to set the
ShowInTaskB ar to false, but then an exception is thrown.

Here's my code:

Form1 (master form):

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As_
System.EventArg s) Handles Button1.Click
Dim frm2 As New Form2
frm2.Show()
End Sub

Form2 (popup form):

Protected Overrides ReadOnly Property CreateParams() As_
System.Windows. Forms.CreatePar ams
Get
Dim cp As CreateParams = MyBase.CreatePa rams
cp.Style = cp.Style Or &H56000000
Return cp
End Get
End Property

How can I prevent the form to be shown in the taskbar?

Thank you in advance!!

M O J O

Best Regards - OHMBest Regards - OHM On**********@BT Internet.Com


Nov 20 '05 #3
* M O J O <mojo@_no_spam_ delete_this_new websolutions.dk > scripsit:
Below is the result of my code, but I have a single question .... how
can I prevent form2 to show in taskbar? I've tried to set the
ShowInTaskBar to false, but then an exception is thrown.


Which exception?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #4
Actually, I appear to have had a mental abberation, I answered your question
without due thought, I appologise. Having thought about it though. Could you
know use the form load even to shift focus back to the parent form ?

OHM#

M O J O wrote:
I do not understand how setting my form to minimized should prevent it
from taken focus nor showing in the task bar.

Please explain.

Thank you in advance.

M O J O

One Handed Man [ OHM ] wrote:
Set it to minimized.

Regards - OHM#

==============
M O J O wrote:
Hi,

I need to create a popup form what will not steal focus. I've
searched the net and I managed to put some code together.

Below is the result of my code, but I have a single question ....
how can I prevent form2 to show in taskbar? I've tried to set the
ShowInTaskBar to false, but then an exception is thrown.

Here's my code:

Form1 (master form):

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As_
System.EventArg s) Handles Button1.Click
Dim frm2 As New Form2
frm2.Show()
End Sub

Form2 (popup form):

Protected Overrides ReadOnly Property CreateParams() As_
System.Windows. Forms.CreatePar ams
Get
Dim cp As CreateParams = MyBase.CreatePa rams
cp.Style = cp.Style Or &H56000000
Return cp
End Get
End Property

How can I prevent the form to be shown in the taskbar?

Thank you in advance!!

M O J O

Best Regards - OHMBest Regards - OHM On**********@BT Internet.Com


Regards - OHM# On**********@BT Internet.com
Nov 20 '05 #5
Hi again,

Hmmmm - I don't want form1 to lose focus at any time.

M O J O

One Handed Man [ OHM ] wrote:
Actually, I appear to have had a mental abberation, I answered your question
without due thought, I appologise. Having thought about it though. Could you
know use the form load even to shift focus back to the parent form ?

OHM#

M O J O wrote:
I do not understand how setting my form to minimized should prevent it
from taken focus nor showing in the task bar.

Please explain.

Thank you in advance.

M O J O

One Handed Man [ OHM ] wrote:
Set it to minimized.

Regards - OHM#

============ ==
M O J O wrote:
Hi,

I need to create a popup form what will not steal focus. I've
searched the net and I managed to put some code together.

Below is the result of my code, but I have a single question ....
how can I prevent form2 to show in taskbar? I've tried to set the
ShowInTaskB ar to false, but then an exception is thrown.

Here's my code:

Form1 (master form):

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As_
System.EventArg s) Handles Button1.Click
Dim frm2 As New Form2
frm2.Show()
End Sub

Form2 (popup form):

Protected Overrides ReadOnly Property CreateParams() As_
System.Windows. Forms.CreatePar ams
Get
Dim cp As CreateParams = MyBase.CreatePa rams
cp.Style = cp.Style Or &H56000000
Return cp
End Get
End Property

How can I prevent the form to be shown in the taskbar?

Thank you in advance!!

M O J O
Best Regards - OHMBest Regards - OHM On**********@BT Internet.Com

Regards - OHM# On**********@BT Internet.com


Nov 20 '05 #6
Dear Herfried,

I couldn't provoke the exception now, don't know why I got an exception now.

If I set ShowInTaskBar to true, then focus is lost from the form1 and
form2 is never shown.

Any ideas??

Thanks!
M O J O

Herfried K. Wagner [MVP] wrote:
* M O J O <mojo@_no_spam_ delete_this_new websolutions.dk > scripsit:
Below is the result of my code, but I have a single question .... how
can I prevent form2 to show in taskbar? I've tried to set the
ShowInTaskB ar to false, but then an exception is thrown.

Which exception?


Nov 20 '05 #7
I've tried your code and I dont get and exception. Not does the form appear
in either the task bark or on screen

Regards OHM#
M O J O wrote:
Hi,

I need to create a popup form what will not steal focus. I've searched
the net and I managed to put some code together.

Below is the result of my code, but I have a single question .... how
can I prevent form2 to show in taskbar? I've tried to set the
ShowInTaskBar to false, but then an exception is thrown.

Here's my code:

Form1 (master form):

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e
As_
System.EventArg s) Handles Button1.Click
Dim frm2 As New Form2
frm2.Show()
End Sub

Form2 (popup form):

Protected Overrides ReadOnly Property CreateParams() As_
System.Windows. Forms.CreatePar ams
Get
Dim cp As CreateParams = MyBase.CreatePa rams
cp.Style = cp.Style Or &H56000000
Return cp
End Get
End Property

How can I prevent the form to be shown in the taskbar?

Thank you in advance!!

M O J O


Regards - OHM# On**********@BT Internet.com
Nov 20 '05 #8
Hi,

I think you may need to set the owner the form5, since form will have the
WS_CHILD style.

So you sould set the form5's owner as MainForm, this will restrict the
form5 to move inside the mainForm, but the mainform will not lost the focus.
Or you can set the form5's owner to the Desktop, this will let the form5 to
move around the desktop, but when you move the form5, the mainform will
lost the focus.

[MainForm]
Public Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal
hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
Public Declare Function GetDesktopWindo w Lib "user32" Alias
"GetDesktopWind ow" () As IntPtr
Private Sub Button1_Click_1 (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim frm As New Form5
SetParent(frm.H andle, GetDesktopWindo w())
frm.ShowInTaskb ar = False
frm.Show()
End Sub

[MainForm]
Private Sub Button1_Click_1 (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim frm As New Form5
frm.Owner = Me
frm.ShowInTaskb ar = False
frm.Show()
End Sub

[form5]
Protected Overrides ReadOnly Property CreateParams() As
System.Windows. Forms.CreatePar ams
Get
Dim cp As CreateParams = MyBase.CreatePa rams
cp.Style = cp.Style Or &H56000000
Return cp
End Get
End Property

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Me.Close()
End Sub

If you have any concern on this issue, please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.

Nov 20 '05 #9
Hi Peter,

I've tried to set the forms owner to Desktop, but then it doesn't show.
Hmmm strange.

I imagine that a combo box's dropdown is a form with a listbox on it.
But if I click the listbox, the dropdown form does not take focus. This
is kinda what I'm trying to archive.

Any other solutions?

Thanks!!!!!!

M O J O

Peter Huang wrote:
Hi,

I think you may need to set the owner the form5, since form will have the
WS_CHILD style.

So you sould set the form5's owner as MainForm, this will restrict the
form5 to move inside the mainForm, but the mainform will not lost the focus.
Or you can set the form5's owner to the Desktop, this will let the form5 to
move around the desktop, but when you move the form5, the mainform will
lost the focus.

[MainForm]
Public Declare Function SetParent Lib "user32" Alias "SetParent" (ByVal
hWndChild As IntPtr, ByVal hWndNewParent As IntPtr) As Integer
Public Declare Function GetDesktopWindo w Lib "user32" Alias
"GetDesktopWind ow" () As IntPtr
Private Sub Button1_Click_1 (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim frm As New Form5
SetParent(frm.H andle, GetDesktopWindo w())
frm.ShowInTaskb ar = False
frm.Show()
End Sub

[MainForm]
Private Sub Button1_Click_1 (ByVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Dim frm As New Form5
frm.Owner = Me
frm.ShowInTaskb ar = False
frm.Show()
End Sub

[form5]
Protected Overrides ReadOnly Property CreateParams() As
System.Windows. Forms.CreatePar ams
Get
Dim cp As CreateParams = MyBase.CreatePa rams
cp.Style = cp.Style Or &H56000000
Return cp
End Get
End Property

Private Sub Button1_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button1.Click
Me.Close()
End Sub

If you have any concern on this issue, please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.


Nov 20 '05 #10

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

Similar topics

8
11334
by: Susan Bricker | last post by:
Hi. I am opening a form (frmUserSettings) just before (or so I thought) the Main Menu form (frmMainMenu) is opening but it's not getting the focus. It gets "painted" and then the Main Menu gets "painted" right on top of the frmUserSettings. Since the Main Menu form is smaller (in width and height) I can click on frmUserSettings and get it to the front (focus). But is there a way to do this programmatically? Can you help me? Here is...
5
10123
by: Petec | last post by:
Is there a way to prevent a form from getting focus? Thanks! - Pete
2
9402
by: Robert Misiak | last post by:
Is it possible to display a window on top without it stealing focus? (and I'm not talking about stealing focus from my application - I'm talking about it stealing focus from any application.) I've read that calling ShowWindow() with SW_SHOWNOACTIVATE would work but I tried and it didn't. I'm implementing a Windows Messenger-style notification window that occasionally pops up with information. Thanks, Robert
0
1336
by: gkelly | last post by:
I have an AppBar that works fine, except for one problem. It's stealing focus -The AppBar is written in C# -Access to it is via a COM object -Main app is a C++ app. -Button on app will use com to access C# object which pops up AppBar -When the appbar is floating it works fine, but when it is docked it wants to have the focus all the time. -If you click on the main app window the focus will blink and go back to the
2
1848
by: BluDog | last post by:
Hi I have a borderless form that i am using as a popup, i want to display this form without it stealing focus from the form it pops up over. I do not want to display the form modally, as when the user click back to the parent form i want it to dissapear (this i have working just fine). Any suggestions would be greatly appreciated.
1
1686
by: damonwischik | last post by:
I'm using the Python Image Library (PIL) for Python 2.4. If I have an image and I show it from PIL import Image im = Image.new('RGB',100,100) im.show() then the output window steals focus. It's very handy to use an image to show the progress of execution for my program, but the computer is unusable when focus keeps on being stolen every few seconds. How can I prevent Image.show() from stealing
21
9973
by: Sharon | last post by:
I have added an auto scroll feature to my DataGrid control like this: private void DoAutoScroll() { DataView dv = m_DataGrid.DataSource as DataView; DataGridCell cell = m_DataGrid.CurrentCell; cell.RowNumber = dv.Count; m_DataGrid.CurrentCell = cell; } But this the last line of this code is putting the focus on the current
2
7900
by: Dave Booker | last post by:
I have a Windows form application that I generally run minimized. When a critical event occurs it instantiates another "Alert" form which I want to grab the user focus. In the Alert constructor I call both this.Show() and this.Activate(), but if the parent application is minimized then the Alert form will also stay minimized (and just flash). How can I cause the Alert form to show itself and grab focus?
3
1555
by: sravan_reddy001 | last post by:
i want to prevent a form from closing.. to do this i want to handle the formClosing or FormClosed events. from here i want to prevent the form from closing. New instance of same form should not be used. is there any way to do this? is it posiible to do the same thing with anycode?
0
8761
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9281
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8148
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6722
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6022
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4525
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3238
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2680
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2163
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.