HINSTANCE GetInstance() const { return _hInstance; }
HWND GetRunningWindow();
protected:
HINSTANCE _hInstance;
std::string _name;
};
WinSimpleClass::WinSimpleClass(int resid, hinstance hinst) : _hInstance (hInst) {
ResString resStr (hInst, resId);
_name = resStr;
}
HWND WinSimpleClass::GetRunningWindow () {
HWND hwnd = ::FindWindow(getname(), 0);
if (::IsWindow(hwnd)) {
HWND hwndPopup = ::GetLastActivePopup(hwnd);
if (::IsWindow(hwndpopup)) hwnd = hwndPopup;
} else hwnd = 0;
return hwnd;
}
class WinClass: public WinSimpleClass {
public:
WinClass(char const* className, HINSTANCE hInst, WNDPROC wndProc);
WinClass(int resId, HINSTANCE hInst, WNDPROC wndProc);
void SetBgSysColor (int sysColor) {
_class.hbrBackground = reinterpret_cast<HBRUSH> (sysColor + 1);
}
void SetResIcons(int resId);
void Register();
protected:
void SetDefaults();
WNDCLASSEX _class;