Ausrichtung in einem CFormView mittels OnSize



  • Hallo Leute,

    ich habe da ein Problem und bekomme es einfach nicht hin.
    In meinem Projekt habe ich von der Seite

    http://www.codeproject.com/treectrl/newtreelistcode.asp

    Das Beispiel herunter geladen und in mein Projekt eingebunden.
    Soweit funktioniert es auch.

    Doch jetzt wollte ich, da ich es ja auf einem CFormView eingebastelt habe, das neue Projekt etwas nach Unten Verschieben.
    Es tut zwar, das richtige ergebnis bleibt aber aus.
    Das Projekt sollte 100 Punkte von der Oberen Kante entfernt sein...

    void CProjekt::OnSize(UINT nType, int cx, int cy) 
    {
    	CFormView::OnSize(nType, cx, cy);
    
    	SetScrollRange(SB_HORZ, 0, 0);
    	SetScrollRange(SB_VERT, 0, 0);
    
    	if(m_TLInitialized)
    	{	
    		// resize all the controls	
    		CRect m_wndRect;
    		GetClientRect(&m_wndRect);
    
    		CRect m_headerRect;
    		m_tree.m_wndHeader.GetClientRect(&m_headerRect);
    		m_tree.m_wndHeader.SetWindowPos(&wndTop, 0, 0, m_wndRect.Width(), m_headerRect.Height(), SWP_NOMOVE);
    
    		CRect m_scrollRect;
    		m_horScrollBar.GetClientRect(&m_scrollRect);
    
    		m_tree.SetWindowPos(&wndTop, 0, 0, m_wndRect.Width(), m_wndRect.Height() - m_scrollRect.Height(), SWP_NOMOVE);
    
    		CRect m_treeRect(0,120,cx,cy);
    		m_tree.GetClientRect(&m_treeRect);
    		m_horScrollBar.MoveWindow(0, m_treeRect.bottom, m_wndRect.Width(), m_scrollRect.Height());
    
    		if(m_tree.GetColumnsWidth() > m_treeRect.Width())
    		{
    			// show the horz scroll bar
    			{
    				CRect m_barRect;
    				m_horScrollBar.GetClientRect(&m_barRect);			
    
    				m_horScrollBar.EnableWindow(TRUE);
    
    				m_horScrollBar.ShowWindow(SW_SHOW);
    
    				// the tree becomes smaller
    				m_tree.SetWindowPos(&wndTop, 0, 0, m_wndRect.Width(), m_wndRect.Height()-m_barRect.Height()-m_headerRect.Height(), SWP_NOMOVE);
    
    				int tfdsfsd=m_wndRect.Width() - GetSystemMetrics(SM_CXVSCROLL);
    				m_horScrollBar.SetWindowPos(&wndTop, 0, 0, m_wndRect.Width() - GetSystemMetrics(SM_CXVSCROLL), m_barRect.Height(), SWP_NOMOVE);
    
    			}
    
    			m_horScrollBar.SetScrollRange(0, m_tree.GetColumnsWidth()-m_treeRect.Width());
    
    		}
    		else
    		{
    			// hide the scroll bar
    			{
    				m_horScrollBar.EnableWindow(FALSE);
    
    				m_horScrollBar.ShowWindow(SW_HIDE);
    
    				// the tree becomes larger
    				m_tree.SetWindowPos(&wndTop, 0, 0, m_wndRect.Width(), m_wndRect.Height()-m_headerRect.Height(), SWP_NOMOVE);				
    			}
    
    			m_horScrollBar.SetScrollRange(0, 0);
    		}
    
    		m_tree.ResetVertScrollBar();
    
    		// Reset the header control position and scroll
    		// the tree control as required.
    		int m_nCurPos = m_horScrollBar.GetScrollPos();
    		m_tree.m_nOffset = -m_nCurPos;
    
    		// smoothly scroll the tree control
    	    {
    		CRect m_scrollRect;
    		m_tree.GetClientRect(&m_scrollRect);
    		m_tree.ScrollWindow(m_nCurPos, 0, &m_scrollRect, &m_scrollRect);
    		}
    		m_tree.m_wndHeader.GetWindowRect(&m_headerRect);	
    		GetClientRect(&m_wndRect);
    
    		m_tree.m_wndHeader.SetWindowPos(&wndTop, m_tree.m_nOffset, 100,max(StretchWidth(m_tree.GetColumnsWidth(),m_treeRect.Width()),m_wndRect.Width()), m_headerRect.Height(),SWP_SHOWWINDOW);			
    	}	
    }
    

    Kann mir jeman dazu Helfen ??

    Gruß
    andy_mann


Anmelden zum Antworten