[C++/Win32] Netjes ChildWindows plaatsen...

Pagina: 1
Acties:

  • The - DDD
  • Registratie: Januari 2000
  • Laatst online: 03-09 16:40
In mijn hoofd window heb ik een aantal child windows.

Een toolbar, een statusbar, een treeview en een listview. Allen common controls.

Zodra mijn app start moet ik alles op de onderstaande manier doen. Doe ik de 2 updatewindows niet, dan krijg ik listview over mijn treeview 'gesmeerd' en vice versa.

Vraag is, waarom? Een WM_SIZE zorgt toch voor een WM_PAINT?

En ten tweede, je ziet dat er nogal het een en ander aan breedtes en hoogtes hard coded is. Stel ik maak iets waardoor mijn toolbar hoger of lager wordt, dan moet ik dat aanpassen. Hoe krijg ik die hoogtes dynamisch?
code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
case WM_SIZE:
{
    //Update the window sizes.
    int cxClient = LOWORD (lParam);
    int cyClient = HIWORD (lParam);

    //create new StatusBar widths array.
    int aWidths[5];
    aWidths[0] = 100;// chrono part
    aWidths[1] = cxClient/2 -25;
    aWidths[2] = cxClient/2 +25;// clock part
    aWidths[3] = cxClient - 200;
    aWidths[4] = -1;// appcounter part

    //Update the StatusBar's part width's
    SendMessage(hStatusBar, SB_SETPARTS, (WPARAM) 5, (LPARAM) (LPINT) aWidths);

    //Update the treeviews and listviews size
    SetWindowPos(hListView, HWND_TOP,250,27,cxClient-250,cyClient-47,0);
    SetWindowPos(hTreeView, HWND_TOP,0,27,250,cyClient-47,0);
    UpdateWindow(hTreeView);
    UpdateWindow(hListView);

    //Let the StatusBar, treeview, listview and ToolBar know there's been a resize.
    SendMessage(hStatusBar, WM_SIZE, wParam, lParam);
    SendMessage(hToolBar, WM_SIZE, wParam, lParam);
    SendMessage(hTreeView, WM_SIZE, wParam, lParam);
    SendMessage(hListView, WM_SIZE, wParam, lParam);

    break;
}

En als aller aller laatste: Heb je toevallig het idee dat ik iets helemaal verkeerd doe, laat het even weten. ;)

  • Sponz
  • Registratie: Juni 2001
  • Niet online

Sponz

nul nest parfait saif moi

Op woensdag 05 december 2001 23:28 schreef The - DDD het volgende:

Vraag is, waarom? Een WM_SIZE zorgt toch voor een WM_PAINT?
Ik dacht 't niet. Voor de rest weet ik 't niet :)

/edit: je moet de wm_paint wel afvangen natuurlijk. doe je dat?

  • The - DDD
  • Registratie: Januari 2000
  • Laatst online: 03-09 16:40
Ja, die werkt op dit moment ook gewoon. Ik doe er alleen weinig in omdat mijn gehele window bedekt is met childwindows.

Menu, statusbar, toolbar, treeview en een listview. Ik vraag me alleen af waarom ik na het sturen van een WM_SIZE naar mijn childs (tree en list) ik nog een UpdateWindow moet doen om alles mooi opscherm te krijgen. 't Enige wat dat ding doet is direct WM_PAINT aanroepen.

  • The - DDD
  • Registratie: Januari 2000
  • Laatst online: 03-09 16:40
Haha, ik heb het al door. :)

Ik zat child windows aan te maken nadat ik mijn mainwindow had geschowed en geupdate....

Gniffel... Oeps...:D