当前位置: 首页>>代码示例>>C++>>正文


C++ Kinect::setScreenRect方法代码示例

本文整理汇总了C++中Kinect::setScreenRect方法的典型用法代码示例。如果您正苦于以下问题:C++ Kinect::setScreenRect方法的具体用法?C++ Kinect::setScreenRect怎么用?C++ Kinect::setScreenRect使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Kinect的用法示例。


在下文中一共展示了Kinect::setScreenRect方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: WinMain

INT WINAPI WinMain(HINSTANCE Instance, HINSTANCE, LPSTR, INT) {
    gInstance = Instance;

    INITCOMMONCONTROLSEX icc;

    // Initialise common controls.
    icc.dwSize = sizeof(icc);
    icc.dwICC = ICC_WIN95_CLASSES;
    InitCommonControlsEx(&icc);

    // Initialize menu bar and set the check boxes' initial state
    gMainMenu = LoadMenu(Instance, "mainMenu");
    CheckMenuItem(gMainMenu, IDM_DISPLAYVIDEO, MF_BYCOMMAND | MF_CHECKED);

    const char* mainClassName = "KinectBoard";

    gKinectON = LoadIcon(Instance, "kinect1-ON");
    gKinectOFF = LoadIcon(Instance, "kinect2-OFF");

    HBRUSH mainBrush = CreateSolidBrush(RGB(0, 0, 0));

    // Define a class for our main window
    WNDCLASSEX WindowClass;
    ZeroMemory(&WindowClass, sizeof(WNDCLASSEX));
    WindowClass.cbSize        = sizeof(WNDCLASSEX);
    WindowClass.style         = 0;
    WindowClass.lpfnWndProc   = &MainProc;
    WindowClass.cbClsExtra    = 0;
    WindowClass.cbWndExtra    = 0;
    WindowClass.hInstance     = Instance;
    WindowClass.hIcon         = gKinectOFF;
    WindowClass.hCursor       = LoadCursor(nullptr, IDC_ARROW);
    WindowClass.hbrBackground = mainBrush;
    WindowClass.lpszMenuName  = "mainMenu";
    WindowClass.lpszClassName = mainClassName;
    WindowClass.hIconSm       = gKinectOFF;
    RegisterClassEx(&WindowClass);

    MSG Message;
    HACCEL hAccel;

    /* ===== Make two windows to display ===== */
    // Set the size, but not the position
    RECT winSize = {0, 0, static_cast<int>(ImageVars::width),
                    static_cast<int>(ImageVars::height)};
    AdjustWindowRect(
        &winSize,
        WS_SYSMENU | WS_CAPTION | WS_VISIBLE | WS_MINIMIZEBOX | WS_CLIPCHILDREN,
        TRUE); // window has menu

    // Create a new window to be used for the lifetime of the application
    gDisplayWindow = CreateWindowEx(0,
        mainClassName,
        "KinectBoard",
        WS_SYSMENU | WS_CAPTION | WS_VISIBLE | WS_MINIMIZEBOX | WS_CLIPCHILDREN,
        (GetSystemMetrics(SM_CXSCREEN) - (winSize.right - winSize.left)) / 2,
        (GetSystemMetrics(SM_CYSCREEN) - (winSize.bottom - winSize.top)) / 2,
        winSize.right - winSize.left, // returns image width (resized as window)
        winSize.bottom - winSize.top, // returns image height (resized as window)
        nullptr,
        gMainMenu,
        Instance,
        nullptr);
    /* ======================================= */

    // Load keyboard accelerators
    hAccel = LoadAccelerators(gInstance, "KeyAccel");

    gProjectorKnt.setScreenRect(gCurrentMonitor.dim);

    // Make window receive video stream events and image from Kinect instance
    gProjectorKnt.registerVideoWindow(gDisplayWindow);

    gProjectorKnt.startVideoStream();
    gProjectorKnt.startDepthStream();
    gProjectorKnt.enableColor(Processing::Red);
    gProjectorKnt.enableColor(Processing::Blue);

    while (GetMessage(&Message, nullptr, 0, 0) > 0) {
        if (!TranslateAccelerator(gDisplayWindow, // Handle to receiving window
                                  hAccel, // Handle to active accelerator table
                                  &Message)) // Message data
        {
            // If a message was waiting in the message queue, process it
            TranslateMessage(&Message);
            DispatchMessage(&Message);
        }
    }

    DestroyIcon(gKinectON);
    DestroyIcon(gKinectOFF);

    UnregisterClass(mainClassName, Instance);
    UnregisterClass("monitorButton", Instance);
    TestScreen::unregisterClass();

    return Message.wParam;
}
开发者ID:calcmogul,项目名称:KinectBoard,代码行数:98,代码来源:Main.cpp

示例2: MonitorCbk


//.........这里部分代码省略.........
                "BUTTON",
                (buttonText + to_string(monitor.dim.right - monitor.dim.left) +
                        " x " + to_string(monitor.dim.bottom - monitor.dim.top) +
                        " ").c_str(),
                WS_VISIBLE | WS_CHILD,
                boxWidth * (monitor.dim.left - desktopDims.left) / desktopWidth,
                boxHeight * (monitor.dim.top - desktopDims.top) / desktopHeight,
                boxWidth * (monitor.dim.right - monitor.dim.left) / desktopWidth,
                boxHeight * (monitor.dim.bottom - monitor.dim.top) / desktopHeight,
                buttonBox,
                reinterpret_cast<HMENU>(NULL),
                gInstance,
                nullptr);

            if (isButtonClicked) {
                gCurrentMonitor = monitor;
            }
        }

        return TRUE;
    }

    case WM_PARENTNOTIFY: {
        if (LOWORD(wParam) == WM_LBUTTONDOWN) {
            /* This message is only received when a button other than OK was
             * pressed in the dialog window
             */

            /* Convert cursor coordinates from dialog to desktop,
             * since the button's position is also in desktop coordinates
             */
            POINT cursorPos = {LOWORD(lParam), HIWORD(lParam)};
            MapWindowPoints(hDlg, nullptr, &cursorPos, 1);

            RECT buttonPos;

            // Change where test pattern will be drawn if button was clicked on
            for (auto& monitor : gMonitors) {
                GetWindowRect(monitor.activeButton, &buttonPos);

                // If cursor is within boundaries of button
                if (cursorPos.x > buttonPos.left &&
                    cursorPos.x < buttonPos.right &&
                    cursorPos.y > buttonPos.top &&
                    cursorPos.y < buttonPos.bottom) {
                    // Remove asterisk from previous button's text
                    SetWindowText(gCurrentMonitor.activeButton,
                            (" " + to_string(gCurrentMonitor.dim.right - gCurrentMonitor.dim.left) +
                             " x " + to_string(gCurrentMonitor.dim.bottom - gCurrentMonitor.dim.top) +
                             " ").c_str());

                    // Set new selected button
                    gCurrentMonitor = monitor;

                    // Add asterisk to new button's text
                    SetWindowText(gCurrentMonitor.activeButton,
                            ("*" + to_string(gCurrentMonitor.dim.right - gCurrentMonitor.dim.left) +
                             " x " + to_string(gCurrentMonitor.dim.bottom - gCurrentMonitor.dim.top) +
                             " ").c_str());
                }
            }
        }

        break;
    }

    case WM_COMMAND: {
        if (LOWORD(wParam) == IDOK) {
            for (auto& monitor : gMonitors) {
                DestroyWindow(monitor.activeButton);
            }
            gMonitors.clear();

            gCurrentMonitor.activeButton = nullptr;

            // Give Kinect correct monitor dimensions so mouse is moved to proper position
            gProjectorKnt.setScreenRect(gCurrentMonitor.dim);

            EndDialog(hDlg, LOWORD(wParam));
        }
        else if (LOWORD(wParam) == IDCANCEL) {
            EndDialog(hDlg , LOWORD(wParam));
        }

        break;
    }

    case WM_CLOSE: {
        EndDialog(hDlg, 0);

        break;
    }

    default: {
        return FALSE;
    }
    }

    return TRUE;
}
开发者ID:calcmogul,项目名称:KinectBoard,代码行数:101,代码来源:Main.cpp


注:本文中的Kinect::setScreenRect方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。