Domanda

I am new to C++ so forgive me if this question is too general..... I am using VS2010 to create a simple MFC text editor in C++. At the moment I am trying to get the following basic functionality up and running: a toolbar that has an underline button that underlines the selected text when you click it.

I have scoured the internet for a solution but have only come up with the following:

http://aclacl.brinkster.net/MFC/ch12e.htm

however either this code is incomplete or I can't figure out how they link the actual button to the command handlers(or whatever they call the code that executes the actual underlining).

Can someone kindly:

a) clarify where the underline button is found in StyleBar.cpp

OR

b) point me in the direction of a better solution if one exists.

Much Thanks.

È stato utile?

Soluzione

In the BEGIN_MESSAGE_MAP...END_MESSAGE_MAP block is where the message queue mapping to handlers happens. Specifically the line ON_COMMAND(ID_CHAR_UNDERLINE, OnCharUnderline) maps the WM_COMMAND for the underline control identifier to the method OnCharUnderline which handles setting the selection style. The page you reference doesn't include the resource file(s). The toolbar itself appears to be constructed on the previous page of the article.

Autorizzato sotto: CC-BY-SA insieme a attribuzione
Non affiliato a StackOverflow
scroll top