Click here to Skip to main content
65,938 articles
CodeProject is changing. Read more.
Articles
(untagged)

CWndSliderView - An animated child window manager

0.00/5 (No votes)
11 Jan 2000 1  
An article on using an Outlook style window slider control.
  • Download demo project - 71 Kb
  • Download source files - 28 Kb

    Sample Image - CWndSlider.jpg

    Introduction

    This is yet another control inspired from the Outlook shortcut-bar.  The CWndSliderView control is pretty much (to put it simply) a child window manager, with fancy looking buttons and a cool sliding window animation effect.  The control was created to be rather simple and self explanatory.  I have done my best to heavily comment CWndSliderView's source code.  Hopefully everyone who views my code will find it useful and or educational.  Have fun!

    Setting up and using the CWndSliderView control

    First create an instance of CWndSliderView in the Main Frame of your application.  On CMainFrame::OnCreate, get a pointer to the context information and the CWndSliderView.  To create a new child view, call CWndSliderView::Create with the new child views title, RUNTIME_CLASS pointer, and create context parameters.  CWndSliderView::Create returns SOB_ERROR on error; otherwise the index of newly created view.  Use CWndSlider::ModifyViewStyle to make child views animate vertically or horizontally.  That's pretty much it.  It's all simple.

    #include "WndSlider.h"
    
    
    int CMainFrame::OnCreate(LPCREATESTRUCT lpCreateStruct)
    {
    	//
    
    	//  ...[SNIP]...
    
    	//
    
    	
    	//
    
    	// Get the Create Context struct.
    
    	//
    
    	CCreateContext* pContext = (CCreateContext*)lpCreateStruct->lpCreateParams;
    
    	//
    
    	// Grab the main CWndSliderView windows.  
    
    	//
    
    	CWndSliderView *pObar = STATIC_DOWNCAST( CWndSliderView, m_wndSplitter.GetPane(0,0) );
    
    	//
    
    	// Check for NULL...
    
    	//
    
    	if( NULL != pObar )
    	{
    		int nID;
    
    		//
    
    		// Modify the default button style to be vertical...
    
    		//
    
    		pObar->ModifyBarStyle( SOB_BAR_HORZ, SOB_BAR_VERT, FALSE );	
    
    		//
    
    		// Start adding views to the slider...  
    
    		//
    
    		nID = pObar->CreateView( _T("0 CMyListView 0"), RUNTIME_CLASS(CMyListView), pContext );
    
    		//
    
    		// Debug-check if view creation worked without error...
    
    		//		
    
    		ASSERT( SOB_ERROR != nID );
    
    		//
    
    		// Add a simple CEditView to the CWndSliderView window.
    
    		//		
    
    		nID = pObar->CreateView( _T("1 CEditView 1"), RUNTIME_CLASS(CEditView), pContext );
    
    		//
    
    		// Debug-check if view creation worked without error...
    
    		//
    
    		ASSERT( SOB_ERROR != nID );
    
    		//
    
    		// Continue adding more views if you like...
    
    		//
    
    
    	}
    
    	//
    
    	//  ...[SNIP]...
    
    	//
    
    }
    

    Constants Defined 

      SOB_VIEW_DEFAULT_BTN_HEIGHT : Increase or decrease to change default button height (VALUE = 24 pixels).
      SOB_VIEW_DEFAULT_ANIMATION_SPEED
      :Increase or decrease to change animation step speed (VALUE = 10 ms).
      SOB_VIEW_DEFAULT_ANIMATION_LIMIT : Increase or decrease value to to limit the total amount of time spent animating (VALUE = 200 ms).

      SOB_VIEW_HORZ : Set view style bit to have child windows animate horizontally (DEFAULT).
      SOB_VIEW_VERT :
      Set view style bit to have child windows animate vertically.
      SOB_VIEW_ANIMATE : Set view style bit to turn on child window animation (DEFAULT). 

      SOB_BTN_ANIMATE :Set button style bit to turn on animation (DEFAULT) - used to turn off animation per child window.
      SOB_BTN_FANCYFACE : Set button style bit to turn on 3D fancy face surface (DEFAULT).

      Comments, suggestions, and notes

      CWndSliderView is just the sliding / animating component of a "Outlook Bar."  Perhaps someday in the future when I have some free time, I'll work on a real  "Outlook Bar" looking control.  Until then...  If anyone has comments, suggestions, or questions please feel free to send me a quick message. 

    • License

      This article has no explicit license attached to it but may contain usage terms in the article text or the download files themselves. If in doubt please contact the author via the discussion board below.

      A list of licenses authors might use can be found here