////////////////////////////////////////////////////////////////////////// // create BcBool OsClientWindows::create( const BcChar* pTitle, BcHandle Instance, BcU32 Width, BcU32 Height, BcBool Fullscreen, BcBool Visible ) { WNDCLASSEX wc; RECT WindowRect; WindowRect.left = (long)0; WindowRect.right = (long)Width; WindowRect.top = (long)0; WindowRect.bottom = (long)Height; hInstance_ = Instance; // Enumerate device guff. BOOL EnumSuccess = FALSE; BcU32 ModeIdx = 0; do { DEVMODEA DevMode; ZeroMemory( &DevMode, sizeof( DevMode ) ); EnumSuccess = ::EnumDisplaySettingsA( nullptr, ModeIdx++, &DevMode ); if( EnumSuccess ) { DeviceModes_.push_back( DevMode ); } } while( EnumSuccess ); BcU32 DeviceIdx = 0; do { DISPLAY_DEVICEA DisplayDevice; ZeroMemory( &DisplayDevice, sizeof( DisplayDevice ) ); EnumSuccess = ::EnumDisplayDevicesA( nullptr, DeviceIdx++, &DisplayDevice, EDD_GET_DEVICE_INTERFACE_NAME ); if( EnumSuccess ) { DisplayDevices_.push_back( DisplayDevice ); } } while( EnumSuccess ); BcU32 MonitorIdx = 0; do { MONITORINFO MonitorInfo; ZeroMemory( &MonitorInfo, sizeof( MonitorInfo ) ); EnumSuccess = ::GetMonitorInfoA( (HMONITOR)MonitorIdx, &MonitorInfo ); if( EnumSuccess ) { MonitorInfos_.push_back( MonitorInfo ); } } while( EnumSuccess ); // Generate class name. BcSPrintf( ClassName_, "PsybrusWindow_0x%x", gClassID_++ ); wc.cbSize = sizeof( WNDCLASSEX ); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC) WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = (HINSTANCE)Instance; wc.hIcon = ::LoadIcon( NULL, IDI_WINLOGO ); wc.hCursor = ::LoadCursor( NULL, IDC_ARROW ); wc.hbrBackground = (HBRUSH)( COLOR_WINDOW ); wc.lpszMenuName = NULL; wc.lpszClassName = ClassName_; wc.hIconSm = NULL; if ( !RegisterClassEx( &wc ) ) { return BcFalse; } if( Fullscreen == BcFalse ) { WindowStyleEx_ = WS_EX_WINDOWEDGE; WindowStyle_ = WS_CAPTION | WS_SYSMENU | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_MINIMIZEBOX | WS_SIZEBOX | WS_MAXIMIZEBOX; } else { WindowStyleEx_ = WS_EX_APPWINDOW; WindowStyle_ = WS_POPUP; } ::AdjustWindowRectEx( &WindowRect, WindowStyle_, FALSE, WindowStyleEx_); centreWindow( Width, Height ); // Create The Window if ( !( hWnd_= ::CreateWindowEx( WindowStyleEx_, ClassName_, pTitle, WindowStyle_, WindowSize_.left, WindowSize_.top, WindowRect.right-WindowRect.left, WindowRect.bottom-WindowRect.top, NULL, NULL, (HINSTANCE)Instance, NULL))) { return BcFalse; } // Set user data. ::SetWindowLongPtr( hWnd_, GWLP_USERDATA, (LONG_PTR)this ); // Get the device context hDC_ = GetDC( hWnd_ ); // Show the window if( Visible ) { ::ShowWindow( hWnd_, SW_SHOWNORMAL ); ::SetForegroundWindow( hWnd_ ); ::SetFocus( hWnd_ ); } return BcTrue; }
////////////////////////////////////////////////////////////////////////// // create BcBool OsClientWindows::create( const BcChar* pTitle, BcHandle Instance, BcU32 Width, BcU32 Height, BcBool Fullscreen, BcBool Visible ) { WNDCLASSEX wc; RECT WindowRect; WindowRect.left = (long)0; WindowRect.right = (long)Width; WindowRect.top = (long)0; WindowRect.bottom = (long)Height; hInstance_ = Instance; // Generate class name. BcSPrintf( ClassName_, "PsybrusWindow_0x%x", gClassID_++ ); wc.cbSize = sizeof( WNDCLASSEX ); wc.style = CS_HREDRAW | CS_VREDRAW; wc.lpfnWndProc = (WNDPROC) WndProc; wc.cbClsExtra = 0; wc.cbWndExtra = 0; wc.hInstance = (HINSTANCE)Instance; wc.hIcon = ::LoadIcon( NULL, IDI_WINLOGO ); wc.hCursor = ::LoadCursor( NULL, IDC_ARROW ); wc.hbrBackground = (HBRUSH)( COLOR_WINDOW ); wc.lpszMenuName = NULL; wc.lpszClassName = ClassName_; wc.hIconSm = NULL; if ( !RegisterClassEx( &wc ) ) { return BcFalse; } if( Fullscreen == BcFalse ) { WindowStyleEx_ = WS_EX_WINDOWEDGE; WindowStyle_ = WS_CAPTION | WS_SYSMENU | WS_CLIPSIBLINGS | WS_CLIPCHILDREN | WS_MINIMIZEBOX | WS_SIZEBOX | WS_MAXIMIZEBOX; } else { WindowStyleEx_ = WS_EX_APPWINDOW; WindowStyle_ = WS_POPUP; } ::AdjustWindowRectEx( &WindowRect, WindowStyle_, FALSE, WindowStyleEx_); centreWindow( Width, Height ); // Create The Window if ( !( hWnd_=::CreateWindowEx( WindowStyleEx_, ClassName_, pTitle, WindowStyle_, WindowSize_.left, WindowSize_.top, WindowRect.right-WindowRect.left, WindowRect.bottom-WindowRect.top, NULL, NULL, (HINSTANCE)Instance, NULL))) { return BcFalse; } // Set user data. ::SetWindowLongPtr( hWnd_, GWL_USERDATA, (LONG_PTR)this ); // Get the device context hDC_ = GetDC( hWnd_ ); // Show the window if( Visible ) { ::ShowWindow( hWnd_, SW_SHOW ); ::SetForegroundWindow( hWnd_ ); ::SetFocus( hWnd_ ); } return BcTrue; }