Google Skupine ne podpirajo več novih objav ali naročnin v storitvi Usenet. Zgodovinsko vsebino si je še vedno mogoče ogledati.
Dismiss

ATL Dialog Accelerators

103 ogledi
Preskoči na prvo neprebrano sporočilo

Mathew

neprebran,
3. mar. 2004, 22:34:133. 3. 04
do
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]

neprebran,
4. mar. 2004, 14:19:184. 3. 04
do
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

neprebran,
4. mar. 2004, 16:34:344. 3. 04
do
"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

neprebran,
4. mar. 2004, 20:24:244. 3. 04
do
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]

neprebran,
5. mar. 2004, 00:25:155. 3. 04
do
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

neprebran,
5. mar. 2004, 14:19:185. 3. 04
do
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 novih sporočil