void CEasySizeDialog::OnSizing(UINT fwSide, LPRECT pRect) { CDialogEx::OnSizing(fwSide, pRect); if (_resizable) { CSize min_size = OnGetMinSize(); EASYSIZE_MINSIZE(min_size.cx, min_size.cy, fwSide, pRect); } }
// Window procedure override. Handles layout engine private messages. LRESULT ClsLayoutEngine::WindowProc( UINT uMsg, WPARAM wParam, LPARAM lParam ) { // Interpred message. switch ( uMsg ) { case WM_CREATE: { // Get the default font height used // by the layout control. This information // is needed if the control font is not // set. ClsGetDC dc( this ); ClsSize sz = dc.GetTextExtent( _T( "W" ), 1 ); m_nFontHeight = sz.CY(); break; } case WM_GETFONT: // Valid font? return ( LRESULT )( m_Font.IsValid() ? ( HFONT )m_Font : NULL ); case WM_SETFONT: { // Detach old font. m_Font.Detach(); // Valid? if ( wParam ) { // Attach the new font. m_Font.Attach(( HFONT )wParam, FALSE ); // Set the font to the frame // if it exists. if ( m_Frame.GetSafeHWND()) m_Frame.SetFont( &m_Font, FALSE ); // Pass this message to all our members // when they do not have a font set. ClsMember *pMember; for ( pMember = m_Members.GetFirst(); pMember; pMember = m_Members.GetNext( pMember )) { // Skip spacing members. if (( pMember->m_dwFlags & ClsMember::MF_SPACING ) != ClsMember::MF_SPACING ) { // Does it have a font? if ( pMember->m_pMember->SendMessage( WM_GETFONT ) == NULL ) // No. Set it. pMember->m_pMember->SendMessage( WM_SETFONT, wParam, MAKELPARAM( FALSE, 0 )); } } // Pickup the font height. ClsGetDC dc(this); ClsSelector sel( &dc, ( HFONT )wParam ); ClsSize sz = dc.GetTextExtent( _T( "W" ), 1 ); // Store the height. m_nFontHeight = sz.CY(); m_dwFlags &= ~LF_DIMENSIONED; } break; } case WM_ISLAYOUTENGINE: // Yes, we really are a layout engine... return TRUE; case WM_ORGANIZE: // Organize the members. m_dwFlags &= ~LF_ORGANIZED; OrganizeMembers(); return TRUE; case WM_GETCONTROLS: // Add members to the passed list. GetControls(( ClsLinkedList<ClsCNode> * )lParam ); return TRUE; case WM_ERRORS: // Return error bool. return ( LRESULT )(( BOOL )( m_dwFlags & LF_ADDERROR )); //case WM_SIZE: // Resize the frame. // if ( m_bFrameGroup && m_Frame.GetSafeHWND()) // { // ClsRect rc; // GetClientRect( rc ); // m_Frame.MoveWindow( rc, FALSE ); // } // return 0; case WM_RELAYOUT: // Group dimensioned? When ever a group contents // has changed we need to call the OnGetMinSize() // method before we re-layout. This is to make sure // the layout engine always works with the latest // information. if (( m_dwFlags & LF_DIMENSIONED ) != LF_DIMENSIONED ) { ClsSize szMinSize( 0, 0 ); // OK? if ( OnGetMinSize( szMinSize ) == FALSE ) return FALSE; } // Is this the master group? if ( m_dwFlags & LF_MASTER ) { // Organized? if (( m_dwFlags & LF_ORGANIZED ) != LF_ORGANIZED ) OrganizeMembers(); // Get the parent it's client rectangle. ClsRect rc = GetParent()->GetClientRect(); // Re-size the group. MoveWindow( rc, FALSE ); } // Scale the group members. if ( m_bIsHorizontal ) ScaleHGroup(); else ScaleVGroup(); // Master group? if ((( m_dwFlags & LF_MASTER ) == LF_MASTER ) && GetParent()->IsWindowVisible()) // Force the parent to redraw. GetParent()->RedrawWindow( NULL, NULL, RDW_INVALIDATE | RDW_ERASE | RDW_ALLCHILDREN ); return TRUE; case WM_SHOWMEMBERS: { // Show/Hide members. ClsMember *pMember; for ( pMember = m_Members.GetFirst(); pMember; pMember = m_Members.GetNext( pMember )) { // A spacing member? if (( pMember->m_dwFlags & ClsMember::MF_SPACING ) != ClsMember::MF_SPACING ) { if ( pMember->m_pMember->SendMessage( WM_ISLAYOUTENGINE )) pMember->m_pMember->SendMessage( WM_SHOWMEMBERS, wParam ); else { pMember->m_pMember->ShowWindow( wParam ? SW_SHOW : SW_HIDE ); if ( wParam ) pMember->m_pMember->UpdateWindow(); } } } // Show/Hide the frame. if ( m_bFrameGroup && m_Frame.GetSafeHWND()) { m_Frame.ShowWindow( wParam ? SW_SHOW : SW_HIDE ); if ( wParam ) m_Frame.UpdateWindow(); } return TRUE; } case WM_REFRESH: { // Do longer dimensioned or organized... m_dwFlags &= ~( LF_ORGANIZED | LF_DIMENSIONED ); // Refresh layout engine members. ClsMember *pMember; for ( pMember = m_Members.GetFirst(); pMember; pMember = m_Members.GetNext( pMember )) { // A spacing member? if (( pMember->m_dwFlags & ClsMember::MF_SPACING ) != ClsMember::MF_SPACING ) { // Is it a layout engine? if ( pMember->m_pMember->SendMessage( WM_ISLAYOUTENGINE )) pMember->m_pMember->SendMessage( WM_REFRESH ); } } // Are we the master? if ( m_dwFlags & LF_MASTER ) // Layout the group. SendMessage( WM_RELAYOUT ); return TRUE; } } // Call the base class. return ClsWindow::WindowProc( uMsg, wParam, lParam ); }