在 MFC C++中获取窗口或面板的大小

getting the size of a window or panel in MFC C++

本文关键字:窗口 MFC C++ 获取      更新时间:2023-10-16

如何在MFC C++中获取"窗口"或"面板"的大小?有功能什么的吗?

CWnd::GetWindowRect

CWnd  wnd; // the window to query
CRect wndrect;
wnd.GetWindowRect(wndrect);

从那里你可以得到

int w = wndrect.Width ();
int h = wndrect.Height();

这将适用于所有类型的 MFC 窗口,因为所有 MFC 窗口类都继承CWnd