CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2009
    Posts
    20

    how to add ScrollBar to Dialog

    I have added Vertical ScrollBar to my Dialog.I have added variable m_ScrollBarto to it and set its range.
    m_ScrollBar.SetScrollRange(0,10);

    I have to add Eventhandler to ScrollBar.How to add WM_VSCROLL message map
    to it.If I press ctrl+w class wizard is not coming.How to open Class wizard Dialog Box. Can anyone suggest me.

  2. #2
    Join Date
    Mar 2004
    Location
    KL, Malaysia
    Posts
    63

    Re: how to add ScrollBar to Dialog

    Using ctrl+w to invoke class wizard only apply to VC6, are you using VC6?

  3. #3
    Join Date
    Jan 2009
    Posts
    20

    Re: how to add ScrollBar to Dialog

    Hi,
    I am using Visual Studio 2005.

  4. #4
    Join Date
    Mar 2004
    Location
    KL, Malaysia
    Posts
    63

    Re: how to add ScrollBar to Dialog

    There is no similar ctrl+w class wizard in VS2005. However you can always hand-code the event handler code.

    Copy below code to your class definition.
    Code:
    protected:
    	// Generated message map functions
    	afx_msg void OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
    	afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);

    Copy below code to your class implementation.
    Code:
    BEGIN_MESSAGE_MAP(CScrollBarDlg, CPropertyPage)
    	ON_WM_HSCROLL()
    	ON_WM_VSCROLL()
    END_MESSAGE_MAP()
    
    void CScrollBarDlg::OnHScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
    {
    }
    
    void CScrollBarDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar) 
    {
    }
    Last edited by ckweius; February 27th, 2009 at 09:03 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured