Jump to content
Sign in to follow this  
kikekoikan

Override Volume up/down with HTC or Sony Ericson Phones

Recommended Posts

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:

{

printf("event up");

}

break;

case VK_TVOLUMEDOWN:

{

printf("event up");

}

break;

default:

break;

}

break;

}

I hope you can help me

Good afternoon

Edited by kikekoikan

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this  

×