Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to bind child windows to parent window in relative positions?

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: List view dialog

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.

like image 395
Robertas Avatar asked Nov 28 '11 20:11

Robertas


People also ask

How do you close the child window when the parent closes?

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.

What is parent window and child window?

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.

What is child window in HTML?

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.


1 Answers

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.

like image 90
Jerry Coffin Avatar answered Oct 05 '22 04:10

Jerry Coffin