如何使用 GetWindowRect

编程入门 行业动态 更新时间:2024-10-24 20:12:28
本文介绍了如何使用 GetWindowRect的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

限时送ChatGPT账号..

考虑以下代码:

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屋!

更多推荐

[db:关键词]

本文发布于:2023-04-26 00:46:39,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1126836.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   GetWindowRect

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!