Link to home
Start Free TrialLog in
Avatar of win32
win32

asked on

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.
Avatar of MichaelS
MichaelS

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.
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;
ASKER CERTIFIED SOLUTION
Avatar of Meir Rivkin
Meir Rivkin
Flag of Israel image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of win32

ASKER

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

Like this or how, is it to be found ?
Avatar of win32

ASKER

Sorry. I found it !!
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");
}
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...
add this declaration to the .h file:

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

now its ok....

cheers mate