Home > Technology > 全屏模式的开发

全屏模式的开发

Sat, 13 Dec 2008 16:57:07 +0800
近日,在使用SDK开发全屏程序时,遇到一些奇怪的问题。

一般我们要全屏时,首先要获取屏幕最大像素,使用GetSystemMetrics可以达到目的。

int iX, iY;


iX = GetSystemMetrics(SM_CXSCREEN);
iY = GetSystemMetrics(SM_CYSCREEN);


获取当前窗口位置。其实这一步骤只是获取一个有效WINDOWPLACEMENT结构以后填充。

WINDOWPLACEMENT		wpc;


GetWindowPlacement(hWnd, &wpc);


再次,我们要设置窗口的属性不要包含WS_CAPTION和WS_THICKFRAME风格。

SetWindowLong(hWnd, GWL_STYLE, GetWindowLong(hWnd, GWL_STYLE)

& ~(WS_CAPTION|WS_THICKFRAME));


重算客户区并设置窗口新Placement:
AdjustWindowRectEx(&rc, GetWindowLong(hWnd, GWL_STYLE),

FALSE, GetWindowLong(hWnd, GWL_EXSTYLE));

wpc.rcNormalPosition = rc;
wpc.showCmd = SW_SHOWNORMAL;
SetWindowPlacement(hWnd, &wpc);


这样,全屏就完成了。当然恢复一般窗口模式就不用多说了吧,反操作就成。
有些资料说要处理WM_GETMINMAXINFO消息,这要看个人需要,你不处理也OK,处理更好。
Tag:WINDOWS
Hots
评论
发表评论:


  [TIPS:首次发表评论的朋友,需要验证]
Tags
Recent Post
Recent Comments
Links
Copyright Notes
You can reship all of these articles without permission but MUST mark the original link in your post. Please contact with me() if u have advice or other arrangements.
Copyright©2007-2011 lewphee.com All rights reserved.