Platform: Win32 / ATL 7.0
How should I get accelarators working in ATL dialogs? I know how to use
TranslateAccelerator for raw old fashioned WndProcs. What's the
easy/elegant way to setup dialog accelerators in ATL 7.0 / VS .NET 2003?
Regards
Mathew
-========================================-
HyungChul Shin
2004 Microsoft MVP - [ Visual C++ ]
"Mathew" <mat...@nospam.planet> wrote in message
news:upnpRmZA...@TK2MSFTNGP10.phx.gbl...
If you mean a modal dialog, the only way I know of is with a hook - see
SetWindowsHookEx
--
With best wishes,
Igor Tandetnik
"For every complex problem, there is a solution that is simple, neat,
and wrong." H.L. Mencken
Regard
Mathew
"신형철(Hyungchul Shin)[MVP]" <kri...@unitel.co.kr> wrote in message
news:uUo6Z2hA...@TK2MSFTNGP09.phx.gbl...
I'm guessing youre using modeless dialogs here. A modal dialog generally
already supports accelerators.
You'll need modify your ATL module's message loop to call IsDialogMessage()
on your dialog's HWND. A generic ATL7 EXE has it's message pump implemented
in the CAtlExeModuleT::RunMessageLoop in ATLBASE.H. The implemention is
below.
void RunMessageLoop() throw()
{
MSG msg;
while (GetMessage(&msg, 0, 0, 0) > 0)
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
You'll want to reimplement this in your own module object that derived from
CAtlExeModuleT, and add a call to IsDialogMessage() when the msg.hwnd
belongs to your dialog, or is a child window belonging to your dialog. For
example:
void RunMessageLoop() throw()
{
MSG msg;
while (GetMessage(&msg, 0, 0, 0) > 0)
{
if (msg.hwnd==m_hWndDlg || IsChild(m_hWndDlg,msg.hwnd)
if (!::IsDialogMessage(m_hWndDlg,&msg))
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
Sincerely,
Ed Dore [MSFT]
This post is "AS IS" with no warranties, and confers no rights.
void CMyAtlExeModule::RunMessageLoop() throw()
{
MSG msg;
while (GetMessage(&msg, 0, 0, 0) > 0)
{
if ( !(::IsWindow(m_hWnd) &&
((msg.hwnd==m_hWndDlg) || ::IsChild(m_hWndDlg,msg.hwnd)) &&
(::IsDialogMessage(m_hWndDlg,&msg))) )
{
TranslateMessage(&msg);
DispatchMessage(&msg);
}
}
}
m_hWndDlg should be a member of the derived class set when the
dialog is displayed and reset it when the dialog is destroyed. FWIW,
WTL has a much more elegant solution with its CMessageFilter
interface and CMessageLoop handling the filters like connection
point sinks...
--
=====================================
Alexander Nickolov
Microsoft MVP [VC], MCSD
email: agnic...@mvps.org
MVP VC FAQ: http://www.mvps.org/vcfaq
=====================================
"Ed Dore [MSFT]" <ed...@online.microsoft.com> wrote in message news:%aU1c.42878$ko6.381731@attbi_s02...