如何控制消息框显示 [英] how to control message box display

查看:50
本文介绍了如何控制消息框显示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在计时器上显示一个消息框,每隔1分钟显示一个消息框,问题是如果用户没有单击确定",并且计时器仍在运行,则打开多个我不知道的消息框.不想要.

请帮助我只显示一个消息框,仅当用户单击确定"按钮时才会显示下一个消息框,不应禁用计时器..


请帮忙.

I am displaying a message box on timer which displays a message box after every 1 minute, the problem is if user does not clicks on "OK" , and timer is still running then multiple message boxes get opened which I don''t want..

Please help me to display only one message box and next will be displayed only if user clicks on oK button, timer should not be disabled..


please help.

推荐答案

创建一个自定义消息框,并在计时器计时时调用它.当用户单击确定"时销毁它.如果用户未单击确定",请在下一个timerTick事件中检查消息框对象,如果该对象存在,则不要打开新的消息框.

希望这能解决您的问题.. !!!
Create a custom message box and call it when timer ticks. Destroy it when user clicks OK. If user doesn''t click OK, check for the messagebox object in the next timerTick event and if it exists, do not open a new message box.

Hope this solves your problem..!!!


亲爱的DjRocks,

这是逻辑部分,如果您在计时器运行时提示消息,它将提示您进行每个间隔.

所以我的建议是

在提示消息之前,请检查现有消息结果,

Dear DjRocks,

This is the logic part, if you prompt messages while timer is running , it will prompt you for each and every intervel.

So my suggession is

Before prompting the message, check for existing message result,

DialogResult result1 = MessageBox.Show("Is Clicked?",
		"Mybox",
		MessageBoxButtons.YesNo);
}



//在提示消息之前



// before prompting message

if(result1==DialogResult.yes)
{
   // Go ahead
}



这只是个主意,对您有帮助

谢谢,
SP



This is only the idea,and will helpfull to you

Thanks,
SP



为此,您需要为此检查消息框是否正在运行
设置 CBT钩子然后,您将收到所有通知创建,激活,停用和销毁的窗口.然后使用GetWindowClass检查创建/激活的hWnd实际上是否为MessageBox.
Hi,
For this you need to check if the messagebox is running or not for this
Set up a CBT hooks Then you''ll get notification of all created, activated, deactivated and destroyed windows. Then use GetWindowClass to check if the hWnd created/activated is in fact a MessageBox.


这篇关于如何控制消息框显示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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