timmay3141
Programmer
I'm trying to figure out how to use accelerator tables without MFC. I'm trying to get Ctrl+N to do the same as the menu selection File, New. Here is the handler of the menu item:
void OnCommand(WPARAM wParam)
{
switch(wParam)
{
case IDM_FILE_NEW:
MessageBox(NULL, "Recieved Message", "adsfa", MB_OK);
}
}
This works fine when I use the menu, and I see a message box. The problem is using the accelerator to handle messages. I put this in the accelerator resource table:
IDM_FILE_NEW Ctrl + N VIRTKEY
I added this to WinMain:
HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_MYACCELERATOR));
I added this to the message pump:
if(TranslateAccelerator(hWnd, hAccelTable, &msg)) continue;
From what I read, this should be sending the WM_COMMAND message, which should then handle it like a File, New. The OnCommand function is called, but the wParam in the function doesn't equal IDM_FILE_NEW. Any ideas?
void OnCommand(WPARAM wParam)
{
switch(wParam)
{
case IDM_FILE_NEW:
MessageBox(NULL, "Recieved Message", "adsfa", MB_OK);
}
}
This works fine when I use the menu, and I see a message box. The problem is using the accelerator to handle messages. I put this in the accelerator resource table:
IDM_FILE_NEW Ctrl + N VIRTKEY
I added this to WinMain:
HACCEL hAccelTable = LoadAccelerators(hInstance, MAKEINTRESOURCE(IDR_MYACCELERATOR));
I added this to the message pump:
if(TranslateAccelerator(hWnd, hAccelTable, &msg)) continue;
From what I read, this should be sending the WM_COMMAND message, which should then handle it like a File, New. The OnCommand function is called, but the wParam in the function doesn't equal IDM_FILE_NEW. Any ideas?