首先是考虑全屏处理的时机,是在创建窗口时还是显示窗口时进行,若是前者,则可以:
BOOLInitInstance(HINSTANCEhInstance,
int
nCmdShow)
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
HWNDhWnd;
hInst=hInstance;//将实例句柄存储在全局变量中
UINTwidth=GetSystemMetrics(SM_CXSCREEN);
UINTheight=GetSystemMetrics(SM_CYSCREEN);
//创建窗口
hWnd=CreateWindow(
szWindowClass,
szTitle,
WS_POPUP,
0,0,
width,height,
NULL,NULL,
hInstance,
NULL);
if(!hWnd)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
returnFALSE;
}
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
returnTRUE;
}
若是在显示窗口时进行处理:
BOOLInitInstance(HINSTANCEhInstance,
int
nCmdShow)
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
HWNDhWnd;
hInst=hInstance;//将实例句柄存储在全局变量中
hWnd=CreateWindow(szWindowClass,szTitle,WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,0,CW_USEDEFAULT,0,NULL,NULL,hInstance,NULL);
if(!hWnd)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
returnFALSE;
}
HWNDhDesk;
RECTrc;
hDesk=GetDesktopWindow();
GetWindowRect(hDesk,&rc);
SetWindowLong(hWnd,GWL_STYLE,WS_BORDER);
SetWindowPos(hWnd,HWND_TOPMOST,0,0,rc.right,rc.bottom,SWP_SHOWWINDOW);
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
returnTRUE;
}
也可以让用户控制全屏的时机,比如按下”ESC“键后进入全屏
BOOLInitInstance(HINSTANCEhInstance,
int
nCmdShow)
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
HWNDhWnd;
hInst=hInstance;//将实例句柄存储在全局变量中
hWnd=CreateWindow(szWindowClass,szTitle,WS_OVERLAPPEDWINDOW,
CW_USEDEFAULT,0,CW_USEDEFAULT,0,NULL,NULL,hInstance,NULL);
if(!hWnd)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
returnFALSE;
}
ShowWindow(hWnd,nCmdShow);
UpdateWindow(hWnd);
returnTRUE;
}
在窗口处理函数中对ESC键进行处理:
switch
(message)
![ExpandedBlockStart.gif](/Images/OutliningIndicators/ExpandedBlockStart.gif)
{
caseWM_KEYDOWN:
switch(wParam)
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
caseVK_ESCAPE:
![ExpandedSubBlockStart.gif](/Images/OutliningIndicators/ExpandedSubBlockStart.gif)
![ContractedSubBlock.gif](/Images/OutliningIndicators/ContractedSubBlock.gif)
{
HWNDhDesk;
RECTrc;
hDesk=GetDesktopWindow();
GetWindowRect(hDesk,&rc);
SetWindowLong(hWnd,GWL_STYLE,WS_BORDER);
SetWindowPos(hWnd,HWND_TOPMOST,0,0,rc.right,rc.bottom,SWP_SHOWWINDOW);
}
break;
}
return0;
}
<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />