admin 发表于 2023-4-7 21:31:51

013-imGui窗口中的菜单Menu


郁金香灬外挂技术
       
        https://www.yjxsoft.com/
       
        本教程视频1920*1080分辩率下观看最佳
        VS2017+win10 64位 环境
        郁金香老师:扣扣 150330575
        欢迎大家参加 郁金香灬技术 游戏安全与外挂的研究学习。
       
        兴趣是我们最好的老师
        成长需要过程与循序渐进        
        兴趣+坚持+时间+优秀的教程会帮助你快速成功



学习目标:
    BeginMenuBar
        EndMenuBar       
       
        BeginMenu
        EndMenu
       
          IMGUI_API bool          MenuItem(
                const char* label, //项名字
                const char* shortcut = NULL,//
                bool selected = false,//是否选中OUT
                bool enabled = true);// return true when activated.
               
    IMGUI_API bool          MenuItem(
        const char* label,
        const char* shortcut,
        bool* p_selected,
        bool enabled = true);            // return true when activated + toggle (*p_selected) if p_selected != NULL



enum ImGuiWindowFlags_
ImGuiWindowFlags_MenuBar       
       

void CDX11::测试菜单()
{

   // Dear ImGui Tools/Apps (accessible from the "Tools" menu)
   static bool show_app_metrics = false;
   static bool show_app_debug_log = false;
   static bool show_app_stack_tool = false;
   static bool show_app_about = false;
   static bool show_app_style_editor = false;


   static bool show_app_main_menu_bar = false;
   static bool show_app_documents = false;
   static bool show_app_console = false;
   static bool show_app_log = false;
   static bool show_app_layout = false;
   static bool show_app_property_editor = false;
   static bool show_app_long_text = false;
   static bool show_app_auto_resize = false;
   static bool show_app_constrained_resize = false;
   static bool show_app_simple_overlay = false;
   static bool show_app_fullscreen = false;
   static bool show_app_window_titles = false;
   static bool show_app_custom_rendering = false;

   static bool isopen = false;
   ImGui::Text("3333 a=%d\r\n",GetTickCount());
   ImGui::Button("123##");
   ImGui::Button("123###");
   ImGui::Button("123###");
   ImGui::Button("123###");
   ImGui::Begin("Menu test window",&isopen, ImGuiWindowFlags_MenuBar);
   // Menu Bar
      if (ImGui::BeginMenuBar())
   {

         if (ImGui::BeginMenu("Examples"))
         {
            // IMGUI_DEMO_MARKER("Menu/Examples");
             ImGui::MenuItem("Main menu bar", NULL, &show_app_main_menu_bar);
          bool ispress=   ImGui::MenuItem("Console", NULL, &show_app_console);
          if (ispress)
          {
            printf("Console 被按下 show_app_console=%d \r\n", show_app_console);
          }
             ImGui::MenuItem("Log", NULL, &show_app_log);
             ImGui::MenuItem("Simple layout", NULL, &show_app_layout);
             ImGui::MenuItem("Property editor", NULL, &show_app_property_editor);
             ImGui::MenuItem("Long text display", NULL, &show_app_long_text);
             ImGui::MenuItem("Auto-resizing window", NULL, &show_app_auto_resize);
             ImGui::MenuItem("Constrained-resizing window", NULL, &show_app_constrained_resize);
             ImGui::MenuItem("Simple overlay", NULL, &show_app_simple_overlay);
             ImGui::MenuItem("Fullscreen window", NULL, &show_app_fullscreen);
             ImGui::MenuItem("Manipulating window titles", NULL, &show_app_window_titles);
             ImGui::MenuItem("Custom rendering", NULL, &show_app_custom_rendering);
             ImGui::MenuItem("Documents", NULL, &show_app_documents);
             ImGui::EndMenu();
         }
         //if (ImGui::MenuItem("MenuItem")) {} // You can also use MenuItem() inside a menu bar!
         if (ImGui::BeginMenu("Tools"))
         {
            // IMGUI_DEMO_MARKER("Menu/Tools");
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
             const bool has_debug_tools = true;
#else
             const bool has_debug_tools = false;
#endif
             ImGui::MenuItem("Metrics/Debugger", NULL, &show_app_metrics, has_debug_tools);
             ImGui::MenuItem("Debug Log", NULL, &show_app_debug_log, has_debug_tools);
             ImGui::MenuItem("Stack Tool", NULL, &show_app_stack_tool, has_debug_tools);
             ImGui::MenuItem("Style Editor", NULL, &show_app_style_editor);
             ImGui::MenuItem("About Dear ImGui", NULL, &show_app_about);
             ImGui::EndMenu();
         }

         ImGui::EndMenuBar();
   }


      //if (ImGui::MenuItem("MenuItem")) {} // You can also use MenuItem() inside a menu bar!
      if (ImGui::BeginMenu("Tools######1"))
      {
          // IMGUI_DEMO_MARKER("Menu/Tools");4
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
          const bool has_debug_tools = true;
#else
          const bool has_debug_tools = false;
#endif
          ImGui::MenuItem("Metrics/Debugger1", NULL, &show_app_metrics, has_debug_tools);
          ImGui::MenuItem("Debug Log", NULL, &show_app_debug_log, has_debug_tools);
          ImGui::MenuItem("Stack Tool", NULL, &show_app_stack_tool, has_debug_tools);
          ImGui::MenuItem("Style Editor", NULL, &show_app_style_editor);
          ImGui::MenuItem("About Dear ImGui", NULL, &show_app_about);
          ImGui::EndMenu();
      }

      if (ImGui::BeginMenu("Tools##2"))
      {
          // IMGUI_DEMO_MARKER("Menu/Tools"); 1
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
          const bool has_debug_tools = true;
#else
          const bool has_debug_tools = false;
#endif
          ImGui::MenuItem("Metrics/Debugger2", NULL, &show_app_metrics, has_debug_tools);
          ImGui::MenuItem("Debug Log", NULL, &show_app_debug_log, has_debug_tools);
          ImGui::MenuItem("Stack Tool", NULL, &show_app_stack_tool, has_debug_tools);
          ImGui::MenuItem("Style Editor", NULL, &show_app_style_editor);
          ImGui::MenuItem("About Dear ImGui", NULL, &show_app_about);
          ImGui::EndMenu();
      }

      if (ImGui::BeginMenu("Tools###3"))
      {
          // IMGUI_DEMO_MARKER("Menu/Tools");2
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
          const bool has_debug_tools = true;
#else
          const bool has_debug_tools = false;
#endif
          ImGui::MenuItem("Metrics/Debugger3", NULL, &show_app_metrics, has_debug_tools);
          ImGui::MenuItem("Debug Log", NULL, &show_app_debug_log, has_debug_tools);
          ImGui::MenuItem("Stack Tool", NULL, &show_app_stack_tool, has_debug_tools);
          ImGui::MenuItem("Style Editor", NULL, &show_app_style_editor);
          ImGui::MenuItem("About Dear ImGui", NULL, &show_app_about);
          ImGui::EndMenu();
      }

      if (ImGui::BeginMenu("Tools###4"))
      {
          // IMGUI_DEMO_MARKER("Menu/Tools");3
#ifndef IMGUI_DISABLE_DEBUG_TOOLS
          const bool has_debug_tools = true;
#else
          const bool has_debug_tools = false;
#endif
          ImGui::MenuItem("Metrics/Debugger4", NULL, &show_app_metrics, has_debug_tools);
          ImGui::MenuItem("Debug Log", NULL, &show_app_debug_log, has_debug_tools);
          ImGui::MenuItem("Stack Tool", NULL, &show_app_stack_tool, has_debug_tools);
          ImGui::MenuItem("Style Editor", NULL, &show_app_style_editor);
          ImGui::MenuItem("About Dear ImGui", NULL, &show_app_about);
          ImGui::EndMenu();
      }




   ImGui::End();


}


页: [1]
查看完整版本: 013-imGui窗口中的菜单Menu