コード例 #1
0
ファイル: Mixer.cpp プロジェクト: victimofleisure/Fractice
bool CMixer::CreateBackBuf(CString& ErrMsg, const DISPLAY_MODE_INFO *ModeInfo)
{
	CRect	rc(0, 0, 100, 100);	// initial size is arbitrary
	LPCTSTR	ClassName = AfxRegisterWndClass(NULL, 0, NULL, 0);
	CString	WndName((LPCTSTR)IDS_EXCLUSIVE_WND_NAME);
	DWORD	dwStyle = WS_POPUP | WS_VISIBLE;
	if (!CreateEx(0, ClassName, WndName, dwStyle, rc, NULL, 0))
		return(FALSE);	// can't create our window
	if (!m_FrameDC.CreateCompatibleDC(NULL))
		return(FALSE);	// can't create frame DC
	m_FrameDefBmp = m_FrameDC.GetCurrentBitmap(); // save default bitmap
	CDDEnumObj	dev;
	CMainFrame	*pMain = theApp.GetMain();
	pMain->GetOptionsDlg().GetDisplayInfo(dev);
	dev.GetScreenCoords(m_DispRect);
	m_DispSize = m_DispRect.Size();
	if (ModeInfo == NULL) {	// if display size wasn't specified as an argument
		// verify that both image sizes match display size
		if ((m_View[CH_A] != NULL && m_View[CH_A]->GetImageSize() != m_DispSize)
		|| (m_View[CH_B] != NULL && m_View[CH_B]->GetImageSize() != m_DispSize)) {
			if (AfxMessageBox(IDS_MIX_BAD_IMAGE_SIZE, MB_OKCANCEL) != IDOK)
				return(FALSE);	// user heeded image size warning
		}
	}
	// if display device is a secondary monitor, we must pass its
	// GUID to DirectDraw to ensure proper hardware acceleration
	GUID	*pGuid = dev.m_hMonitor ? &dev.m_Guid : NULL;
	int	ErrId = 0;
	if (m_BackBuf.Create(m_hWnd, m_hWnd, pGuid, TRUE)) {
		if (ModeInfo != NULL) {
			if (m_BackBuf.GetDD()->SetDisplayMode(ModeInfo->Width,
			ModeInfo->Height, ModeInfo->BPP, 0, 0) != DD_OK) {
				ErrId = IDS_CANT_SET_DISPLAY_MODE;
				goto DDError;
			}
			m_DispSize = CSize(ModeInfo->Width, ModeInfo->Height);
		}
		if (m_BackBuf.CreateSurface(m_DispSize.cx, m_DispSize.cy)) {
			m_FrameTimer.Create(m_hWnd, FRAME_TIMER_ID, 0);
			m_FrameSize = CSize(0, 0);	// ensure frame gets created
			CRect	MainRect;
			HMONITOR	hOurMon, hMainMon;
			hOurMon = CBackBufDD::GetFullScreenRect(m_hWnd, m_DispRect);
			hMainMon = CBackBufDD::GetFullScreenRect(pMain->m_hWnd, MainRect);
			bool	SingleMon = hOurMon == hMainMon || MainRect == m_DispRect;
			m_IsDualMonitor = !SingleMon;
			m_IsExclusive = TRUE;	// success
		} else	// can't create surface
			ErrId = IDS_CANT_CREATE_SURFACE;
	} else	// can't create DirectDraw
		ErrId = IDS_CANT_CREATE_DIRECTDRAW;
DDError:
	if (ErrId) {
		CString	msg((LPCTSTR)ErrId);	// show error message
		msg += CString("\n") + m_BackBuf.GetLastErrorString();
		ErrMsg = msg;
		return(FALSE);	// DirectDraw error
	}
	return(TRUE);
}
コード例 #2
0
ファイル: IngameMenuPanel.cpp プロジェクト: niello/dem-test
void CIngameMenuPanel::Init(CEGUI::Window* pWindow)
{
	CUIWindow::Init(pWindow);

	CString WndName(pWindow->getName().c_str());

	pInventoryBtn = (CEGUI::PushButton*)pWnd->getChild("InvBtn");
	pInventoryBtn->subscribeEvent(CEGUI::PushButton::EventClicked,
		CEGUI::Event::Subscriber(&CIngameMenuPanel::OnInventoryBtnClick, this));
}