如何让窗口独立出来,不要在主窗口里面,独立随意移动放大缩小。
```c++
static void Render(ID3D11Device* g_pd3dDevice, const ImFontAtlas* FontAtlas)
{
ImGui::SetNextWindowViewport(ImGui::GetMainViewport()->ID);
ImGui::Begin("Map", nullptr, ImGuiWindowFlags_NoBackground | ImGuiWindowFlags_NoDecoration | ImGuiWindowFlags_NoDocking | ImGuiWindowFlags_NoSavedSettings | ImGuiWindowFlags_NoCollapse | ImGuiWindowFlags_NoResize);
RECT Rect;
GetWindowRect(GameData.Config.Overlay.hWnd, &Rect);
DrawStates(Rect, FontAtlas);
if (GameData.Config.ESP.MinMap)
{
std::string MapFile = "Assets/Maps/" + GameData.MapName + ".png";
if (MapsSize[GameData.MapName].Size > 0 && GetFileAttributesA(MapFile.c_str()) != INVALID_FILE_ATTRIBUTES) {
auto Allocator = Texture::LoadTexture(g_pd3dDevice, "Assets/Maps/" + GameData.MapName + ".png");
GameData.Radar.ImageMapHeight = Allocator.Height;
static DMARender::MapTransform mTrans = DMARender::MapTransform();
if (mTrans.mapZoom < 0) {
float mapSize = fmaxf(Allocator.Width, Allocator.Height);
float screenSize = fminf(Rect.right - Rect.left, Rect.bottom - Rect.top);
mTrans.mapZoom = screenSize / mapSize;
mTrans.mapHeight = Allocator.Height;
mTrans.mapWidth = Allocator.Width;
}
auto mousePos = ImGui::GetMousePos();
static float lastMousePosX = mousePos.x;
static float lastMousePosY = mousePos.y;
if (ImGui::IsMouseDown(ImGuiMouseButton_Left) && !ImGui::GetIO().WantCaptureMouse) {
mTrans.dragOffsetX += mousePos.x - lastMousePosX;
mTrans.dragOffsetY += mousePos.y - lastMousePosY;
}
if (ImGui::GetIO().MouseWheel != 0.0f) {
float oldZoom = mTrans.mapZoom;
//Zoom in/out
mTrans.mapZoom *= (1 + (ImGui::GetIO().MouseWheel * .05));
if (mTrans.mapZoom < 0.01)
mTrans.mapZoom = 0.01;
//Zoom toward cursor
float deltaX = (Allocator.Width * oldZoom) - (Allocator.Width * mTrans.mapZoom);
float deltaY = (Allocator.Height * oldZoom) - (Allocator.Height * mTrans.mapZoom);
float percX = (mousePos.x - Rect.left - mTrans.dragOffsetX) / ((Allocator.Width * mTrans.mapZoom));
float percY = (mousePos.y - Rect.top - mTrans.dragOffsetY) / ((Allocator.Width * mTrans.mapZoom));
mTrans.dragOffsetX += (deltaX * percX);
mTrans.dragOffsetY += (deltaY * percY);
}
lastMousePosX = mousePos.x;
lastMousePosY = mousePos.y;
ImDrawList* fgDrawList = ImGui::GetBackgroundDrawList();
fgDrawList->AddImage(
Allocator.Texture,
ImVec2(
Rect.left + mTrans.dragOffsetX,
Rect.top + mTrans.dragOffsetY
),
ImVec2(
Rect.left + mTrans.dragOffsetX + (Allocator.Width * mTrans.mapZoom),
Rect.top + mTrans.dragOffsetY + (Allocator.Height * mTrans.mapZoom)
)
);
DrawOverlay(Rect, mTrans);
}
else {
DrawStates(Rect, FontAtlas);
}
}
DrawFPS(Rect);
ImGui::End();
DrawButton(Rect);
}
```