Добавил:
Upload Опубликованный материал нарушает ваши авторские права? Сообщите нам.
Вуз: Предмет: Файл:
SSW_8_11.doc
Скачиваний:
0
Добавлен:
01.05.2025
Размер:
5.22 Mб
Скачать

10.3 The handlers of help messages

To make MFC-program answering the help calls, it’s need add the next commands to the messages map:

ON_COMMAND(ID_HELP, OnHelp)

ON_COMMAND(ID_HELP_FINDER, OnHelpFinder)

ON_COMMAND(ID_HELP_INDEX, OnHelpIndex)

ON_COMMAND(ID_HELP_USING, OnHelpUsing)

Sometimes, there is need the command

ON_COMMAND(ID_CONTEXT_HELP, OnContextHelp)

Functions OnHelp(),OnHelpFinder(),OnHelpIndex(),OnHelpUsing and OnContextHelp are the members of CWinApp class. On call, they, in their turn, call WinHelp() function. It’s provided in the following way:

Function

Action

CWinApp::OnHelp()

Calls function WinHelp(), basing the current help context

CWinApp::OnHelpFinder()

Calls function WinHelp(), with HELP_FINDER parameter

CWinApp::OnHelpIndex()

Calls function WinHelp(), with HELP_INDEX parameter

CWinApp::OnHelpUsing()

Calls function WinHelp(), with HELP_INDEXONHELP parameter

CWinApp::OnContextHelp()

Calls function WinHelp(), basing the current help context. The cursor of mouse has a form of “?”. The context of help is defined by element, to which the cursor is pointered

The processing of help calls

We’ve already said, that there are two types of help: the reference system and context help. But, if for different types of call, the program would answer in different way, there is need some kind to distinguish them. On “F1” button pressing (or “?” button) there is sent two messages: WM_COMMAND_HELP and WM_HELP_INFO. And when the user clicks by right button on window or on some element, that window is sent WM_CONTEXT_MENU message. Of the correct processing of these messages, there is depend the implementation of whole interactive help.

Wm_commandhelp message processing

In some cases, there is need to create it’s own handler of WM_COMMANDHELP message. WM_COMMANDHELP is an MFC private Windows message that is received by the active window when Help is requested. When the window receives this message, it may call CWinApp::WinHelp with context that matches the window's internal state. To include that message you need include the standard library files AFXPRIV.H and AFEXT.H. After to the messages map of every window, for which the processing of that message is provided, there is included macro command:

ON_MESSAGE(WM_COMMANDHELP, OnCommandHelp)

At last, it’s need to re-define the function OnCommandHelp() of the next prototype: afx_msg LRESULT CWnd::OnCommandHelp(WPARAM, LPARAM lParam);

Here: lParam   contains the currently available Help context. lParam is zero if no Help context has been determined yet. An implementation of OnCommandHelp can use the context ID in lParam to determine a "better" context or can just pass it to CWinApp::WinHelp.

wParam   is not used and will be zero.

If the OnCommandHelp function calls CWinApp::WinHelp, it should return TRUE. Returning TRUE stops the routing of this command to other classes (base classes) and to other windows.

Соседние файлы в предмете [НЕСОРТИРОВАННОЕ]