我无法获得 LPRECT 结构数据,我做错了什么? [英] I can't get hold of LPRECT structure data, what I'm doing wrong?

查看:30
本文介绍了我无法获得 LPRECT 结构数据,我做错了什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它应该可以正常工作:

#include <iostream>
#define _WIN32_WINNT 0x501
#include <windows.h>

using namespace std;

int main() {
  HWND consoleWindow = GetConsoleWindow();
  LPRECT lpRect;
  GetWindowRect(consoleWindow,lpRect);
  cout << lpRect.top <<endl;
}

但我得到了这个:

error: request for member 'top' in 'lpRect', which is of non-class type 'LPRECT {aka tagRECT*}'

推荐答案

您的代码有误.Windows 在这里需要一个有效的 Rect.LPRECT 只是一个指针,你还没有初始化它.请像这样修改.

Your code is wrong. Windows expects a valid Rect here. LPRECT is just a pointer and you haven't initialized it. Please modify it like this.

HWND consoleWindow = GetConsoleWindow();
RECT aRect;
GetWindowRect(consoleWindow,&aRect);
cout << aRect.top <<endl;

这篇关于我无法获得 LPRECT 结构数据,我做错了什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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