浅谈【windows.h】(3)
Dimly_dust · · 个人记录
上期回顾:
- 浅谈【windows.h】(1)
-
FindWindow 函数
-
SendMessage 函数
-
WindowFromPoint 函数
- 浅谈【windows.h】(2)
-
GetCursorPos 函数
-
SetCursorPos 函数
-
ShowWindow 函数
- 功能:GetClientRect 函数获取窗口的尺寸,尺寸信息储存在REC T的right 和 bottom 两个元素中。
void GetClient()
{
HWND windows; //句柄变量,第一节中有介绍
while(true)
{
windows=FindWindow(NULL,"新建文本文档.txt - 记事本");
RECT rectangle; //矩形变量,用于记录矩形四个角的数据
GetClientRect(windows,&rectangle);
printf("%d,%d,%d,%d\n",rectangle.left,rectangle.top,rectangle.right,rectangle.bottom);
Sleep(1000);
}
}
- 功能:此函数功能类似于 GetClientRect 函数,同样是可以用来获取窗口的尺寸,但是与 GetClientRect 函数不同的是它的返回值为窗口左上角和窗口右下角顶点相对于屏幕左上角的水平/垂直距离。
void GetWin()
{
HWND windows;
while(true)
{
windows=FindWindow(NULL,"新建文本文档.txt - 记事本");
RECT rectangle;
GetWindowRect(windows,&rect);
printf("%d,%d,%d,%d\n",rectangle.left,rectangle.top,rectangle.right,rectangle.bottom);
Sleep(300);
}
}
- 功能:延迟时间(单位:毫秒)
void SleepTime(double x)
{
Sleep(x*1000);//换算,1秒=1000毫秒
}
上一篇