跳到正文

个人记录

浅谈【windows.h】(3)

Dimly_dust约 3 分钟
原文
文章信息与版本

文章信息

收录
2025年12月12日
更新
2026年6月9日
篇幅
约 3 分钟

版本

  1. v2当前
  2. v1

上期回顾:

  1. 浅谈【windows.h】(1)
  • FindWindow 函数

  • SendMessage 函数

  • WindowFromPoint 函数

  1. 浅谈【windows.h】(2)
  • GetCursorPos 函数

  • SetCursorPos 函数

  • ShowWindow 函数


  1.  ~GetClientRect
  • 功能:GetClientRect 函数获取窗口的尺寸,尺寸信息储存在REC T的right 和 bottom 两个元素中。
C++
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);
	}
}
  1.  ~GetCWindowRect
  • 功能:此函数功能类似于 GetClientRect 函数,同样是可以用来获取窗口的尺寸,但是与 GetClientRect 函数不同的是它的返回值为窗口左上角和窗口右下角顶点相对于屏幕左上角的水平/垂直距离。
C++
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);
	}

}
  1.  ~Sleep
  • 功能:延迟时间(单位:毫秒)
C++
void SleepTime(double x)
{
	Sleep(x*1000);//换算,1秒=1000毫秒
}

上一篇    ~~~~下一篇

原文
存档评论1 条抓取于