Click here to Skip to main content
15,881,424 members
Articles / Desktop Programming / MFC
Article

CWndSliderView - An animated child window manager

Rate me:
Please Sign up or sign in to vote.
4.89/5 (10 votes)
11 Jan 2000 98.4K   2.8K   39   10
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).<BR>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).<BR>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


      Written By
      United States United States
      This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.

      Comments and Discussions

       
      QuestionDialog-based program? Pin
      mingluen12-Dec-04 23:15
      mingluen12-Dec-04 23:15 
      AnswerRe: Dialog-based program? Pin
      izst7-Jun-06 20:47
      izst7-Jun-06 20:47 
      Generalrendering bug Pin
      Jan1101197728-Jun-04 5:52
      Jan1101197728-Jun-04 5:52 
      GeneralZer gut! Pin
      ThEN12-Feb-02 23:57
      ThEN12-Feb-02 23:57 
      GeneralNot created in case of CFormView Pin
      28-Jan-02 5:12
      suss28-Jan-02 5:12 
      GeneralRe: Not created in case of CFormView Pin
      Warren Gardner6-Dec-02 3:55
      Warren Gardner6-Dec-02 3:55 
      GeneralSuggestion Pin
      Noman Nadeem19-Sep-01 2:41
      Noman Nadeem19-Sep-01 2:41 
      GeneralTwo Comments Pin
      17-Aug-01 10:55
      suss17-Aug-01 10:55 
      Generaloutlook bar Pin
      vinayb1318-Jul-01 9:20
      vinayb1318-Jul-01 9:20 
      GeneralMessage Closed Pin
      12-Jan-00 18:40
      Paul Selormey12-Jan-00 18:40 

      General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

      Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.