GUIFramework 1.1.0
Framework for desktop GUI applications in C++.
Loading...
Searching...
No Matches
ICloseable.cpp
Go to the documentation of this file.
1#include "ICloseable.h"
2
4#include "GUIFramework.h"
6
7using namespace std;
8
9namespace gui_framework
10{
11 namespace interfaces
12 {
13 ICloseable::ICloseable(HWND closeableHandle) :
14 closeableHandle(closeableHandle),
15 onClose([]() { return true; })
16 {
17
18 }
19
20 bool ICloseable::close(int exitCode)
21 {
22 dynamic_cast<BaseComposite*>(this)->setExitCode(exitCode);
23
24 return DestroyWindow(closeableHandle);
25 }
26
27 void ICloseable::setOnClose(const function<bool()>& onClose)
28 {
29 this->onClose = onClose;
30
31 onCloseFunctionName.clear();
33 }
34
35 void ICloseable::setOnClose(const string& onCloseFunctionName, const string& onCloseFunctionModuleName)
36 {
37 GUIFramework& instance = GUIFramework::get();
38 const HMODULE& module = instance.getModules().at(onCloseFunctionModuleName);
39
40 onCloseSignature tem = reinterpret_cast<onCloseSignature>(GetProcAddress(module, onCloseFunctionName.data()));
41
42 if (!tem)
43 {
45 }
46
47 onClose = tem;
48
49 this->onCloseFunctionName = onCloseFunctionName;
50 this->onCloseFunctionModuleName = onCloseFunctionModuleName;
51 }
52
53 const function<bool()>& ICloseable::getOnClose() const
54 {
55 return onClose;
56 }
57 }
58}
Base class for all windows that has children windows.
Singleton with GUIFramework settings and some functionality.
const std::unordered_map< std::string, HMODULE, localization::utility::StringViewHash, localization::utility::StringViewEqual > & getModules() const
Get all loaded modules.
static GUIFramework & get()
Singleton instance access.
virtual void setOnClose(const std::function< bool()> &onClose) final
std::function< bool()> onClose
Definition ICloseable.h:13
virtual const std::function< bool()> & getOnClose() const final
bool(*)() onCloseSignature
Default on close signature. Worked only in BaseSeparateWindow subclasses. Called if user pressed clos...