473,757 Members | 9,145 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
13 3611
Hi Mojo,

I want to make a clarify that the setparent API, is used to set the parent
of a window, not the owner. And I did not make a clear test on my code.

Here is an article about parent and owner of a window.
http://support.dundas.com/Articles/A...?ArticleID=577

It seems that you want to make an app like the combo box.

I think you may try to set the form's style as follows.
Protected Overrides ReadOnly Property CreateParams() As
System.Windows. Forms.CreatePar ams
Get
Dim cp As CreateParams = MyBase.CreatePa rams
cp.Style = cp.Style Or &H40000000
cp.ExStyle = cp.ExStyle Or &H8000000
cp.ExStyle = cp.ExStyle And (Not &H40000)
Return cp
End Get
End Property

I also has sent a sample to you.

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 #11
Dear Peter,

Than you for your example, but it doesn't work :o( ....

It seams like this line 'cp.Style = cp.Style Or &H40000000' blocks the
listbox, so I cannot chose ane values.

Any ideas??

Thanks again! :o)

M O J O

Peter Huang wrote:
Hi Mojo,

I want to make a clarify that the setparent API, is used to set the parent
of a window, not the owner. And I did not make a clear test on my code.

Here is an article about parent and owner of a window.
http://support.dundas.com/Articles/A...?ArticleID=577

It seems that you want to make an app like the combo box.

I think you may try to set the form's style as follows.
Protected Overrides ReadOnly Property CreateParams() As
System.Windows. Forms.CreatePar ams
Get
Dim cp As CreateParams = MyBase.CreatePa rams
cp.Style = cp.Style Or &H40000000
cp.ExStyle = cp.ExStyle Or &H8000000
cp.ExStyle = cp.ExStyle And (Not &H40000)
Return cp
End Get
End Property

I also has sent a sample to you.

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 #12
Hi Mojo,

You may try to handle the MouseMove and Click event of listbox.

Private Sub ListBox1_MouseM ove(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles ListBox1.MouseM ove
ListBox1.Select edIndex = ListBox1.IndexF romPoint(New Point(e.X,
e.Y))
End Sub

Private Sub ListBox1_Click( ByVal sender As Object, ByVal e As
System.EventArg s) Handles ListBox1.Click
Console.WriteLi ne(ListBox1.Sel ectedItem)
End Sub

Since the ListBox can not get focus, the stuff should be down by yourself.

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 #13
Perfect THANKS!!!!!!!!! !!!!!!!!!!!!!

Have a nice weekend!!!!!

:o)

M O J O

Peter Huang wrote:
Hi Mojo,

You may try to handle the MouseMove and Click event of listbox.

Private Sub ListBox1_MouseM ove(ByVal sender As Object, ByVal e As
System.Windows. Forms.MouseEven tArgs) Handles ListBox1.MouseM ove
ListBox1.Select edIndex = ListBox1.IndexF romPoint(New Point(e.X,
e.Y))
End Sub

Private Sub ListBox1_Click( ByVal sender As Object, ByVal e As
System.EventArg s) Handles ListBox1.Click
Console.WriteLi ne(ListBox1.Sel ectedItem)
End Sub

Since the ListBox can not get focus, the stuff should be down by yourself.

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 #14

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

Similar topics

8
11339
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
10124
by: Petec | last post by:
Is there a way to prevent a form from getting focus? Thanks! - Pete
2
9405
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
1337
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
1851
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
1689
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
9982
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
1556
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
9298
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,...
1
9885
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9737
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8737
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
7286
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
6562
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
5172
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
3829
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
3
2698
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.