Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

ATL Dialog Accelerators

103 views
Skip to first unread message

Mathew

unread,
Mar 3, 2004, 10:34:13 PM3/3/04
to
Hi

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)[MVP]

unread,
Mar 4, 2004, 2:19:18 PM3/4/04
to
Try calling IsDialogMessage() in the message loop.


-========================================-
HyungChul Shin
2004 Microsoft MVP - [ Visual C++ ]


"Mathew" <mat...@nospam.planet> wrote in message
news:upnpRmZA...@TK2MSFTNGP10.phx.gbl...

Igor Tandetnik

unread,
Mar 4, 2004, 4:34:34 PM3/4/04
to
"Mathew" <mat...@nospam.planet> wrote in message
news:upnpRmZA...@TK2MSFTNGP10.phx.gbl...
> 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?

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


Mathew

unread,
Mar 4, 2004, 8:24:24 PM3/4/04
to
Am I supposed to write my own message loop for ATL dialogs? I had imagined
there might be some appropriate pre-processing hook that I could use.

Regard
Mathew

"신형철(Hyungchul Shin)[MVP]" <kri...@unitel.co.kr> wrote in message
news:uUo6Z2hA...@TK2MSFTNGP09.phx.gbl...

Ed Dore [MSFT]

unread,
Mar 5, 2004, 12:25:15 AM3/5/04
to
Hi Mathew,

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.


Alexander Nickolov

unread,
Mar 5, 2004, 2:19:18 PM3/5/04
to
Well, this won't work for obvious reasons. Make it like this:

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...

0 new messages