Google 網路論壇不再支援新的 Usenet 貼文或訂閱項目,但過往內容仍可供查看。

ATL Dialog Accelerators

瀏覽次數:103 次
跳到第一則未讀訊息

Mathew

未讀,
2004年3月3日 晚上10:34:132004/3/3
收件者:
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]

未讀,
2004年3月4日 下午2:19:182004/3/4
收件者:
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

未讀,
2004年3月4日 下午4:34:342004/3/4
收件者:
"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

未讀,
2004年3月4日 晚上8:24:242004/3/4
收件者:
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]

未讀,
2004年3月5日 凌晨12:25:152004/3/5
收件者:
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

未讀,
2004年3月5日 下午2:19:182004/3/5
收件者:
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 則新訊息