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 open all child windows with window. open, include this javascript in all pages, then CloseAll(false); from any included page will close all child, grandchildren, great-grand... etc., and redirect the first (root) page to login.
A child window has only one parent window, but a parent can have any number of child windows. Each child window, in turn, can have child windows. In this chain of windows, each child window is called a descendant window of the original parent window.
A child window is a window that is launched and contained inside of a parent window. By definition, a child window is one that is dependent on a parent window and is minimized or closed when the parent minimizes or closes.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With