• 11
• 9
• 10
• 9
• 11

# Child window auto-resize?

This topic is 4274 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

I'm currently in the midst of developing a Map Editor for a 2D RPG in c++. I just finished writing the engine yesterday (or so I think), and I have a seemingly trivial problem but it's not. When I create my main window, I also create 2 child windows in the main one. The main window is 800 x 600, and the child windows fit perfectly TO THE PIXEL thanks to the GetSystemMetrics function. But when I resize the main window (i.e. maximize), the child windows obviously stay the same size. I need help with a technique to auto-resize the child windows when the main one is resized. Here's what I tried, but it didn't work.
m_iWndWidth = GetSystemMetrics(SM_CXSCREEN); // Supposed to get window width, but gets COMPUTER MONITOR WIDTH!
m_iWndHeight = GetSystemMetrics(SM_CYSCREEN); // Same thing

MoveWindow(hChildWnd, 0, 0, m_iWndWidth, m_iWndHeight, FALSE); // This would be a situation with only 1 child window (for testing)


can anyone help me?

##### Share on other sites
According to the msdn documentation, SM_CXSCREEN gets "The width of the screen of the primary display monitor, in pixels. This is the same value obtained by calling GetDeviceCaps as follows: GetDeviceCaps( hdcPrimaryMonitor, HORZRES)."

A quick search of the forums reveals this topic: http://www.gamedev.net/community/forums/topic.asp?topic_id=164835. That should answer your question.

##### Share on other sites
Wow don't I feel dumb. :) Thanks njpaul. I guess I was searching for the wrong thing. This should definitely do it.

##### Share on other sites
You could try SetWindowPos(...) or setting the FALSE to TRUE for the redraw.

I'm doing Win32 stuff at the moment. I'll remember to mess around with this myself and see if I can learn anything.

EDIT: ah, solved before I could post and more correct than mine :(

##### Share on other sites
Yeah I tried SetWindowPos. It didn't work for me for some reason. 8-)