Hello,
I want to get the volume up/down key events in my application.
To do that I create a menu bar and then receive the event in WM_HOTKEY or WM_KEYUP. This method works well with Samsung phones or emulator but not with HTC phones.
Here is my code :
Creation of the menu bar in WM_CREATE :
SHMENUBARINFO mbi;
memset(&mbi, 0, sizeof(SHMENUBARINFO));
mbi.cbSize = sizeof(SHMENUBARINFO);
mbi.hwndParent = hWnd;
mbi.nToolBarId = IDR_MENU;
mbi.hInstRes = g_hInst;
if (!SHCreateMenuBar(&mbi))
{
g_hWndMenuBar = NULL;
}
else
{
g_hWndMenuBar = mbi.hwndMB;
SendMessage(g_hWndMenuBar, SHCMBM_OVERRIDEKEY, VK_TVOLUMEUP,MAKELPARAM (SHMBOF_NODEFAULT | SHMBOF_NOTIFY,SHMBOF_NODEFAULT | SHMBOF_NOTIFY));
SendMessage(g_hWndMenuBar, SHCMBM_OVERRIDEKEY, VK_TVOLUMEDOWN,MAKELPARAM (SHMBOF_NODEFAULT | SHMBOF_NOTIFY,SHMBOF_NODEFAULT | SHMBOF_NOTIFY));
}
Receive the event in WM_KEYUP :
case WM_KEYUP:
{
switch(wParam)
{
case VK_TVOLUMEUP:
{
}
break;
case VK_TVOLUMEDOWN:
{
}
break;
default:
break;
}
break;
}
I want to get the volume up/down key events in my application.
To do that I create a menu bar and then receive the event in WM_HOTKEY or WM_KEYUP. This method works well with Samsung phones or emulator but not with HTC phones.
Here is my code :
Creation of the menu bar in WM_CREATE :
SHMENUBARINFO mbi;
memset(&mbi, 0, sizeof(SHMENUBARINFO));
mbi.cbSize = sizeof(SHMENUBARINFO);
mbi.hwndParent = hWnd;
mbi.nToolBarId = IDR_MENU;
mbi.hInstRes = g_hInst;
if (!SHCreateMenuBar(&mbi))
{
g_hWndMenuBar = NULL;
}
else
{
g_hWndMenuBar = mbi.hwndMB;
SendMessage(g_hWndMenuBar, SHCMBM_OVERRIDEKEY, VK_TVOLUMEUP,MAKELPARAM (SHMBOF_NODEFAULT | SHMBOF_NOTIFY,SHMBOF_NODEFAULT | SHMBOF_NOTIFY));
SendMessage(g_hWndMenuBar, SHCMBM_OVERRIDEKEY, VK_TVOLUMEDOWN,MAKELPARAM (SHMBOF_NODEFAULT | SHMBOF_NOTIFY,SHMBOF_NODEFAULT | SHMBOF_NOTIFY));
}
Receive the event in WM_KEYUP :
case WM_KEYUP:
{
switch(wParam)
{
case VK_TVOLUMEUP:
{
}
break;
case VK_TVOLUMEDOWN:
{
}
break;
default:
break;
}
break;
}







Sign In
Create Account

Back to top









