Response Message of udn_deltapos
Message udn_deltapos of the rotating button control
Indicates that the widget location will change.
The udn_deltapos message of the reload spin control will have the following functions:
Void ctestdlg: ondeltaposspin3 (nmhdr * pnmhdr, lresult * presult)
{
Nm_updown * pnmupdown = (nm_updown *) pnmhdr;
If (pnmupdown-> idelta = 1) // if this value is 1, the spin arrow is clicked.
{
// Process the characters. For example, convert "A" to "B"
}
Else if (pnmupdown-> idelta =-1) // if this value is-1, it means you have clicked the up arrow of spin.
{
// Process the characters. For example, convert "B" to ""
}
* Presult = 0;
}
Detailed practices:
1: assume that the edit box is idc_edit and the spin button is idc_spin.
2: Ctrl + W, Enter Class Wizard, select idc_spin in the object IDs column, select udn_deltapos in the messages column, and click "add function. the "ondeltaposspin" dialog box is displayed. Click OK to add this function. click "edit code" to enter the newly added function.
3: A new function will be added.
Void ctestdlg: ondeltaposspin (nmhdr * pnmhdr, lresult * presult )...
4: Add the following code:
Void ctestdlg: ondeltaposspin (nmhdr * pnmhdr, lresult * presult)
{
Nm_updown * pnmupdown = (nm_updown *) pnmhdr;
Cwnd * pwnd = (cwnd *) getdlgitem (idc_edit); // get the window pointer pointing to the edit box.
Cstring strvalue;
Pwnd-> getwindowtext (strvalue); // get the content in the edit box.
If (pnmupdown-> idelta = 1) // if you click the up button in spin
{
If (! Strvalue. isempty ())
{
Strvalue. setat (0, strvalue [0] + 1); // Add 1 to the first letter of the edit box
Pwnd-> setwindowtext (strvalue); // Save the modification
}
}
Else if (pnmupdown-> idelta =-1) // if you click the down button in spin
{
If (! Strvalue. isempty ())
{
Strvalue. setat (0, strvalue [0]-1); // The first letter of the edit box minus 1.
Pwnd-> setwindowtext (strvalue); // Save the modification
}
}
* Presult = 0;
}
After using the above method, I encountered a problem: when I keep holding up or down, I will not increase after increasing 16. Later I found that I can change the condition to be greater than 0 or less than 0, greater than 0 indicates the up button