Add a prompt to the toolbar of a single document Program

Source: Internet
Author: User

Author: Zhu Jincan

Source: http://www.cnblogs.com/clever101

 

Generally, toolbar buttons are generated through configuration, and the button prompts can also be saved in the configuration file. However, there is not much information on how to dynamically add this prompt. The Microsoft official website provides an article on how to display the tooltip.Article:

How to call laterEnabletooltipsDisplay tooltip

 

I have tried it.ProgramAdd a prompt dynamically on the toolbar. I noticed that the derived class of cformview is used in this article. Using this class actually requires a dialog box resource. In fact, I guess this method is more suitable for adding a prompt to the control in the dialog box. What I want to achieve now is to dynamically Add a prompt to the toolbar of the single-document program.

 

One effective method I found is to reloadWindowprocFunction, and then process the corresponding message. Specifically

1.Add the lresult function to the cmainframe class Windowproc(Uint Message,Wparam Wparam,Lparam Lparam);

 

2.Add the following to the CPP file:Code:

Lresult cmainframe: windowproc (uint message, wparam, lparam)
{
// Todo: Add dedicated code and/or call the base class here
Switch (Message)
{
Case Wm_notify:
Switch (Lpnmhdr) lparam) -> Code)
{
Case Ttn_getdispinfo:
{
Lptooltiptext lpttt;
Lpttt = (Lptooltiptext) lparam;
Lpttt -> Hinst = AfxGetInstanceHandle ();
Int ID = Lpttt -> HDR. idfrom;
Switch (ID) // The ID here is the ID of the toolbar button
{
Case Sys_command_begin:
Lpttt -> Lpsztext = Text ( " Add button " );
Break ;
Case Sys_command_begin + 1 :
Lpttt -> Lpsztext = Text ( " Tag button " );
Break ;
Case Sys_command_begin + 2 :
Lpttt -> Lpsztext = Text ( " Comment button " );
Break ;
Case Sys_command_begin + 3 :
Lpttt -> Lpsztext = Text ( " Conversion button " );
Break ;
Case Sys_command_begin + 4 :
Lpttt -> Lpsztext = Text ( " Delete button " );
Break ;
Case Sys_command_begin + 5 :
Lpttt -> Lpsztext = Text ( " Exit button " );
Break ;
Default :
Break ;
}
}
Default :
Break ;
}
Break ;
Default :
Break ;
}
Return Cframewnd: windowproc (message, wparam, lparam );
}

 

 

 

 

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.