Window Groups

I made a main, matrix window (WS_OVERLAPPEDWINDOW) and 100 child windows that all have edit control, laid out in a 10x10 grid.

At some points during runtime, I want to move a row (of 10 windows). Right now, I'm moving each window of that row separately. Isn't there a more convenient way to do this, e.g. by putting the 10 windows of a row inside (as a child of) a group window, then moving only that group window?

I tried this, but when I specify the group window as the parent of a child window, this child window won't show up, while it does show up as a child of the main window:

1
2
3
4
5
6
7
mainwindow = CreateWindow("classname", mainwindowstr, WS_OVERLAPPEDWINDOW | WS_VISIBLE | WS_VSCROLL, CW_USEDEFAULT, CW_USEDEFAULT, WindowRect.right - WindowRect.left, WindowRect.bottom - WindowRect.top, NULL, NULL, inst, NULL);

for(int a = 0; a < 10; a++){
	trow[a] = CreateWindow("trow", NULL, WS_CHILD | WS_VISIBLE, 0, a*20, 200, 20, mainwindow, NULL, inst, NULL);

	for(int n = 0; n < 10; n++)
		tbox[n][a] = CreateWindow("EDIT", NULL, WS_CHILD | WS_BORDER | WS_CLIPSIBLINGS | WS_VISIBLE, n*20, a*20, 20, 20, trow[a], NULL, inst, NULL);}


Any ideas?
While I'm here, it's better coding style to wrap long lines (definitely any lines over 100 chars long.) Doubly so when posting here (so it fits in the webbrowser window.)

1
2
3
4
5
6
7
8
9
10
11
12
13
    mainwindow = CreateWindow("classname", mainwindowstr, WS_OVERLAPPEDWINDOW
        | WS_VISIBLE | WS_VSCROLL, CW_USEDEFAULT, CW_USEDEFAULT, WindowRect.right
        - WindowRect.left, WindowRect.bottom - WindowRect.top, NULL, NULL, inst,
        NULL);

    for(int a = 0; a < 10; a++){
        trow[a] = CreateWindow("trow", NULL, WS_CHILD | WS_VISIBLE, 0, a*20, 200,
            20, mainwindow, NULL, inst, NULL);

    for(int n = 0; n < 10; n++)
        tbox[n][a] = CreateWindow("EDIT", NULL, WS_CHILD | WS_BORDER | WS_CLIPSIBLINGS
            | WS_VISIBLE, n*20, a*20, 20, 20, trow[a], NULL, inst, NULL);
    }


But, the main issue is the positioning of your edit controls. Remember that child control are positioned with respect to their parent. So the y coord of the edit controls is always 0 (with respect to parent control.) That is

1
2
3
4
    for(int n = 0; n < 10; n++)
        tbox[n][a] = CreateWindow("EDIT", NULL, WS_CHILD | WS_BORDER | WS_CLIPSIBLINGS
            | WS_VISIBLE, n*20, 0 /*not a*20*/, 20, 20, trow[a], NULL, inst, NULL);
    }


Andy

PS I assume trow is a new window class that you've registered?
Last edited on
Oh ... kay. I made a mistake with the class registering.

Thanks!
Topic archived. No new replies allowed.