iw5-mod/src/launcher/window.hpp

29 lines
642 B
C++
Raw Normal View History

2018-12-23 07:17:08 -05:00
#pragma once
#define WM_KILL_WINDOW (WM_USER+0)
class window final
{
public:
window(const std::string& title, int width, int height);
~window();
void close();
void run() const;
2018-12-23 12:25:22 -05:00
void clear(const HDC hdc) const;
void set_callback(const std::function<LRESULT(UINT, WPARAM, LPARAM)>& callback);
2018-12-23 07:17:08 -05:00
operator HWND() const;
private:
2018-12-23 12:25:22 -05:00
ULONG_PTR token_;
2018-12-23 07:17:08 -05:00
WNDCLASSEX wc_{};
HWND handle_ = nullptr;
2018-12-23 12:25:22 -05:00
std::function<LRESULT(UINT, WPARAM, LPARAM)> callback_;
2018-12-23 07:17:08 -05:00
LRESULT CALLBACK processor(UINT message, WPARAM w_param, LPARAM l_param) const;
static LRESULT CALLBACK static_processor(HWND hwnd, UINT message, WPARAM w_param, LPARAM l_param);
};