io.KeyMap[ImGuiKey_Tab]=VK_TAB;// Keyboard mapping. ImGui will use those indices to peek into the io.KeyDown[] array that we will update during the application lifetime.
io.KeyMap[ImGuiKey_LeftArrow]=VK_LEFT;
io.KeyMap[ImGuiKey_RightArrow]=VK_RIGHT;
io.KeyMap[ImGuiKey_UpArrow]=VK_UP;
io.KeyMap[ImGuiKey_DownArrow]=VK_DOWN;
io.KeyMap[ImGuiKey_PageUp]=VK_PRIOR;
io.KeyMap[ImGuiKey_PageDown]=VK_NEXT;
io.KeyMap[ImGuiKey_Home]=VK_HOME;
io.KeyMap[ImGuiKey_End]=VK_END;
io.KeyMap[ImGuiKey_Insert]=VK_INSERT;
io.KeyMap[ImGuiKey_Delete]=VK_DELETE;
io.KeyMap[ImGuiKey_Backspace]=VK_BACK;
io.KeyMap[ImGuiKey_Space]=VK_SPACE;
io.KeyMap[ImGuiKey_Enter]=VK_RETURN;
io.KeyMap[ImGuiKey_Escape]=VK_ESCAPE;
io.KeyMap[ImGuiKey_A]='A';
io.KeyMap[ImGuiKey_C]='C';
io.KeyMap[ImGuiKey_V]='V';
io.KeyMap[ImGuiKey_X]='X';
io.KeyMap[ImGuiKey_Y]='Y';
io.KeyMap[ImGuiKey_Z]='Z';
io.ImeWindowHandle=g_hWnd;returntrue;
}
voidImGui_ImplWin32_Shutdown()
{
g_hWnd=(HWND)0;
}
voidImGui_ImplWin32_NewFrame()
{
ImGuiIO&io=ImGui::GetIO();
// Setup display size (every frame to accommodate for window resizing)
// io.KeysDown : filled by WM_KEYDOWN/WM_KEYUP events
// io.MousePos : filled by WM_MOUSEMOVE events
// io.MouseDown : filled by WM_*BUTTON* events
// io.MouseWheel : filled by WM_MOUSEWHEEL events
// Set OS mouse position if requested last frame by io.WantMoveMouse flag (used when io.NavMovesTrue is enabled by user and using directional navigation)
if(io.WantMoveMouse)
{
POINTpos={(int)io.MousePos.x,(int)io.MousePos.y};
ClientToScreen(g_hWnd,&pos);
SetCursorPos(pos.x,pos.y);
}
// Hide OS mouse cursor if ImGui is drawing it
if(io.MouseDrawCursor)
SetCursor(NULL);
// Start the frame. This call will update the io.WantCaptureMouse, io.WantCaptureKeyboard flag that you can use to dispatch inputs (or not) to your application.
ImGui::NewFrame();
}
// Process Win32 mouse/keyboard inputs.
// You can read the io.WantCaptureMouse, io.WantCaptureKeyboard flags to tell if dear imgui wants to use your inputs.
// - When io.WantCaptureMouse is true, do not dispatch mouse input data to your main application.
// - When io.WantCaptureKeyboard is true, do not dispatch keyboard input data to your main application.
// Generally you may always pass all inputs to dear imgui, and hide them from your application based on those two flags.
// PS: In this Win32 handler, we use the capture API (GetCapture/SetCapture/ReleaseCapture) to be able to read mouse coordinations when dragging mouse outside of our window bounds.
// PS: We treat DBLCLK messages as regular mouse down messages, so this code will work on windows classes that have the CS_DBLCLKS flag set. Our own example app code doesn't set this flag.