Esempio n. 1
0
CMonitor CMonitors::GetNearestMonitor( const LPRECT lprc )
{
	CMonitor monitor;
	monitor.Attach( ::MonitorFromRect( lprc, MONITOR_DEFAULTTONEAREST ) );

	return monitor;
}
Esempio n. 2
0
CMonitor CMonitors::GetNearestMonitor( const POINT pt )
{
	CMonitor monitor;
	monitor.Attach( ::MonitorFromPoint( pt, MONITOR_DEFAULTTONEAREST ) );

	return monitor;
}
Esempio n. 3
0
CMonitor CMonitors::GetNearestMonitor( const CWnd* pWnd )
{
	ASSERT( pWnd );
	ASSERT( ::IsWindow( pWnd->m_hWnd ) );

	CMonitor monitor;
	monitor.Attach( ::MonitorFromWindow( pWnd->GetSafeHwnd(), MONITOR_DEFAULTTONEAREST ) );

	return monitor;
}
Esempio n. 4
0
CMonitor CMonitors::GetPrimaryMonitor()
{
	HMONITOR hMonitor = ::MonitorFromPoint( CPoint( 0,0 ), MONITOR_DEFAULTTOPRIMARY );
	ASSERT( IsMonitor( hMonitor ) );

	CMonitor monitor;
	monitor.Attach( hMonitor );
	ASSERT( monitor.IsPrimaryMonitor() );

	return monitor;
}
Esempio n. 5
0
//
// returns the primary monitor
CMonitor CMonitors::GetPrimaryMonitor()
{
	//the primary monitor always has its origin at 0,0
	HMONITOR hMonitor = ::MonitorFromPoint( CPoint( 0,0 ), MONITOR_DEFAULTTOPRIMARY );
	ASSERT( IsMonitor( hMonitor ) );

	CMonitor monitor;
	monitor.Attach( hMonitor );
	ASSERT( monitor.IsPrimaryMonitor() );

	return monitor;
}
Esempio n. 6
0
BOOL CALLBACK CMonitors::AddMonitorsCallBack( HMONITOR hMonitor, HDC hdcMonitor, LPRECT lprcMonitor, LPARAM dwData )
{
	LPADDMONITOR pAddMonitor = (LPADDMONITOR)dwData;

	CMonitor* pMonitor = DNew CMonitor;
	pMonitor->Attach( hMonitor );

	pAddMonitor->pMonitors->Add( pMonitor );
	pAddMonitor->currentIndex++;

	return TRUE;
}
Esempio n. 7
0
void CPPageFullscreen::OnUpdateSetFullscreenRes()
{
	CMonitor curmonitor;
	CMonitors monitors;
	CString strCurMon;
	curmonitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
	curmonitor.GetName(strCurMon);
	if (m_iMonitorTypeCtrl.GetCurSel() == 0) {
		m_iMonitorTypeCtrl.SetCurSel(iCurMon);
		m_f_hmonitor = strCurMon;
	}

	SetModified();
}
Esempio n. 8
0
static BOOL CALLBACK /*CMonitors::*/ AddMonitorsCallBack(HMONITOR hMonitor, 
											 HDC /*hdcMonitor*/, 
											 LPRECT /*lprcMonitor*/, 
											 LPARAM dwData )
{
	LPADDMONITOR pAddMonitor = (LPADDMONITOR)dwData;

	CMonitor* pMonitor = new CMonitor;
	pMonitor->Attach( hMonitor );

	//CString str;
	//str.Format("currentIndex=%d  GetSize=%d", pAddMonitor->currentIndex, pAddMonitor->pMonitors->GetSize());
	//AfxMessageBox(str);
	//ASSERT((pAddMonitor->currentIndex >= 0) && (pAddMonitor->currentIndex < pAddMonitor->pMonitors->GetSize()));

	if (pAddMonitor->currentIndex < pAddMonitor->pMonitors->GetSize())
	{
		pAddMonitor->pMonitors->SetAt( pAddMonitor->currentIndex, pMonitor );
		pAddMonitor->currentIndex++;
	}

	return TRUE;
}
Esempio n. 9
0
void CPPageFullscreen::OnUpdateFullScrCombo()
{
	CMonitors monitors;
	CMonitor curmonitor;
	CString str, strCurMonID, strCurMon;
	str = m_MonitorDisplayNames[m_iMonitorTypeCtrl.GetCurSel()];
	if (str.GetLength() == 14) { m_f_hmonitor = str.Left(7); }
	if (str.GetLength() == 19) { m_f_hmonitor = str.Left(12); }
	strCurMonID = str.Right(7);
	curmonitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
	curmonitor.GetName(strCurMon);

	if (m_f_hmonitor == _T("Current") && m_AutoChangeFullscrRes.bEnabled > 0) {
		m_f_hmonitor = strCurMon;
	}

	if (m_f_hmonitor != _T("Current") && m_f_hmonitor != strCurMon) {
 		m_AutoChangeFullscrRes.bEnabled = false;
 	}

	ModesUpdate();
	SetModified();
}
Esempio n. 10
0
bool CBIServer::onStartup(string logconf, string logfile)
{
	CBaseServer::onStartup(logconf, logfile);

	//初始化启动参数
	char g_szExePath[512] = { 0 };
	GetExePath(g_szExePath, 512);
	char szConfile[256] = { 0 };
	sprintf(szConfile, "%ssconf.lua", g_szExePath);
	if (!LuaEngine.LoadLuaFile(szConfile))
	{
		Log.Error("[CBIServer] Load sconf.lua Error");
		return false;
	}

	//读取启动参数
	const char* centralip = LuaEngine.GetLuaVariableString("CentralServer_ip", "Sconf");
	int centralid = LuaEngine.GetLuaVariableNumber("CentralServer_id", "Sconf");
	int centralport = LuaEngine.GetLuaVariableNumber("CentralServer_port", "Sconf");
	const char* myip = LuaEngine.GetLuaVariableString("BIServer_ip", "Sconf");
	int myid = LuaEngine.GetLuaVariableNumber("BIServer_id", "Sconf");
	int myport = LuaEngine.GetLuaVariableNumber("BIServer_port", "Sconf");
	const char* eventdbip = LuaEngine.GetLuaVariableString("db_event_ip", "Sconf");
	const char* eventdbname = LuaEngine.GetLuaVariableString("db_event_name", "Sconf");
	const char* eventdbport = LuaEngine.GetLuaVariableString("db_event_port", "Sconf");
	int worldID = LuaEngine.GetLuaVariableNumber("WorldID", "Sconf");
	int connmax = LuaEngine.GetLuaVariableNumber("connect_count_max", "BIServer");
	int packsize = LuaEngine.GetLuaVariableNumber("packet_pool_size", "BIServer");
	int recvsize = LuaEngine.GetLuaVariableNumber("recv_buff_size", "BIServer");
	int sendsize = LuaEngine.GetLuaVariableNumber("send_buff_size", "BIServer");
	int dboperator = LuaEngine.GetLuaVariableNumber("db_operator_max", "BIServer");
	const char* udPath = LuaEngine.GetLuaVariableString("MonitorPath", "Key");

	//初始化
	char mpath[1024] = { 0 };
	sprintf(mpath, "%s//FPS_%d.sock", udPath, myid);
	this->initialize(worldID, CBaseServer::Linker_Server_DataAnalysis, myid, myport, myip, 0, NULL, mpath);

	CNetwork* servernet = (CNetwork *)this->createPlugin(CBaseServer::Plugin_Net4Server);
	if (!servernet->startup(CNet::NET_IO_SELECT, myport, connmax, sendsize, recvsize, packsize)) {
		Log.Error("[CBIServer] create Plugin_Net4Server failed");
		return false;
	}

	CMongoDB* db = (CMongoDB *)this->createPlugin(CBaseServer::Plugin_Mongodb);
	if (!db->startup(eventdbip, eventdbport, eventdbname)) {
		Log.Error("[CBIServer] create plugin CMongoDB failed");
		return false;
	}

	char spath[1024] = { 0 };
	sprintf(spath, "%s//Server_%d.sock", udPath, myid);
	CMonitor* monitor = (CMonitor *)this->createPlugin(CBaseServer::Plugin_Monitor);
	if (!monitor->startup(spath)) {
		Log.Error("[CBIServer] create Plugin_Monitor failed");
		return false;
	}

	if (!this->createLinker(CBaseServer::Linker_Server_Central, centralid, centralport, centralip, 0, NULL, worldID, true)) {
		Log.Error("[CBIServer] create Central Server failed");
		return false;
	}

	return true;
}
Esempio n. 11
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
}
Esempio n. 12
0
BOOL CPPageFullscreen::OnApply()
{
	UpdateData();

	AppSettings& s = AfxGetAppSettings();
	m_AutoChangeFullscrRes.bEnabled = !!m_fSetFullscreenRes;
	if (m_fSetFullscreenRes == 2) m_AutoChangeFullscrRes.bEnabled = 2;
	for (int i = 0; i < MaxFpsCount; i++) {
		int n = m_iSeldm[i];
		if (n >= 0 && (size_t)n < m_dms.GetCount() && i < m_list.GetItemCount()) {
			m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes = m_dms[n];
			m_AutoChangeFullscrRes.dmFullscreenRes[i].fChecked = !!m_list.GetCheck(i);
			m_AutoChangeFullscrRes.dmFullscreenRes[i].fIsData = true;
			m_AutoChangeFullscrRes.dmFullscreenRes[i].vfr_from = wcstod(m_list.GetItemText(i, COL_VFR_F), NULL);
			m_AutoChangeFullscrRes.dmFullscreenRes[i].vfr_to = wcstod(m_list.GetItemText(i, COL_VFR_T), NULL);
		} else {
			m_AutoChangeFullscrRes.dmFullscreenRes[i].fIsData = false;
			m_AutoChangeFullscrRes.dmFullscreenRes[i].vfr_from = 0;
			m_AutoChangeFullscrRes.dmFullscreenRes[i].vfr_to = 0;
			m_AutoChangeFullscrRes.dmFullscreenRes[i].fChecked = 0;
			m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes.bpp = 0;
			m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes.dmDisplayFlags = 0;
			m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes.freq = 0;
			m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes.fValid = 0;
			m_AutoChangeFullscrRes.dmFullscreenRes[i].dmFSRes.size = 0;
		}
	}

	m_AutoChangeFullscrRes.bApplyDefault	= !!m_fSetDefault;
	m_AutoChangeFullscrRes.bSetGlobal		= !!m_fSetGlobal;
	s.AutoChangeFullscrRes					= m_AutoChangeFullscrRes;
	s.fLaunchfullscreen						= !!m_launchfullscreen;

	CString str;
	CString strCurFSMonID;
	CString strCurMon;
	str = m_MonitorDisplayNames[m_iMonitorType];
	if (str.GetLength() == 14) { m_f_hmonitor = str.Left(7); }
	if (str.GetLength() == 19) { m_f_hmonitor = str.Left(12); }
	m_f_hmonitorID = str.Right(7);
	if (m_AutoChangeFullscrRes.bEnabled > 0 && m_f_hmonitor == _T("Current")) {
		CMonitors monitors;
		CMonitor curmonitor;
		curmonitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
		curmonitor.GetName(strCurMon);
		m_f_hmonitor = strCurMon;
	}
	if (m_AutoChangeFullscrRes.bEnabled == false && m_f_hmonitor == _T("Current")) {
		m_f_hmonitor = _T("Current");
	}
 	s.strFullScreenMonitor					= m_f_hmonitor;
	s.strFullScreenMonitorID				= m_f_hmonitorID;

	s.fShowBarsWhenFullScreen				= !!m_iShowBarsWhenFullScreen;
	s.nShowBarsWhenFullScreenTimeOut		= m_nShowBarsWhenFullScreenTimeOut;
	s.fExitFullScreenAtTheEnd				= !!m_fExitFullScreenAtTheEnd;
	s.fExitFullScreenAtFocusLost			= !!m_fExitFullScreenAtFocusLost;
	s.fRestoreResAfterExit					= !!m_fRestoreResAfterExit;

	return __super::OnApply();
}
Esempio n. 13
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_fSetGlobal						= s.AutoChangeFullscrRes.bSetGlobal;
	m_f_hmonitor						= s.strFullScreenMonitor;
	m_f_hmonitorID						= s.strFullScreenMonitorID;
	m_iShowBarsWhenFullScreen			= s.fShowBarsWhenFullScreen;
	m_nShowBarsWhenFullScreenTimeOut	= s.nShowBarsWhenFullScreenTimeOut;
	m_nTimeOutCtrl.SetRange(-1, 10);
	m_fExitFullScreenAtTheEnd			= s.fExitFullScreenAtTheEnd;
	m_fExitFullScreenAtFocusLost		= s.fExitFullScreenAtFocusLost;
	m_fRestoreResAfterExit				= s.fRestoreResAfterExit;

	CString str;
	m_iMonitorType = 0;
	CMonitor curmonitor;
	CMonitors monitors;
	CString strCurMon;

 	m_iMonitorTypeCtrl.AddString(ResStr(IDS_FULLSCREENMONITOR_CURRENT));
	m_MonitorDisplayNames.Add(_T("Current"));
	m_MonitorDeviceName.Add(_T("Current"));
	curmonitor = monitors.GetNearestMonitor(AfxGetApp()->m_pMainWnd);
	curmonitor.GetName(strCurMon);
	if(m_f_hmonitor.IsEmpty()) {
		m_f_hmonitor = _T("Current");
		m_iMonitorType = 0;
 	}

	DISPLAY_DEVICE dd;
	dd.cb = sizeof(dd);
	DWORD dev = 0; // device index
	int id = 0;
	CString str2;
	CString DeviceID;
	CString strMonID;
	while (EnumDisplayDevices(0, dev, &dd, 0)) {
        DISPLAY_DEVICE ddMon;
        ZeroMemory(&ddMon, sizeof(ddMon));
        ddMon.cb = sizeof(ddMon);
        DWORD devMon = 0;

        while (EnumDisplayDevices(dd.DeviceName, devMon, &ddMon, 0)) {
			if (ddMon.StateFlags & DISPLAY_DEVICE_ACTIVE && !(ddMon.StateFlags & DISPLAY_DEVICE_MIRRORING_DRIVER)) {
				DeviceID.Format (L"%s", ddMon.DeviceID);
                strMonID = DeviceID = DeviceID.Mid (8, DeviceID.Find (L"\\", 9) - 8);
				str.Format(L"%s", ddMon.DeviceName);
				str = str.Left(12);
				if (str == strCurMon) {
					m_iMonitorTypeCtrl.AddString(str.Mid(4, 7) + _T("( ") + str.Right(1) + _T(" ) ") + _T("- [id: ") + DeviceID + _T(" *") +  ResStr(IDS_FULLSCREENMONITOR_CURRENT) + _T("] - ") + ddMon.DeviceString);
					m_MonitorDisplayNames[0] = _T("Current") + strMonID;
					m_MonitorDeviceName[0] = str;

					if(m_f_hmonitor == _T("Current") && m_AutoChangeFullscrRes.bEnabled > 0) {
						m_iMonitorType = m_iMonitorTypeCtrl.GetCount()-1;
						m_f_hmonitor = strCurMon;
					}
					iCurMon = m_iMonitorTypeCtrl.GetCount()-1;
				} else {
					m_iMonitorTypeCtrl.AddString(str.Mid(4, 7) + _T("( ") + str.Right(1) + _T(" ) ") + _T("- [id: ") + DeviceID + _T("] - ") + ddMon.DeviceString);
				}
				m_MonitorDisplayNames.Add(str + strMonID);
				m_MonitorDeviceName.Add(str);
				if(m_iMonitorType == 0 && m_f_hmonitor == str) {
					m_iMonitorType = m_iMonitorTypeCtrl.GetCount()-1;
				}

				if (m_f_hmonitorID == strMonID  && m_f_hmonitor != _T("Current")) {
					id = m_iMonitorType = m_iMonitorTypeCtrl.GetCount()-1;
					str2 = str;
				}
            }
            devMon++;
            ZeroMemory(&ddMon, sizeof(ddMon));
            ddMon.cb = sizeof(ddMon);
        }
        ZeroMemory(&dd, sizeof(dd));
        dd.cb = sizeof(dd);
        dev++;
	}

	if(m_iMonitorTypeCtrl.GetCount() > 2) {
		if (m_MonitorDisplayNames[m_iMonitorType] != m_f_hmonitor + m_f_hmonitorID) {
			if ( id > 0 ) {
				m_iMonitorType = id;
				m_f_hmonitor = str2;
 			}
 		}
	 	GetDlgItem(IDC_COMBO1)->EnableWindow(TRUE);
 	} else {
		if(m_AutoChangeFullscrRes.bEnabled == false)  {
			m_iMonitorType = 0;
		} else {
			m_iMonitorType = 1;
 		}
 		GetDlgItem(IDC_COMBO1)->EnableWindow(FALSE);
 	}

	if (m_AutoChangeFullscrRes.bEnabled == false && (m_MonitorDisplayNames[m_iMonitorType]).Left(7) == _T("Current")){
		m_f_hmonitor = _T("Current");
 	}

	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;
}
Esempio n. 14
0
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;
}
Esempio n. 15
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
}
Esempio n. 16
0
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();
	}*/
}
Esempio n. 17
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;
		}
	}