关于System.Windows.Forms(C#)中控件类中的Show方法 [英] about Show Method in Control Class under System.Windows.Forms (C#)

查看:118
本文介绍了关于System.Windows.Forms(C#)中控件类中的Show方法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述




我的函数:myAdjustForm.Show();


我使用Show方法显示弹出窗口在我的C#程序中给用户的窗口




我发现我在开始之前调用了这个函数TWICE

看到弹出的弹出窗口。


你知道我怎么解决它吗?是否与缺少初始化相关

例程?


谢谢。


祝你好运,


Albert

Hi,

my function: myAdjustForm.Show();

I am using the Show method to show the pop-up window to the users
in my C# program.

I found that I have invoke this function TWICE at the beginning before I can
see the pop-up window poping up.

Do you know how I can fix it? Is it related to missing initialization
routines?

Thanks.

Best regards,

Albert

推荐答案

嗨Albert,


当你调用myAdjustForm.Show(),你的进程是否拥有前景

窗口?如果你这样做,那么这个问题确实很奇怪,请你点赞
给我一些代码,以便我可以尝试在我身边重现这个问题吗?


如果前台窗口不属于你的进程,那么调用

myAdjustForm.Show()将不会在win2000 / xp上将它带到前台,这是

因为默认情况下窗口会阻止应用程序窃取焦点,

它会闪烁任务栏按钮。在这种情况下,两次调用Show()

也无法解决问题;因此可能不是这样的情况

。 (对于这个问题,你将不得不使用SetForegroundWindow和

一起使用AttachThreadInput作为一种解决方法,搜索这两个API并且你将获得关于它的大量信息)

如果您发布了代码,请告诉我您使用的是哪个.NET版本。谢谢。


此致,

Walter Wang(wa****@online.microsoft.com,删除''在线。'')

Microsoft在线社区支持


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

通过电子邮件收到我的帖子通知?请参阅
http://msdn.microsoft .com / subscripti ... ult.aspx#notif

ications。如果您使用的是Outlook Express,请确保清除

复选框工具/选项/读取:一次获取300个标题及时看到你的回复




注意:MSDN托管新闻组支持服务是针对非紧急问题

其中来自社区或Microsoft支持的初步响应

工程师可在1个工作日内完成。请注意,每个跟随

的响应可能需要大约2个工作日作为支持

专业人士与您合作可能需要进一步调查才能达到

最有效的分辨率。该产品不适用于需要紧急,实时或基于电话的交互或复杂的b $ b项目分析和转储分析问题的情况。这种性质的问题最好通过联系

Microsoft客户支持服务(CSS)处理
href =http://msdn.microsoft.com/subscriptions/support/default.aspx\"target =_ blank> http://msdn.microsoft.com/subscripti...t/default.aspx

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


此帖子按原样提供。没有保证,也没有授予任何权利。

Hi Albert,

When you call myAdjustForm.Show(), does your process own the foreground
window? If you do, then the issue is quite strange indeed, would you please
give me some code so that I can try to reproduce the issue on my side?

If the foreground window doesn''t belong to your process, then calling
myAdjustForm.Show() will NOT bring it to foreground on win2000/xp, this is
because by default windows will prevent applications from stealing focus,
it will flash the taskbar button instead. In this case, calling Show()
twice will also not solve the issue; therfore it might not be the case
either. (For this issue, you will have to use SetForegroundWindow along
with AttachThreadInput as a workaround, search for these two APIs and you
will much information about it)

If you do post the code, please let me know which .NET version you''re
using. Thanks.

Sincerely,
Walter Wang (wa****@online.microsoft.com, remove ''online.'')
Microsoft Online Community Support

==================================================
Get notification to my posts through email? Please refer to
http://msdn.microsoft.com/subscripti...ult.aspx#notif
ications. If you are using Outlook Express, please make sure you clear the
check box "Tools/Options/Read: Get 300 headers at a time" to see your reply
promptly.

Note: The MSDN Managed Newsgroup support offering is for non-urgent issues
where an initial response from the community or a Microsoft Support
Engineer within 1 business day is acceptable. Please note that each follow
up response may take approximately 2 business days as the support
professional working with you may need further investigation to reach the
most efficient resolution. The offering is not appropriate for situations
that require urgent, real-time or phone-based interactions or complex
project analysis and dump analysis issues. Issues of this nature are best
handled working with a dedicated Microsoft Support Engineer by contacting
Microsoft Customer Support Services (CSS) at
http://msdn.microsoft.com/subscripti...t/default.aspx.
==================================================

This posting is provided "AS IS" with no warranties, and confers no rights.


Albert,


这是一个从来没有过的奇怪问题发生在我身上。你能发布

简单的可编辑样本来证明这个问题。

-

Stoitcho Goutsev(100)


" Albert Fu" < ko ** @ community.nospamwrote in message

news:93 **************************** ****** @ microsof t.com ...
Albert,

This is a strange problem that have never happened to me. Can you post
simple compilable sample that demonstrates the problem.
--
Stoitcho Goutsev (100)

"Albert Fu" <ko**@community.nospamwrote in message
news:93**********************************@microsof t.com...




我的函数:myAdjustForm.Show ();


我使用Show方法向用户显示弹出窗口

在我的C#程序中。


我发现我在开始之前调用了这个函数TWICE

可以

看到弹出的弹出窗口。


你知道我怎么解决它吗?是否与缺少初始化相关

例程?


谢谢。


祝你好运,


Albert
Hi,

my function: myAdjustForm.Show();

I am using the Show method to show the pop-up window to the users
in my C# program.

I found that I have invoke this function TWICE at the beginning before I
can
see the pop-up window poping up.

Do you know how I can fix it? Is it related to missing initialization
routines?

Thanks.

Best regards,

Albert






谢谢你所有的回复。


我正在使用MS VS 2005(MS Visual C#2005 77626-009-0000007-41501)。


我包含了这个功能在我的电子邮件结尾处,我的程序中有。我在
中在调试器中设置了一个断点。当我选择显示弹出窗口时,调试器在函数内停止



(在这种情况下,myAdjustForm.Visible为false)。


这是我的观察结果:

1)第一次

程序在我跨过后以另一种形式停止另一种形式

myAdjustForm.Show()。没有弹出窗口出现。

2)第二次

程序在我走过后停在myAdjustForm.BringToFront()

myAdjustForm.Show()。弹出窗口按我的预期显示。

3)弹出窗口每次都会出现在第二次之后。


我认为这个可能是一个C#编译器错误,因为我不明白为什么我的程序的

执行顺序将在第一次之后改变。我试图在b / b
中取消选中构建页面中的优化代码框,但这个问题仍然是

。因此,如果这是与编译器相关的问题,我不确定同样的问题会出现在我的程序的简化版本中。


你有没有想法如何改变编译器的行为以便它能够生成反映程序流程的代码?


祝你好运,


Albert


****************************** ******************** ****

private void menuItemAdjust_Click(object sender,EventArgs e)

{

if(myAdjustForm.Visible == true)

myAdjustForm.Hide();

else

{

myAdjustForm.Show();

myAdjustForm.BringToFront();

}

}

********************************************** **** ***
Hi,

Thank you for all the replies.

I am using MS VS 2005 (MS Visual C# 2005 77626-009-0000007-41501).

I included the function that I have in my program at the end of my email. I
set a breakpoint inside this function in the debugger. The debugger stops
inside the function when I select to display the pop-up windows.
(myAdjustForm.Visible is false in this case).

Here is my obeservation:
1) 1st time
The program stops at another function in another form after I stepped over
myAdjustForm.Show(). There is no pop-up window showing up.
2) 2nd time
The program stops at myAdjustForm.BringToFront() after I stepped over
myAdjustForm.Show(). The pop-up window shows up as I expected.
3) The pop-up window shows up every time after the second time.

I think this could be a C# compiler bug since I don''t understand why the
execution sequence of my program will change after the first time. I tried to
uncheck the optimize code box in the build page but this problem is still
there. So I am not sure that the same problem will show up in a simplified
version of my program if this is compiler related problems.

Do you have any ideas how to change the behavior of the compiler so that it
will generate the code that reflects the program flow?

Best regards,

Albert

************************************************** ****
private void menuItemAdjust_Click(object sender, EventArgs e)
{
if (myAdjustForm.Visible == true)
myAdjustForm.Hide();
else
{
myAdjustForm.Show();
myAdjustForm.BringToFront();
}
}
************************************************** ***


这篇关于关于System.Windows.Forms(C#)中控件类中的Show方法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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