It's a window class that has to interact with the windows API which is not as simple as just setting a variable. Here are some of the functions I turned into variables:
void E_WINDOW::set_title( std::string title ){ SetWindowText( hWnd, title.c_str() );}std::string E_WINDOW::get_title(){ char* title = NULL; GetWindowText( hWnd, title, 256 ); return title;}void E_WINDOW::set_icon( std::string file ){ HANDLE icon = LoadImage(NULL, file.c_str(), IMAGE_ICON, 0, 0, LR_LOADFROMFILE); SendMessage(hWnd, (UINT)WM_SETICON, ICON_BIG, (LPARAM)icon); IconFileName = file;}std::string E_WINDOW::get_icon(){ return IconFileName;}void E_WINDOW::set_left( int left ){ RECT rect; GetWindowRect( hWnd, &rect ); SetWindowPos( hWnd, NULL, left, rect.top, (rect.right - rect.left), (rect.bottom - rect.top), NULL);}int E_WINDOW::get_left(){ RECT rect; GetWindowRect( hWnd, &rect ); return rect.left;}void E_WINDOW::set_top( int top ){ RECT rect; GetWindowRect( hWnd, &rect ); SetWindowPos( hWnd, NULL, rect.left, top, (rect.right - rect.left), (rect.bottom - rect.top), NULL);}int E_WINDOW::get_top(){ RECT rect; GetWindowRect( hWnd, &rect ); return rect.top;}void E_WINDOW::set_width( int width ){ RECT rect; GetWindowRect( hWnd, &rect ); SetWindowPos( hWnd, NULL, rect.left, rect.top, width, (rect.bottom - rect.top), NULL); SwapChain->Resize();}int E_WINDOW::get_width(){ RECT rect; GetWindowRect( hWnd, &rect ); return rect.right - rect.left;}void E_WINDOW::set_height( int height ){ RECT rect; GetWindowRect( hWnd, &rect ); SetWindowPos( hWnd, NULL, rect.left, rect.top, (rect.right - rect.left), height, NULL); SwapChain->Resize();}int E_WINDOW::get_height(){ RECT rect; GetWindowRect( hWnd, &rect ); return rect.bottom - rect.top;}void E_WINDOW::set_visible( bool visible ){ long style = GetWindowLongPtr(hWnd, GWL_STYLE); bool isset = !!(style & WS_VISIBLE); if (visible) { if (!isset) { SetWindowLongPtr( hWnd, GWL_STYLE, style | WS_VISIBLE ); SetWindowPos( hWnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DRAWFRAME ); } } else { if (isset) { SetWindowLongPtr( hWnd, GWL_STYLE, style & ~WS_VISIBLE ); SetWindowPos( hWnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DRAWFRAME ); } }}bool E_WINDOW::get_visible(){ long style = GetWindowLongPtr(hWnd, GWL_STYLE); bool isset = !!(style & WS_VISIBLE); return isset;}void E_WINDOW::set_maximize( bool maximize ){ long style = GetWindowLongPtr(hWnd, GWL_STYLE); bool isset = !!(style & WS_MAXIMIZEBOX); if (maximize) { if (!isset) { SetWindowLongPtr( hWnd, GWL_STYLE, style | WS_MAXIMIZEBOX ); SetWindowPos( hWnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DRAWFRAME ); } } else { if (isset) { SetWindowLongPtr( hWnd, GWL_STYLE, style & ~WS_MAXIMIZEBOX ); SetWindowPos( hWnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DRAWFRAME ); } }}bool E_WINDOW::get_maximize(){ long style = GetWindowLongPtr(hWnd, GWL_STYLE); bool isset = !!(style & WS_MAXIMIZEBOX); return isset;}void E_WINDOW::set_minimize( bool minimize ){ long style = GetWindowLongPtr(hWnd, GWL_STYLE); bool isset = !!(style & WS_MINIMIZEBOX); if (minimize) { if (!isset) { SetWindowLongPtr( hWnd, GWL_STYLE, style | WS_MINIMIZEBOX ); SetWindowPos( hWnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DRAWFRAME ); } } else { if (isset) { SetWindowLongPtr( hWnd, GWL_STYLE, style & ~WS_MINIMIZEBOX ); SetWindowPos( hWnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DRAWFRAME ); } }}bool E_WINDOW::get_minimize(){ long style = GetWindowLongPtr(hWnd, GWL_STYLE); bool isset = !!(style & WS_MINIMIZEBOX); return isset;}void E_WINDOW::set_buttons( bool buttons ){ long style = GetWindowLongPtr(hWnd, GWL_STYLE); bool isset = !!(style & WS_SYSMENU); if (buttons) { if (!isset) { SetWindowLongPtr( hWnd, GWL_STYLE, style | WS_SYSMENU ); SetWindowPos( hWnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DRAWFRAME ); } } else { if (isset) { SetWindowLongPtr( hWnd, GWL_STYLE, style & ~WS_SYSMENU ); SetWindowPos( hWnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DRAWFRAME ); } }}bool E_WINDOW::get_buttons(){ long style = GetWindowLongPtr(hWnd, GWL_STYLE); bool isset = !!(style & WS_SYSMENU); return isset;}void E_WINDOW::set_caption( bool caption ){ long style = GetWindowLongPtr(hWnd, GWL_STYLE); bool isset = !!(style & WS_CAPTION); if (caption) { if (!isset) { SetWindowLongPtr( hWnd, GWL_STYLE, style | WS_CAPTION ); SetWindowPos( hWnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DRAWFRAME ); } } else { if (isset) { SetWindowLongPtr( hWnd, GWL_STYLE, style & ~WS_CAPTION ); SetWindowPos( hWnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DRAWFRAME ); } }}bool E_WINDOW::get_caption(){ long style = GetWindowLongPtr(hWnd, GWL_STYLE); bool isset = !!(style & WS_CAPTION); return isset;}void E_WINDOW::set_opacity( float val ){ opacity = val; SetLayeredWindowAttributes( hWnd, 0, (BYTE)(255 * opacity), LWA_ALPHA );}float E_WINDOW::get_opacity(){ return opacity;}void E_WINDOW::set_size( bool size ){ long style = GetWindowLongPtr(hWnd, GWL_STYLE); bool isset = !!(style & WS_SIZEBOX); if (size) { if (!isset) { SetWindowLongPtr( hWnd, GWL_STYLE, style | WS_SIZEBOX ); SetWindowPos( hWnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DRAWFRAME ); } } else { if (isset) { SetWindowLongPtr( hWnd, GWL_STYLE, style & ~WS_SIZEBOX ); SetWindowPos( hWnd, NULL, 0, 0, 0, 0, SWP_NOZORDER | SWP_NOMOVE | SWP_NOSIZE | SWP_NOACTIVATE | SWP_DRAWFRAME ); } }}bool E_WINDOW::get_size(){ long style = GetWindowLongPtr(hWnd, GWL_STYLE); bool isset = !!(style & WS_SIZEBOX); return isset;}void E_WINDOW::set_show_cursor(bool state){ show_cursor = state; POINT MousePos; GetCursorPos(&MousePos); if ( hWnd == WindowFromPoint(MousePos) ) { if ( state ) { SetCursor(LoadCursor( NULL, IDC_ARROW )); } else { SetCursor(NULL); } }}bool E_WINDOW::get_show_cursor(){ return show_cursor;}void E_WINDOW::set_bgcolor(luabind::object color){ bgcolor = D3DXCOLOR( luabind::object_cast<float>(color[1]), luabind::object_cast<float>(color[2]), luabind::object_cast<float>(color[3]), luabind::object_cast<float>(color[4]) );}luabind::object E_WINDOW::get_bgcolor(){ luabind::object table = luabind::newtable( g_Lua ); table[1] = bgcolor.r; table[2] = bgcolor.g; table[3] = bgcolor.b; table[4] = bgcolor.a; return table;}
As you could imagine it made working with a window super easy! I also had it initialize the windows with default values which meant I only needed to set values that I wanted different then the default.