mirror of
https://github.com/reactos/reactos.git
synced 2024-12-28 01:55:19 +00:00
[STOBJECT] Use timers to distinguish between single and double clicks
- Volume, Power and Hotplug icon: Use timers to distinguish between single and double clicks. - Volume icon: Show the tray volume dialog on a single click.
This commit is contained in:
parent
b95fff5bce
commit
2baafa61c6
4 changed files with 39 additions and 9 deletions
|
@ -241,8 +241,12 @@ BOOL CSysTray::ProcessWindowMessage(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM
|
|||
return TRUE;
|
||||
|
||||
case WM_TIMER:
|
||||
UpdateIcons();
|
||||
if (wParam == 1)
|
||||
UpdateIcons();
|
||||
else
|
||||
ProcessIconMessage(uMsg, wParam, lParam, lResult);
|
||||
return TRUE;
|
||||
|
||||
case WM_DESTROY:
|
||||
KillTimer(1);
|
||||
ShutdownIcons();
|
||||
|
|
|
@ -280,19 +280,28 @@ HRESULT STDMETHODCALLTYPE Hotplug_Message(_In_ CSysTray * pSysTray, UINT uMsg, W
|
|||
}
|
||||
return S_FALSE;
|
||||
|
||||
case WM_TIMER:
|
||||
if (wParam == HOTPLUG_TIMER_ID)
|
||||
{
|
||||
KillTimer(pSysTray->GetHWnd(), HOTPLUG_TIMER_ID);
|
||||
_ShowContextMenu(pSysTray);
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_ICON_HOTPLUG:
|
||||
Hotplug_Update(pSysTray);
|
||||
|
||||
switch (lParam)
|
||||
{
|
||||
case WM_LBUTTONDOWN:
|
||||
SetTimer(pSysTray->GetHWnd(), HOTPLUG_TIMER_ID, 500, NULL);
|
||||
break;
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
_ShowContextMenu(pSysTray);
|
||||
break;
|
||||
|
||||
case WM_LBUTTONDBLCLK:
|
||||
KillTimer(pSysTray->GetHWnd(), HOTPLUG_TIMER_ID);
|
||||
_RunHotplug(pSysTray);
|
||||
break;
|
||||
|
||||
|
|
|
@ -374,19 +374,28 @@ HRESULT STDMETHODCALLTYPE Power_Message(_In_ CSysTray * pSysTray, UINT uMsg, WPA
|
|||
}
|
||||
return S_FALSE;
|
||||
|
||||
case WM_TIMER:
|
||||
if (wParam == POWER_TIMER_ID)
|
||||
{
|
||||
KillTimer(pSysTray->GetHWnd(), POWER_TIMER_ID);
|
||||
ShowPowerSchemesPopupMenu(pSysTray);
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_ICON_POWER:
|
||||
Power_Update(pSysTray);
|
||||
|
||||
switch (lParam)
|
||||
{
|
||||
case WM_LBUTTONDOWN:
|
||||
SetTimer(pSysTray->GetHWnd(), POWER_TIMER_ID, 500, NULL);
|
||||
break;
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
ShowPowerSchemesPopupMenu(pSysTray);
|
||||
break;
|
||||
|
||||
case WM_LBUTTONDBLCLK:
|
||||
KillTimer(pSysTray->GetHWnd(), POWER_TIMER_ID);
|
||||
_RunPower();
|
||||
break;
|
||||
|
||||
|
|
|
@ -214,10 +214,9 @@ HRESULT Volume_OnDeviceChange(_In_ CSysTray * pSysTray, WPARAM wParam, LPARAM lP
|
|||
return Volume_FindMixerControl(pSysTray);
|
||||
}
|
||||
|
||||
static void _RunVolume()
|
||||
static void _RunVolume(BOOL bTray)
|
||||
{
|
||||
// FIXME: ensure we are loading the right one
|
||||
ShellExecuteW(NULL, NULL, L"sndvol32.exe", NULL, NULL, SW_SHOWNORMAL);
|
||||
ShellExecuteW(NULL, NULL, bTray ? L"sndvol32.exe /t" : L"sndvol32.exe", NULL, NULL, SW_SHOWNORMAL);
|
||||
}
|
||||
|
||||
static void _RunMMCpl()
|
||||
|
@ -250,7 +249,7 @@ static void _ShowContextMenu(CSysTray * pSysTray)
|
|||
switch (id)
|
||||
{
|
||||
case IDS_VOL_OPEN:
|
||||
_RunVolume();
|
||||
_RunVolume(FALSE);
|
||||
break;
|
||||
case IDS_VOL_ADJUST:
|
||||
_RunMMCpl();
|
||||
|
@ -285,6 +284,14 @@ HRESULT STDMETHODCALLTYPE Volume_Message(_In_ CSysTray * pSysTray, UINT uMsg, WP
|
|||
}
|
||||
return S_FALSE;
|
||||
|
||||
case WM_TIMER:
|
||||
if (wParam == VOLUME_TIMER_ID)
|
||||
{
|
||||
KillTimer(pSysTray->GetHWnd(), VOLUME_TIMER_ID);
|
||||
_RunVolume(TRUE);
|
||||
}
|
||||
break;
|
||||
|
||||
case ID_ICON_VOLUME:
|
||||
TRACE("Volume_Message uMsg=%d, w=%x, l=%x\n", uMsg, wParam, lParam);
|
||||
|
||||
|
@ -293,14 +300,15 @@ HRESULT STDMETHODCALLTYPE Volume_Message(_In_ CSysTray * pSysTray, UINT uMsg, WP
|
|||
switch (lParam)
|
||||
{
|
||||
case WM_LBUTTONDOWN:
|
||||
SetTimer(pSysTray->GetHWnd(), VOLUME_TIMER_ID, 500, NULL);
|
||||
break;
|
||||
|
||||
case WM_LBUTTONUP:
|
||||
TRACE("TODO: display volume slider\n");
|
||||
break;
|
||||
|
||||
case WM_LBUTTONDBLCLK:
|
||||
_RunVolume();
|
||||
KillTimer(pSysTray->GetHWnd(), VOLUME_TIMER_ID);
|
||||
_RunVolume(FALSE);
|
||||
break;
|
||||
|
||||
case WM_RBUTTONDOWN:
|
||||
|
|
Loading…
Reference in a new issue