What is the best practices for laying out child windows (common controls) in a dialog box or main window? I mean is there a binding mechanism which would fix a relative positions of the control to parent window’s border like in WPF. And during window resize the child control would resize together with the main window.
Currently I have this:
As you can see from the red lines it does not look pretty when I am resizing parent window of a list view control. I would like to bind for example ListView’s right side to DialogBox’s right border and similarly other controls.
I know that I can play around with GetWindowRect, GetClientRect and MoveWindow functions. But is this the correct way?
Currently I am working with pure Win32 Api without MFC.
If you’re just using the Win32 API, you normally handle this by handling the WM_SIZE message, and respond by calling GetClientRect on the parent window and MoveWindow on the children to move/resize the children to fill the parent appropriately.
If you want to badly enough, you can (of course) implement a layout manager, so the rest of the program doesn’t need to handle things like this directly. At least IME, doing this well is sufficiently difficult that it’s rarely worth the trouble unless you can make quite a lot of use of that layout code.