简体   繁体   English

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

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

How can I get the size of a "window" or a "panel" in MFC C++? 如何获得MFC C ++中“窗口”或“面板”的大小 is there a function or something? 有功能或东西吗?

CRect MyRect; CRect MyRect;

CWnd::GetDesktopWindow ()->GetWindowRect (MyRect) CWnd :: GetDesktopWindow()-> GetWindowRect(MyRect)

There is CWnd::GetWindowRect : CWnd::GetWindowRect

CWnd  wnd; // the window to query
CRect wndrect;

wnd.GetWindowRect(wndrect);

And from there you can get 从那里你可以得到

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

This will work for all kinds of MFC windows because all MFC window classes inherit CWnd . 这将适用于所有类型的MFC窗口,因为所有MFC窗口类都继承CWnd

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM