Sun Xin video menu (lower)

Source: Internet
Author: User

How to dynamically add and delete the Insert menu (by tapping the code)
Cmenu menu;
Menu. createpopupmenu ();
// Getmenu ()-> appendmenu (mf_popup, (uint) menu. m_hmenu, "Fuck ");
// Menu. insertmenu (2, mf_byposition, (uint) menu. m_hmenu, "you"); // This call is incorrect. You must use a menu handle to call
Getmenu ()-> insertmenu (2, mf_byposition | mf_popup, (uint) menu. m_hmenu, "you ");
Menu. appendmenu (mf_string, 111, "hello ");
Menu. appendmenu (mf_string, 112, "world ");
Menu. Detach (); // This is not prompted
// Disconnect the handle from the cmenu object
Getmenu ()-> getsubmenu (0)-> appendmenu (mf_string, 114, "MFC"); // This is to add a menu item to the file submenu.
// You can also insert
Getmenu ()-> getsubmenu (0)-> insertmenu (2, mf_byposition, 115, "Dongqing ");
// Getmenu ()-> getsubmenu (0)-> deletemenu (2, mf_byposition); // use this sentence to delete the added content.

// How can I add a command response to a dynamically created menu?
// Go to resource. h and # define idm_hello 111. In this way, we have an ID number.
// Then go to the header file afx_msg void onhello (); the prototype of the message is finished, and the next step is message ing.
// On_command (idm_hello, onhello)
// Finally, the implementation of our functions,
// Void cmainframe: onhello () can be tested with MessageBox
2. Write a telephone program as follows:
Enter a blank phone number in the view and add it to the menu, and vice versa.
Capture the onchar message on the keyboard.
Cclientdc DC (this );
If (0x0d = nchar)
{
If (0 = + m_nindex) // The first press enter to add
{
M_menu.createpopupmenu ();
Getparent ()-> getmenu ()-> appendmenu (mf_popup,
(Uint) m_menu.m_hmenu, "Phonebook ");
Getparent ()-> drawmenubar ();
}
M_menu.appendmenu (mf_string, 111, m_str.left (m_str.find ('')));
// There is a space between the person name and the number at the time of input, so find the space, return the index, and then take the left side of the string
// A few characters. We will take out the name of the person.
M_str.empty ();
Invalidate (); // re-paint the window to help erase the text
}
Else // The input string is output in characters
{
M_str + = nchar;
DC. textout (0, 0, m_str );
}
Add it, awesome. Haha
Next, we need to display it back.
Here we need to store all the strings.
Use the cstringarray collection class
M_strarray.add (m_str );
I don't want to write any more, so let's get there.

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.