最小化和最大化窗口的事件处理程序
我正在为 PocketPC 开发一个应用程序。 当应用程序启动时,调用自定义函数 SetScreenOrientation(270) 来旋转屏幕。 当应用程序关闭时,调用函数 SetScreenOrientation(0) 以恢复屏幕方向。
这样,如果用户最小化应用程序,则屏幕方向不会恢复,这是不可接受的。
有谁知道应该在哪里(在哪个事件处理程序中)调用 SetScreenOrientation(int angle) 来设置应用程序启动时的屏幕方向、最小化时恢复方向、最大化时设置方向以及关闭时恢复方向?
实际上我不知道哪个事件处理程序处理最小化和最大化事件。
I am developing an application for PocketPC. When the application starts the custom function SetScreenOrientation(270) is called which rotates the screen. When the application closes the function SetScreenOrientation(0) is called which restores the screen orientation.
This way the screen orientation isn't restored if the user minimizes the application and this is not acceptable.
Does anyone know where (in which event handlers) should SetScreenOrientation(int angle) be called to set the screen orientation on application start, restore orientation on minimize, set the orientation on maximize and restore the orientation on close?
Actually I don't know which event handler handles the Minimize and Maximize event.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
正确的消息是 WM_SIZE,但 Daemin 的答案指向错误的 WM_SIZE帮助主题。 检查 wParam。 请小心,因为您的窗口可能会最大化但隐藏。
The correct message is WM_SIZE, but Daemin's answer points to the wrong WM_SIZE help topic. Check the wParam. Be careful as your window may be maximized but hidden.
根据我的 Windows CE 经验,您应该处理 WM_SIZE 或 < a href="http://msdn.microsoft.com/en-us/library/ms942858.aspx" rel="nofollow noreferrer">WM_WINDOWPOSCHANGED 消息。 如果您正在使用 PocketPC,我建议您首先查看 WM_WINDOWPOSCHANGED 消息,因为我不确定 WM_SIZE 是否具有您需要的正确参数。
从 WM_WINDOWPOSCHANGED 消息的 WINDOWPOS 结构中查看 flags 成员,特别是 SWP_SHOWWINDOW 和 SWP_HIDEWINDOW。
您需要查看的消息的具体版本因您所使用的操作系统而异。 Pocket PC 操作系统基于 Windows CE 3.0(及更低版本)构建,而 Windows Mobile 现在基于 Windows CE 5.0(甚至 Windows Mobile 6)构建,但也基于 Windows CE 4 构建。 www.pocketpcfaq.com/wce/versions.htm" rel="nofollow noreferrer">(来源)
因此,只需在 MSDN 中的相关部分中查找您正在编写的操作系统即可。
Going from my Windows CE experience you should handle either the WM_SIZE or WM_WINDOWPOSCHANGED messages. If you're working on PocketPC I would suggest you take a look at the WM_WINDOWPOSCHANGED message first because I'm not sure the WM_SIZE has the right parameters that you need.
From the WM_WINDOWPOSCHANGED message's WINDOWPOS structure take a look at the flags member, specifically SWP_SHOWWINDOW and SWP_HIDEWINDOW.
The specific version of the messages that you need to look at vary with what operating system you're using. The Pocket PC OS is built on Windows CE 3.0 (and lower), while Windows Mobile is now built on Windows CE 5.0 (even Windows Mobile 6), but was also built on Windows CE 4. (Source)
So just look under the relevant section in MSDN for the OS that you're writing for.
我不知道这些在 C++ 世界中被称为什么,但是在 .NET Compact Framework 中,当您最小化/最大化窗口时,将调用应用程序窗体的 Resize 事件,然后在事件代码中您将检查该窗口的 WindowState 属性。表单以查看其是否最小化或最大化。
从应用程序内部更改 PDA 的状态是有风险的(尽管有很多充分的理由这样做),因为如果您的应用程序崩溃,它将使 PDA 处于其原来的状态。我已经做了很多 kiosk - 在 Windows Mobile 中键入(全屏)应用程序,有效地做到这一点的技巧之一是隐藏 WM 标题栏(带有 Windows 开始按钮的顶行)以防止它每次都闪烁一瞬间您打开一个新表格。 如果应用程序崩溃,窗口栏将保持不可见,直到您重置设备,这并不好。 至少通过屏幕旋转,用户可以手动恢复它。
I don't know what these are called in the C++ world, but in .NET Compact Framework your application form's Resize event would be called when you minimize/maximize a window, and then in the event code you would check the WindowState property of the form to see if its minimized or mazimized.
Altering the state of your PDA from within your application is risky (although there are lots of good reasons to do it), because if your app crashes it will leave the PDA in whatever state it was in. I've done a lot of kiosk-type (full-screen) apps in Windows Mobile, and one of the tricks to doing this effectively is to hide the WM title bar (the top row with the Windows start button) to keep it from flashing up for a split second every time you open a new form. If the app crashes, the windows bar remains invisible until you reset the device, which isn't good. At least with screen rotation the user can restore it manually.
这确实取决于平台,但我会选择 WM_WINDOWPOSCHANGED 或 OnShow。 它不是 wm_size .. 并不总是在所有平台上抛出这个。 卡西欧不会在您期望的时候抛出尺寸事件。 TDS 和Symbol 都可以。
尽管 MSDN 是一个很好的信息来源,但请记住,并非所有操作系统都是一样的。 在 PPC 世界中,硬件提供商可以创建自己的操作系统,有时会错过一些事情,或者故意忽略一些事情。
我这里有一个平台(为了保护...好吧我)有一个左按钮和右按钮..当你按下它们时,你会期望能够捕捉到 VK_LEFT,VK_RIGHT ..你错了。 你实际上得到了';' 或者 ':'。 这怎么样,就像踢裤子一样。
It really depends on the platform, but I'd go with WM_WINDOWPOSCHANGED or the OnShow. It's not wm_size.. That one is not always thrown on all platforms. Casio's don't throw the size event when you'd expect them to. TDS and Symbol's do.
Even though the MSDN is a great sourse for info, remember not all OS's are created equal. In the PPC world the hardware provider gets to create their own OS and sometimes the miss things, or purposfully ignore things.
I've got a platform here (name withheld to protect... well me) that has left and right buttons.. When you press them, you'd expect to be able to catch VK_LEFT, VK_RIGHT.. You'd be wrong. You actually get ';' or ':'. How's that for a kick in the pants.