防止新形式窃取焦点 [英] Preventing new form from stealing focus

查看:92
本文介绍了防止新形式窃取焦点的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我需要创建一个不会窃取焦点的弹出窗口。我已经搜索了网上的b $ b,我设法将一些代码放在一起。


以下是我的代码的结果,但我只有一个问题....如何使用
我可以阻止form2在任务栏中显示?我试图将

ShowInTaskBar设置为false,但随后会抛出异常。


这是我的代码:


Form1(主表格):


Private Sub Button1_Click(ByVal sender As System.Object,ByVal e

As_

System.EventArgs)处理Button1.Click

Dim frm2 As New Form2

frm2.Show()

End Sub


Form2(弹出窗体):


受保护的覆盖ReadOnly属性CreateParams()As_

System.Windows。 Forms.CreateParams

获取

尺寸CP作为的CreateParams = MyBase.CreateParams

cp.Style = cp.Style或安培; H56000000

返回cp

结束获取

结束财产


如何防止表格显示在任务栏?


提前谢谢!!


MOJO

解决方案

将其设置为最小化。


问候 - OHM#


==============

MOJO写道:


<我需要创建一个不会窃取焦点的弹出窗体。我已经搜索了网络,我设法将一些代码放在一起。

以下是我的代码的结果,但我有一个问题....如何
我可以阻止form2显示在任务栏中吗?我试图将
ShowInTaskBar设置为false,但随后会抛出异常。

这是我的代码:

Form1(主表单) ):私有子Button1_Click(ByVal sender As System.Object,ByVal e
As_
System.EventArgs)处理Button1.Click
Dim frm2 As New Form2
frm2.Show()
End Sub

Form2(弹出窗体):

受保护的覆盖ReadOnly属性CreateParams()As_
系统。 Windows.Forms.CreateParams
获取
昏暗CP作为的CreateParams = MyBase.CreateParams
cp.Style = cp.Style或安培; H56000000
返回CP
最终获取<结束属性

如何防止表单显示在任务栏中?

提前谢谢!!

MOJO




最诚挚的问候 - OHMBest问候 - OHM On *** ******* @ BTInternet.Com


我不明白如何将我的表单设置为最小化应该如何防止它

从焦点开始也不显示任务栏。


请解释。


提前谢谢。


MOJO


一名男子[OHM]写道:

将其设置为最小化。

问候 - OHM#

==============

MOJO写道:



我需要创建一个不会窃取焦点的弹出窗体。我已经搜索了网络,我设法将一些代码放在一起。

以下是我的代码的结果,但我有一个问题....如何
我可以阻止form2显示在任务栏中吗?我试图将
ShowInTaskBar设置为false,但随后会抛出异常。

这是我的代码:

Form1(主表单) ):私有子Button1_Click(ByVal sender As System.Object,ByVal e
As_
System.EventArgs)处理Button1.Click
Dim frm2 As New Form2
frm2.Show()
End Sub

Form2(弹出窗体):

受保护的覆盖ReadOnly属性CreateParams()As_
系统。 Windows.Forms.CreateParams
获取
昏暗CP作为的CreateParams = MyBase.CreateParams
cp.Style = cp.Style或安培; H56000000
返回CP
最终获取<结束属性

如何防止表单显示在任务栏中?

提前谢谢!!

MOJO



最诚挚的问候 - OHMBest问候 - OHM On ******* ***@BTInternet.Com




* M O J O< mojo@_no_spam_delete_this_newwebsolutions.dk> scripsit:

下面是我的代码的结果,但我有一个问题......我怎么能阻止form2在任务栏中显示?我试图将
ShowInTaskBar设置为false,但随后抛出异常。




哪个例外?


-

Herfried K. Wagner [MVP]

< http://www.mvps.org/dotnet>


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(ByVal sender As System.Object, ByVal e
As_
System.EventArgs) Handles Button1.Click
Dim frm2 As New Form2
frm2.Show()
End Sub

Form2 (popup form):

Protected Overrides ReadOnly Property CreateParams() As_
System.Windows.Forms.CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
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

解决方案

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(ByVal sender As System.Object, ByVal e
As_
System.EventArgs) Handles Button1.Click
Dim frm2 As New Form2
frm2.Show()
End Sub

Form2 (popup form):

Protected Overrides ReadOnly Property CreateParams() As_
System.Windows.Forms.CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
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**********@BTInternet.Com


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(ByVal sender As System.Object, ByVal e
As_
System.EventArgs) Handles Button1.Click
Dim frm2 As New Form2
frm2.Show()
End Sub

Form2 (popup form):

Protected Overrides ReadOnly Property CreateParams() As_
System.Windows.Forms.CreateParams
Get
Dim cp As CreateParams = MyBase.CreateParams
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**********@BTInternet.Com




* M O J O <mojo@_no_spam_delete_this_newwebsolutions.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>


这篇关于防止新形式窃取焦点的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆