• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 947
  • Last Modified:

GetUpDown, from CSpinButtonCtrl

Hi, I can get the pos.. by caling CSpinButtonCtrl.GetPos(), But I don't need it.. All I need to know is, if I hit the UP, or DOWN button...

How is that done ?

What I've done now is, somthing lik this

If(OldPop<NewPos)POS_IS_INCREASED = true;

But the programming looks bad, can't I get a flag, that tels me if its up, or down ???

CB.
0
win32
Asked:
win32
  • 3
  • 2
  • 2
  • +1
1 Solution
 
MichaelSCommented:
You have to take a look at UDN_DELTAPOS message. It's sould arrive to the parent of you Spin control in the form of WM_NOTIFY message.

lParam of the message is a pointer to the NMUPDOWN structure where you have to check iDelta value. This is a change you need.
0
 
MadYugoslavCommented:
CSpinButtonControl sent notify message UDN_DELTAPOS.
Get that message from Your control and You will have as lParam struct NMUPDOWN.
struct
{
    NMHDR hdr;
    int   iPos;// current position
    int   iDelta;// proposed change in position
} NMUPDOWN;
0
 
Meir RivkinFull stack Software EngineerCommented:
add UDN_DELTAPOS message handler using the wizard:

void CZ3LicenseGenDlg::OnDeltaposUserSpin(NMHDR* pNMHDR, LRESULT* pResult)
{
     NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;
     if(pNMUpDown->iDelta > 0)
     {
//spin up
     }
     else
     {
//spin down
     }
     UpdateData();
     
     *pResult = 0;
}

good luck
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
win32Author Commented:
How do I find, UDN_DELTAPOS... ?
if (HIWORD (wParam) == UDN_DELTAPOS) MessageBox("Test");

Like this or how, is it to be found ?
0
 
win32Author Commented:
Sorry. I found it !!
0
 
MichaelSCommented:
As I said it gets sent in the form of WM_NOTIFY message. So it sould be something like that:

CYourDlg::OnWmNotify(...)
{  if(HOWORD(wParam) == UDN_DELTAPOS)
       MessageBox("text");
}
0
 
Meir RivkinFull stack Software EngineerCommented:
win32:

add this declaration to the .h file:

add this code to the MESSAGE MAP in the .cpp:

BEGIN_MESSAGE_MAP(...)
.
.
ON_NOTIFY(UDN_DELTAPOS, IDC_USER_ID_SPIN, OnDeltaposUserIdSpin)
.
.
END_MESSAGE_MAP()


IDC_USER_ID_SPIN-> is the spin control resource ID

the callbacl function of the spin control:
void CMyDlg::OnDeltaposUserIdSpin(NMHDR* pNMHDR, LRESULT* pResult)
{
     NM_UPDOWN* pNMUpDown = (NM_UPDOWN*)pNMHDR;

     if(pNMUpDown->iDelta > 0)
{
//up
}
     else
{
//down
}    

     UpdateData();
     
     *pResult = 0;
}

thats it...
0
 
Meir RivkinFull stack Software EngineerCommented:
add this declaration to the .h file:

     afx_msg void OnDeltaposUserIdSpin(NMHDR* pNMHDR, LRESULT* pResult);

now its ok....

cheers mate
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 3
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now