Child window auto-resize?

Started by
3 comments, last by GuitarPlayer0912 17 years, 8 months ago
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?
Advertisement
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.
Wow don't I feel dumb. :) Thanks njpaul. I guess I was searching for the wrong thing. This should definitely do it.
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 :(
Yeah I tried SetWindowPos. It didn't work for me for some reason. 8-)

This topic is closed to new replies.

Advertisement