首先编写了CMainFrame::FullScreen()函数,
里面用SetWindowPos设置最前端显示,用SetWindowPlacement设置为全屏显示
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;
}
SetWindowPlacement ( &wpNew );

}然后再void CMainFrame::ActivateFrame(int nCmdShow)函数中初,调用FullScreen()函数但是由于我在View类中使用了DirectDraw的双缓冲方式,编写了下面的创建双缓冲内存的函数
void CMyView::CreateDoubleBuff()
{ if(FAILED(CoInitialize(NULL))) 
AfxMessageBox("初始化COM对象失败!");//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("创建DirectDraw对象失败!");//return FALSE;
}
    // 如果你用MFC,CWnd的m_hWnd成员变量指明了CWnd对象对应的窗口句柄
hr=m_plDraw->SetCooperativeLevel(m_mywhnd,DDSCL_EXCLUSIVE|DDSCL_FULLSCREEN|DDSCL_ALLOWREBOOT);//AfxGetMainWnd()->GetSafeHwnd(),必须是应用程序窗口句柄
//设置合作等级后,将现出整个程序窗口
((CMainFrame*)GetParent())->m_bFullScreen=FALSE;
((CMainFrame*)GetParent())->FullScreen(); if(FAILED(hr))
AfxMessageBox("设置合作等级出错!"); memset(&DrawSurfaceDesc,0,sizeof(DrawSurfaceDesc));//先初始化该结构中的所有参数为0,然后再细化;
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("创建后台缓冲区出错!");//return false;
DrawSurfaceDesc.ddsCaps.dwCaps = DDSCAPS_BACKBUFFER;
hr=m_plMainSurface->GetAttachedSurface(&DrawSurfaceDesc.ddsCaps,&m_plBackSurface);//获得后台缓冲区地址
}这样我的程序就没有最前端显示的功能了!
怎么回事呢?
谢谢!!
如果在程序中不调用void CMyView::CreateDoubleBuff()就可以使用程序在最前端显示了~