【问题标题】:Window Corner Coordinates in MFCMFC中的窗口角坐标
【发布时间】:2014-10-23 21:37:10
【问题描述】:

所以,我正在尝试获取我的 MFC 窗口的 CORNERS 的 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 坐标?

【问题讨论】:

    标签: c++ visual-studio-2013 mfc


    【解决方案1】:

    使用GetWindowRect 函数代替GetClientRect 函数。

    您还可以查看ScreenToClientClientToScreen 函数。

    【讨论】:

      【解决方案2】:

      向“左:”添加内容无效。使用 Format 语句构建要显示的整个字符串,如果需要长度,请使用 CString::GetLength() 方法。 (有一个 TextOut 版本可以接受不带长度参数的 CString。)

      【讨论】:

      • 我并不担心,但谢谢。你能帮我找到窗口和屏幕的角落吗?
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2011-04-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-12-31
      • 2017-06-14
      相关资源
      最近更新 更多