aboutsummaryrefslogtreecommitdiff
path: root/src/ui
diff options
context:
space:
mode:
Diffstat (limited to 'src/ui')
-rw-r--r--src/ui/window.cpp14
-rw-r--r--src/ui/window.hpp1
2 files changed, 13 insertions, 2 deletions
diff --git a/src/ui/window.cpp b/src/ui/window.cpp
index 349b78ff..f7506f18 100644
--- a/src/ui/window.cpp
+++ b/src/ui/window.cpp
@@ -113,13 +113,23 @@ namespace cru::ui
}
}
- Window::Window() : Control(WindowConstructorTag{}, this), control_list_({ this }) {
+ Window::Window() : Window(nullptr)
+ {
+
+ }
+
+ Window::Window(Window* parent) : Control(WindowConstructorTag{}, this), control_list_({ this }) {
+
+ if (parent != nullptr && !parent->IsWindowValid())
+ throw std::runtime_error("Parent window is not valid.");
+
const auto window_manager = WindowManager::GetInstance();
hwnd_ = CreateWindowEx(0,
window_manager->GetGeneralWindowClass()->GetName(),
L"", WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT,
- nullptr, nullptr, Application::GetInstance()->GetInstanceHandle(), nullptr
+ parent == nullptr ? nullptr : parent->GetWindowHandle(),
+ nullptr, Application::GetInstance()->GetInstanceHandle(), nullptr
);
if (hwnd_ == nullptr)
diff --git a/src/ui/window.hpp b/src/ui/window.hpp
index d3e86f2d..82cbfc4f 100644
--- a/src/ui/window.hpp
+++ b/src/ui/window.hpp
@@ -90,6 +90,7 @@ namespace cru::ui
static constexpr auto control_type = L"Window";
Window();
+ explicit Window(Window* parent);
Window(const Window& other) = delete;
Window(Window&& other) = delete;
Window& operator=(const Window& other) = delete;