【Demo 0035】获取窗体状态
2011-08-26 23:09
218 查看
本章学习内容非常少就一个API(GetWindowPlacement)
1. 代码演示
//////////////////////////////////////////////////////////////////////////
BOOL CALLBACK WndEnumProc(HWND hWnd, LPARAM lParam)
{
HWND hListbox = (HWND)lParam;
if (NULL == hWnd) return FALSE;
if (NULL != hListbox && IsWindow(hListbox) && IsWindowVisible(hWnd))
{
TCHAR szWndInfo[512] = {0};
TCHAR szWndTitle[256] = {0};
TCHAR szClsName[64] = {0};
WINDOWPLACEMENT wp = {0};
wp.flags = 0;
wp.length = sizeof(wp);
RECT rtWnd, rtClient;
GetWindowRect(hWnd, &rtWnd);
GetClientRect(hWnd, &rtClient);
GetWindowText(hWnd, szWndTitle, 256);
GetClassName(hWnd, szClsName, 64);
GetWindowPlacement(hWnd, &wp);
_stprintf(szWndInfo,
_T("\"%s\"")
_T(" %d ")
_T("wnd[%d,%d,%d,%d], client[%d,%d,%d,%d], normal[%d,%d,%d,%d] min[%d, %d] max[%d, %d]"),
szWndTitle,
wp.showCmd,
rtWnd.left, rtWnd.top, rtWnd.right, rtWnd.bottom,
rtClient.left, rtClient.top, rtClient.right, rtClient.bottom,
wp.rcNormalPosition.left, wp.rcNormalPosition.top, wp.rcNormalPosition.right, wp.rcNormalPosition.bottom,
wp.ptMinPosition.x, wp.ptMinPosition.y,
wp.ptMaxPosition.x, wp.ptMaxPosition.y);
SendMessage(hListbox, LB_ADDSTRING, 0, (LPARAM)szWndInfo);
}
return TRUE;
} 2. BOOL GetWindowPlacement(HWND hWnd, WINDOWPLACEMENT *lpwndpl )
功能: 该函数返回指定窗口的显示状态以及被恢复的、最大化的和最小化的窗口位置
SW_HIDE
Hides the window and activates another window. SW_MAXIMIZEMaximizes the specified window. SW_MINIMIZEMinimizes the specified window and activates the next top-level window in the z-order. SW_RESTOREActivates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position.An application should specify this flag when restoring a minimized window. SW_SHOWActivates the window and displays it in its current size and position. SW_SHOWMAXIMIZEDActivates the window and displays it as a maximized window. SW_SHOWMINIMIZEDActivates the window and displays it as a minimized window. SW_SHOWMINNOACTIVEDisplays the window as a minimized window.
This value is similar to SW_SHOWMINIMIZED, except the window is not activated.
SW_SHOWNADisplays the window in its current size and position. This value is similar to SW_SHOW, except the window is not activated.
SW_SHOWNOACTIVATEDisplays a window in its most recent size and position.
This value is similar to SW_SHOWNORMAL, except the window is not actived.
SW_SHOWNORMAL 演示代码
1. 代码演示
//////////////////////////////////////////////////////////////////////////
BOOL CALLBACK WndEnumProc(HWND hWnd, LPARAM lParam)
{
HWND hListbox = (HWND)lParam;
if (NULL == hWnd) return FALSE;
if (NULL != hListbox && IsWindow(hListbox) && IsWindowVisible(hWnd))
{
TCHAR szWndInfo[512] = {0};
TCHAR szWndTitle[256] = {0};
TCHAR szClsName[64] = {0};
WINDOWPLACEMENT wp = {0};
wp.flags = 0;
wp.length = sizeof(wp);
RECT rtWnd, rtClient;
GetWindowRect(hWnd, &rtWnd);
GetClientRect(hWnd, &rtClient);
GetWindowText(hWnd, szWndTitle, 256);
GetClassName(hWnd, szClsName, 64);
GetWindowPlacement(hWnd, &wp);
_stprintf(szWndInfo,
_T("\"%s\"")
_T(" %d ")
_T("wnd[%d,%d,%d,%d], client[%d,%d,%d,%d], normal[%d,%d,%d,%d] min[%d, %d] max[%d, %d]"),
szWndTitle,
wp.showCmd,
rtWnd.left, rtWnd.top, rtWnd.right, rtWnd.bottom,
rtClient.left, rtClient.top, rtClient.right, rtClient.bottom,
wp.rcNormalPosition.left, wp.rcNormalPosition.top, wp.rcNormalPosition.right, wp.rcNormalPosition.bottom,
wp.ptMinPosition.x, wp.ptMinPosition.y,
wp.ptMaxPosition.x, wp.ptMaxPosition.y);
SendMessage(hListbox, LB_ADDSTRING, 0, (LPARAM)szWndInfo);
}
return TRUE;
} 2. BOOL GetWindowPlacement(HWND hWnd, WINDOWPLACEMENT *lpwndpl )
功能: 该函数返回指定窗口的显示状态以及被恢复的、最大化的和最小化的窗口位置
typedef struct _WINDOWPLACEMENT { UINT length; UINT flags; UINT showCmd; POINT ptMinPosition; POINT ptMaxPosition; RECT rcNormalPosition; } WINDOWPLACEMENT;
返回值说明:
showCmd – 直接COPY MSDN
SW_HIDE
Hides the window and activates another window. SW_MAXIMIZEMaximizes the specified window. SW_MINIMIZEMinimizes the specified window and activates the next top-level window in the z-order. SW_RESTOREActivates and displays the window. If the window is minimized or maximized, the system restores it to its original size and position.An application should specify this flag when restoring a minimized window. SW_SHOWActivates the window and displays it in its current size and position. SW_SHOWMAXIMIZEDActivates the window and displays it as a maximized window. SW_SHOWMINIMIZEDActivates the window and displays it as a minimized window. SW_SHOWMINNOACTIVEDisplays the window as a minimized window.
This value is similar to SW_SHOWMINIMIZED, except the window is not activated.
SW_SHOWNADisplays the window in its current size and position. This value is similar to SW_SHOW, except the window is not activated.
SW_SHOWNOACTIVATEDisplays a window in its most recent size and position.
This value is similar to SW_SHOWNORMAL, except the window is not actived.
SW_SHOWNORMAL 演示代码
相关文章推荐
- 其他窗体赋值给comboBox实现值的回显,并使赋的值处于选中状态(根据text获取selectedindex)
- 【Demo 0030】获取其他进程窗体信息(防SPY++)
- react demo12 (获取组件属性状态this.state)
- 获取窗体状态
- C#获取当前系统的活动窗体和状态
- 【Demo 0027】获取窗体类信息(2)
- jssdk获取微信用户网络状态,公众号用户网络状态demo实例
- 【Demo 0028】获取窗体信息
- Android获取手机存储状态
- 获取屏幕方向及键盘状态
- 安卓学习笔记--获取网络连接状态
- MFC获取窗体在设备上的相关信息,位置,设备信息等
- android获取状态栏高度
- JAVA程序获取Tomcat的运行状态
- Android 获取便携式wifi热点开关状态、热点开启与关闭
- Android 获取网络状态
- PowerShell脚本远程获取多台服务器系统状态(CPU、内存、运行服务)
- javascript 基础 获取元素并创建列表demo 2017-1-10
- android获取SD卡的状态