如何使用 GetWindowRect [英] How to use GetWindowRect

查看:27
本文介绍了如何使用 GetWindowRect的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

考虑以下代码:

LPRECT lpRect;
GetWindowRect(hwnd, lpRect);

我不知道如何从lpRect获取信息;请指教.

I don't know how to get information from lpRect; please advise.

推荐答案

你写的是错误的.Windows API 使用可怕的变量和类型命名约定.LPRECT 的意思是指向矩形的长指针",在你通常的架构中,它只是一个RECT*.你写的是一些未初始化的指针变量,指向某个任意位置(如果你不走运,修改后会导致程序崩溃).

What you wrote is wrong. The Windows API uses a hideous variable and type naming convention. LPRECT means "Long Pointer to Rect", which on your usual architecture is just a RECT*. What you wrote is some uninitialized pointer variable, pointing at some arbitrary location (if you're unlucky something that when modified will crash your program).

这才是你真正需要的:

RECT rect;
GetWindowRect(hwnd, &rect);

RECT 本身就是一个结构

RECT itself is a structure

typedef struct _RECT {
  LONG left;
  LONG top;
  LONG right;
  LONG bottom;
} RECT;

这篇关于如何使用 GetWindowRect的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆