简体   繁体   English

如何确定 Windows Mobile 中的程序中断

[英]How do I determine program interupt in Windows Mobile

I have an game application I have written for Windows Mobile and I want to have a timer associated with the puzzle.我有一个为 Windows Mobile 编写的游戏应用程序,我想要一个与拼图相关联的计时器。 If the program loses focus for any reason (call comes in, user switches programs, user hits the Windows button) then I want a pop up dialog box to cover the puzzle and the timer to stop.如果程序因任何原因失去焦点(呼叫进来、用户切换程序、用户点击 Windows 按钮),那么我想要一个弹出对话框来覆盖拼图并停止计时器。 When the user closes the pop up dialog the timer can start up again.当用户关闭弹出对话框时,计时器可以再次启动。

Does anyone know how to do this?有谁知道如何做到这一点?

Thanks谢谢

A quick way would be to use PInvoke to call GetForegroundWindow() and GetWindowText( ) whenever your timer ticks (once a second?).一个快速的方法是使用 PInvoke在您的计时器计时(每秒一次?)时调用 GetForegroundWindow() 和 GetWindowText( )。

GetForegroundWindow() returns a windows handle which you can use to call GetWindowText(). GetForegroundWindow() 返回一个窗口句柄,您可以使用它来调用 GetWindowText()。 If the text of the foreground window matches your form's Text property (its caption), you know your app has the focus.如果前台窗口的文本与表单的 Text 属性(其标题)匹配,您就知道您的应用程序具有焦点。 You can then show or hide your puzzle in each timer tick.然后,您可以在每个计时器滴答声中显示或隐藏您的拼图。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM