Same hotkey for different dialogs in the same MFC program ??
-
Hi I have a MFC-dialog program with a list in it. I have assigned F5 as a hotkey to update the list through the RegisterHotKey function. This works fine But from the main window I want to open another dialog with a different list in it. I want to use F5 as a update-hotkey in this dialog too .. but I cant get it to work. F5 only updates the list in the main dialog. I thought that a RegisterHotKey registered a hotkey for the whole system so that I can capture it in every dialog in my program ?? Any help is much appreciated !
-
Hi I have a MFC-dialog program with a list in it. I have assigned F5 as a hotkey to update the list through the RegisterHotKey function. This works fine But from the main window I want to open another dialog with a different list in it. I want to use F5 as a update-hotkey in this dialog too .. but I cant get it to work. F5 only updates the list in the main dialog. I thought that a RegisterHotKey registered a hotkey for the whole system so that I can capture it in every dialog in my program ?? Any help is much appreciated !
How are you calling
RegisterHotKey()
?
A rich person is not the one who has the most, but the one that needs the least.
-
How are you calling
RegisterHotKey()
?
A rich person is not the one who has the most, but the one that needs the least.
I do it like this: In the maindialogs OnInit-function:
RegisterHotKey(GetSafeHwnd(), m_IDHotKey, NULL, VK_F5);
And add this to the messagemap in every dialog that should use the hotkey:ON_MESSAGE(WM_HOTKEY,OnHotKey)
And the OnHotKey function looks like this:LRESULT CFingerIDAdminDlg::OnHotKey(WPARAM wParam, LPARAM lParam) { // Do stuff }
It only works for the main dialog ... a F5-keystroke in the child window registrates as a F5-key in the main window. I thought that the WM_HOTKEY-message was going to be handled by the dialog that is active ?? -
I do it like this: In the maindialogs OnInit-function:
RegisterHotKey(GetSafeHwnd(), m_IDHotKey, NULL, VK_F5);
And add this to the messagemap in every dialog that should use the hotkey:ON_MESSAGE(WM_HOTKEY,OnHotKey)
And the OnHotKey function looks like this:LRESULT CFingerIDAdminDlg::OnHotKey(WPARAM wParam, LPARAM lParam) { // Do stuff }
It only works for the main dialog ... a F5-keystroke in the child window registrates as a F5-key in the main window. I thought that the WM_HOTKEY-message was going to be handled by the dialog that is active ??Have you used Spy++ to see the messages that are being received by both the main window and the child dialogs?
A rich person is not the one who has the most, but the one that needs the least.
-
I do it like this: In the maindialogs OnInit-function:
RegisterHotKey(GetSafeHwnd(), m_IDHotKey, NULL, VK_F5);
And add this to the messagemap in every dialog that should use the hotkey:ON_MESSAGE(WM_HOTKEY,OnHotKey)
And the OnHotKey function looks like this:LRESULT CFingerIDAdminDlg::OnHotKey(WPARAM wParam, LPARAM lParam) { // Do stuff }
It only works for the main dialog ... a F5-keystroke in the child window registrates as a F5-key in the main window. I thought that the WM_HOTKEY-message was going to be handled by the dialog that is active ??me think you need to put the handler in all the different dialogs ?
Maximilien Lincourt Your Head A Splode - Strong Bad