void CSequencerSlider::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar*
pScrollBar)
{
SetPos(100);
CSliderCtrl::OnHScroll( nSBCode, nPos, pScrollBar );
}
Isn't that message sent to the parent?
--
Jeff Partch [VC++ MVP]
<bg_ie@yahoo.com> wrote in message
news:1156160841.328022.322410@m79g2000cwm.googlegroups.com...
Hi,
I have created my own derived CSliderCtrl class. Objects of this class
respond to OnKeyDown, OnKeyUp, OnKillFocus, but when I reposition the
slider OnVScroll is not being called. I create my objects as follows -
CSequencerSlider* pSlider[4];
for(int i=0;i<4;i++)
pSlider[i] = new CSequencerSlider;
for(int i=0;i<4;i++)
{
pSlider[i]->Create(WS_VISIBLE | TBS_VERT, CRect(12, 20+i*125, 38,
130+i*125), this, 0);
pSlider[i]->SetRangeMin(0);
pSlider[i]->SetRangeMax(100);
pSlider[i]->SetRange(0, 100);
pSlider[i]->SetPos(50);
}
This all works fine. My .cpp and .h file are included below, perhaps
someone can spot a mistake. When I hit a key or when a slider loses
focus, the correct events are being called. But when I reposition the
slider, no the OnVScroll is not being called.
Thanks for your help,
Barry.
// SequencerSlider.cpp : implementation file
//
#include "stdafx.h"
#include "Sequencer.h"
#include "SequencerSlider.h"
#include "SequencerDoc.h"
#include "SequencerView.h"
#ifdef _DEBUG
#define new DEBUG_NEW
#undef THIS_FILE
static char THIS_FILE[] = __FILE__;
#endif
/////////////////////////////////////////////////////////////////////////////
// CSequencerSlider
CSequencerSlider::CSequencerSlider()
{
}
CSequencerSlider::~CSequencerSlider()
{
}
BEGIN_MESSAGE_MAP(CSequencerSlider, CSliderCtrl)
//{{AFX_MSG_MAP(CSequencerSlider)
ON_WM_KEYDOWN()
ON_WM_KEYUP()
ON_WM_VSCROLL()
ON_WM_KILLFOCUS()
//}}AFX_MSG_MAP
END_MESSAGE_MAP()
/////////////////////////////////////////////////////////////////////////////
// CSequencerSlider message handlers
void CSequencerSlider::OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags)
{
SetPos(0);
// TODO: Add your message handler code here and/or call default
CSliderCtrl::OnKeyDown(nChar, nRepCnt, nFlags);
}
void CSequencerSlider::OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags)
{
SetPos(25);
//MessageBox ( 0 , "WRONG WINSOCK VERSION" , MB_OKCANCEL );
CSliderCtrl::OnKeyUp(nChar, nRepCnt, nFlags);
}
void CSequencerSlider::OnKillFocus(CWnd* pNewWnd)
{
SetPos(75);
//MessageBox ( 0 , "WRONG WINSOCK VERSION" , MB_OKCANCEL );
CSliderCtrl::OnKillFocus(pNewWnd);
}
void CSequencerSlider::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar*
pScrollBar)
{
SetPos(100);
CSliderCtrl::OnHScroll( nSBCode, nPos, pScrollBar );
}
#if !defined(AFX_SEQUENCER_SLIDER)
#define AFX_SEQUENCER_SLIDER
#if _MSC_VER >= 1000
#pragma once
#endif // _MSC_VER >= 1000
// SequencerSlider.h : header file
//
/////////////////////////////////////////////////////////////////////////////
// CSequencerScroll window
class CSequencerSlider : public CSliderCtrl
{
// Construction
public:
CSequencerSlider();
// Attributes
public:
// Operations
public:
// Overrides
// ClassWizard generated virtual function overrides
//{{AFX_VIRTUAL(CSequencerSlider)
//}}AFX_VIRTUAL
// Implementation
public:
virtual ~CSequencerSlider();
// Generated message map functions
protected:
//{{AFX_MSG(CSequencerSlider)
afx_msg void OnKeyDown(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnKeyUp(UINT nChar, UINT nRepCnt, UINT nFlags);
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar*
pScrollBar);
afx_msg void OnKillFocus(CWnd* pNewWnd);
//}}AFX_MSG
DECLARE_MESSAGE_MAP()
};
/////////////////////////////////////////////////////////////////////////////
//{{AFX_INSERT_LOCATION}}
// Microsoft Developer Studio will insert additional declarations
immediately before the previous line.
#endif //
!defined(AFX_SEQUENCEREDIT_H__0EF85D2F_FA3F_41CB_80D5_AB5D589351E3__INCLUDED_)