 |
|
 |
Gives clear answer to complex question - accelerators and atl/wtl
|
|
|
|
 |
|
 |
This works great without any pain
Regards
N. Sharjith
|
|
|
|
 |
|
 |
Hi,
Thanks for the wonderfull solution.
Do you have the same thing in C# .NET ??
Thanks in Advance,
Saleem
|
|
|
|
 |
|
 |
And works well with MFC activex's non-modal dialogs, that would be otherway hard to use without mouse.
|
|
|
|
 |
|
 |
Thanks!
I was looking for a solution for hours!
|
|
|
|
 |
|
 |
i want to add progress bar in dialog based application using ATL COM in Visual Studio 2003
Regards
Manisha
|
|
|
|
 |
|
 |
WORKS GREAT. USES CRT. Could you add alternative for _ATL_MIN_CRT
|
|
|
|
 |
|
 |
I was able to use this idea to solve a slightly different problem I had that I was working on for quite a while.
Thanks so much, this was incredibly useful to me!!
Richard
|
|
|
|
 |
|
 |
I use
Dlg::PreTranslateMessage(MSG* pMsg)
{
if( m_hAccelTable )
{
if( ::TranslateAccelerator( m_hWnd, m_hAccelTable, pMsg ) )
{
return TRUE;
}
}
/*and do an*/
with
m_hAccelTable = ::LoadAccelerators( AfxGetInstanceHandle(), MAKEINTRESOURCE( IDR_MAINFRAME ) );
in a MFC based app. It works fine
Try this @ home. (B&B)
|
|
|
|
 |
|
 |
Unfortunately this wouldn't work for ATL DLLs, which is what the solution in the article was designed for.
Anatoly Ivasyuk is co-founder of DTLink Software, a company specializing in Internet software and technologies. He is the author of DTLink's Windows products: Personal Stock Streamer, NeoPhoto, AnswerTool, and FAQTool
|
|
|
|
 |
|
 |
This, my friend... is exactly what i was looking for!!! I have just dropped it into my code, and it worked 1st time! - Does exactly what is says on the tin.
Are you planning to update the article to take into consideration, other users comments? It would really polish everything off
Anyway, you get my 5!
|
|
|
|
 |
|
 |
Thanks! Actually the code works quite well for the purpose it was designed so I'm tempted to leave it alone. The other way of implementing this would probably be better served by a separate class.
Also, I should say that I did finally find a workaround for the popup menu mnemonics, and that is to temporarily disable the hook while the popup menu is active.
Anatoly Ivasyuk is co-founder of DTLink Software, a company specializing in Internet software and technologies. He is the author of DTLink's Windows products: Personal Stock Streamer, NeoPhoto, AnswerTool, and FAQTool
|
|
|
|
 |
|
 |
Thanks a lot from me too
The only minor thing i would change is the 'redefinition' of lpMsg as done in CDialogMessageHook::GetMessageProc():
LPMSG lpMsg = (LPMSG) lParam;
The first time its actually unused and therefore redundant.
|
|
|
|
 |
|
 |
What you are calling "accelerators" are actually keyboard mnemonics...the undelined characters in button text or static text before an input control.
To handle real accelerators from an acclerator table, you need to add a call to TranslateAccelerator to the hook proc. This is necessary even for modal dialogs, but for modal dialogs you don't need the call to IsDialogMessage.
Example (modified portion of GetMessageProc):
...
HWND hWnd, hActiveWindow = GetActiveWindow();
THWNDCollection::iterator it = m_aWindows.begin();
// check each window we manage to see if the message is meant for them
while (it != m_aWindows.end())
{
hWnd = *it;
if (hWnd == g_pMainDlg->m_hWnd &&
hWnd == hActiveWindow &&
::TranslateAccelerator(hWnd, g_pMainDlg->m_hAccel, lpMsg))
{
...
Mark Woodard
Symon Communications, Inc.
|
|
|
|
 |
|
 |
In my opinion system hooks should be used only when absolutely necessary... this is not the case.
If you're using WTL with it's CMessageLoop you can override the PreTranslateMessage function and test for dialog messages only on dialogs:
class CMessageLoopEx : public CMessageLoop
{
// Overrides
public:
// Override to change message filtering
virtual BOOL PreTranslateMessage(MSG* pMsg)
{
if (ATOM(::GetClassLongPtr(pMsg->hwnd, GCW_ATOM)) == 0x8002 &&
::IsDialogMessage(pMsg->hwnd, pMsg))
return TRUE;
return CMessageLoop::PreTranslateMessage(pMsg);
}
};
This way you guarantee proper dialog behavior and optionally implement dialog style behavior on non-dialog windows.
If you are not using WTL you can adapt this solution to your normal message translation loop as follows:
if (ATOM(::GetClassLongPtr(pMsg->hwnd, GCW_ATOM)) != 0x8002 ||
!::IsDialogMessage(pMsg->hwnd, pMsg))
{
::TranslateMessage(pMsg);
::DispatchMessage(pMsg);
}
Now if you are wandering if 0x8002 is some sort of magic number, I assure you it is not. It is simply the global ATOM value for dialog windows (those windows using class name "#32770") which you can obtain by using GlobalFindAtom.
Best wishes to all,
Miguel Hasse
|
|
|
|
 |
|
 |
You should call IsDialogMessage with the first parameter being HWND of dialog not the pMsg->hwnd which is usually a handle of a control placed on a dialog.
You could find that dialog handle by looping though parents of pMsg->hwnd until dialog is reached (or not).
It is also better to filter messages before making such search to pMsg->message be in between [WM_KEYFIRST, WM_KEYLAST] or [WM_MOUSEFIRST, WM_MOUSELAST]
|
|
|
|
 |
|
 |
I couldnt enter simplified chinese characters after installing this hook (Using Chinese input method).Any idea?
|
|
|
|
 |
|
 |
hi! wht can i help u? im engineer!
|
|
|
|
 |
|
 |
me too, who know how to resolve it?
|
|
|
|
 |
|
 |
LRESULT CALLBACK CDialogMessageHook::GetMessageProc(int nCode, WPARAM wParam, LPARAM lParam)
{
LPMSG lpMsg = (LPMSG) lParam;
if ((nCode >= 0) &&
PM_REMOVE == wParam &&
(
lpMsg->wParam==VK_TAB
||lpMsg->wParam==VK_RETURN
)
)
I solved it by this.Can anybody has a better way of judge Alt key press whithout using GetKeyState(VK_MENU)?
modified 20 Mar '12.
|
|
|
|
 |
|
 |
Menu shortcut wont work anymore... but the tab
key between control is fine now... any suggestion ?
MGJC
|
|
|
|
 |
|
 |
Anonymous wrote:
Menu shortcut wont work anymore... but the tab
key between control is fine now... any suggestion ?
You should put some debugging code in there or use Spy++ to determine where the menu shortcut messages are going. Perhaps you are not routing the messages correctly elsewhere and they are not reaching your modeless dialog.
-Anatoly
Anatoly Ivasyuk is co-founder of DTLink Software, a company specializing in Internet software and technologies. He is the author of DTLink's Windows products: AnswerTool, FAQTool, AppUpdate, and Personal Stock Monitor
|
|
|
|
 |
|
 |
I am also experiencing problems with popup menus and keyboard messages. When I right click in an edit field of a modeless dialog that I've hooked GetMessage() for, the GetMessage hook takes the keystrokes that were destined for the menu and routes them instead to the edit control, because IsDialogMessage() returns TRUE.
This means that I can't use the arrow keys to navigate a popup menu and that I can't keyboard shortcuts to jump to a specific spot on the menu. It seems that we need something in the hook that determines if a menu is active and if so, ignores the messages. I am unaware of anything that can do this though.
Any thoughts?
Thanks,
Dan Christensen
|
|
|
|
 |
|
 |
The only thing I can think of is that you would have to hook the pop-up menu creation using a CBT hook (see CBT_CREATEWND), subclass the window, and handle the WM_GETDLGCODE message to return DLGC_WANTALLKEYS. I don't have any nice code for this at the moment, but I will probably have to whip something up in the near future since I'm running into the same problem.
-Anatoly
Anatoly Ivasyuk is co-founder of DTLink Software, a company specializing in Internet software and technologies. He is the author of DTLink's Windows products: AnswerTool, FAQTool, AppUpdate, and Personal Stock Monitor
|
|
|
|
 |
|
|
 |