diff options
author | crupest <crupest@outlook.com> | 2022-01-29 21:25:15 +0800 |
---|---|---|
committer | crupest <crupest@outlook.com> | 2022-01-29 21:25:15 +0800 |
commit | a2c2089c8d97b4910d4287c14c82e20d33366c24 (patch) | |
tree | f98eca54fe1856dca136780f345da212f8e3c4c6 | |
parent | 30060773b06d93ae08a8c6fa5836c81e595594ed (diff) | |
download | cru-a2c2089c8d97b4910d4287c14c82e20d33366c24.tar.gz cru-a2c2089c8d97b4910d4287c14c82e20d33366c24.tar.bz2 cru-a2c2089c8d97b4910d4287c14c82e20d33366c24.zip |
...
-rw-r--r-- | include/cru/win/gui/Window.hpp | 2 | ||||
-rw-r--r-- | src/win/gui/Window.cpp | 8 |
2 files changed, 10 insertions, 0 deletions
diff --git a/include/cru/win/gui/Window.hpp b/include/cru/win/gui/Window.hpp index d0ea5b41..75530596 100644 --- a/include/cru/win/gui/Window.hpp +++ b/include/cru/win/gui/Window.hpp @@ -62,6 +62,8 @@ class CRU_WIN_GUI_API WinNativeWindow : public WinNativeResource, void SetCursor(std::shared_ptr<ICursor> cursor) override; + void SetToForeground() override; + IEvent<std::nullptr_t>* CreateEvent() override { return &create_event_; } IEvent<std::nullptr_t>* DestroyEvent() override { return &destroy_event_; } IEvent<std::nullptr_t>* PaintEvent() override { return &paint_event_; } diff --git a/src/win/gui/Window.cpp b/src/win/gui/Window.cpp index 2bd29476..f30b4e59 100644 --- a/src/win/gui/Window.cpp +++ b/src/win/gui/Window.cpp @@ -281,6 +281,14 @@ void WinNativeWindow::SetCursor(std::shared_ptr<ICursor> cursor) { } } +void WinNativeWindow::SetToForeground() { + if (hwnd_) { + if (!::SetForegroundWindow(hwnd_)) + throw Win32Error(::GetLastError(), + u"Failed to set window to foreground."); + } +} + IInputMethodContext* WinNativeWindow::GetInputMethodContext() { return static_cast<IInputMethodContext*>(input_method_context_.get()); } |