Задача отображения ToolTip на компонентах немодального диалога.
Нашел решение подобной задачи:
здесьАвтор: AEgor
Дата: 16.10.02
Вместо обработки событий клавиатуры обработал события мыши.
// Hook procedure for WH_GETMESSAGE hook type.
LRESULT CALLBACK GetMessageProc(int nCode, WPARAM wParam, LPARAM lParam)
{
// Switch the module state for the correct handle to be used.
AFX_MANAGE_STATE(AfxGetStaticModuleState( ));
// If this is a keystrokes message, translate it in controls'
// PreTranslateMessage().
LPMSG lpMsg = (LPMSG) lParam;
if( (nCode >= 0) &&
PM_REMOVE == wParam &&
(lpMsg->message >= WM_MOUSEFIRST && lpMsg->message <= WM_MOUSELAST) &&
AfxGetApp()->PreTranslateMessage((LPMSG)lParam) )
{
// The value returned from this hookproc is ignored, and it cannot
// be used to tell Windows the message has been handled. To avoid
// further processing, convert the message to WM_NULL before
// returning.
lpMsg->message = WM_NULL;
lpMsg->lParam = 0L;
lpMsg->wParam = 0;
}
// Passes the hook information to the next hook procedure in
// the current hook chain.
return ::CallNextHookEx(hHook, nCode, wParam, lParam);
}
BOOL CDlgDataSources::OnInitDialog()
{
CDialog::OnInitDialog();
// Install the WH_GETMESSAGE hook function.
hHook = ::SetWindowsHookEx(
WH_GETMESSAGE,
GetMessageProc,
AfxGetInstanceHandle(),
GetCurrentThreadId());
ASSERT (hHook);
return TRUE;
}
BOOL CDlgDataSources::PreTranslateMessage(MSG* pMsg)
{
m_ToolTip->RelayEvent( pMsg );
return CDialog::PreTranslateMessage(pMsg);
}
ToolTip'ы отображаются.
Но счастья нет, после клика на компоненте диалога программа с моим диалогом виснет, при перемещении фокуса на другое окно и назад — работа продолжается.
Помогите локализовать проблему.
Заранее благодарен.
Готов выслушать любые предложения...
С этим багом мне не жить!
В ходе тестирования выявлено, что зависание происходит после клика на Item'е ListCtrl. Остальные контролы — кнопки и комбобоксы адекватно реагируют