aa7481542 2024-10-11 11:03 采纳率: 16.7%
浏览 31
已结题

c++ 主窗口里面的菜单如何脱离主窗口

如何让下面这个窗口脱离主窗口,打开老是在主窗口里面,拖动拖不出来,只能在主窗口里面移动。



```c++

class Menu
{
public:
    static void DrawMain(const ImFontAtlas* FontAtlas)
    {
        ImGui::PushFont(FontAtlas->Fonts[3]);

        MenuPlayerLists::Render(FontAtlas);

        ImGui::PopFont();
        if (GameData.Config.Window.Setting)
        {
            ImGui::PushFont(FontAtlas->Fonts[2]);
            const ImVec2 Spacing = ImGui::GetStyle().ItemSpacing;
            ImGui::SetNextWindowViewport(ImGui::GetMainViewport()->ID);
            ImGui::SetNextWindowSize({ Style::Window::Size.x + Spacing.x, Style::Window::Size.y + Spacing.y });

            ImGui::Begin(U8("窗口2"), &GameData.Config.Window.Setting, ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoResize);
            {
                ImVec2 Pos = ImGui::GetWindowPos();
                ImVec2 OPos = Pos;
                Pos.x += Spacing.x / 2;
                Pos.y += Spacing.y / 2;
                
                ImGui::GetWindowDrawList()->AddRectFilled(Pos, ImVec2(Pos.x + Style::Window::Size.x, Pos.y + Style::Window::Size.y), ImGui::GetColorU32(Style::Window::Background), Style::Window::Rounding);
                
                ImGui::SetCursorPos(ImVec2(Style::Padding + Spacing.x / 2, Style::Padding));
                ImGui::PushFont(FontAtlas->Fonts[1]);
                ImGui::PopFont();

```

  • 写回答

9条回答 默认 最新

  • threenewbee 2024-10-11 11:07
    关注

    你这个当然拖动不出来,你应该使用标准的windows窗口作为菜单。

    评论

报告相同问题?

问题事件

  • 已结题 (查看结题原因) 10月11日
  • 创建了问题 10月11日