c++ - MFC 中的窗口角坐标

标签 c++ visual-studio-2013 mfc

所以,我正在尝试获取我的 MFC 窗口角的 x-y 坐标...

到目前为止,这是我的绘图函数:

// TODO: add draw code for native data here
RECT rect;
GetClientRect(&rect);

// Get window coordinates
int left = rect.left;
int right = rect.right;
int bottom = rect.bottom;
int top = rect.top;

// Print them out
CString l;
l.Format(L"%d", left);
pDC->TextOutW(0, 100, L"Left: " + l, _tcslen(l)+6);
CString r;
r.Format(L"%d", right);
pDC->TextOutW(0, 130, L"Right: " + r, _tcslen(r)+7);
CString b;
b.Format(L"%d", bottom);
pDC->TextOutW(0, 160, L"Bottom: " + b, _tcslen(b)+8);
CString t;
t.Format(L"%d", top);
pDC->TextOutW(0, 190, L"Top: " + t, _tcslen(t)+5);

我的方向是否正确? 我在想我可以找到两者的中点或沿着这些线的东西....

我还需要做什么?

另外:我如何获取物理显示器角的 x-y 坐标?

最佳答案

使用 GetWindowRect函数而不是 GetClientRect功能。

您还可以查看 ScreenToClientClientToScreen功能。

关于c++ - MFC 中的窗口角坐标,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/26537903/

相关文章:

c++ - MFC 日期时间选取器零值

c++ - mfc 加速器 Ctrl + 不起作用

c++ - 使用系统设置图标

c++ - 谷歌模拟 : Mock private variable member that is instantiated in target class's constructor

c++ - 您如何在 Visual Studio 中生成具有随机输出名称的 PDB 文件?

c++ - Visual Studio 2013 中的环境变量

android-emulator - Genymotion 查看本地主机站点

c++ - 位集程序 C++

c++ - UWP : WACK test failing on Windows Runtime metadata validation

visual-c++ - VS2008 : "Resource file opened in another editor"