void CLMenu::UpdatePosition(CPoint pt)
{
	if(!IsWindow(m_hWnd) || !IsWindowVisible())
	{
		return;
	}

	CMonitors monitors;
	CMonitor *monitor = monitors.GetMonitor(pt);
	if(!monitor)
	{
		return;
	}

	CRect r;
	GetWindowRect(&r);

	if(parent)
	{
		r.MoveToXY(pt.x - SHADOW_SIZE - BORDER_SIZE, pt.y - SHADOW_SIZE - BORDER_SIZE - RADIUS / 2);
	}
	else
	{
		switch(position)
		{
		case DockPositionBottom:
			{
				r.MoveToXY(pt.x - SHADOW_SIZE - BORDER_SIZE - RADIUS / 2 - ARROW_WIDTH / 2, 
					pt.y - SHADOW_SIZE - BORDER_SIZE - RADIUS - ARROW_HEIGHT - ITEM_HEIGHT * ItemCount(TRUE));
			}
			break;

		case DockPositionTop:
			{
				r.MoveToXY(pt.x - SHADOW_SIZE - BORDER_SIZE - RADIUS / 2 - ARROW_WIDTH / 2, pt.y - SHADOW_SIZE - BORDER_SIZE);
			}
			break;

		case DockPositionRight:
			{
				r.MoveToXY(pt.x - SHADOW_SIZE - BORDER_SIZE - RADIUS - ITEM_ADDITION - GetMaxItemWidth(), 
					pt.y - SHADOW_SIZE - BORDER_SIZE - RADIUS / 2 - (ITEM_HEIGHT * ItemCount(TRUE)) / 2);
			}
			break;

		case DockPositionLeft:
			{
				r.MoveToXY(pt.x - SHADOW_SIZE - BORDER_SIZE, 
					pt.y - SHADOW_SIZE - BORDER_SIZE - RADIUS / 2 - (ITEM_HEIGHT * ItemCount(TRUE)) / 2);
			}
			break;

		default:
			{
				r.MoveToXY(pt.x - SHADOW_SIZE - BORDER_SIZE, pt.y - SHADOW_SIZE - BORDER_SIZE - RADIUS / 2);
			}
			break;
		}
	}

	CRect monitorRect = monitor->Rect();
	// update position on the screen
	//int a = arrowOffset;
	//arrowOffset = 0;
	if(r.left < monitorRect.left)
	{
		/*arrowOffset = r.left - monitor->rect.left;
		if(arrowOffset < SHADOW_SIZE + RADIUS / 2)
		{
			arrowOffset = 0;
		}*/
		r.MoveToX(monitorRect.left);
	}
	if(r.top < monitorRect.top)
	{
		r.MoveToY(monitorRect.top);
	}
	if(r.bottom > monitorRect.bottom)
	{
		r.MoveToY(r.top - (r.bottom - monitorRect.bottom));
	}
	//int arrowRight = r.Width() - SHADOW_SIZE * 2 - RADIUS - ARROW_WIDTH;
	if(!parent)
	{
		if(r.right > monitorRect.right)
		{
			/*arrowOffset = r.right - monitor->rect.right;
			if(arrowOffset > arrowRight)
			{
				arrowOffset = arrowRight;
			}*/
			r.MoveToX(r.left - (r.right - monitorRect.right));
		}
	}
	else
	{
		CRect rect;
		parent->GetWindowRect(&rect);

		if(r.right > monitorRect.right)
		{
			/*arrowOffset = r.right - monitor->rect.right;
			if(arrowOffset > arrowRight)
			{
				arrowOffset = arrowRight;
			}*/
			r.MoveToX(rect.left - r.Width() + SHADOW_SIZE * 2);
		}
	}

	SetWindowPos(this, r.left, r.top, 0, 0, SWP_NOSIZE | SWP_NOZORDER | SWP_NOACTIVATE);

	/*if(a != arrowOffset)
	{
		DrawBckg();
		Draw();
	}*/
}
bool CLMenu::Popup(CLMenu *Parent, DockPosition position, int X, int Y)
{
	if(!IsWindow(m_hWnd) || IsWindowVisible())
	{
		return FALSE;
	}

	CMonitors monitors;
	CMonitor *monitor = monitors.GetMonitor(CPoint(X, Y));
	if(!monitor)
	{
		return FALSE;
	}

	CLMenu::position = position;
	parent = Parent;
	SetSelected(NULL);

	if(ItemCount(TRUE, TRUE) == 0)
	{
		return FALSE;
	}

	CRect r;

	if(parent)
	{
		r.left = X - SHADOW_SIZE - BORDER_SIZE;
		r.top = Y - SHADOW_SIZE - BORDER_SIZE - RADIUS / 2;
		r.right = r.left + SHADOW_SIZE * 2 + BORDER_SIZE * 2 + RADIUS + ITEM_ADDITION + GetMaxItemWidth();
		r.bottom = r.top + SHADOW_SIZE * 2 + BORDER_SIZE * 2 + RADIUS + ITEM_HEIGHT * ItemCount(TRUE);
	}
	else
	{
		switch(position)
		{
		case DockPositionBottom:
			{
				r.left = X - SHADOW_SIZE - BORDER_SIZE - RADIUS / 2 - ARROW_WIDTH / 2;
				r.top = Y - SHADOW_SIZE - BORDER_SIZE - RADIUS - ARROW_HEIGHT - ITEM_HEIGHT * ItemCount(TRUE);
				r.right = r.left + SHADOW_SIZE * 2 + BORDER_SIZE * 2 + RADIUS + ITEM_ADDITION + GetMaxItemWidth();
				r.bottom = Y + SHADOW_SIZE + BORDER_SIZE;
			}
			break;

		case DockPositionTop:
			{
				r.left = X - SHADOW_SIZE - BORDER_SIZE - RADIUS / 2 - ARROW_WIDTH / 2;
				r.top = Y - SHADOW_SIZE - BORDER_SIZE;
				r.right = r.left + SHADOW_SIZE * 2 + BORDER_SIZE * 2 + RADIUS + ITEM_ADDITION + GetMaxItemWidth();
				r.bottom = Y + SHADOW_SIZE + BORDER_SIZE + ARROW_HEIGHT + RADIUS + ITEM_HEIGHT * ItemCount(TRUE);
			}
			break;

		case DockPositionRight:
			{
				r.left = X - SHADOW_SIZE - BORDER_SIZE - RADIUS - ITEM_ADDITION - GetMaxItemWidth();
				r.top = Y - SHADOW_SIZE - BORDER_SIZE - RADIUS / 2 - (ITEM_HEIGHT * ItemCount(TRUE)) / 2;
				r.right = X + SHADOW_SIZE + BORDER_SIZE;
				r.bottom = r.top + SHADOW_SIZE * 2 + BORDER_SIZE * 2 + RADIUS + ITEM_HEIGHT * ItemCount(TRUE);
			}
			break;

		case DockPositionLeft:
			{
				r.left = X - SHADOW_SIZE - BORDER_SIZE;
				r.top = Y - SHADOW_SIZE - BORDER_SIZE - RADIUS / 2 - (ITEM_HEIGHT * ItemCount(TRUE)) / 2;
				r.right = X + SHADOW_SIZE + BORDER_SIZE + RADIUS + ITEM_ADDITION + GetMaxItemWidth();
				r.bottom = r.top + SHADOW_SIZE * 2 + BORDER_SIZE * 2 + RADIUS + ITEM_HEIGHT * ItemCount(TRUE);
			}
			break;

		default:
			{
				r.left = X - SHADOW_SIZE - BORDER_SIZE;
				r.top = Y - SHADOW_SIZE - BORDER_SIZE - RADIUS / 2;
				r.right = r.left + SHADOW_SIZE * 2 + BORDER_SIZE * 2 + RADIUS + ITEM_ADDITION + GetMaxItemWidth();
				r.bottom = r.top + SHADOW_SIZE * 2 + BORDER_SIZE * 2 + RADIUS + ITEM_HEIGHT * ItemCount(TRUE);
			}
			break;
		}
	}

	// update position on the screen
	CRect monitorRect = monitor->Rect();
	arrowOffset = 3;
	if(r.left < monitorRect.left)
	{
		arrowOffset = r.left - monitorRect.left;
		if(arrowOffset < SHADOW_SIZE + RADIUS / 2)
		{
			arrowOffset = 3;
		}
		r.MoveToX(monitorRect.left);
	}
	if(r.top < monitorRect.top)
	{
		r.MoveToY(monitorRect.top);
	}
	if(r.bottom > monitorRect.bottom)
	{
		r.MoveToY(r.top - (r.bottom - monitorRect.bottom));
	}
	int arrowRight = r.Width() - SHADOW_SIZE * 2 - RADIUS - ARROW_WIDTH;
	if(!parent)
	{
		if(r.right > monitorRect.right)
		{
			arrowOffset = r.right - monitorRect.right;
			if(arrowOffset > arrowRight)
			{
				arrowOffset = arrowRight - 3;
			}
			r.MoveToX(r.left - (r.right - monitorRect.right));
		}
	}
	else
	{
		CRect rect;
		parent->GetWindowRect(&rect);

		if(r.right > monitorRect.right)
		{
			arrowOffset = r.right - monitorRect.right;
			if(arrowOffset > arrowRight)
			{
				arrowOffset = arrowRight - 3;
			}
			r.MoveToX(rect.left - r.Width() + SHADOW_SIZE * 2);
		}
	}

	SetWindowPos(this, r.left, r.top, r.Width(), r.Height(), SWP_NOZORDER | SWP_NOACTIVATE);

	POSITION p = items.GetHeadPosition();
	while(p)
	{
		DrawItem(items.GetAt(p));
		items.GetNext(p);
	}

	DrawBckg();
	DrawLayer();

	tmp = new CDIB();
	tmp->Resize(dib->Width(), dib->Height());

	UpdateLayer(tmp);
	ShowWindow(SW_SHOW);

	SetTimer(TIMER_SHOW, 10, NULL);
	showStartAt = GetTickCount();

	return TRUE;
}
Example #3
0
BOOL CPPageFullscreen::OnInitDialog()
{
	__super::OnInitDialog();

	SetHandCursor(m_hWnd, IDC_COMBO1);

	AppSettings& s = AfxGetAppSettings();

	m_launchfullscreen = s.fLaunchfullscreen;
	m_AutoChangeFullscrRes = s.AutoChangeFullscrRes;
	m_fSetDefault = s.AutoChangeFullscrRes.bApplyDefault;
	m_f_hmonitor = s.strFullScreenMonitor;
	m_iShowBarsWhenFullScreen = s.fShowBarsWhenFullScreen;
	m_nShowBarsWhenFullScreenTimeOut = s.nShowBarsWhenFullScreenTimeOut;
	m_nTimeOutCtrl.SetRange(-1, 10);
	m_fExitFullScreenAtTheEnd = s.fExitFullScreenAtTheEnd;
	m_fRestoreResAfterExit = s.fRestoreResAfterExit;

	CString str;
	m_iMonitorType = 0;
	CMonitor monitor;
	CMonitors monitors;

	CString strCurMon;

	monitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
	monitor.GetName(strCurMon);

	m_iMonitorTypeCtrl.AddString(ResStr(IDS_FULLSCREENMONITOR_CURRENT));
	m_MonitorDisplayNames.Add(_T("Current"));
	if (m_f_hmonitor == _T("Current")) {
		m_iMonitorType = m_iMonitorTypeCtrl.GetCount()-1;
	}

	for ( int i = 0; i < monitors.GetCount(); i++ ) {
		monitor = monitors.GetMonitor( i );
		monitor.GetName(str);

		if (monitor.IsMonitor()) {
			DISPLAY_DEVICE displayDevice;
			ZeroMemory(&displayDevice, sizeof(displayDevice));
			displayDevice.cb = sizeof(displayDevice);
			VERIFY(EnumDisplayDevices(str, 0,  &displayDevice, 0));
			if (str == strCurMon) {
				m_iMonitorTypeCtrl.AddString(str+_T(" - [") + ResStr(IDS_FULLSCREENMONITOR_CURRENT) +_T("] - ")+ displayDevice.DeviceString);
			} else {
				m_iMonitorTypeCtrl.AddString(str+_T(" - ")+ displayDevice.DeviceString);
			}
			m_MonitorDisplayNames.Add(str);

			if (m_f_hmonitor == str && m_iMonitorType == 0) {
				m_iMonitorType = m_iMonitorTypeCtrl.GetCount()-1;
			}
		}
	}

	if (m_iMonitorTypeCtrl.GetCount() > 2) {
		GetDlgItem(IDC_COMBO1)->EnableWindow(TRUE);
	} else {
		m_iMonitorType = 0;
		GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
	}

	m_list.SetExtendedStyle(m_list.GetExtendedStyle()|LVS_EX_FULLROWSELECT|LVS_EX_DOUBLEBUFFER
							|LVS_EX_GRIDLINES|LVS_EX_BORDERSELECT|LVS_EX_ONECLICKACTIVATE|LVS_EX_CHECKBOXES|LVS_EX_FLATSB);
	m_list.InsertColumn(COL_Z, ResStr(IDS_PPAGE_FS_CLN_ON_OFF), LVCFMT_LEFT, 60);
	m_list.InsertColumn(COL_VFR_F, ResStr(IDS_PPAGE_FS_CLN_FROM_FPS), LVCFMT_RIGHT, 60);
	m_list.InsertColumn(COL_VFR_T, ResStr(IDS_PPAGE_FS_CLN_TO_FPS), LVCFMT_RIGHT, 60);
	m_list.InsertColumn(COL_SRR, ResStr(IDS_PPAGE_FS_CLN_DISPLAY_MODE), LVCFMT_LEFT, 135);

	ModesUpdate();
	UpdateData(FALSE);

	return TRUE;  // return TRUE unless you set the focus to a control
	// EXCEPTION: OCX Property Pages should return FALSE
}
Example #4
0
BOOL CPPageFullscreen::OnInitDialog()
{
    __super::OnInitDialog();

    SetHandCursor(m_hWnd, IDC_COMBO1);

    const CAppSettings& s = AfxGetAppSettings();

    m_fullScreenMonitor = s.strFullScreenMonitor;
    m_bLaunchFullscreen = s.fLaunchfullscreen;
    m_fExitFullScreenAtTheEnd = s.fExitFullScreenAtTheEnd;

    m_autoChangeFSModes = s.autoChangeFSMode.modes;
    m_bAutoChangeFSModeEnabled = s.autoChangeFSMode.bEnabled;
    m_bAutoChangeFSModeApplyDefModeAtFSExist = s.autoChangeFSMode.bApplyDefaultModeAtFSExit;
    m_bAutoChangeFSModeRestoreResAfterProgExit = s.autoChangeFSMode.bRestoreResAfterProgExit;
    m_uAutoChangeFullscrResDelay = s.autoChangeFSMode.uDelay;

    CMonitors monitors;

    CString currentMonitorName;
    monitors.GetNearestMonitor(AfxGetMainWnd()).GetName(currentMonitorName);

    m_fullScreenMonitorCtrl.AddString(ResStr(IDS_FULLSCREENMONITOR_CURRENT));
    m_monitorDisplayNames.emplace_back(_T("Current"));
    m_iFullScreenMonitor = 0;

    for (int i = 0; i < monitors.GetCount(); i++) {
        CMonitor monitor = monitors.GetMonitor(i);

        if (monitor.IsMonitor()) {
            CString monitorName;
            monitor.GetName(monitorName);

            CString str = monitorName;
            if (monitorName == currentMonitorName) {
                str.AppendFormat(_T(" - [%s]"), ResStr(IDS_FULLSCREENMONITOR_CURRENT));
            }

            DISPLAY_DEVICE displayDevice = { sizeof(displayDevice) };
            if (EnumDisplayDevices(monitorName, 0, &displayDevice, 0)) {
                str.AppendFormat(_T(" - %s"), displayDevice.DeviceString);
            }

            m_fullScreenMonitorCtrl.AddString(str);
            m_monitorDisplayNames.emplace_back(monitorName);

            if (m_fullScreenMonitor == monitorName && m_iFullScreenMonitor == 0) {
                m_iFullScreenMonitor = m_fullScreenMonitorCtrl.GetCount() - 1;
            }
        }
    }

    if (m_fullScreenMonitorCtrl.GetCount() > 2) {
        GetDlgItem(IDC_COMBO1)->EnableWindow(TRUE);
    } else {
        m_iFullScreenMonitor = 0;
        GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
    }

    m_list.SetExtendedStyle(m_list.GetExtendedStyle() | LVS_EX_FULLROWSELECT | LVS_EX_DOUBLEBUFFER
                            | LVS_EX_GRIDLINES | LVS_EX_BORDERSELECT | LVS_EX_ONECLICKACTIVATE | LVS_EX_CHECKBOXES | LVS_EX_FLATSB);
    m_list.InsertColumn(COL_N, ResStr(IDS_PPAGE_FS_CLN_ON_OFF), LVCFMT_LEFT, 60);
    m_list.InsertColumn(COL_FRAMERATE_START, ResStr(IDS_PPAGE_FS_CLN_FROM_FPS), LVCFMT_RIGHT, 60);
    m_list.InsertColumn(COL_FRAMERATE_STOP, ResStr(IDS_PPAGE_FS_CLN_TO_FPS), LVCFMT_RIGHT, 60);
    m_list.InsertColumn(COL_DISPLAY_MODE, ResStr(IDS_PPAGE_FS_CLN_DISPLAY_MODE), LVCFMT_LEFT, 135);


    m_bHideFullscreenControls = s.bHideFullscreenControls;
    m_uHideFullscreenControlsDelay = s.uHideFullscreenControlsDelay;
    m_bHideFullscreenDockedPanels = s.bHideFullscreenDockedPanels;

    auto addHidePolicy = [&](LPCTSTR lpszName, CAppSettings::HideFullscreenControlsPolicy ePolicy) {
        int n = m_hidePolicy.InsertString(-1, lpszName);
        if (n >= 0) {
            VERIFY(m_hidePolicy.SetItemData(n, static_cast<DWORD_PTR>(ePolicy)) != CB_ERR);
            if (ePolicy == s.eHideFullscreenControlsPolicy) {
                VERIFY(m_hidePolicy.SetCurSel(n) == n);
            }
        } else {
            ASSERT(FALSE);
        }
    };
    auto loadString = [&](UINT nID) {
        CString ret;
        VERIFY(ret.LoadString(nID));
        return ret;
    };
    addHidePolicy(loadString(IDS_PPAGEFULLSCREEN_SHOWNEVER), CAppSettings::HideFullscreenControlsPolicy::SHOW_NEVER);
    addHidePolicy(loadString(IDS_PPAGEFULLSCREEN_SHOWMOVED), CAppSettings::HideFullscreenControlsPolicy::SHOW_WHEN_CURSOR_MOVED);
    addHidePolicy(loadString(IDS_PPAGEFULLSCREEN_SHOHHOVERED), CAppSettings::HideFullscreenControlsPolicy::SHOW_WHEN_HOVERED);

    m_delaySpinner.SetRange32(0, 9);

    CorrectComboListWidth(m_fullScreenMonitorCtrl);
    CorrectComboListWidth(m_hidePolicy);
    CorrectComboBoxHeaderWidth(GetDlgItem(IDC_CHECK2));
    CorrectComboBoxHeaderWidth(GetDlgItem(IDC_CHECK4));

    ModesUpdate();

    EnableToolTips(TRUE);

    UpdateData(FALSE);

    return TRUE;  // return TRUE unless you set the focus to a control
    // EXCEPTION: OCX Property Pages should return FALSE
}
Example #5
0
BOOL CPPageOutput::OnInitDialog()
{
	__super::OnInitDialog();

	AppSettings& s = AfxGetAppSettings();

	m_iDSVideoRendererType	= s.iDSVideoRendererType;
	m_iRMVideoRendererType	= s.iRMVideoRendererType;
	m_iQTVideoRendererType	= s.iQTVideoRendererType;
	m_iAPSurfaceUsage		= s.iAPSurfaceUsage;
	m_fVMRSyncFix			= s.fVMRSyncFix;
	m_iDX9Resizer			= s.iDX9Resizer;
	m_fVMR9MixerMode		= s.fVMR9MixerMode;
	m_fVMR9MixerYUV			= s.fVMR9MixerYUV;
	m_fD3DFullscreen		= s.fD3DFullscreen;
	m_iEvrBuffers			= s.iEvrBuffers-3;

	// Multi-Monitor code
	CString str;
	m_iMonitorType = 0;

	CMonitor monitor;
	CMonitors monitors;

	m_iMonitorTypeCtrl.AddString(ResStr(IDS_FULLSCREENMONITOR_CURRENT));
	m_MonitorDisplayNames.Add(_T("Current"));
	if(s.f_hmonitor == _T("Current"))
	{
		m_iMonitorType = m_iMonitorTypeCtrl.GetCount()-1;
	}

	for ( int i = 0; i < monitors.GetCount(); i++ )
	{
		monitor = monitors.GetMonitor( i );
		monitor.GetName(str);
		
		if(monitor.IsMonitor())
		{
			DISPLAY_DEVICE displayDevice;
			ZeroMemory(&displayDevice, sizeof(displayDevice));
			displayDevice.cb = sizeof(displayDevice);
			VERIFY(EnumDisplayDevices(str, 0,  &displayDevice, 0));
						
			m_iMonitorTypeCtrl.AddString(str+_T(" - ")+displayDevice.DeviceString);
			m_MonitorDisplayNames.Add(str);
			
			if(s.f_hmonitor == str && m_iMonitorType == 0)
			{
				m_iMonitorType = m_iMonitorTypeCtrl.GetCount()-1;
			}
		}
	}

	//(m_iMonitorTypeCtrl.GetCount() > 2)	? {GetDlgItem(IDC_COMBO2)->EnableWindow(TRUE)} : GetDlgItem(IDC_COMBO2)->EnableWindow(FALSE);
	if(m_iMonitorTypeCtrl.GetCount() > 2)
	{
		GetDlgItem(IDC_COMBO2)->EnableWindow(TRUE);
	}
	else
	{
		m_iMonitorType = 0;
		GetDlgItem(IDC_COMBO2)->EnableWindow(FALSE);
	}

	m_AudioRendererDisplayNames.Add(_T(""));
	m_iAudioRendererTypeCtrl.AddString(_T("System Default"));
	m_iAudioRendererType = 0;

	BeginEnumSysDev(CLSID_AudioRendererCategory, pMoniker)
	{
		LPOLESTR olestr = NULL;
		if(FAILED(pMoniker->GetDisplayName(0, 0, &olestr)))
			continue;

		CStringW str(olestr);
		CoTaskMemFree(olestr);

		m_AudioRendererDisplayNames.Add(CString(str));

		CComPtr<IPropertyBag> pPB;
		if(SUCCEEDED(pMoniker->BindToStorage(0, 0, IID_IPropertyBag, (void**)&pPB)))
		{
			CComVariant var;
			pPB->Read(CComBSTR(_T("FriendlyName")), &var, NULL);

			CString fstr(var.bstrVal);

			var.Clear();
			if(SUCCEEDED(pPB->Read(CComBSTR(_T("FilterData")), &var, NULL)))
			{			
				BSTR* pbstr;
				if(SUCCEEDED(SafeArrayAccessData(var.parray, (void**)&pbstr)))
				{
					fstr.Format(_T("%s (%08x)"), CString(fstr), *((DWORD*)pbstr + 1));
					SafeArrayUnaccessData(var.parray);
				}
			}

			m_iAudioRendererTypeCtrl.AddString(fstr);
		}
		else
		{
			m_iAudioRendererTypeCtrl.AddString(CString(str));
		}

		if(s.AudioRendererDisplayName == str && m_iAudioRendererType == 0)
		{
			m_iAudioRendererType = m_iAudioRendererTypeCtrl.GetCount()-1;
		}
	}