diff options
author | crupest <crupest@outlook.com> | 2018-11-10 16:36:23 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2018-11-10 16:36:23 +0800 |
commit | a46c8d05392cf07c4897f9856e35bcd3f2382b25 (patch) | |
tree | d0c26b2fdddb22f1d59922701fcb7ec7c0df67f1 /src/ui | |
parent | 6cc74c662b862599141a624af74a4d5b2881321d (diff) | |
download | cru-a46c8d05392cf07c4897f9856e35bcd3f2382b25.tar.gz cru-a46c8d05392cf07c4897f9856e35bcd3f2382b25.tar.bz2 cru-a46c8d05392cf07c4897f9856e35bcd3f2382b25.zip |
Add parent window constructor.
Diffstat (limited to 'src/ui')
-rw-r--r-- | src/ui/window.cpp | 14 | ||||
-rw-r--r-- | src/ui/window.hpp | 1 |
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; |