Pocket PC 上的屏幕旋转

发布于 2024-07-09 08:00:52 字数 1298 浏览 12 评论 0原文

我正在为袖珍电脑开发一个应用程序,它应该在横向模式下运行。

我编写了函数 SetScreenOrientation(int angle),它可以旋转屏幕。 该函数在应用程序启动和关闭时调用。 当我最小化/最大化方向时,我也想更改屏幕方向。 为此,我编辑了以下函数:

void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
    RECT r;
    GetWindowRect(&r);

    RECT rstatus;
    rstatus.left = 0;
    rstatus.top = 0;
    rstatus.right = r.right;
    rstatus.bottom = TOOLBAR_HEIGHT;
    m_wndStatus.MoveWindow(&rstatus, TRUE);

    RECT rcamera;
    rcamera.left = 0;
    rcamera.top = 0;
    rcamera.right = r.right;
    rcamera.bottom = r.bottom - TOOLBAR_HEIGHT;
    m_wndCameraView.MoveWindow(&rcamera, TRUE);

    if(nType == SIZE_MAXIMIZED)
    {
        CScreenOrientation::SetScreenOrientation(270);
    }
    if(nType == SIZE_MINIMIZED)
    {
        CScreenOrientation::SetScreenOrientation(0);
    }
}

问题是,当我最小化应用程序时,该函数会执行多次,因此屏幕首先旋转回 0 度,然后旋转到 270 度。

在调试时,我可以看到第二次执行该函数时,执行了以下 wincore 代码:

BOOL CWnd::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
...
switch (lpEntry->nSig)
    {
...
case AfxSig_v_u_ii:
        (this->*mmf.pfn_v_u_i_i)(static_cast<UINT>(wParam), LOWORD(lParam), HIWORD(lParam));
        break;
...
}
}

有谁知道在应用程序最小化/最大化上设置屏幕方向的任何其他方法或任何可能阻止多个函数执行的技巧?

I am developing an application for pocket PC which should run in landscape mode.

I wrote the function SetScreenOrientation(int angle), which rotates the screen. This function is called on application start and on application close. I want to change the screen orientation when I minimize/maximize orientation as well. To do this I edited the following function:

void CMainFrame::OnSize(UINT nType, int cx, int cy)
{
    RECT r;
    GetWindowRect(&r);

    RECT rstatus;
    rstatus.left = 0;
    rstatus.top = 0;
    rstatus.right = r.right;
    rstatus.bottom = TOOLBAR_HEIGHT;
    m_wndStatus.MoveWindow(&rstatus, TRUE);

    RECT rcamera;
    rcamera.left = 0;
    rcamera.top = 0;
    rcamera.right = r.right;
    rcamera.bottom = r.bottom - TOOLBAR_HEIGHT;
    m_wndCameraView.MoveWindow(&rcamera, TRUE);

    if(nType == SIZE_MAXIMIZED)
    {
        CScreenOrientation::SetScreenOrientation(270);
    }
    if(nType == SIZE_MINIMIZED)
    {
        CScreenOrientation::SetScreenOrientation(0);
    }
}

The problem is that when I minimize the application the function is executed more than once so the screen first rotates back to 0 degrees and then it rotates to 270 degrees.

While debugging I can see that the second time the function is executed the following piece of wincore code is executed:

BOOL CWnd::OnWndMsg(UINT message, WPARAM wParam, LPARAM lParam, LRESULT* pResult)
{
...
switch (lpEntry->nSig)
    {
...
case AfxSig_v_u_ii:
        (this->*mmf.pfn_v_u_i_i)(static_cast<UINT>(wParam), LOWORD(lParam), HIWORD(lParam));
        break;
...
}
}

Does anyone know any other way to set the screen orientation on application minimize/maximize or any trick that could prevent multiple function execution?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

陌生 2024-07-16 08:00:52

一方面,SetScreenOrientation 似乎会给您另一个 OnSize 通知,因此您希望检测递归调用,并且在发生这种情况时不执行任何操作。

更重要的是,你如何知道用户真正想要什么方向? 当您的应用程序启动时,您可以检查方向并保存。 但是,如果用户在您碰巧跑步时改变了方向,那么当您将其改回来时,他们将不会高兴。 也许您可以检查系统设置更改的通知并检测用户是否自行更改了方向。

For one thing, it seems likely that SetScreenOrientation is going to give you another OnSize notification, so you want to detect recursive calls and do nothing when that happens.

More importantly, how do you know what orientation the user really wants? When your application starts up you can check the orientation and save that. But if the user changed the orientation while you happened to be running, they won't be happy when you change it back. Maybe you can check notifications of system settings changes and detect if the user changed the orientation themselves.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文