|
-
March 31st, 2004, 09:33 AM
#1
Spin Control Notification
I have a spin control for which I need to execute a particular function AFTER the user has released the button (up or down) on the spin control... that is, I do not want to do this function for each iteration of the spin control... ONLY when the spin control has stopped incrementing. The only message handlers I see that are offered by the MFC ClassWizard are NM_OUTOFMEMORY and UDN_DELTAPOS. Neither of these seems to be what I need.
How can I know that the spin control has changed its buddy CEdit control AND that the spin control is not continuing to increment?
-
March 31st, 2004, 11:22 AM
#2
If you are from Washington (state), take a run to Redmond WA and ask the MS fellows. 
Now serious...
After sending UDN_DELTAPOS (in that the position is not changed yet), a WM_VSCROLL or WM_HSCROLL is also sent.
See the example below. I hope this solves your problem.
Code:
void CADialog::OnDeltaposSpin1(NMHDR* pNMHDR, LRESULT* pResult)
{
NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
// the position is not changed yet, so
// keep in mind the old position
m_iPos = pNMUpDown->iPos;
*pResult = 0;
}
void CADialog::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
if(pScrollBar->m_hWnd == m_spin.m_hWnd)
{
if(SB_THUMBPOSITION == nSBCode)
{
if( m_iPos == nPos )
{
// the position was not changed, so...
AfxMessageBox( _T("Bau!!!") );
return;
}
}
}
CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
Last edited by ovidiucucu; March 31st, 2004 at 11:38 AM.
-
March 31st, 2004, 01:14 PM
#3
Thanks ! I will give this a try...
-
April 1st, 2004, 08:24 AM
#4
THANKS ovidiucucu !
With one minor change, this does exactly what I need.
I had to change
if(SB_THUMBPOSITION == nSBCode)
to
if(SB_ENDSCROLL == nSBCode)
-
November 30th, 2010, 07:31 PM
#5
Re: Spin Control Notification
Sford or Ovidiucucu:
I'm trying to do the same thing in VC++6, but till now i can't , Ovidiucucu you said that after sending UDN_DELTAPOS a WM_VSCROLL or WM_VSCROLL is sent , so for spin control (not scroll bar) WM_VSCROLL and WM_VSCROLL are sent too? .Only to see if this is happening in my app ,i wrote:
Code:
void CADialog::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// the position was not changed, so...
AfxMessageBox( _T("Bau!!!") );
return;
CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
i think that with this every time the i touch de spin, the message box should apperas, but it doesn't. The code compiles with no erros.
What is wrong ?
-
November 30th, 2010, 07:53 PM
#6
Re: Spin Control Notification
 Originally Posted by Timbk
Sford or Ovidiucucu:
I'm trying to do the same thing in VC++6, but till now i can't , Ovidiucucu you said that after sending UDN_DELTAPOS a WM_VSCROLL or WM_VSCROLL is sent , so for spin control (not scroll bar) WM_VSCROLL and WM_VSCROLL are sent too? .Only to see if this is happening in my app ,i wrote:
Code:
void CADialog::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
// the position was not changed, so...
AfxMessageBox( _T("Bau!!!") );
return;
CDialog::OnVScroll(nSBCode, nPos, pScrollBar);
}
i think that with this every time the i touch de spin, the message box should apperas, but it doesn't. The code compiles with no erros.
What is wrong ?
Did you create the corresponding message map entry for OnVScroll?
-
November 30th, 2010, 09:07 PM
#7
Re: Spin Control Notification
Nice, the message map entry was wrong , now works nicely. 1 day to solve this , anyway this is how it looks now
header file
Code:
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
Source file
Message map
And handler
Code:
void CCalibracionDlg::OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar)
{
if(SB_ENDSCROLL == nSBCode)
{
if(pScrollBar->m_hWnd == m_Spin1m_hWnd)
{
// the position was not changed, so...
AfxMessageBox( _T("Termino el Spin1!!!") );
return;
}
if(pScrollBar->m_hWnd == m_Spin2.m_hWnd)
{
// the position was not changed, so...
AfxMessageBox( _T("Termino el Spin2!!!") );
return;
}
}
}
Thanks Arjay, where are you from?
-
November 30th, 2010, 09:11 PM
#8
Re: Spin Control Notification
 Originally Posted by Timbk
Thanks Arjay, where are you from?
...from a galaxy far, far away.
-
November 30th, 2010, 09:23 PM
#9
Re: Spin Control Notification
 Originally Posted by Arjay
...from a galaxy far, far away.
incredible, even that, your posts come so fast !!!
-
November 30th, 2010, 09:31 PM
#10
Re: Spin Control Notification
I live in Bellevue, WA - close to Seattle. When I moved there I traded in my light saber for a high speed internet connection.
-
November 30th, 2010, 10:07 PM
#11
Re: Spin Control Notification
Jejejej , i thought that, well thanks again, and May the Force be with you, oh no no i have to say May the speed be with you.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|