aboutsummaryrefslogtreecommitdiff
path: root/src/ui/window.cpp
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2018-11-10 16:36:23 +0800
committercrupest <crupest@outlook.com>2018-11-10 16:36:23 +0800
commita46c8d05392cf07c4897f9856e35bcd3f2382b25 (patch)
treed0c26b2fdddb22f1d59922701fcb7ec7c0df67f1 /src/ui/window.cpp
parent6cc74c662b862599141a624af74a4d5b2881321d (diff)
downloadcru-a46c8d05392cf07c4897f9856e35bcd3f2382b25.tar.gz
cru-a46c8d05392cf07c4897f9856e35bcd3f2382b25.tar.bz2
cru-a46c8d05392cf07c4897f9856e35bcd3f2382b25.zip
Add parent window constructor.
Diffstat (limited to 'src/ui/window.cpp')
-rw-r--r--src/ui/window.cpp14
1 files changed, 12 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)