development/Common/Utility/source/Win32/ProcHandler.cpp
//--------------------------------------------------------------------------------------------------
// this will create window of safe default size and center it on primary monitor
this will create window of safe default size and center it on primary monitor
this will create window of safe default size and center it on primary monitor
yaget::app::WindowAppearance MakeSafeConfiguration(HWND hWnd, const yaget::dev::Configuration::Init* init)
    {
        using namespace yaget;
        const app::SysDisplays sysDisplays;
        const auto& primary = sysDisplays.FindPrimary();
        app::WindowAppearance windowAppearance{ app::Appearance::Window, SafeResolutionX, SafeResolutionY, primary.mIndex };
        if (init)
        {
            UpdateFromCLO(windowAppearance, *init);
        }
        if (windowAppearance.mAppearance == app::Appearance::Fullscreen)
        {
            if (!init || !init->mCLO.IsResValid())
            {
                windowAppearance.mResX = primary.Width();
                windowAppearance.mResY = primary.Height();
            }
            windowAppearance.mLeft = primary.GetRect()->left;
            windowAppearance.mTop = primary.GetRect()->top;
            windowAppearance.mRight = windowAppearance.mLeft + windowAppearance.mResX;
            windowAppearance.mBottom = windowAppearance.mTop + windowAppearance.mResY;
        }
        else
        {
            const auto& frameSize = CalculateWindowFrame(hWnd, windowAppearance.mResX, windowAppearance.mResY);
            windowAppearance.mLeft = (primary.WorkWidth()/2) - (std::get<0>(frameSize)/2);
            windowAppearance.mTop = (primary.WorkHeight()/2) - (std::get<1>(frameSize)/2);
            windowAppearance.mRight = windowAppearance.mLeft + std::get<0>(frameSize);
            windowAppearance.mBottom = windowAppearance.mTop + std::get<1>(frameSize);
        }
        return windowAppearance;
    }
yaget :: app :: WindowAppearance MakeSafeConfiguration ( HWND hWnd , const yaget :: dev :: Configuration :: Init * init ) { using namespace yaget ; const app :: SysDisplays sysDisplays ; const auto & primary = sysDisplays . FindPrimary ( ) ; app :: WindowAppearance windowAppearance { app :: Appearance :: Window , SafeResolutionX , SafeResolutionY , primary . mIndex } ; if ( init ) { UpdateFromCLO ( windowAppearance , * init ) ; } if ( windowAppearance . mAppearance == app :: Appearance :: Fullscreen ) { if ( ! init || ! init -> mCLO . IsResValid ( ) ) { windowAppearance . mResX = primary . Width ( ) ; windowAppearance . mResY = primary . Height ( ) ; } windowAppearance . mLeft = primary . GetRect ( ) -> left ; windowAppearance . mTop = primary . GetRect ( ) -> top ; windowAppearance . mRight = windowAppearance . mLeft + windowAppearance . mResX ; windowAppearance . mBottom = windowAppearance . mTop + windowAppearance . mResY ; } else { const auto & frameSize = CalculateWindowFrame ( hWnd , windowAppearance . mResX , windowAppearance . mResY ) ; windowAppearance . mLeft = ( primary . WorkWidth ( ) / 2 ) - ( std :: get < 0 > ( frameSize ) / 2 ) ; windowAppearance . mTop = ( primary . WorkHeight ( ) / 2 ) - ( std :: get < 1 > ( frameSize ) / 2 ) ; windowAppearance . mRight = windowAppearance . mLeft + std :: get < 0 > ( frameSize ) ; windowAppearance . mBottom = windowAppearance . mTop + std :: get < 1 > ( frameSize ) ; } return windowAppearance ; }
this will create window of safe default size and center it on primary monitor
this will create window of safe default size and center it on primary monitor
// i think left needs to be adjusted to the monitor, since the pixel position will be adjusted by where that monitor is located // in relationship to other ones // we only do this if we are in window mode, otherwise frameSize will be ResX and ResY