使用DirectDraw时,为什么不能将窗口设置为TopMost和FullScreen? [英] When I use the DirectDraw, why can't I make the window be TopMost and FullScreen?

查看:123
本文介绍了使用DirectDraw时,为什么不能将窗口设置为TopMost和FullScreen?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

首先,我编写了CMainFrame::FullScreen()函数,并使用SetWindowPos() 函数将窗口设置为TopMost,然后使用SetWindowPlacement() 函数将其显示为全屏:

First I wrote the CMainFrame::FullScreen() function and I use the SetWindowPos() function to set the window to be TopMost,and use the SetWindowPlacement() function to fullScreen:

void CMainFrame::FullScreen()
{
	RECT rectDesktop;
	WINDOWPLACEMENT wpNew;
	WINDOWPLACEMENT wpPrev;
	
	if (!m_bFullScreen)
	{
		
		
		// We''ll need these to restore the original state.
		GetWindowPlacement (&wpPrev);
		
		wpPrev.length = sizeof wpPrev;
		
		//Adjust RECT to new size of window
		::GetWindowRect ( ::GetDesktopWindow(), &rectDesktop );
		::AdjustWindowRectEx(&rectDesktop, GetStyle(), TRUE, GetExStyle());
		
		// Remember this for OnGetMinMaxInfo()
		m_rctFullScreenWindow = rectDesktop;
		
		wpNew = wpPrev;
		wpNew.showCmd =  SW_SHOWNORMAL;
		wpNew.rcNormalPosition = rectDesktop;
		
		m_bFullScreen=TRUE;
	}
	else
	{
		m_bFullScreen=FALSE;
		GetWindowPlacement (&wpPrev);
		wpNew = wpPrev;
	}
	SetWindowPos(&wndTopMost,0, 0, 0, 0, SWP_NOMOVE);
	SetWindowPlacement ( &wpNew );
	
}



然后我在CMainFrame::ActivateFrame(int nCmdShow)中使用FullScreen() .

但是在我编写下面的函数之后:



Then I use the FullScreen() in CMainFrame::ActivateFrame(int nCmdShow).

But after I write the function below:

void CMyView::CreateDoubleBuff()
{
	if(FAILED(CoInitialize(NULL))) 
		AfxMessageBox("ERROR!");//return false;
	HRESULT hr=CoCreateInstance(CLSID_DirectDraw,NULL,CLSCTX_INPROC_SERVER,IID_IDirectDraw2,(void**)&m_plDraw);
	if(!(FAILED(hr)))
	{
		hr=m_plDraw->Initialize((GUID*)NULL);
		if(hr!=DD_OK)
			AfxMessageBox("ERROR!");//return FALSE;		
	}
   	
	hr=m_plDraw->SetCooperativeLevel(m_mywhnd,DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN|DDSCL_ALLOWREBOOT;	
	((CMainFrame*)GetParent())->m_bFullScreen=FALSE;
	((CMainFrame*)GetParent())->FullScreen();
	if(FAILED(hr))
		AfxMessageBox("ERROR");
	memset(&DrawSurfaceDesc,0,sizeof(DrawSurfaceDesc));
	DrawSurfaceDesc.dwSize =sizeof(DrawSurfaceDesc);
	DrawSurfaceDesc.dwFlags = DDSD_CAPS|DDSD_BACKBUFFERCOUNT;
	DrawSurfaceDesc.ddsCaps.dwCaps= DDSCAPS_COMPLEX|DDSCAPS_FLIP|DDSCAPS_PRIMARYSURFACE;
	DrawSurfaceDesc.dwBackBufferCount = 1;
	hr=m_plDraw->CreateSurface(&DrawSurfaceDesc,(IDirectDrawSurface**)&m_plMainSurface,NULL); 
	if(FAILED(hr))
		AfxMessageBox("ERROR!");//return false;
	DrawSurfaceDesc.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
	hr=m_plMainSurface->GetAttachedSurface(&DrawSurfaceDesc.ddsCaps,&m_plBackSurface);
}



并在void CEISView::OnInitialUpdate()中使用它,那么我的窗口就不能成为TopMost!
任何想法为什么?!

非常感谢!
(对于我的英语不好,我感到抱歉).



And used it in the void CEISView::OnInitialUpdate() then my window can''t be TopMost!
Any ideas why?!

Thank you very very much!
(I am sorry for my poor English)

推荐答案

您需要将窗口样式更改为WS_EX_TOPMOST | WS_POPUP.

祝你好运!
You would need to change the window style to WS_EX_TOPMOST | WS_POPUP.

Good luck!


这篇关于使用DirectDraw时,为什么不能将窗口设置为TopMost和FullScreen?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆