AmirAhmad
AmirAhmad

Reputation: 163

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++? is there a function or something?

Upvotes: 0

Views: 1376

Answers (1)

Wintermute
Wintermute

Reputation: 44063

There is 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.

Upvotes: 1

Related Questions