资源描述:
《全屏幕窗口的创建实验报告》由会员上传分享,免费在线阅读,更多相关内容在应用文档-天天文库。
1、实验四实验报告课程:全屏幕窗口的创建班级:2010级远程教育班专业:教育技术学(远程教育方向)实验人:XXX学号:实验时间:实验室:数字媒体实验室指导老师:XXX一、实验目的1.熟悉窗口基本创建;2.学会对窗口模式改为全屏模式;3.熟悉全屏窗口的创建;二、实验任务1.创建全屏窗口模式;三、实验过程1.源代码为:#include#include#include//definethescreenresolution(定义屏幕分辨率)#defineSCREEN_WID
2、TH800#defineSCREEN_HEIGHT600//includetheDirect3DLibraryfile#pragmacomment(lib,"d3d9.lib")//globaldeclarationsLPDIRECT3D9d3d;//thepointertoourDirect3DinterfaceLPDIRECT3DDEVICE9d3ddev;//thepointertothedeviceclass//functionprototypesvoidinitD3D(HWNDhWnd);//setsupandi
3、nitializesDirect3D(建立和初始化装置)voidrender_frame(void);//rendersasingleframevoidcleanD3D(void);//closesDirect3Dandreleasesmemory//theWindowProcfunctionprototypeLRESULTCALLBACKWindowProc(HWNDhWnd,UINTmessage,WPARAMwParam,LPARAMlParam);//theentrypointforanyWindowsprogra
4、m(入口点的任何窗口程序)intWINAPIWinMain(HINSTANCEhInstance,HINSTANCEhPrevInstance,LPSTRlpCmdLine,intnCmdShow){HWNDhWnd;WNDCLASSEXwc;ZeroMemory(&wc,sizeof(WNDCLASSEX));wc.cbSize=sizeof(WNDCLASSEX);wc.style=CS_HREDRAW
5、CS_VREDRAW;wc.lpfnWndProc=WindowProc;wc.hInstance=hInstanc
6、e;wc.hCursor=LoadCursor(NULL,IDC_ARROW);WS_EX_TOPMOST
7、WS_POPUP为全屏模式,WS_OVERLAPPEDWINDOW为窗口模式//wc.hbrBackground=(HBRUSH)COLOR_WINDOW;//notneededanymorewc.lpszClassName=L"WindowClass";RegisterClassEx(&wc);hWnd=CreateWindowEx(NULL,L"WindowClass",L"OurDirect3DProgram"
8、,WS_EX_TOPMOST
9、WS_POPUP,//全屏模式的代码0,0,//thestartingxandypositionsshouldbe0SCREEN_WIDTH,SCREEN_HEIGHT,//setthewindowto640x480(设置窗口为×)NULL,NULL,hInstance,NULL);ShowWindow(hWnd,nCmdShow);//setupandinitializeDirect3DinitD3D(hWnd);//enterthemainloop:MSGmsg;while(TRUE){w
10、hile(PeekMessage(&msg,NULL,0,0,PM_REMOVE)){TranslateMessage(&msg);DispatchMessage(&msg);}if(msg.message==WM_QUIT)break;render_frame();}//cleanupDirectXandCOMcleanD3D();returnmsg.wParam;}//thisisthemainmessagehandlerfortheprogram(这是主要的消息处理程序)LRESULTCALLBACKWindowPr
11、oc(HWNDhWnd,UINTmessage,WPARAMwParam,LPARAMlParam){switch(message){caseWM_DESTROY:{PostQuitMessage(0);return0;}break;}returnDefWindowProc(hWnd,message,w