};
WinClass::WinClass(char const * classname, HINSTANCE hInst, WNDPROC wndProc) : WinSimpleClass (className, hInst) {
_class.lpfnWndProc = wndProc;
SetDefaults();
}
WinClass::WinClass(int resid, hinstance hinst, wndproc wndproc) : WinSimpleClass (resId, hInst) {
_class.lpfnWndProc = wndProc;
SetDefaults();
}
void WinClass::SetDefaults () {
// Provide reasonable default values
_class.cbSize = sizeof (WNDCLASSEX);
_class.style = 0;
_class.lpszClassName = GetName();
_class.hInstance = GetInstance();
_class.hIcon = 0;
_class.hIconSm = 0;
_class.lpszMenuName = 0;
_class.cbClsExtra = 0;
_class.cbWndExtra = 0;
_class.hbrBackground = reinterpret_cast<HBRUSH>(COLOR_WINDOW + 1);
_class.hCursor = ::LoadCursor(0, IDC_ARROW);
}
void WinClass::SetResIcons (int resid) {
_class.hIcon = reinterpret_cast<HICON>(::LoadImage(_class.hInstance, MAKEINTRESOURCE(resId), IMAGE_ICON, ::GetSystemMetrics(sm_cxicon), ::GetSystemMetrics(sm_cyicon), 0));
// Small icon can be loaded from the same resource
_class.hIconSm = reinterpret_cast<HICON>(::LoadImage(_class.hInstance, MAKEINTRESOURCE(resId), IMAGE_ICON, :: GetSystemMetrics(sm_cxsmicon), ::GetSystemMetrics(sm_cysmicon), 0));
}
void WinClass::Register () {
if (::RegisterClassEx(&_class) == 0) throw WinException("Internal error: RegisterClassEx failed.");