VC control -- use the spin control to increase or decrease characters

Source: Internet
Author: User

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

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.