#include using namespace wkgl; BOOL OnButton( Component*, UINT, WPARAM, LPARAM ); LAYOUT_INFO linfo; LayoutManager *lm; WPARAM main() { Window win( "Test LayoutManager" ); Button button( "Change Layout", 0, 120 ); Static s1( "Type some text:", AUTOPOS, AUTOPOS ); Static s2( "Type some more text:", AUTOPOS, AUTOPOS ); Edit edit1( AUTOPOS, AUTOPOS, 10 ); Edit edit2( AUTOPOS, AUTOPOS, 15 ); //Set the information about the layout linfo.hgap = 5; linfo.vgap = 5; linfo.client.top = 0; linfo.client.left = 0; //Create the panel lm = new LayoutManager( &win, linfo, FormLayout ); //Add the controls to the panel, order matters lm->add( &s1 ); lm->add( &edit1 ); lm->add( &s2 ); lm->add( &edit2 ); //Add the contols to the window. win.add( &s1 ); win.add( &edit1 ); win.add( &s2 ); win.add( &edit2 ); win.add( &button ); button.addCallBack( OnButton ); //Layout the components. lm->layout(); //Show the window win.show(); WPARAM param = win.beginMessageLoop(); //Delete the layout manager delete lm; return param; } BOOL OnButton( Component *com, UINT message, WPARAM wParam, LPARAM lParam ) { static int clicked = 0; if ( message == BN_CLICKED ) { //Change the layout switch ( clicked ) { case 0: lm->setLayout( FlowLayoutL ); //Set the layout clicked = 1; break; case 1: //The right field may have a bogus value so set it correctly. linfo.client.right = ((Control*)com->getParent())->getWidth(); lm->setLayoutInfo( linfo ); //Set the layout information lm->setLayout( FlowLayoutR ); //Set the layout clicked = 0; break; } //Layout the component. lm->layout(); return TRUE; } return FALSE; }