Spin control , it's possible to know when the control is released?
-
hello, i'm using vc++ 6 , in my app i need to do some things when the spin control is released, but in vc++6 there is only two events for this control: UDN_DELTAPOS and NM_OUTOFMEMORY, no events for control released, i've been reading that in .net 2003 there is a event NM_RELEASEDCAPTURE in order to do this, but how can i do this in VC++6?
-
hello, i'm using vc++ 6 , in my app i need to do some things when the spin control is released, but in vc++6 there is only two events for this control: UDN_DELTAPOS and NM_OUTOFMEMORY, no events for control released, i've been reading that in .net 2003 there is a event NM_RELEASEDCAPTURE in order to do this, but how can i do this in VC++6?
From commctrl.h:
#define NM_RELEASEDCAPTURE (NM_FIRST-16)
See if you get this notification with ON_NOTIFY
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<
-
From commctrl.h:
#define NM_RELEASEDCAPTURE (NM_FIRST-16)
See if you get this notification with ON_NOTIFY
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<
I'm not sure to understand what you mean, perhpas because I'm newbie :( . I looked for ON_NOTIFY and the unique reference is:
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnDeltaposSpin1)
no references for NM_RELEASEDCAPTURE,of course inside of commctrl.h i can find this line that you posted:
#define NM_RELEASEDCAPTURE (NM_FIRST-16
but I don't know what to do with this, can you explain a little more?
-
I'm not sure to understand what you mean, perhpas because I'm newbie :( . I looked for ON_NOTIFY and the unique reference is:
ON_NOTIFY(UDN_DELTAPOS, IDC_SPIN1, OnDeltaposSpin1)
no references for NM_RELEASEDCAPTURE,of course inside of commctrl.h i can find this line that you posted:
#define NM_RELEASEDCAPTURE (NM_FIRST-16
but I don't know what to do with this, can you explain a little more?
Try this:
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SPIN1, OnSpinReleasedCapture)
The
OnSpinReleaseCapture
method should look the same asOnDeltaposSpin1
, am not sure how it looks in VS6 anymore, something like this probably:void OnSpinReleaseCapture(LPNMHDR lpNMHDR, LRESULT *pResult)
. Am not sure you will get this called but it is worht a try i guess.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<
-
Try this:
ON_NOTIFY(NM_RELEASEDCAPTURE, IDC_SPIN1, OnSpinReleasedCapture)
The
OnSpinReleaseCapture
method should look the same asOnDeltaposSpin1
, am not sure how it looks in VS6 anymore, something like this probably:void OnSpinReleaseCapture(LPNMHDR lpNMHDR, LRESULT *pResult)
. Am not sure you will get this called but it is worht a try i guess.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<
Thanks for your answer, ok I've trying, I did this: In the header file CalibracionDlg.h
afx\_msg void OnDeltaposSPIN1(NMHDR\* pNMHDR, LRESULT\* pResult); afx\_msg void OnReleasedCaptureSPIN1(NMHDR\* pNMHDR, LRESULT\* pResult);
In the source file Calibraciondlg.cpp
ON\_NOTIFY(UDN\_DELTAPOS, IDC\_SPIN1, OnDeltaposSPIN1) ON\_NOTIFY(NM\_RELEASEDCAPTURE, IDC\_SPIN1, OnReleasedCaptureSPIN1)
and the methods
void CCalibracionDlg::OnDeltaposSPIN1(NMHDR* pNMHDR, LRESULT* pResult)
{NM\_UPDOWN\* pNMUpDown = (NM\_UPDOWN\*)pNMHDR; // TODO: Add your control notification handler code here //some code
}
void CCalibracionDlg::OnReleasedCaptureSPIN1(NMHDR* pNMHDR, LRESULT* pResult)
{
GetDlgItem(IDC_SPIN1)->EnableWindow(FALSE);//just to see if it works.
}the compiler doesn't show any erros, but when I execute , nothing, when the control is released nothing happens. may be i forgot something?
-
Thanks for your answer, ok I've trying, I did this: In the header file CalibracionDlg.h
afx\_msg void OnDeltaposSPIN1(NMHDR\* pNMHDR, LRESULT\* pResult); afx\_msg void OnReleasedCaptureSPIN1(NMHDR\* pNMHDR, LRESULT\* pResult);
In the source file Calibraciondlg.cpp
ON\_NOTIFY(UDN\_DELTAPOS, IDC\_SPIN1, OnDeltaposSPIN1) ON\_NOTIFY(NM\_RELEASEDCAPTURE, IDC\_SPIN1, OnReleasedCaptureSPIN1)
and the methods
void CCalibracionDlg::OnDeltaposSPIN1(NMHDR* pNMHDR, LRESULT* pResult)
{NM\_UPDOWN\* pNMUpDown = (NM\_UPDOWN\*)pNMHDR; // TODO: Add your control notification handler code here //some code
}
void CCalibracionDlg::OnReleasedCaptureSPIN1(NMHDR* pNMHDR, LRESULT* pResult)
{
GetDlgItem(IDC_SPIN1)->EnableWindow(FALSE);//just to see if it works.
}the compiler doesn't show any erros, but when I execute , nothing, when the control is released nothing happens. may be i forgot something?
I have VS2003, i did a quick dialog based app and used the event handler wizard (right clicked the spin and selected 'add event handler') to add a handler for NM_RELEASEDCAPTURE, it generates the same code as you used (except for the custom parts of course) so it should be correct, however the event handler never seems to fire. Confusing... it says here[^] too that it is -suposedly- sent. Maybe this requires a deeper googling act.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<
-
I have VS2003, i did a quick dialog based app and used the event handler wizard (right clicked the spin and selected 'add event handler') to add a handler for NM_RELEASEDCAPTURE, it generates the same code as you used (except for the custom parts of course) so it should be correct, however the event handler never seems to fire. Confusing... it says here[^] too that it is -suposedly- sent. Maybe this requires a deeper googling act.
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<
-
Ok, thanks a lot for your time, yes it's easier in VS2003, but is not my choice to use VC6 , i have to, so i gonna keep searching.
This might be re-inventing the wheel but try this:
class CMySpin: public CSpinButtonCtrl
{
protected:
DECLARE_MESSAGE_MAP()
afx_msg void OnCaptureChanged(CWnd *pWnd);
};and the implementation:
BEGIN_MESSAGE_MAP(CMySpin, CSpinButtonCtrl)
ON_WM_CAPTURECHANGED()
END_MESSAGE_MAP()void CMySpin::OnCaptureChanged(CWnd *pWnd)
{
CSpinButtonCtrl::OnCaptureChanged(pWnd);
if (pWnd != this)
{
NMHDR NMHdr;
NMHdr.code = NM_RELEASEDCAPTURE;
NMHdr.hwndFrom = m_hWnd;
NMHdr.idFrom = GetDlgCtrlID();
GetParent()->SendMessage(WM_NOTIFY, NMHdr.idFrom, (LPARAM)&NMHdr);
}
}use a
CMySpin
as a control variable for your spin button in your dialog. (You might need to modify the code to compile under VS6, don't know what has changed since VS6)> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<
-
This might be re-inventing the wheel but try this:
class CMySpin: public CSpinButtonCtrl
{
protected:
DECLARE_MESSAGE_MAP()
afx_msg void OnCaptureChanged(CWnd *pWnd);
};and the implementation:
BEGIN_MESSAGE_MAP(CMySpin, CSpinButtonCtrl)
ON_WM_CAPTURECHANGED()
END_MESSAGE_MAP()void CMySpin::OnCaptureChanged(CWnd *pWnd)
{
CSpinButtonCtrl::OnCaptureChanged(pWnd);
if (pWnd != this)
{
NMHDR NMHdr;
NMHdr.code = NM_RELEASEDCAPTURE;
NMHdr.hwndFrom = m_hWnd;
NMHdr.idFrom = GetDlgCtrlID();
GetParent()->SendMessage(WM_NOTIFY, NMHdr.idFrom, (LPARAM)&NMHdr);
}
}use a
CMySpin
as a control variable for your spin button in your dialog. (You might need to modify the code to compile under VS6, don't know what has changed since VS6)> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<
Ok, sorry if my questions are too basics, so I already add the class CMyspin to the proyect as you decribed, and i added a control variable " m_Spin1" of CMySpin type to the spin 1 control , compiled with no errors, so wich is the next step? how can i catch the event of control released?
-
hello, i'm using vc++ 6 , in my app i need to do some things when the spin control is released, but in vc++6 there is only two events for this control: UDN_DELTAPOS and NM_OUTOFMEMORY, no events for control released, i've been reading that in .net 2003 there is a event NM_RELEASEDCAPTURE in order to do this, but how can i do this in VC++6?
:-D thanks for your time Code-o-mate :thumbsup:, finally google and 5 hours of work give me the solution, one of them at least. This how it looks now: Header file
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
Source file Message map
ON_WM_VSCROLL()
And handler
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;
}
}
} -
:-D thanks for your time Code-o-mate :thumbsup:, finally google and 5 hours of work give me the solution, one of them at least. This how it looks now: Header file
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
Source file Message map
ON_WM_VSCROLL()
And handler
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;
}
}
}Yaay for google! :) :thumbsup:
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<
-
:-D thanks for your time Code-o-mate :thumbsup:, finally google and 5 hours of work give me the solution, one of them at least. This how it looks now: Header file
afx_msg void OnVScroll(UINT nSBCode, UINT nPos, CScrollBar* pScrollBar);
Source file Message map
ON_WM_VSCROLL()
And handler
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;
}
}
}Yeey for google! :) :thumbsup:
> The problem with computers is that they do what you tell them to do and not what you want them to do. < > Leela: Fry, you're wasting your life sitting in front of that TV. You need to get out and see the real world. Fry: But this is HDTV. It's got better resolution than the real world < >Nothing is free in the universe.<